rubyapp 0.1.0 → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore CHANGED
@@ -1 +1,3 @@
1
- .DS_Store
1
+ .DS_Store
2
+ pkg
3
+ *.gemspec
@@ -36,9 +36,10 @@ Alternatively run it using the binary
36
36
  ## Options ##
37
37
 
38
38
  You can define system wide default options for ruby apps you create (your preferred framework stack) in a <code>~/.rubyapp</code> file.
39
- The *~* implies ENV['HOME], the environment variable "HOME" on any system. Any options you call the program with explicitly will override the defaults in this file.
39
+ The <code>~*</code> implies <code>ENV['HOME]</code>, the environment variable "HOME" on any system.
40
+ Any options you call the program with explicitly will override the defaults in this file.
40
41
 
41
- The options --rspec2, --cucumber, --license, --autotest, and --bundler are all set to true unless explicitly disabled either in the .rubyapp file or using the negation option when rubyapp is run (see negating boolean options below).
42
+ The options <code>--rspec2, --cucumber, --license, --autotest, and --bundler</code> are all set to true unless explicitly disabled either in the <code>.rubyapp</code> file or using the negation option when rubyapp is run (see negating boolean options below).
42
43
 
43
44
  Boolean options:
44
45
  To negate a boolean option prefix it with <code>no-</code>, fx <code>--no-rspec2</code> to disable rspec2 from the project infrastructure creation.
@@ -55,22 +56,31 @@ Rubyproject currently supports the following boolean options:
55
56
  --binaries
56
57
  --test_unit
57
58
  --shoulda
58
- --mock_lib
59
59
  --autotest
60
60
  --heckle
61
61
  --rake
62
- --rcov
62
+ --rcov
63
+ --timecop
64
+ --fakefs
63
65
  --require_me
64
66
  </code></pre>
65
67
 
66
68
  String options:
67
69
  <code>--mock-lib</code>
70
+ <code>--factory-lib</code>
68
71
 
72
+ Mock-lib:
69
73
  Valid *mock-lib* values: rspec, mocha, flexmock, rr
70
74
 
71
75
  Example:
72
76
  <code>$ rubyapp my-ruby-mock-project --mock-lib flexmock</code>
73
77
 
78
+ Factory-lib:
79
+ Valid *factory-lib* values: factory_girl, machinist, object_daddy, blueprints
80
+
81
+ Example:
82
+ <code>$ rubyapp my-ruby-mock-project --factory-lib factory_girl</code>
83
+
74
84
  ## Community ##
75
85
  Please feel free to fork this project or provide suggestions for improvements, bug fixes etc.
76
86
 
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.0
1
+ 0.1.2
@@ -1,8 +1,10 @@
1
1
  require 'active_support/inflector'
2
+ require 'thor'
3
+ require 'thor/group'
2
4
 
3
5
  module Ruby
4
- class App < Thor::Group
5
- include Thor::Actions
6
+ class App < ::Thor::Group
7
+ include ::Thor::Actions
6
8
 
7
9
  desc "Generates a ruby application"
8
10
 
@@ -18,15 +20,18 @@ module Ruby
18
20
  class_option :test_unit, :type => :boolean, :desc => "Use Test-unit"
19
21
  class_option :shoulda, :type => :boolean, :desc => "Use Shoulda"
20
22
 
21
- class_option :mock_lib, :type => :string, :desc => "Which Mocking framework to use"
23
+ class_option :mock_lib, :type => :string, :desc => "Mocking framework to be used"
22
24
  class_option :autotest, :type => :boolean, :desc => "Use autotest"
23
25
  class_option :heckle, :type => :boolean, :desc => "Use Heckle"
24
26
 
25
27
  class_option :rake, :type => :boolean, :desc => "Configure Rakefile for Rake"
26
28
  class_option :jeweler, :type => :boolean, :desc => "Use Jeweler"
27
29
  class_option :rcov, :type => :boolean, :desc => "Use RCov"
30
+ class_option :fakefs, :type => :boolean, :desc => "Use FakeFS to fake the File system"
28
31
 
29
- class_option :require_me, :type => :boolean, :desc => "Use require-me gem"
32
+ class_option :readme, :type => :string, :desc => "README markup language to be used"
33
+
34
+ class_option :require_me, :type => :boolean, :desc => "Use require-me gem for require DSL"
30
35
 
31
36
  class_option :bundler, :type => :boolean, :desc => "Create a Gemfile and configure project to use Bundler"
32
37
 
@@ -61,7 +66,9 @@ module Ruby
61
66
 
62
67
  def default_settings
63
68
  @project_options ||= options.dup
64
- [:rspec2, :cucumber, :license, :autotest, :bundler].each{|key| project_options[key] ||= true}
69
+ [:rspec2, :cucumber, :license, :autotest, :bundler].each{|key| project_options[key] ||= true}
70
+ project_options[:mock_lib] ||= 'mocha'
71
+ project_options[:readme] ||= 'markdown'
65
72
  end
66
73
 
67
74
  def create_root
@@ -72,8 +79,10 @@ module Ruby
72
79
 
73
80
  def install_gems
74
81
  return nil if !project_options[:install_gems]
82
+ gems = []
75
83
  gems << "heckle" if project_options[:heckle]
76
84
  gems << "rcov" if project_options[:rcov]
85
+ gems << "fakefs" if project_options[:fakefs]
77
86
  gems << "cucumber" if project_options[:cucumber]
78
87
  gems << "ZenTest autotest-growl autotest-fsevent" if project_options[:autotest]
79
88
  gems << "#{project_options[:mock_lib]}"
@@ -88,28 +97,24 @@ module Ruby
88
97
  run "gem install #{gems.join(' ')}"
89
98
  end
90
99
 
91
- def main_runner
100
+ def main_runner
101
+ say "rubyapp v.0.1.1"
92
102
  if project_options[:jeweler]
93
103
  run "jeweler #{appname}"
94
104
  else
95
105
  create_app
96
106
  end
97
- create_gemfile if !skip?(:bundler, 'Use Bundler?')
98
- create_binaries if !skip?(:binaries, 'Create binaries?')
99
- configure_cucumber if !skip?(:cucumber, 'Use Cucumber?')
107
+ create_gemfile if !skip? :bundler, 'Use Bundler?'
108
+ create_binaries if !skip? :binaries, 'Create binaries?'
109
+ configure_cucumber if !skip? :cucumber, 'Use Cucumber?'
100
110
  configure_rspec2 if project_options[:rspec2]
101
- configure_autotest if !skip?(:autotest, 'Use autotest?')
111
+ configure_autotest if !skip? :autotest, 'Use autotest?'
102
112
  configure_shoulda if project_options[:shoulda]
103
- configure_test_unit if project_options[:test_unit]
113
+ configure_test_unit if project_options[:test_unit]
104
114
  create_gitignore
105
115
  create_readme
106
116
  create_signatures if project_options[:signatures]
107
- if skip?(:license, 'Use MIT license?')
108
- say "Shame on you…", :red
109
- return
110
- else
111
- copy_licence
112
- end
117
+ copy_licence if !skip? :license, 'Use MIT license?'
113
118
  autotest_feature_notice if project_options[:cucumber]
114
119
  end
115
120
 
@@ -136,22 +141,22 @@ module Ruby
136
141
  def create_binaries
137
142
  empty_directory 'bin'
138
143
  inside "bin" do
139
- template('binary', "#{app_name}")
140
- template('binary.bat', "#{app_name}.bat")
144
+ template 'binary', "#{app_name}"
145
+ template 'binary.bat', "#{app_name}.bat"
141
146
  end
142
147
  end
143
148
 
144
149
  def configure_cucumber
145
150
  empty_directory 'features'
146
151
  inside 'features' do
147
- template('app_name.feature.erb', "#{app_name}.feature")
152
+ template 'app_name.feature.erb', "#{app_name}.feature"
148
153
  empty_directory 'step_definitions'
149
154
  inside 'step_definitions' do
150
- template('app_name_steps.erb', "#{app_name}_steps.rb")
155
+ template 'app_name_steps.erb', "#{app_name}_steps.rb"
151
156
  end
152
157
  empty_directory 'support'
153
158
  inside 'support' do
154
- template('env.rb.erb', 'env.rb')
159
+ template 'env.rb.erb', 'env.rb'
155
160
  end
156
161
  end
157
162
  end
@@ -174,23 +179,28 @@ module Ruby
174
179
  def configure_shoulda
175
180
  empty_directory 'shoulda'
176
181
  inside 'shoulda' do
177
- template('test_app_name.rb.erb', "test_#{app_name}.rb")
182
+ template 'test_app_name.rb.erb', "test_#{app_name}.rb"
178
183
  end
179
184
  end
180
185
 
181
186
  def configure_test_unit
182
187
  empty_directory 'test'
183
188
  inside 'test' do
184
- template('test_app_name.rb.erb', "test_#{app_name}.rb")
189
+ template 'test_app_name.rb.erb', "test_#{app_name}.rb"
185
190
  end
186
191
  end
187
192
 
188
193
  def create_gitignore
189
- template('gitignore', '.gitignore')
194
+ template 'gitignore', '.gitignore'
190
195
  end
191
196
 
192
- def create_readme
193
- template('README.markdown', 'README.markdown')
197
+ def create_readme
198
+ case options[:readme]
199
+ when 'rdoc'
200
+ template 'readme/README.rdoc', 'README.rdoc'
201
+ else
202
+ template 'readme/README.markdown', 'README.markdown'
203
+ end
194
204
  end
195
205
 
196
206
 
@@ -1,8 +1,10 @@
1
1
  require 'active_support/inflector'
2
+ require 'thor'
3
+ require 'thor/group'
2
4
 
3
5
  module Ruby
4
- class App < Thor::Group
5
- include Thor::Actions
6
+ class App < ::Thor::Group
7
+ include ::Thor::Actions
6
8
 
7
9
  desc "Generates a ruby application"
8
10
 
@@ -18,15 +20,22 @@ module Ruby
18
20
  class_option :test_unit, :type => :boolean, :desc => "Use Test-unit"
19
21
  class_option :shoulda, :type => :boolean, :desc => "Use Shoulda"
20
22
 
21
- class_option :mock_lib, :type => :string, :desc => "Which Mocking framework to use"
23
+ class_option :mock_lib, :type => :string, :desc => "Mocking framework to be used"
24
+
25
+
22
26
  class_option :autotest, :type => :boolean, :desc => "Use autotest"
23
27
  class_option :heckle, :type => :boolean, :desc => "Use Heckle"
24
28
 
25
29
  class_option :rake, :type => :boolean, :desc => "Configure Rakefile for Rake"
26
30
  class_option :jeweler, :type => :boolean, :desc => "Use Jeweler"
27
31
  class_option :rcov, :type => :boolean, :desc => "Use RCov"
32
+ class_option :fakefs, :type => :boolean, :desc => "Use FakeFS to fake the File system"
33
+ class_option :spies, :type => :boolean, :desc => "Use Rspec-spies"
34
+ class_option :timecop, :type => :boolean, :desc => "Use timecop gem"
28
35
 
29
- class_option :require_me, :type => :boolean, :desc => "Use require-me gem"
36
+ class_option :readme, :type => :string, :desc => "README markup language to be used"
37
+
38
+ class_option :require_me, :type => :boolean, :desc => "Use require-me gem for require DSL"
30
39
 
31
40
  class_option :bundler, :type => :boolean, :desc => "Create a Gemfile and configure project to use Bundler"
32
41
 
@@ -61,7 +70,9 @@ module Ruby
61
70
 
62
71
  def default_settings
63
72
  @project_options ||= options.dup
64
- [:rspec2, :cucumber, :license, :autotest, :bundler].each{|key| project_options[key] ||= true}
73
+ [:rspec2, :cucumber, :license, :autotest, :bundler].each{|key| project_options[key] ||= true}
74
+ project_options[:mock_lib] ||= 'mocha'
75
+ project_options[:readme] ||= 'markdown'
65
76
  end
66
77
 
67
78
  def create_root
@@ -72,8 +83,10 @@ module Ruby
72
83
 
73
84
  def install_gems
74
85
  return nil if !project_options[:install_gems]
86
+ gems = []
75
87
  gems << "heckle" if project_options[:heckle]
76
88
  gems << "rcov" if project_options[:rcov]
89
+ gems << "fakefs" if project_options[:fakefs]
77
90
  gems << "cucumber" if project_options[:cucumber]
78
91
  gems << "ZenTest autotest-growl autotest-fsevent" if project_options[:autotest]
79
92
  gems << "#{project_options[:mock_lib]}"
@@ -82,34 +95,32 @@ module Ruby
82
95
  gems << "shoulda" if project_options[:shoulda]
83
96
  gems << "test-unit" if project_options[:test_unit]
84
97
  gems << "rake" if project_options[:rake]
85
- gems << "jeweler" if project_options[:jeweler]
86
-
98
+ gems << "jeweler" if project_options[:jeweler]
99
+ gems << "timecop" if project_options[:timecop]
100
+
101
+ gems << "#{project_options[:factory_lib]}"
87
102
  run "gem install rspec --pre" if project_options[:rspec]
88
103
  run "gem install #{gems.join(' ')}"
89
104
  end
90
105
 
91
- def main_runner
106
+ def main_runner
107
+ say "rubyapp v.0.1.1"
92
108
  if project_options[:jeweler]
93
109
  run "jeweler #{appname}"
94
110
  else
95
111
  create_app
96
112
  end
97
- create_gemfile if !skip?(:bundler, 'Use Bundler?')
98
- create_binaries if !skip?(:binaries, 'Create binaries?')
99
- configure_cucumber if !skip?(:cucumber, 'Use Cucumber?'
113
+ create_gemfile if !skip? :bundler, 'Use Bundler?'
114
+ create_binaries if !skip? :binaries, 'Create binaries?'
115
+ configure_cucumber if !skip? :cucumber, 'Use Cucumber?'
100
116
  configure_rspec2 if project_options[:rspec2]
101
- configure_autotest if !skip?(:autotest, 'Use autotest?')
117
+ configure_autotest if !skip? :autotest, 'Use autotest?'
102
118
  configure_shoulda if project_options[:shoulda]
103
119
  configure_test_unit if project_options[:test_unit]
104
120
  create_gitignore
105
121
  create_readme
106
122
  create_signatures if project_options[:signatures]
107
- if skip?(:license, 'Use MIT license?')
108
- say "Shame on you…", :red
109
- return
110
- else
111
- copy_licence
112
- end
123
+ copy_licence if !skip? :license, 'Use MIT license?'
113
124
  autotest_feature_notice if project_options[:cucumber]
114
125
  end
115
126
 
@@ -136,22 +147,22 @@ module Ruby
136
147
  def create_binaries
137
148
  empty_directory 'bin'
138
149
  inside "bin" do
139
- template('binary', "#{app_name}")
140
- template('binary.bat', "#{app_name}.bat")
150
+ template 'binary', "#{app_name}"
151
+ template 'binary.bat', "#{app_name}.bat"
141
152
  end
142
153
  end
143
154
 
144
155
  def configure_cucumber
145
156
  empty_directory 'features'
146
157
  inside 'features' do
147
- template('app_name.feature.erb', "#{app_name}.feature")
158
+ template 'app_name.feature.erb', "#{app_name}.feature"
148
159
  empty_directory 'step_definitions'
149
160
  inside 'step_definitions' do
150
- template('app_name_steps.erb', "#{app_name}_steps.rb")
161
+ template 'app_name_steps.erb', "#{app_name}_steps.rb"
151
162
  end
152
163
  empty_directory 'support'
153
164
  inside 'support' do
154
- template('env.rb.erb', 'env.rb')
165
+ template 'env.rb.erb', 'env.rb'
155
166
  end
156
167
  end
157
168
  end
@@ -164,6 +175,8 @@ module Ruby
164
175
  empty_directory "#{app_name}"
165
176
  template 'spec_helper.rb.erb', "spec_helper.rb"
166
177
  template 'app_name/sample_spec.rb.erb', "#{app_name}/#{app_name}_spec.rb"
178
+
179
+ configure_factory_lib 'spec'
167
180
  end
168
181
  end
169
182
 
@@ -174,23 +187,43 @@ module Ruby
174
187
  def configure_shoulda
175
188
  empty_directory 'shoulda'
176
189
  inside 'shoulda' do
177
- template('test_app_name.rb.erb', "test_#{app_name}.rb")
190
+ template 'test_app_name.rb.erb', "test_#{app_name}.rb"
178
191
  end
179
192
  end
180
-
193
+
181
194
  def configure_test_unit
182
195
  empty_directory 'test'
183
196
  inside 'test' do
184
- template('test_app_name.rb.erb', "test_#{app_name}.rb")
197
+ template 'test_app_name.rb.erb', "test_#{app_name}.rb"
198
+
199
+ configure_factory_lib 'test'
185
200
  end
186
201
  end
202
+ def configure_factory_lib(test_dir)
203
+ # factory lib setup
204
+ case project_options[:factory_lib]
205
+ when 'factory_girl'
206
+ empty_directory 'factories'
207
+ when 'machinist'
208
+ copy_file 'machinist/blueprints.rb', "#{test_dir}/blueprints.rb"
209
+ when 'object_daddy'
210
+ copy_file 'object_daddy/model_exemplar.rb', "#{test_dir}/exemplars/model_exemplar.rb"
211
+ when 'blueprints'
212
+ empty_directory 'blueprint'
213
+ end
214
+ end
187
215
 
188
216
  def create_gitignore
189
- template('gitignore', '.gitignore')
217
+ template 'gitignore', '.gitignore'
190
218
  end
191
219
 
192
- def create_readme
193
- template('README.markdown', 'README.markdown')
220
+ def create_readme
221
+ case project_options[:readme]
222
+ when 'rdoc'
223
+ template 'readme/README.rdoc', 'README.rdoc'
224
+ else
225
+ template 'readme/README.markdown', 'README.markdown'
226
+ end
194
227
  end
195
228
 
196
229
 
@@ -214,11 +247,10 @@ module Ruby
214
247
  say "autotest notice:"
215
248
  say "To avoid cucumber features being run, start autotest like this"
216
249
  say "$ AUTOFEATURE=false autotest"
217
- end
218
-
219
- protected
220
- def skip?(key, question)
221
- !project_options[key] || !yes?(question)
222
- end
250
+ end
251
+
252
+ def skip?(key, question)
253
+ !project_options[key] || !yes?(question)
254
+ end
223
255
  end
224
256
  end
@@ -0,0 +1 @@
1
+ # Machinist bluerprints here
@@ -0,0 +1 @@
1
+ # Object Daddy: model_exemplar
@@ -0,0 +1,11 @@
1
+ = <%= app_name.humanize %>
2
+
3
+ The <%= app_name.humanize %> project ...
4
+
5
+ == Installation
6
+
7
+ == Usage
8
+
9
+ == Copyright
10
+
11
+ Copyright (c) <<%= Time.new.year %>> <<%= ENV['USERNAME'] || ENV['USER'] %>>
@@ -3,6 +3,10 @@
3
3
  <%= "require 'require-me'" if project_options[:require_me] %>
4
4
  require 'rspec'
5
5
  require 'rspec/autorun'
6
+ <%= "require 'fakefs'" if project_options[:fakefs] %>
7
+ <%= "require 'rspec-spies'" if project_options[:spies] %>
8
+ <%= "require 'timecop'" if project_options[:timecop] %>
9
+
6
10
  require '<%= app_name %>'
7
11
 
8
12
  RSpec.configure do |config|
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 1
8
- - 0
9
- version: 0.1.0
8
+ - 2
9
+ version: 0.1.2
10
10
  platform: ruby
11
11
  authors:
12
12
  - Kristian Mandrup
@@ -14,7 +14,7 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2010-06-06 00:00:00 -04:00
17
+ date: 2010-06-07 00:00:00 -04:00
18
18
  default_executable: rubyapp
19
19
  dependencies: []
20
20
 
@@ -36,7 +36,6 @@ files:
36
36
  - lib/ruby_app.rb
37
37
  - templates/Gemfile
38
38
  - templates/MITLICENSE
39
- - templates/README.markdown
40
39
  - templates/_signatures/APP.RUBY.signature
41
40
  - templates/autotest.options
42
41
  - templates/autotest/discover.rb
@@ -50,6 +49,10 @@ files:
50
49
  - templates/gitignore
51
50
  - templates/lib/app_entrypoint.erb
52
51
  - templates/lib/app_name.rb.erb
52
+ - templates/machinist/blueprints.rb
53
+ - templates/object_daddy/model_exemplar.rb
54
+ - templates/readme/README.markdown
55
+ - templates/readme/README.rdoc
53
56
  - templates/shoulda/test_app_name.rb.erb
54
57
  - templates/spec/app_name/sample_spec.rb.erb
55
58
  - templates/spec/rspec.options