Removed rake tasks. Added generators. Modern engine dir structure

This commit is contained in:
Sam Davies
2012-03-28 18:43:27 -04:00
committed by Michael Bianco
parent b7355fded8
commit d2923b595f
11 changed files with 73 additions and 23 deletions
+4 -2
View File
@@ -1,8 +1,10 @@
require 'rubygems'
require 'rake'
require 'rake/testtask'
require 'rake/packagetask'
require 'rake/gempackagetask'
require 'rubygems/package_task'
require 'rspec/core/rake_task'
require 'cucumber/rake/task'
require 'spree_core/testing_support/common_rake'
gemfile = File.expand_path('../spec/test_app/Gemfile', __FILE__)
if File.exists?(gemfile) && (%w(spec cucumber).include?(ARGV.first.to_s) || ARGV.size == 0)
@@ -0,0 +1 @@
//= require admin/spree_core
@@ -0,0 +1 @@
//= require store/spree_core
@@ -0,0 +1,3 @@
/*
*= require admin/spree_core
*/
@@ -0,0 +1,3 @@
/*
*= require store/spree_core
*/
@@ -1,5 +1,5 @@
Deface::Override.new(:virtual_path => "spree/admin/shared/_product_tabs",
:name => "spree_digital_product_admin",
Deface::Override.new(:virtual_path => "admin/shared/_product_tabs",
:name => "add_digital_versions_to_admin_product_tabs",
:insert_bottom => "[data-hook='admin_product_tabs'], #admin_product_tabs[data-hook]",
:text => " <li<%== ' class=\"active\"' if current == \"Digital Versions\" %>>
<%= link_to t(\"digital_versions\"), admin_product_digitals_path(@product) %>
@@ -0,0 +1,31 @@
module SpreeDigital
module Generators
class InstallGenerator < Rails::Generators::Base
def add_javascripts
append_file "app/assets/javascripts/store/all.js", "//= require store/spree_digital\n"
append_file "app/assets/javascripts/admin/all.js", "//= require admin/spree_digital\n"
end
def add_stylesheets
inject_into_file "app/assets/stylesheets/store/all.css", " *= require store/spree_digital\n",
:before => /\*\//, :verbose => true
inject_into_file "app/assets/stylesheets/admin/all.css", " *= require admin/spree_digital\n",
:before => /\*\//, :verbose => true
end
def add_migrations
run 'bundle exec rake railties:install:migrations FROM=spree_digital'
end
def run_migrations
res = ask "Would you like to run the migrations now? [Y/n]"
if res == "" || res.downcase == "y"
run 'bundle exec rake db:migrate'
else
puts "Skipping rake db:migrate, don't forget to run it!"
end
end
end
end
end
+4
View File
@@ -1,4 +1,5 @@
require 'spree_core'
<<<<<<< HEAD
module SpreeDigital
class Engine < Rails::Engine
@@ -14,3 +15,6 @@ module SpreeDigital
config.to_prepare &method(:activate).to_proc
end
end
=======
require 'spree_digital/engine'
>>>>>>> 9b919de... Modified to fit spree 0.70 extension
+24
View File
@@ -0,0 +1,24 @@
module SpreeDigital
class Engine < Rails::Engine
engine_name 'spree_digital'
config.autoload_paths += %W(#{config.root}/lib)
# Use RSpec for tests
config.generators do |g|
g.test_framework :rspec
end
def self.activate
Dir.glob(File.join(File.dirname(__FILE__), "../../app/**/*_decorator*.rb")) do |c|
Rails.application.config.cache_classes ? require(c) : load(c)
end
Dir.glob(File.join(File.dirname(__FILE__), "../../app/overrides/*.rb")) do |c|
Rails.application.config.cache_classes ? require(c) : load(c)
end
end
config.to_prepare &method(:activate).to_proc
end
end
-18
View File
@@ -1,18 +0,0 @@
namespace :spree_digital do
desc "Copies all migrations (NOTE: This will be obsolete with Rails 3.1)"
task :install do
Rake::Task['spree_digital:install:migrations'].invoke
end
namespace :install do
desc "Copies all migrations (NOTE: This will be obsolete with Rails 3.1)"
task :migrations do
source = File.join(File.dirname(__FILE__), '..', '..', 'db')
destination = File.join(Rails.root, 'db')
Spree::FileUtilz.mirror_files(source, destination)
end
end
end
-1
View File
@@ -1 +0,0 @@
# add custom rake tasks here