xspree 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License
2
+
3
+ Copyright (c) 2010 Alessio Rocco
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,52 @@
1
+ xSpree is a base Spree application that you can upgrade.
2
+
3
+ Installation
4
+ ------------
5
+
6
+ First install the xSpree gem:
7
+
8
+ gem install xspree
9
+
10
+ Then run:
11
+
12
+ xspree create projectname
13
+
14
+ This will create a Spree app in `projectname'. This script creates a
15
+ new git repository. It is not meant to be used against an existing repo.
16
+
17
+ Gemfile
18
+ -------
19
+
20
+ To see the latest and greatest gems, look at xSpree'
21
+ [template/files/xspree_Gemfile](https://github.com/AlessioRocco/xSpree/template/files/xspree_Gemfile),
22
+ which will be copied into your projectname/Gemfile.
23
+
24
+ It includes testing gems like:
25
+
26
+ * [Cucumber](https://github.com/aslakhellesoy/cucumber-rails) for integration testing
27
+ * [Capybara](https://github.com/jnicklas/capybara) for acceptance tests
28
+ * [Database Cleaner](https://github.com/bmabey/database_cleaner) for cleaning your database
29
+ * [RSpec](https://github.com/rspec/rspec) for awesome, readable isolation testing
30
+ * [Shoulda](http://github.com/thoughtbot/shoulda) for frequently needed Rails and RSpec matchers
31
+
32
+
33
+ Issues
34
+ ------
35
+
36
+ If you have problems, please create a [Github issue](https://github.com/AlessioRocco/xSpree/issues).
37
+
38
+ Credits
39
+ -------
40
+
41
+ This gem is forked by Suspenders:
42
+
43
+ ![thoughtbot](http://thoughtbot.com/images/tm/logo.png)
44
+
45
+ Suspenders is maintained and funded by [thoughtbot, inc](http://thoughtbot.com/community)
46
+
47
+ The names and logos for thoughtbot are trademarks of thoughtbot, inc.
48
+
49
+ License
50
+ -------
51
+
52
+ xSpree is Copyright © 2008-2011 Alessio Rocco. It is free software, and may be redistributed under the terms specified in the LICENSE file.
data/Rakefile ADDED
@@ -0,0 +1,102 @@
1
+ require 'rubygems'
2
+ require 'rake'
3
+ require 'cucumber/rake/task'
4
+ require 'date'
5
+
6
+ XSPREE_GEM_VERSION = '0.1.1'
7
+
8
+ #############################################################################
9
+ #
10
+ # Testing functions
11
+ #
12
+ #############################################################################
13
+
14
+ Cucumber::Rake::Task.new
15
+
16
+ namespace :test do
17
+ desc "A full xspree app's test suite"
18
+ task :full => ['cucumber']
19
+ end
20
+
21
+ desc 'Run the test suite'
22
+ task :default => ['test:full']
23
+
24
+ #############################################################################
25
+ #
26
+ # Helper functions
27
+ #
28
+ #############################################################################
29
+
30
+ def name
31
+ @name ||= Dir['*.gemspec'].first.split('.').first
32
+ end
33
+
34
+ def version
35
+ XSPREE_GEM_VERSION
36
+ end
37
+
38
+ def date
39
+ Date.today.to_s
40
+ end
41
+
42
+ def gemspec_file
43
+ "#{name}.gemspec"
44
+ end
45
+
46
+ def gem_file
47
+ "#{name}-#{version}.gem"
48
+ end
49
+
50
+ def replace_header(head, header_name)
51
+ head.sub!(/(\.#{header_name}\s*= ').*'/) { "#{$1}#{send(header_name)}'"}
52
+ end
53
+
54
+ #############################################################################
55
+ #
56
+ # Packaging tasks
57
+ #
58
+ #############################################################################
59
+
60
+ task :release => :build do
61
+ unless `git branch` =~ /^\* master$/
62
+ puts "You must be on the master branch to release!"
63
+ exit!
64
+ end
65
+ sh "git commit --allow-empty -a -m 'Release #{version}'"
66
+ sh "git tag v#{version}"
67
+ sh "git push origin master"
68
+ sh "git push --tags"
69
+ sh "gem push pkg/#{name}-#{version}.gem"
70
+ end
71
+
72
+ task :build => :gemspec do
73
+ sh "mkdir -p pkg"
74
+ sh "gem build #{gemspec_file}"
75
+ sh "mv #{gem_file} pkg"
76
+ end
77
+
78
+ task :gemspec do
79
+ # read spec file and split out manifest section
80
+ spec = File.read(gemspec_file)
81
+ head, manifest, tail = spec.split(" # = MANIFEST =\n")
82
+
83
+ # replace name version and date
84
+ replace_header(head, :name)
85
+ replace_header(head, :version)
86
+ replace_header(head, :date)
87
+
88
+ # determine file list from git ls-files
89
+ files = `git ls-files`.
90
+ split("\n").
91
+ sort.
92
+ reject { |file| file =~ /^\./ }.
93
+ reject { |file| file =~ /^(rdoc|pkg)/ }.
94
+ map { |file| " #{file}" }.
95
+ join("\n")
96
+
97
+ # piece file back together and write
98
+ manifest = " s.files = %w[\n#{files}\n ]\n"
99
+ spec = [head, manifest, tail].join(" # = MANIFEST =\n")
100
+ File.open(gemspec_file, 'w') { |io| io.write(spec) }
101
+ puts "Updated #{gemspec_file}"
102
+ end
data/bin/xspree ADDED
@@ -0,0 +1,23 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require File.expand_path(File.dirname(__FILE__) + "/../lib/create")
4
+ require File.expand_path(File.dirname(__FILE__) + "/../lib/errors")
5
+
6
+ include XSpree::Errors
7
+
8
+ def usage
9
+ "Usage: #{File.basename(__FILE__)} create new_project_name"
10
+ end
11
+
12
+ case ARGV[0]
13
+ when 'create', '--create'
14
+ begin
15
+ XSpree::Create.run!(ARGV[1])
16
+ rescue XSpree::InvalidInput => e
17
+ error_with_message(e.message)
18
+ end
19
+ when 'help', '--help'
20
+ puts usage
21
+ else
22
+ error_with_message "Unknown subcommand: #{ARGV[0]}\n#{usage}"
23
+ end
@@ -0,0 +1,13 @@
1
+ Feature: Rake works in the suspended project
2
+
3
+ Scenario: Running rake in the suspended project
4
+ Given a new xspree project named "test_project"
5
+ And I run the rake task "cucumber"
6
+ Then I see a successful response in the shell
7
+
8
+ Scenario: Making a spec then running rake
9
+ Given a new xspree project named "test_project"
10
+ And I generate "model post title:string"
11
+ And I run the rake task "db:migrate"
12
+ And I run the rake task "spec"
13
+ Then I see a successful response in the shell
@@ -0,0 +1,20 @@
1
+ Given 'a new xspree project named "$project_name"' do |project_name|
2
+ `rm -rf ./#{project_name}`
3
+ `./bin/xspree create #{project_name}`
4
+ end
5
+
6
+ When 'I run the rake task "$task_name"' do |task_name|
7
+ Dir.chdir('test_project') do
8
+ system("rake #{task_name}")
9
+ end
10
+ end
11
+
12
+ When 'I generate "$generator_with_args"' do |generator_with_args|
13
+ Dir.chdir('test_project') do
14
+ system("rails generate #{generator_with_args}")
15
+ end
16
+ end
17
+
18
+ Then 'I see a successful response in the shell' do
19
+ $?.to_i.should == 0
20
+ end
@@ -0,0 +1 @@
1
+
data/lib/create.rb ADDED
@@ -0,0 +1,54 @@
1
+ # Methods needed to create a project.
2
+
3
+ require 'rubygems'
4
+ require File.expand_path(File.dirname(__FILE__) + "/errors")
5
+
6
+ module XSpree
7
+ class Create
8
+ attr_accessor :project_path
9
+
10
+ def self.run!(project_path)
11
+ creator = self.new(project_path)
12
+ creator.create_project!
13
+ end
14
+
15
+ def initialize(project_path)
16
+ self.project_path = project_path
17
+ validate_project_path
18
+ validate_project_name
19
+ end
20
+
21
+ def create_project!
22
+ exec(<<-COMMAND)
23
+ rails new #{project_path} \
24
+ --template=#{template} \
25
+ --skip-test-unit \
26
+ --skip-prototype
27
+ COMMAND
28
+ end
29
+
30
+ private
31
+
32
+ def validate_project_name
33
+ project_name = File.basename(project_path)
34
+ unless project_name =~ /^[a-z0-9_]+$/
35
+ raise InvalidInput.new("Project name must only contain [a-z0-9_]")
36
+ end
37
+ end
38
+
39
+ def validate_project_path
40
+ base_directory = Dir.pwd
41
+ full_path = File.join(base_directory, project_path)
42
+
43
+ # This is for the common case for the user's convenience; the race
44
+ # condition can still occur.
45
+ if File.exists?(full_path)
46
+ raise InvalidInput.new("Project directory (#{project_path}) already exists")
47
+ end
48
+ end
49
+
50
+ def template
51
+ File.expand_path(File.dirname(__FILE__) + "/../template/xspree.rb")
52
+ end
53
+ end
54
+ end
data/lib/errors.rb ADDED
@@ -0,0 +1,12 @@
1
+ # User errors
2
+
3
+ module XSpree
4
+ class InvalidInput < Exception; end
5
+
6
+ module Errors
7
+ def error_with_message(msg)
8
+ STDERR.puts msg
9
+ exit 1
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,17 @@
1
+ source 'http://rubygems.org'
2
+
3
+ gem "rails", ">= 3.0.7"
4
+ gem "rake", "~> 0.8.7"
5
+ gem "sqlite3"
6
+
7
+ gem 'spree'
8
+
9
+ # RSpec needs to be in :development group to expose generators
10
+ # and rake tasks without having to type RAILS_ENV=test.
11
+ group :development, :test do
12
+ gem "rspec-rails", "~> 2.4"
13
+ gem "cucumber-rails"
14
+ gem "capybara"
15
+ gem "database_cleaner"
16
+ gem "shoulda"
17
+ end
@@ -0,0 +1,41 @@
1
+ class AppConfiguration < Configuration
2
+
3
+ preference :site_name, :string, :default => 'Spree Demo Site'
4
+ preference :default_seo_title, :string, :default => ''
5
+ preference :site_url, :string, :default => 'demo.spreecommerce.com'
6
+ preference :default_locale, :string, :default => 'en'
7
+ preference :allow_locale_switching, :boolean, :default => true
8
+ preference :default_country_id, :integer, :default => 214
9
+ preference :allow_backorders, :boolean, :default => true
10
+ preference :allow_backorder_shipping, :boolean, :default => false # should only be true if you don't need to track inventory
11
+ preference :track_inventory_levels, :boolean, :default => true # will not track on_hand values for variants /products
12
+ preference :create_inventory_units, :boolean, :default => true # should only be false when track_inventory_levels is false, also disables RMA's
13
+ preference :show_descendents, :boolean, :default => true
14
+ preference :show_zero_stock_products, :boolean, :default => true
15
+ preference :orders_per_page, :integer, :default => 15
16
+ preference :show_only_complete_orders_by_default, :boolean, :default => false
17
+ preference :admin_products_per_page, :integer, :default => 10
18
+ preference :admin_pgroup_preview_size, :integer, :default => 10
19
+ preference :products_per_page, :integer, :default => 10
20
+ preference :logo, :string, :default => '/images/admin/bg/spree_50.png'
21
+ preference :stylesheets, :string, :default => 'screen' # Comma separate multiple stylesheets, e.g. 'screen,mystyle'
22
+ preference :admin_interface_logo, :string, :default => "admin/bg/spree_50.png"
23
+ preference :allow_ssl_in_production, :boolean, :default => true
24
+ preference :allow_ssl_in_development_and_test, :boolean, :default => false
25
+ preference :allow_guest_checkout, :boolean, :default => true
26
+ preference :alternative_billing_phone, :boolean, :default => false # Request extra phone for bill addr
27
+ preference :alternative_shipping_phone, :boolean, :default => false # Request extra phone for ship addr
28
+ preference :shipping_instructions, :boolean, :default => false # Request instructions/info for shipping
29
+ preference :show_price_inc_vat, :boolean, :default => false
30
+ preference :auto_capture, :boolean, :default => false # automatically capture the creditcard (as opposed to just authorize and capture later)
31
+ preference :address_requires_state, :boolean, :default => true # should state/state_name be required
32
+ preference :checkout_zone, :string, :default => nil # replace with the name of a zone if you would like to limit the countries
33
+ preference :always_put_site_name_in_title, :boolean, :default => true
34
+ preference :cache_static_content, :boolean, :default => true
35
+ preference :use_content_controller, :boolean, :default => true
36
+ preference :allow_checkout_on_gateway_error, :boolean, :default => false
37
+ preference :select_taxons_from_tree, :boolean, :default => false # provide opportunity to select taxons from tree instead of search with autocomplete
38
+
39
+ validates :name, :presence => true, :uniqueness => true
40
+
41
+ end
@@ -0,0 +1,11 @@
1
+ db/schema.rb
2
+ public/system
3
+ *.DS_Store
4
+ coverage/*
5
+ *.swp
6
+ rerun.txt
7
+ tags
8
+ !.keep
9
+ vendor/bundler_gems
10
+ .rvmrc
11
+ .idea
@@ -0,0 +1,99 @@
1
+ # xSpree
2
+ # =============
3
+ # by Alessio Rocco
4
+
5
+ require 'net/http'
6
+ require 'net/https'
7
+
8
+ template_root = File.expand_path(File.join(File.dirname(__FILE__)))
9
+ source_paths << File.join(template_root, "files")
10
+
11
+ # Helpers
12
+
13
+ def concat_file(source, destination)
14
+ contents = IO.read(find_in_source_paths(source))
15
+ append_file destination, contents
16
+ end
17
+
18
+ def replace_in_file(relative_path, find, replace)
19
+ path = File.join(destination_root, relative_path)
20
+ contents = IO.read(path)
21
+ unless contents.gsub!(find, replace)
22
+ raise "#{find.inspect} not found in #{relative_path}"
23
+ end
24
+ File.open(path, "w") { |file| file.write(contents) }
25
+ end
26
+
27
+ def action_mailer_host(rails_env, host)
28
+ inject_into_file(
29
+ "config/environments/#{rails_env}.rb",
30
+ "\n\n config.action_mailer.default_url_options = { :host => '#{host}' }",
31
+ :before => "\nend"
32
+ )
33
+ end
34
+
35
+ def download_file(uri_string, destination)
36
+ uri = URI.parse(uri_string)
37
+ http = Net::HTTP.new(uri.host, uri.port)
38
+ http.use_ssl = true if uri_string =~ /^https/
39
+ request = Net::HTTP::Get.new(uri.path)
40
+ contents = http.request(request).body
41
+ path = File.join(destination_root, destination)
42
+ File.open(path, "w") { |file| file.write(contents) }
43
+ end
44
+
45
+ say "Getting rid of files we don't use"
46
+
47
+ remove_file "README"
48
+ remove_file "public/index.html"
49
+ remove_file "public/images/rails.png"
50
+ remove_file "app/views/layouts/application.html.erb"
51
+
52
+ say "Setting up the staging environment"
53
+
54
+ run "cp config/environments/production.rb config/environments/staging.rb"
55
+
56
+ say "Get ready for bundler... (this will take a while)"
57
+
58
+ copy_file 'xspree_Gemfile', 'Gemfile', :force => true
59
+ run "bundle install"
60
+
61
+ say "Setting up plugins"
62
+
63
+ generate "rspec:install"
64
+ generate "cucumber:install", "--rspec --capybara"
65
+
66
+ say "Installing spree"
67
+
68
+ generate "spree:site"
69
+ rake "spree:install"
70
+ copy_file "xspree_app_configuration.rb", "app/models/app_configuration.rb"
71
+ replace_in_file "lib/spree_site.rb", "# Add your custom site logic here",
72
+ <<-eos
73
+ # Add your custom site logic here
74
+ Dir.glob(File.join(File.dirname(__FILE__), "../app/**/*_decorator*.rb")) do |c|
75
+ Rails.configuration.cache_classes ? require(c) : load(c)
76
+ end
77
+ eos
78
+
79
+ language = ask("Would you like to install language? [it]")
80
+ language = "it" if language.blank?
81
+ download_file("https://github.com/svenfuchs/rails-i18n/raw/master/rails/locale/#{language}.yml", "config/locales/#{language}.yml")
82
+ download_file("https://github.com/spree/spree_i18n/raw/master/config/locales/#{language}.yml", "config/locales/#{language}_spree.yml")
83
+
84
+ if yes?("Would you like to run 'db:migrate' and 'db:seed'?")
85
+ rake "db:migrate"
86
+ rake "db:seed"
87
+ end
88
+
89
+ say "Ignore the right files"
90
+
91
+ concat_file "xspree_gitignore", ".gitignore"
92
+ empty_directory_with_gitkeep "app/models"
93
+ empty_directory_with_gitkeep "db/migrate"
94
+ empty_directory_with_gitkeep "log"
95
+ empty_directory_with_gitkeep "public/images"
96
+ empty_directory_with_gitkeep "spec/support"
97
+
98
+ say "Congratulations! You just pulled our xSpree."
99
+
data/xspree.gemspec ADDED
@@ -0,0 +1,51 @@
1
+ Gem::Specification.new do |s|
2
+ s.specification_version = 2 if s.respond_to? :specification_version=
3
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
4
+ s.rubygems_version = '1.6.2'
5
+
6
+ s.name = 'xspree'
7
+ s.version = '0.1.1'
8
+ s.date = '2011-05-30'
9
+
10
+ s.summary = "Generate a Spree app using Alessio Rocco's best practices."
11
+ s.description = <<-HERE
12
+ xSpree is a base Spree project that you can upgrade. It is used by
13
+ Alessio Rocco to get a jump start on a working app. Use xSpree if you're in a
14
+ rush to build something amazing; don't use it if you like missing deadlines.
15
+ HERE
16
+
17
+ s.authors = ["thoughtbot", "Alessio Rocco"]
18
+ s.email = 'alessio.rocco.lt@gmail.com'
19
+ s.homepage = 'http://github.com/AlessioRocco/xSpree'
20
+
21
+ s.executables = ["xspree"]
22
+ s.default_executable = 'xspree'
23
+
24
+ s.rdoc_options = ["--charset=UTF-8"]
25
+ s.extra_rdoc_files = %w[README.md LICENSE]
26
+
27
+ s.add_dependency('rails')
28
+ s.add_dependency('bundler')
29
+ s.add_dependency('spree')
30
+
31
+ # = MANIFEST =
32
+ s.files = %w[
33
+ LICENSE
34
+ README.md
35
+ Rakefile
36
+ bin/xspree
37
+ features/rake_clean.feature
38
+ features/step_definitions/shell.rb
39
+ features/support/env.rb
40
+ lib/create.rb
41
+ lib/errors.rb
42
+ template/files/xspree_Gemfile
43
+ template/files/xspree_app_configuration.rb
44
+ template/files/xspree_gitignore
45
+ template/xspree.rb
46
+ xspree.gemspec
47
+ ]
48
+ # = MANIFEST =
49
+
50
+ s.test_files = s.files.select {|path| path =~ /^features/ }
51
+ end
metadata ADDED
@@ -0,0 +1,107 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: xspree
3
+ version: !ruby/object:Gem::Version
4
+ prerelease:
5
+ version: 0.1.1
6
+ platform: ruby
7
+ authors:
8
+ - thoughtbot
9
+ - Alessio Rocco
10
+ autorequire:
11
+ bindir: bin
12
+ cert_chain: []
13
+
14
+ date: 2011-05-30 00:00:00 Z
15
+ dependencies:
16
+ - !ruby/object:Gem::Dependency
17
+ name: rails
18
+ prerelease: false
19
+ requirement: &id001 !ruby/object:Gem::Requirement
20
+ none: false
21
+ requirements:
22
+ - - ">="
23
+ - !ruby/object:Gem::Version
24
+ version: "0"
25
+ type: :runtime
26
+ version_requirements: *id001
27
+ - !ruby/object:Gem::Dependency
28
+ name: bundler
29
+ prerelease: false
30
+ requirement: &id002 !ruby/object:Gem::Requirement
31
+ none: false
32
+ requirements:
33
+ - - ">="
34
+ - !ruby/object:Gem::Version
35
+ version: "0"
36
+ type: :runtime
37
+ version_requirements: *id002
38
+ - !ruby/object:Gem::Dependency
39
+ name: spree
40
+ prerelease: false
41
+ requirement: &id003 !ruby/object:Gem::Requirement
42
+ none: false
43
+ requirements:
44
+ - - ">="
45
+ - !ruby/object:Gem::Version
46
+ version: "0"
47
+ type: :runtime
48
+ version_requirements: *id003
49
+ description: |
50
+ xSpree is a base Spree project that you can upgrade. It is used by
51
+ Alessio Rocco to get a jump start on a working app. Use xSpree if you're in a
52
+ rush to build something amazing; don't use it if you like missing deadlines.
53
+
54
+ email: alessio.rocco.lt@gmail.com
55
+ executables:
56
+ - xspree
57
+ extensions: []
58
+
59
+ extra_rdoc_files:
60
+ - README.md
61
+ - LICENSE
62
+ files:
63
+ - LICENSE
64
+ - README.md
65
+ - Rakefile
66
+ - bin/xspree
67
+ - features/rake_clean.feature
68
+ - features/step_definitions/shell.rb
69
+ - features/support/env.rb
70
+ - lib/create.rb
71
+ - lib/errors.rb
72
+ - template/files/xspree_Gemfile
73
+ - template/files/xspree_app_configuration.rb
74
+ - template/files/xspree_gitignore
75
+ - template/xspree.rb
76
+ - xspree.gemspec
77
+ homepage: http://github.com/AlessioRocco/xSpree
78
+ licenses: []
79
+
80
+ post_install_message:
81
+ rdoc_options:
82
+ - --charset=UTF-8
83
+ require_paths:
84
+ - lib
85
+ required_ruby_version: !ruby/object:Gem::Requirement
86
+ none: false
87
+ requirements:
88
+ - - ">="
89
+ - !ruby/object:Gem::Version
90
+ version: "0"
91
+ required_rubygems_version: !ruby/object:Gem::Requirement
92
+ none: false
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: "0"
97
+ requirements: []
98
+
99
+ rubyforge_project:
100
+ rubygems_version: 1.8.4
101
+ signing_key:
102
+ specification_version: 2
103
+ summary: Generate a Spree app using Alessio Rocco's best practices.
104
+ test_files:
105
+ - features/rake_clean.feature
106
+ - features/step_definitions/shell.rb
107
+ - features/support/env.rb