spree 0.60.6 → 0.70.0.rc2
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of spree might be problematic. Click here for more details.
- data/README.md +41 -31
- data/lib/spree.rb +1 -4
- data/lib/spree/bin/spree +6 -0
- data/lib/spree/cli.rb +52 -0
- data/lib/spree/engine.rb +5 -0
- data/lib/spree/extension.rb +77 -0
- data/lib/spree/templates/extension/Gemfile +22 -0
- data/lib/{generators/templates → spree/templates/extension}/LICENSE +11 -8
- data/lib/{generators/templates → spree/templates/extension}/README.md +7 -0
- data/lib/spree/templates/extension/Rakefile +31 -0
- data/lib/{generators/templates/Versionfile.tt → spree/templates/extension/Versionfile} +2 -2
- data/lib/spree/templates/extension/app/assets/javascripts/admin/%file_name%.js +1 -0
- data/lib/spree/templates/extension/app/assets/javascripts/store/%file_name%.js +1 -0
- data/lib/spree/templates/extension/app/assets/stylesheets/admin/%file_name%.css +3 -0
- data/lib/spree/templates/extension/app/assets/stylesheets/store/%file_name%.css +3 -0
- data/lib/{generators/templates/extension.gemspec.tt → spree/templates/extension/extension.gemspec} +6 -3
- data/lib/{generators/templates/gitignore.tt → spree/templates/extension/gitignore} +1 -0
- data/lib/spree/templates/extension/lib/%file_name%.rb.tt +2 -0
- data/lib/spree/templates/extension/lib/%file_name%/engine.rb.tt +24 -0
- data/lib/spree/templates/extension/lib/generators/%file_name%/install/install_generator.rb.tt +29 -0
- data/lib/{generators/templates → spree/templates/extension}/routes.rb +0 -0
- data/lib/spree/templates/extension/rspec +1 -0
- data/lib/spree/templates/extension/script/rails.tt +12 -0
- data/lib/spree/templates/extension/spec_helper.rb.tt +33 -0
- metadata +75 -61
- data/lib/generators/spree/extension_generator.rb +0 -71
- data/lib/generators/spree/site_generator.rb +0 -45
- data/lib/generators/spree/test_app_generator.rb +0 -145
- data/lib/generators/templates/Gemfile +0 -32
- data/lib/generators/templates/Rakefile.tt +0 -75
- data/lib/generators/templates/config/database.yml +0 -17
- data/lib/generators/templates/config/database.yml.mysql +0 -29
- data/lib/generators/templates/config/database.yml.sqlite3 +0 -17
- data/lib/generators/templates/config/environments/cucumber.rb +0 -38
- data/lib/generators/templates/extension/extension.rb.tt +0 -17
- data/lib/generators/templates/hooks.rb.tt +0 -3
- data/lib/generators/templates/install.rake.tt +0 -25
- data/lib/generators/templates/lib/tasks/%file_name%.rake.tt +0 -1
- data/lib/generators/templates/spec_helper.rb +0 -30
- data/lib/generators/templates/spree_site.rb +0 -12
- data/lib/tasks/install.rake +0 -29
data/README.md
CHANGED
@@ -29,28 +29,20 @@ Start by adding the gem to your existing Rails 3.x application's Gemfile
|
|
29
29
|
|
30
30
|
Update your bundle
|
31
31
|
|
32
|
-
bundle install
|
32
|
+
$ bundle install
|
33
33
|
|
34
|
-
Then use the install generator to do the basic setup
|
34
|
+
Then use the install generator to do the basic setup
|
35
35
|
|
36
|
-
rails g spree:site
|
36
|
+
$ rails g spree:site
|
37
37
|
|
38
|
-
Now
|
38
|
+
Now you just need to run the new migrations, and setup some basic data
|
39
39
|
|
40
|
-
rake
|
41
|
-
|
42
|
-
If you'd like to also install sample data and images you can follow up the above command with:
|
43
|
-
|
44
|
-
rake spree_sample:install
|
45
|
-
|
46
|
-
Now you just need to run the new migrations
|
47
|
-
|
48
|
-
rake db:migrate
|
49
|
-
rake db:seed
|
40
|
+
$ bundle exec rake db:migrate
|
41
|
+
$ bundle exec rake db:seed
|
50
42
|
|
51
43
|
If you also want some sample products, orders, etc. to play with you can run the appropriate rake task.
|
52
44
|
|
53
|
-
rake
|
45
|
+
$ bundle exec rake spree_sample:load
|
54
46
|
|
55
47
|
|
56
48
|
Browse Store
|
@@ -82,49 +74,67 @@ The source code is essentially a collection of gems. Spree is meant to be run w
|
|
82
74
|
|
83
75
|
3. Create a sandbox rails application for testing purposes (and automatically perform all necessary database setup)
|
84
76
|
|
85
|
-
rake sandbox
|
77
|
+
bundle exec rake sandbox
|
86
78
|
|
87
79
|
6. Start the server
|
88
80
|
|
89
81
|
cd sandbox
|
90
82
|
rails server
|
91
83
|
|
84
|
+
Performance
|
85
|
+
-----------
|
86
|
+
|
87
|
+
You may noticed that your Spree store runs slowly in development mode. This is a side-effect of how Rails works in development mode which is to continuous reload your Ruby objects on each request. The introduction of the asset pipeline in Rails 3.1 made default performance in development mode significantly worse. There are, however, a few tricks to speeding up performance.
|
88
|
+
|
89
|
+
You can recompile your assets as follows:
|
90
|
+
|
91
|
+
$ bundle exec rake assets:precompile RAILS_ENV=development
|
92
|
+
|
93
|
+
If you want to remove precompiled assets (recommended before you commit to git and push your changes) use the following rake task:
|
94
|
+
|
95
|
+
$ bundle exec rake assets:clean
|
96
|
+
|
97
|
+
|
98
|
+
|
92
99
|
Running Tests
|
93
100
|
-------------
|
94
101
|
|
95
102
|
If you want to run all the tests across all the gems then
|
96
103
|
|
97
104
|
$ cd spree
|
98
|
-
$ rake
|
99
|
-
$ rake cucumber #=> 'this will run cucumber tests for all the gems'
|
100
|
-
$ rake #=> 'this will run both spec and cucumber tests for all the gems'
|
105
|
+
$ bundle exec rake #=> 'this will run both spec and cucumber tests for all the gems'
|
101
106
|
|
102
107
|
Each gem contains its own series of tests, and for each directory, you need to do a quick one-time
|
103
108
|
creation of a test application and then you can use it to run the tests. For example, to run the
|
104
109
|
tests for the core project.
|
105
110
|
|
106
111
|
$ cd core
|
107
|
-
$ rake test_app
|
108
|
-
|
109
|
-
|
110
|
-
|
112
|
+
$ bundle exec rake test_app
|
113
|
+
|
114
|
+
Now you can run just the specs, just the features or everything together
|
115
|
+
|
116
|
+
$ bundle exec rake spec
|
117
|
+
$ bundle exec rake cucumber
|
118
|
+
$ bundle exec rake #=> 'this will run both spec and cucumber tests for the gem'
|
119
|
+
|
120
|
+
If you want to run specs for only a single spec file
|
111
121
|
|
112
|
-
# If you want to run specs for only a single spec file
|
113
122
|
$ bundle exec rspec spec/models/state_spec.rb
|
114
123
|
|
115
|
-
|
124
|
+
If you want to run a particular line of spec
|
125
|
+
|
116
126
|
$ bundle exec rspec spec/models/state_spec.rb:7
|
117
127
|
|
118
|
-
|
119
|
-
|
128
|
+
If you want to run a single cucumber feature
|
129
|
+
|
130
|
+
$ bundle exec cucumber features/admin/orders.feature --require features
|
120
131
|
|
121
|
-
|
122
|
-
|
132
|
+
If you want to run a particular scenario then include the line number
|
133
|
+
|
134
|
+
$ bundle exec cucumber features/admin/orders.feature:3 --require features
|
123
135
|
|
124
136
|
|
125
137
|
Contributing
|
126
138
|
------------
|
127
139
|
|
128
140
|
Spree is an open source project. We encourage contributions. Please see the [contributors guidelines](http://spreecommerce.com/documentation/contributing_to_spree.html) before contributing.
|
129
|
-
|
130
|
-
The Github team has also been kind enough to write up some great [documentation](http://help.github.com/pull-requests/) on working with pull requests. Contributions should be performed on [topic branches](http://progit.org/book/ch3-4.html) in your personal forks - just issue your pull requests from there. We're also asking that you continue to log important issues for non-trivial patches in our [lighthouse repository](http://railsdog.lighthouseapp.com/projects/31096-spree). You can just link the pull request in the ticket (and link the ticket in the pull request.)
|
data/lib/spree.rb
CHANGED
data/lib/spree/bin/spree
ADDED
data/lib/spree/cli.rb
ADDED
@@ -0,0 +1,52 @@
|
|
1
|
+
require "rubygems"
|
2
|
+
require "spree_core/version"
|
3
|
+
require "thor"
|
4
|
+
require 'spree/extension'
|
5
|
+
#require 'spree/application'
|
6
|
+
#require 'spree/test'
|
7
|
+
|
8
|
+
module Spree
|
9
|
+
class CLI < Thor
|
10
|
+
def self.basename
|
11
|
+
"spree"
|
12
|
+
end
|
13
|
+
|
14
|
+
map "-v" => "version"
|
15
|
+
map "--version" => "version"
|
16
|
+
|
17
|
+
desc "version", "print the current version"
|
18
|
+
def version
|
19
|
+
shell.say "Spree #{Spree.version}", :green
|
20
|
+
end
|
21
|
+
|
22
|
+
desc "extension NAME", "create a new extension with the given name"
|
23
|
+
method_option "name", :type => :string
|
24
|
+
def extension(name)
|
25
|
+
invoke "spree:extension:generate", [options[:name] || name]
|
26
|
+
end
|
27
|
+
|
28
|
+
#desc "app NAME", "creates a new rails app configured to use Spree"
|
29
|
+
#method_option "name", :type => :string
|
30
|
+
#method_option "sample", :type => :boolean, :default => false
|
31
|
+
#method_option "bootstrap", :type => :boolean, :default => false
|
32
|
+
#method_option "clean", :type => :boolean, :default => false
|
33
|
+
#method_option "dir", :type => :string, :default => '.'
|
34
|
+
#def app(name)
|
35
|
+
#invoke "spree:application:generate", [options[:name] || name, options]
|
36
|
+
#end
|
37
|
+
|
38
|
+
#desc "sandbox", "create a sandbox rails app complete with sample data"
|
39
|
+
#def sandbox(name="sandbox")
|
40
|
+
#invoke "spree:application:generate", [options[:name] || name, {:clean => true, :sample => true,
|
41
|
+
#:bootstrap => true}]
|
42
|
+
#end
|
43
|
+
|
44
|
+
#desc "test_app", "create a rails app suitable for Spree testing"
|
45
|
+
#method_option "dir", :type => :string, :default => '.'
|
46
|
+
#def test_app(name="test_app")
|
47
|
+
##invoke "spree:application:generate", [options[:name] || name, {:clean => true, :dir => options[:dir]}]
|
48
|
+
#invoke "spree:test:generate", [options[:dir]]
|
49
|
+
#end
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
data/lib/spree/engine.rb
ADDED
@@ -0,0 +1,77 @@
|
|
1
|
+
module Spree
|
2
|
+
class Extension < Thor
|
3
|
+
include Thor::Actions
|
4
|
+
|
5
|
+
def self.source_root
|
6
|
+
File.dirname(__FILE__) + '/templates/extension'
|
7
|
+
end
|
8
|
+
|
9
|
+
desc "generate NAME", "generate extension"
|
10
|
+
def generate(name)
|
11
|
+
|
12
|
+
class_path = name.include?('/') ? name.split('/') : name.split('::')
|
13
|
+
class_path.map! { |m| m.underscore }
|
14
|
+
self.file_name = 'spree_' + class_path.pop.gsub('spree_', '')
|
15
|
+
self.human_name = name.titleize
|
16
|
+
self.class_name = file_name.classify
|
17
|
+
|
18
|
+
empty_directory file_name
|
19
|
+
|
20
|
+
directory "app", "#{file_name}/app"
|
21
|
+
|
22
|
+
empty_directory "#{file_name}/app/controllers"
|
23
|
+
empty_directory "#{file_name}/app/helpers"
|
24
|
+
empty_directory "#{file_name}/app/models"
|
25
|
+
empty_directory "#{file_name}/app/views"
|
26
|
+
empty_directory "#{file_name}/app/overrides"
|
27
|
+
empty_directory "#{file_name}/config"
|
28
|
+
empty_directory "#{file_name}/db"
|
29
|
+
|
30
|
+
directory "lib", "#{file_name}/lib"
|
31
|
+
directory "script", "#{file_name}/script"
|
32
|
+
|
33
|
+
empty_directory "#{file_name}/spec"
|
34
|
+
|
35
|
+
template "LICENSE", "#{file_name}/LICENSE"
|
36
|
+
template "Rakefile", "#{file_name}/Rakefile"
|
37
|
+
template "README.md", "#{file_name}/README.md"
|
38
|
+
template "gitignore", "#{file_name}/.gitignore"
|
39
|
+
template "extension.gemspec", "#{file_name}/#{file_name}.gemspec"
|
40
|
+
template "Versionfile", "#{file_name}/Versionfile"
|
41
|
+
template "routes.rb", "#{file_name}/config/routes.rb"
|
42
|
+
template "Gemfile", "#{file_name}/Gemfile" unless integrated
|
43
|
+
template "spec_helper.rb.tt", "#{file_name}/spec/spec_helper.rb"
|
44
|
+
template "rspec", "#{file_name}/.rspec"
|
45
|
+
|
46
|
+
if integrated
|
47
|
+
append_to_file(gemfile) do
|
48
|
+
"\ngem '#{file_name}', :path => '#{file_name}'"
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
no_tasks do
|
54
|
+
# File/Lib Name (ex. spree_paypal_express)
|
55
|
+
attr_accessor :file_name
|
56
|
+
end
|
57
|
+
|
58
|
+
no_tasks do
|
59
|
+
# Human Readable Name (ex. Paypal Express)
|
60
|
+
attr_accessor :human_name
|
61
|
+
end
|
62
|
+
|
63
|
+
no_tasks do
|
64
|
+
# Class Name (ex. PaypalExpress)
|
65
|
+
attr_accessor :class_name
|
66
|
+
end
|
67
|
+
|
68
|
+
protected
|
69
|
+
def gemfile
|
70
|
+
File.expand_path("Gemfile", Dir.pwd)
|
71
|
+
end
|
72
|
+
# extension is integrated with an existing rails app (as opposed to standalone repository)
|
73
|
+
def integrated
|
74
|
+
File.exist?(gemfile)
|
75
|
+
end
|
76
|
+
end
|
77
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
source 'http://rubygems.org'
|
2
|
+
|
3
|
+
gem 'sqlite3'
|
4
|
+
|
5
|
+
group :test do
|
6
|
+
gem 'rspec-rails', '= 2.6.1'
|
7
|
+
end
|
8
|
+
|
9
|
+
group :cucumber do
|
10
|
+
gem 'cucumber-rails', '1.0.0'
|
11
|
+
gem 'database_cleaner', '= 0.6.7'
|
12
|
+
gem 'nokogiri'
|
13
|
+
gem 'capybara', '1.0.1'
|
14
|
+
end
|
15
|
+
|
16
|
+
if RUBY_VERSION < "1.9"
|
17
|
+
gem "ruby-debug"
|
18
|
+
else
|
19
|
+
gem "ruby-debug19"
|
20
|
+
end
|
21
|
+
|
22
|
+
gemspec
|
@@ -1,14 +1,17 @@
|
|
1
|
-
|
1
|
+
Copyright (c) <%= Date.today.year %> [name of plugin creator]
|
2
|
+
All rights reserved.
|
3
|
+
|
4
|
+
Redistribution and use in source and binary forms, with or without modification,
|
2
5
|
are permitted provided that the following conditions are met:
|
3
6
|
|
4
|
-
* Redistributions of source code must retain the above copyright notice,
|
7
|
+
* Redistributions of source code must retain the above copyright notice,
|
5
8
|
this list of conditions and the following disclaimer.
|
6
|
-
* Redistributions in binary form must reproduce the above copyright notice,
|
7
|
-
this list of conditions and the following disclaimer in the documentation
|
9
|
+
* Redistributions in binary form must reproduce the above copyright notice,
|
10
|
+
this list of conditions and the following disclaimer in the documentation
|
8
11
|
and/or other materials provided with the distribution.
|
9
|
-
* Neither the name
|
10
|
-
|
11
|
-
|
12
|
+
* Neither the name Spree nor the names of its contributors may be used to
|
13
|
+
endorse or promote products derived from this software without specific
|
14
|
+
prior written permission.
|
12
15
|
|
13
16
|
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
14
17
|
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
@@ -20,4 +23,4 @@ PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
|
20
23
|
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
21
24
|
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
22
25
|
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
23
|
-
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
26
|
+
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
@@ -9,5 +9,12 @@ Example
|
|
9
9
|
|
10
10
|
Example goes here.
|
11
11
|
|
12
|
+
Testing
|
13
|
+
-------
|
14
|
+
|
15
|
+
Be sure to add the rspec-rails gem to your Gemfile and then create a dummy test app for the specs to run against.
|
16
|
+
|
17
|
+
$ bundle exec rake test app
|
18
|
+
$ bundle exec rspec spec
|
12
19
|
|
13
20
|
Copyright (c) <%= Date.today.year %> [name of extension creator], released under the New BSD License
|
@@ -0,0 +1,31 @@
|
|
1
|
+
require 'rake'
|
2
|
+
require 'rake/testtask'
|
3
|
+
require 'rake/packagetask'
|
4
|
+
require 'rubygems/package_task'
|
5
|
+
require 'rspec/core/rake_task'
|
6
|
+
require 'cucumber/rake/task'
|
7
|
+
require 'spree_core/testing_support/common_rake'
|
8
|
+
|
9
|
+
RSpec::Core::RakeTask.new
|
10
|
+
Cucumber::Rake::Task.new
|
11
|
+
|
12
|
+
task :default => [:spec, :cucumber ]
|
13
|
+
|
14
|
+
spec = eval(File.read('<%=file_name%>.gemspec'))
|
15
|
+
|
16
|
+
Gem::PackageTask.new(spec) do |p|
|
17
|
+
p.gem_spec = spec
|
18
|
+
end
|
19
|
+
|
20
|
+
desc "Release to gemcutter"
|
21
|
+
task :release => :package do
|
22
|
+
require 'rake/gemcutter'
|
23
|
+
Rake::Gemcutter::Tasks.new(spec).define
|
24
|
+
Rake::Task['gem:push'].invoke
|
25
|
+
end
|
26
|
+
|
27
|
+
desc "Generates a dummy app for testing"
|
28
|
+
task :test_app do
|
29
|
+
ENV['LIB_NAME'] = '<%=file_name%>'
|
30
|
+
Rake::Task['common:test_app'].invoke
|
31
|
+
end
|
@@ -0,0 +1 @@
|
|
1
|
+
//= require admin/spree_core
|
@@ -0,0 +1 @@
|
|
1
|
+
//= require store/spree_core
|
data/lib/{generators/templates/extension.gemspec.tt → spree/templates/extension/extension.gemspec}
RENAMED
@@ -1,3 +1,4 @@
|
|
1
|
+
# encoding: UTF-8
|
1
2
|
Gem::Specification.new do |s|
|
2
3
|
s.platform = Gem::Platform::RUBY
|
3
4
|
s.name = '<%= file_name %>'
|
@@ -11,10 +12,12 @@ Gem::Specification.new do |s|
|
|
11
12
|
# s.homepage = 'http://www.rubyonrails.org'
|
12
13
|
# s.rubyforge_project = 'actionmailer'
|
13
14
|
|
14
|
-
s.files = `git ls-files`.split("\n")
|
15
|
-
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
15
|
+
#s.files = `git ls-files`.split("\n")
|
16
|
+
#s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
16
17
|
s.require_path = 'lib'
|
17
18
|
s.requirements << 'none'
|
18
19
|
|
19
|
-
s.add_dependency
|
20
|
+
s.add_dependency 'spree_core', '>= <%= Spree.version %>'
|
21
|
+
s.add_development_dependency 'rspec-rails'
|
20
22
|
end
|
23
|
+
|
@@ -0,0 +1,24 @@
|
|
1
|
+
module <%= class_name %>
|
2
|
+
class Engine < Rails::Engine
|
3
|
+
engine_name '<%= file_name %>'
|
4
|
+
|
5
|
+
config.autoload_paths += %W(#{config.root}/lib)
|
6
|
+
|
7
|
+
# use rspec for tests
|
8
|
+
config.generators do |g|
|
9
|
+
g.test_framework :rspec
|
10
|
+
end
|
11
|
+
|
12
|
+
def self.activate
|
13
|
+
Dir.glob(File.join(File.dirname(__FILE__), "../../app/**/*_decorator*.rb")) do |c|
|
14
|
+
Rails.application.config.cache_classes ? require(c) : load(c)
|
15
|
+
end
|
16
|
+
|
17
|
+
Dir.glob(File.join(File.dirname(__FILE__), "../../app/overrides/*.rb")) do |c|
|
18
|
+
Rails.application.config.cache_classes ? require(c) : load(c)
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
config.to_prepare &method(:activate).to_proc
|
23
|
+
end
|
24
|
+
end
|