spree_cmd 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore ADDED
@@ -0,0 +1,4 @@
1
+ *.gem
2
+ .bundle
3
+ Gemfile.lock
4
+ pkg/*
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source "http://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in spree_cmd.gemspec
4
+ gemspec
data/README.md ADDED
@@ -0,0 +1,45 @@
1
+ Spree Installer
2
+ ===============
3
+
4
+ Command line utility to create new Spree store applications
5
+
6
+ See the main spree project: https://github.com/spree/spree
7
+
8
+ Examples
9
+ --------
10
+
11
+ Until the release of Spree 1.0 you must use the --edge option:
12
+
13
+ spree new my_store --edge
14
+
15
+ If you want to accept all the defaults pass --auto_accept
16
+
17
+ spree new my_store --edge --auto_accept
18
+
19
+ to use a local clone of Spree, pass the --path option
20
+
21
+ spree new my_store --path=../spree
22
+
23
+ Installation
24
+ ------------
25
+
26
+ ```ruby
27
+ gem install spree_cmd
28
+ spree new my_store
29
+
30
+ or for an existing application
31
+
32
+ spree install existing_rails_app
33
+ ```
34
+
35
+ options
36
+ -------
37
+
38
+ * --auto_accept - answer yes to all questions
39
+ * --edge - to use the edge version of Spree
40
+ * --path=../spree - to use a local version of spree
41
+
42
+
43
+
44
+
45
+
data/Rakefile ADDED
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
data/bin/spree ADDED
@@ -0,0 +1,145 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'rubygems'
4
+ require 'thor/group'
5
+
6
+ module SpreeCmd
7
+ class Install < Thor::Group
8
+ include Thor::Actions
9
+
10
+ desc "Creates a new rails project with a spree store"
11
+ argument :new_or_install, :desc => 'new project_name or install existing_project'
12
+ argument :app_path, :type => :string, :desc => 'rails app_path'
13
+
14
+ class_option :auto_accept, :type => :boolean, :aliases => '-A', :desc => "Answer yes to all prompts"
15
+
16
+ class_option :skip_install_data, :type => :boolean, :default => false,
17
+ :desc => 'Skip running migrations and loading seed and sample data'
18
+
19
+ class_option :version, :type => :string, :default => 'current',
20
+ :desc => 'Spree Version to use (current, edge, local)'
21
+
22
+ class_option :edge, :type => :boolean
23
+ class_option :path, :type => :string
24
+
25
+ def prepare_options
26
+ if options[:edge]
27
+ @spree_gem_options = { :git => 'https://github.com/spree/spree.git' }
28
+ elsif options[:path]
29
+ @spree_gem_options = { :path => options[:path] }
30
+ else
31
+ @spree_gem_options = {}
32
+ end
33
+ end
34
+
35
+ def ask_questions
36
+ @install_blue_theme = ask_with_default("Would you like to install the default blue theme?")
37
+ @install_default_gateways = ask_with_default("Would you like to install the default gateways?")
38
+
39
+ if options[:skip_install_data]
40
+ @run_migrations = false
41
+ @load_seed_data = false
42
+ @load_sample_data = false
43
+ else
44
+ @run_migrations = ask_with_default("Would you like to run the migrations?")
45
+ if @run_migrations
46
+ @load_seed_data = ask_with_default("Would you like to load the seed data?")
47
+ @load_sample_data = ask_with_default("Would you like to load the sample data?")
48
+ else
49
+ @load_seed_data = false
50
+ @load_sample_data = false
51
+ end
52
+ end
53
+ end
54
+
55
+ def rails_app
56
+ case @new_or_install
57
+ when 'new'
58
+ create_rails_app
59
+ when 'install'
60
+ if is_rails_project?
61
+ say :install, "Adding Spree to #{@app_path}"
62
+ else
63
+ raise "#{@app_path} rails project not found"
64
+ end
65
+ else
66
+ raise "specify new or install"
67
+ end
68
+ end
69
+
70
+ def add_gems
71
+ inside @app_path do
72
+
73
+ gem :spree, @spree_gem_options
74
+
75
+ if @install_blue_theme
76
+ gem :spree_blue_theme, { :git => 'git@github.com:spree/spree_blue_theme.git',
77
+ :ref => '10666404ccb3ed4a4cc9cbe41e822ab2bb55112e' }
78
+ end
79
+
80
+ if @install_default_gateways
81
+ gem :spree_usa_epay, { :git => 'git@github.com:spree/spree_usa_epay.git',
82
+ :ref => '2be3faede9594327b9bb548ad042ef28f2836509' }
83
+
84
+ gem :spree_skrill, { :git => 'git@github.com:spree/spree_skrill.git',
85
+ :ref => '6743bcbd0146d1c7145d6befc648005d8d0cf79a' }
86
+ end
87
+
88
+ run 'bundle install'
89
+ end
90
+ end
91
+
92
+ def initialize_spree
93
+ spree_options = []
94
+ spree_options << "--migrate=#{@run_migrations}"
95
+ spree_options << "--seed=#{@load_seed_data}"
96
+ spree_options << "--sample=#{@load_sample_data}"
97
+ spree_options << "--auto_accept" if options[:auto_accept]
98
+
99
+ inside @app_path do
100
+ run "rails generate spree:install #{spree_options.join(' ')}"
101
+ end
102
+ end
103
+
104
+ private
105
+
106
+ def gem(name, options={})
107
+ say_status :gemfile, name
108
+ parts = ["'#{name}'"]
109
+ options.each {|key, value| parts << ":#{key} => '#{value}'" }
110
+ append_file "Gemfile", "gem #{parts.join(', ')}\n", :verbose => false
111
+ end
112
+
113
+ def ask_with_default(message, default='yes')
114
+ return true if options[:auto_accept]
115
+
116
+ valid = false
117
+ until valid
118
+ response = ask "#{message} (y/n) [#{default}]"
119
+ response = default if response.empty?
120
+ valid = (response =~ /\Ay(?:es)?|no?\Z/i)
121
+ end
122
+ response.downcase[0] == ?y
123
+ end
124
+
125
+ def create_rails_app
126
+ say :create, @app_path
127
+
128
+ rails_cmd = "rails new #{@app_path} --skip-bundle"
129
+ if options[:template]
130
+ rails_cmd += " -m #{options[:template]}"
131
+ end
132
+ if options[:database]
133
+ rails_cmd += " -d #{options[:database]}"
134
+ end
135
+ run(rails_cmd)
136
+ end
137
+
138
+ def is_rails_project?
139
+ File.exists? File.join(@app_path, 'script', 'rails')
140
+ end
141
+
142
+ end
143
+
144
+ Install.start
145
+ end
data/lib/spree_cmd.rb ADDED
@@ -0,0 +1,5 @@
1
+ require "spree_cmd/version"
2
+
3
+ module SpreeCmd
4
+ # Your code goes here...
5
+ end
@@ -0,0 +1,3 @@
1
+ module SpreeCmd
2
+ VERSION = "0.0.3"
3
+ end
data/spree_cmd.gemspec ADDED
@@ -0,0 +1,24 @@
1
+ # -*- encoding: utf-8 -*-
2
+ $:.push File.expand_path("../lib", __FILE__)
3
+ require "spree_cmd/version"
4
+
5
+ Gem::Specification.new do |s|
6
+ s.name = "spree_cmd"
7
+ s.version = SpreeCmd::VERSION
8
+ s.authors = ["Chris Mar"]
9
+ s.email = ["chris@spreecommerce.com"]
10
+ s.homepage = ""
11
+ s.summary = %q{Create new Spree stores}
12
+ s.description = %q{command line utility to create new stores or add Spree to existing applications}
13
+
14
+ s.rubyforge_project = "spree_cmd"
15
+
16
+ s.files = `git ls-files`.split("\n")
17
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
18
+ s.bindir = 'bin'
19
+ s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
20
+ s.require_paths = ["lib"]
21
+
22
+ s.add_dependency 'rails', '>= 3.1.1'
23
+
24
+ end
metadata ADDED
@@ -0,0 +1,88 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: spree_cmd
3
+ version: !ruby/object:Gem::Version
4
+ hash: 25
5
+ prerelease:
6
+ segments:
7
+ - 0
8
+ - 0
9
+ - 3
10
+ version: 0.0.3
11
+ platform: ruby
12
+ authors:
13
+ - Chris Mar
14
+ autorequire:
15
+ bindir: bin
16
+ cert_chain: []
17
+
18
+ date: 2012-01-10 00:00:00 Z
19
+ dependencies:
20
+ - !ruby/object:Gem::Dependency
21
+ type: :runtime
22
+ prerelease: false
23
+ requirement: &id001 !ruby/object:Gem::Requirement
24
+ none: false
25
+ requirements:
26
+ - - ">="
27
+ - !ruby/object:Gem::Version
28
+ hash: 1
29
+ segments:
30
+ - 3
31
+ - 1
32
+ - 1
33
+ version: 3.1.1
34
+ version_requirements: *id001
35
+ name: rails
36
+ description: command line utility to create new stores or add Spree to existing applications
37
+ email:
38
+ - chris@spreecommerce.com
39
+ executables:
40
+ - spree
41
+ extensions: []
42
+
43
+ extra_rdoc_files: []
44
+
45
+ files:
46
+ - .gitignore
47
+ - Gemfile
48
+ - README.md
49
+ - Rakefile
50
+ - bin/spree
51
+ - lib/spree_cmd.rb
52
+ - lib/spree_cmd/version.rb
53
+ - spree_cmd.gemspec
54
+ homepage: ""
55
+ licenses: []
56
+
57
+ post_install_message:
58
+ rdoc_options: []
59
+
60
+ require_paths:
61
+ - lib
62
+ required_ruby_version: !ruby/object:Gem::Requirement
63
+ none: false
64
+ requirements:
65
+ - - ">="
66
+ - !ruby/object:Gem::Version
67
+ hash: 3
68
+ segments:
69
+ - 0
70
+ version: "0"
71
+ required_rubygems_version: !ruby/object:Gem::Requirement
72
+ none: false
73
+ requirements:
74
+ - - ">="
75
+ - !ruby/object:Gem::Version
76
+ hash: 3
77
+ segments:
78
+ - 0
79
+ version: "0"
80
+ requirements: []
81
+
82
+ rubyforge_project: spree_cmd
83
+ rubygems_version: 1.8.10
84
+ signing_key:
85
+ specification_version: 3
86
+ summary: Create new Spree stores
87
+ test_files: []
88
+