app_drone 0.2.1 → 0.3.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.
Files changed (38) hide show
  1. data/README.md +66 -17
  2. data/README.md~ +68 -18
  3. data/TODO +4 -0
  4. data/TODO~ +4 -6
  5. data/lib/app_drone/drone.rb +24 -6
  6. data/lib/app_drone/drone.rb~ +25 -6
  7. data/lib/app_drone/drones/bootstrap/bootstrap.rb +44 -0
  8. data/lib/app_drone/drones/bootstrap/bootstrap.rb~ +44 -0
  9. data/lib/app_drone/drones/bootstrap/flair.html.slim.erb +7 -0
  10. data/lib/app_drone/drones/bootstrap/flair.html.slim.erb~ +7 -0
  11. data/lib/app_drone/drones/chosen/chosen.rb +1 -0
  12. data/lib/app_drone/drones/chosen/chosen.rb~ +1 -0
  13. data/lib/app_drone/drones/chosen/{flair.html.slim → flair.html.slim.erb} +0 -0
  14. data/lib/app_drone/drones/flair/flair.rb +10 -5
  15. data/lib/app_drone/drones/flair/flair.rb~ +10 -5
  16. data/lib/app_drone/drones/flair/flair_page.erb +2 -5
  17. data/lib/app_drone/drones/flair/flair_page.erb~ +2 -5
  18. data/lib/app_drone/drones/simple_form/install.erb +1 -0
  19. data/lib/app_drone/drones/simple_form/install.erb~ +1 -0
  20. data/lib/app_drone/drones/simple_form/simple_form.rb +20 -0
  21. data/lib/app_drone/drones/simple_form/simple_form.rb~ +20 -0
  22. data/lib/app_drone/object_extensions.rb +6 -0
  23. data/lib/app_drone/object_extensions.rb~ +12 -0
  24. data/lib/app_drone/template.rb +1 -1
  25. data/lib/app_drone/template.rb~ +1 -1
  26. data/lib/app_drone/version.rb +1 -1
  27. data/lib/app_drone/version.rb~ +1 -1
  28. data/out.rb +18 -2
  29. data/out.rb~ +144 -0
  30. data/test/test_app_drone.rb +2 -0
  31. data/test/test_app_drone.rb~ +2 -0
  32. metadata +15 -11
  33. data/lib/app_drone/drones/zzz/bootstrap/bootstrap.rb +0 -29
  34. data/lib/app_drone/drones/zzz/bootstrap/bootstrap.rb~ +0 -29
  35. data/lib/app_drone/drones/zzz/simple_form/install.erb +0 -1
  36. data/lib/app_drone/drones/zzz/simple_form/install.erb~ +0 -1
  37. data/lib/app_drone/drones/zzz/simple_form/simple_form.rb +0 -17
  38. data/lib/app_drone/drones/zzz/simple_form/simple_form.rb~ +0 -17
data/README.md CHANGED
@@ -43,8 +43,8 @@ Parameters can be used to modify drone behavior:
43
43
  To list parameters for a specific drone:
44
44
 
45
45
  AppDrone::Bootstrap.params
46
- # => #<struct Struct::Param name=:vendor, type=:boolean, options=[{:info=>"download a local copy into the repo"}]>
47
- # => #<struct Struct::Param name=:responsive, type=:boolean, options=[{:info=>"include responsive grid"}]>
46
+ # => #<struct Struct::Param name=:vendor, type=:boolean, options={:info=>"download a local copy into the repo"}>
47
+ # => #<struct Struct::Param name=:responsive, type=:boolean, options={:info=>"include responsive grid"}>
48
48
 
49
49
  For readability, you can use the symbol shorthand instead of full class name:
50
50
 
@@ -103,6 +103,33 @@ You can use `desc` in the class declaration to explain what the drone does (most
103
103
  AppDrone::MyDrone.dependencies
104
104
  # => [AppDrone::DeathRay, AppDrone::YourMom]
105
105
 
106
+
107
+ ### Drone pairings
108
+
109
+ Pairing is weaker than a dependency. A template will not render without its dependencies, but pairs are optional inclusions to add extra params and behavior in the presence of another drone.
110
+
111
+ class AppDrone::BarbraStreisand < AppDrone::Drone
112
+ depends_on :bobby_davis_jr
113
+ pairs_with :celine_dion
114
+
115
+ param :wear_human_suit_over_mechaskin, :boolean, info: 'Wear the human disguise'
116
+ param_with :celine_dion, :celine_in_rehab, :boolean, info: 'Is she currently in rehab?'
117
+
118
+ def align
119
+ bobby_davis_jr.say 'Hi'
120
+ bobby_davis_jr.introduce 'This is Celine Dion' if pair?(:celine_dion)
121
+ self.get_changed if param(:wear_human_suit_over_mechaskin)
122
+ end
123
+
124
+ def execute
125
+ do! :duet_with_bobby
126
+ if pair?(:celine_dion)
127
+ do! :coke_with_celine unless param(:celine_in_rehab)
128
+ end
129
+ end
130
+
131
+ end
132
+
106
133
  ### Drone behavior parameters
107
134
 
108
135
  class AppDrone::MyDrone < AppDrone::Drone
@@ -116,6 +143,29 @@ You can use `desc` in the class declaration to explain what the drone does (most
116
143
  t.add :my_drone, lazer_color: 'teh'
117
144
 
118
145
 
146
+ A drone may also declare a parameter that is only to be used in presence of a dependency.
147
+
148
+ You can also use `param_with` to specify a parameter that is expected in presence of a pair:
149
+
150
+ class AppDrone::EddieIzzard
151
+ desc 'Professional transvestite'
152
+
153
+ pairs_with :heels
154
+ param_with :heels, :wearing_heels, :boolean, default: true
155
+
156
+ def align
157
+ # defaults to true in the presence of :heels dependency
158
+ if pair?(:heels) && param(:wearing_heels)
159
+ puts "I am a professional transvestite, so I can run about in heels and not fall over."
160
+ puts "Cause if a woman falls over wearing heels, that’s embarrassing."
161
+ puts "But if a bloke falls over wearing heels, you have to kill yourself."
162
+ puts "It’s the end of your life.
163
+ end
164
+ end
165
+
166
+ end
167
+
168
+
119
169
  ### Drone communication
120
170
 
121
171
  Drones can talk to eachother via a proxy on the template they are included in, using the class name as a reference:
@@ -138,7 +188,6 @@ For convenience, `method_missing` is used to allow you to use the underscore'd n
138
188
  end
139
189
  end
140
190
 
141
-
142
191
  **Take a look at existing drones for more info!**
143
192
 
144
193
 
@@ -153,25 +202,24 @@ AppDrone is not for everyone. It's highly opinionated about how a Rails app shou
153
202
  ### Active drones (put 'em to work!)
154
203
 
155
204
  - Bundle
156
- - Stylesheet
157
- - Javascript
205
+ - Stylesheet (Sass & Compass)
206
+ - Javascript (Coffescript & jQuery)
158
207
  - SlimView
159
208
  - HighVoltage
160
- - Showcase (drones use this to demonstrate their working functionality)
161
209
  - Chosen, by harvestHQ
210
+ - Bootstrap, by Twitter
211
+ - SimpleForm (with optional Country Select and automatic Twitter Bootstrap integration)
212
+ - Flair (drones use this to demonstrate their working functionality)
162
213
  - Cleanup
163
-
214
+
164
215
 
165
216
  ### Frozen drones (currently in development)
166
217
 
167
- - Bootstrap
168
- - FactoryGirl
169
- - Git
170
- - Guard
171
218
  - RankedModel
219
+ - Git
172
220
  - RSpec
173
- - SimpleForm
174
-
221
+ - FactoryGirl
222
+ - Guard
175
223
 
176
224
  ### Future drones (TODO - I'll get there some day!)
177
225
 
@@ -181,17 +229,18 @@ AppDrone is not for everyone. It's highly opinionated about how a Rails app shou
181
229
  - Responders
182
230
  - HasScope
183
231
  - Pagination
184
- - CarrierWave (and optional cloud resizing thingy)
232
+ - jQuery shims
233
+ - jQuery UI (vendor + theme etc.)
234
+ - pie.htc for IE
235
+ - HTML5 shim for IE
185
236
  - Airbrake + API Key
237
+ - CarrierWave (and optional cloud resizing thingy)
186
238
  - rails-best-practices (and the other output gem for debugging)
187
239
  - NewRelic
188
240
  - EngineYard for deployment
189
- - jQuery shims
190
241
  - Backbone integration + Skim
191
242
  - Ember.js integration
192
243
  - Pivotal tracker
193
- - pie.htc for IE
194
- - HTML5 shim for IE
195
244
 
196
245
 
197
246
  ## Contributing
data/README.md~ CHANGED
@@ -43,8 +43,8 @@ Parameters can be used to modify drone behavior:
43
43
  To list parameters for a specific drone:
44
44
 
45
45
  AppDrone::Bootstrap.params
46
- # => #<struct Struct::Param name=:vendor, type=:boolean, options=[{:info=>"download a local copy into the repo"}]>
47
- # => #<struct Struct::Param name=:responsive, type=:boolean, options=[{:info=>"include responsive grid"}]>
46
+ # => #<struct Struct::Param name=:vendor, type=:boolean, options={:info=>"download a local copy into the repo"}>
47
+ # => #<struct Struct::Param name=:responsive, type=:boolean, options={:info=>"include responsive grid"}>
48
48
 
49
49
  For readability, you can use the symbol shorthand instead of full class name:
50
50
 
@@ -103,6 +103,33 @@ You can use `desc` in the class declaration to explain what the drone does (most
103
103
  AppDrone::MyDrone.dependencies
104
104
  # => [AppDrone::DeathRay, AppDrone::YourMom]
105
105
 
106
+
107
+ ### Drone pairings
108
+
109
+ Pairing is weaker than a dependency. A template will not render without its dependencies, but pairs are optional inclusions to add extra params and behavior in the presence of another drone.
110
+
111
+ class AppDrone::BarbraStreisand < AppDrone::Drone
112
+ depends_on :bobby_davis_jr
113
+ pairs_with :celine_dion
114
+
115
+ param :wear_human_suit_over_mechaskin, :boolean, info: 'Wear the human disguise'
116
+ param_with :celine_dion, :celine_in_rehab, :boolean, info: 'Is she currently in rehab?'
117
+
118
+ def align
119
+ bobby_davis_jr.say 'Hi'
120
+ bobby_davis_jr.introduce 'This is Celine Dion' if pair?(:celine_dion)
121
+ self.get_changed if param(:wear_human_suit_over_mechaskin)
122
+ end
123
+
124
+ def execute
125
+ do! :duet_with_bobby
126
+ if pair?(:celine_dion)
127
+ do! :coke_with_celine unless param(:celine_in_rehab)
128
+ end
129
+ end
130
+
131
+ end
132
+
106
133
  ### Drone behavior parameters
107
134
 
108
135
  class AppDrone::MyDrone < AppDrone::Drone
@@ -116,6 +143,29 @@ You can use `desc` in the class declaration to explain what the drone does (most
116
143
  t.add :my_drone, lazer_color: 'teh'
117
144
 
118
145
 
146
+ A drone may also declare a parameter that is only to be used in presence of a dependency.
147
+
148
+ You can also use `param_with` to specify a parameter that is expected in presence of a pair:
149
+
150
+ class AppDrone::EddieIzzard
151
+ desc 'Professional transvestite'
152
+
153
+ pairs_with :heels
154
+ param_with :heels, :wearing_heels, :boolean, default: true
155
+
156
+ def align
157
+ # defaults to true in the presence of :heels dependency
158
+ if pair?(:heels) && param(:wearing_heels)
159
+ puts "I am a professional transvestite, so I can run about in heels and not fall over."
160
+ puts "Cause if a woman falls over wearing heels, that’s embarrassing."
161
+ puts "But if a bloke falls over wearing heels, you have to kill yourself."
162
+ puts "It’s the end of your life.
163
+ end
164
+ end
165
+
166
+ end
167
+
168
+
119
169
  ### Drone communication
120
170
 
121
171
  Drones can talk to eachother via a proxy on the template they are included in, using the class name as a reference:
@@ -138,7 +188,6 @@ For convenience, `method_missing` is used to allow you to use the underscore'd n
138
188
  end
139
189
  end
140
190
 
141
-
142
191
  **Take a look at existing drones for more info!**
143
192
 
144
193
 
@@ -153,45 +202,46 @@ AppDrone is not for everyone. It's highly opinionated about how a Rails app shou
153
202
  ### Active drones (put 'em to work!)
154
203
 
155
204
  - Bundle
156
- - Stylesheet
157
- - Javascript
205
+ - Stylesheet (Sass & Compass)
206
+ - Javascript (Coffescript & jQuery)
158
207
  - SlimView
159
208
  - HighVoltage
160
- - Showcase (drones use this to demonstrate their working functionality)
161
209
  - Chosen, by harvestHQ
210
+ - Bootstrap, by Twitter
211
+ - SimpleForm (with optional Country Select and automatic Twitter Bootstrap integration)
212
+ - Flair (drones use this to demonstrate their working functionality)
162
213
  - Cleanup
163
-
214
+
164
215
 
165
216
  ### Frozen drones (currently in development)
166
217
 
167
- - Bootstrap
168
- - FactoryGirl
169
- - Git
170
- - Guard
171
218
  - RankedModel
219
+ - Git
172
220
  - RSpec
173
- - SimpleForm
174
-
221
+ - FactoryGirl
222
+ - Guard
175
223
 
176
224
  ### Future drones (TODO - I'll get there some day!)
177
225
 
178
226
  - Stylesheet utils
179
- - SlimViews: Add browser-specific classes to <html>
227
+ - SlimViews: Add browser-specific classes to <html> via useragent + helpers..
180
228
  - UserAgent blocking script
181
229
  - Responders
182
230
  - HasScope
183
231
  - Pagination
184
- - CarrierWave (and optional cloud resizing thingy)
232
+ - jQuery shims
233
+ - jQuery UI (vendor + theme etc.)
234
+ - pie.htc for IE
235
+ - HTML5 shim for IE
185
236
  - Airbrake + API Key
237
+ - CarrierWave (and optional cloud resizing thingy)
186
238
  - rails-best-practices (and the other output gem for debugging)
187
239
  - NewRelic
188
240
  - EngineYard for deployment
189
- - jQuery shims
241
+
190
242
  - Backbone integration + Skim
191
243
  - Ember.js integration
192
244
  - Pivotal tracker
193
- - pie.htc for IE
194
- - HTML5 shim for IE
195
245
 
196
246
 
197
247
  ## Contributing
data/TODO ADDED
@@ -0,0 +1,4 @@
1
+ ** templates must be added and run in the order that satisfies dependency order best. (also consider pairings if possible)
2
+ i.e. a drone can only run after it's dependants have had their turn (unless they mutually depend)
3
+
4
+ ** param 'default' values... (when accessing param, if nil, return default (unless default is nil too))
data/TODO~ CHANGED
@@ -1,7 +1,5 @@
1
- 1. Replace (self >> Drone).method syntax within drones (use method missing)
2
- e.g. gems.add('x') -> method_missing('gems') -> (self >> gems.classify.constantize).send
3
-
4
- 2. Drone dependencies
5
- e.g. depends Stylesheets, Gems
6
- - template complains if render is called and dependencies are not met
1
+ ** templates must be added and run in the order that satisfies dependency order best.
2
+ **
3
+ i.e. a drone can only run after it's dependants have had their turn (unless they mutually depend)
7
4
 
5
+ ** param 'default' values... (when accessing param, if nil, return default (unless default is nil too))
@@ -13,19 +13,28 @@ class Drone
13
13
  setup
14
14
  end
15
15
 
16
+ def param(sym)
17
+ (@params || {})[sym]
18
+ end
19
+
16
20
  # DSL
17
- def ^; @template end
21
+ def ^; @template end # This is never used, not even sure if it works (something about a misplaced '.' error)
18
22
  def >>(klass); @template.hook(klass); end
19
23
 
20
24
  def method_missing(meth, *args, &block)
21
25
  if Drone.drones.include?(meth)
22
- klass = ('AppDrone::' + meth.to_s.classify).constantize
26
+ klass = meth.to_app_drone_class
23
27
  return (self >> klass)
24
28
  else
25
29
  super
26
30
  end
27
31
  end
28
32
 
33
+ def pair?(drone_symbol)
34
+ drone_klass = ('AppDrone::' + drone_symbol.to_s.classify).constantize
35
+ return @template.hook?(drone_klass)
36
+ end
37
+
29
38
  # Expected implementations
30
39
  def align; end
31
40
  def execute; end
@@ -33,13 +42,13 @@ class Drone
33
42
  # Optional implementations
34
43
  def setup; end
35
44
 
36
- def render(partial)
45
+ def render(partial, opts={})
37
46
  class_name = self.class.to_s.split('::').last.underscore
38
47
  template_path = "/drones/#{class_name}/#{partial}.erb"
39
48
  full_path = File.dirname(__FILE__) + template_path
40
49
  snippet = ERB.new File.read(full_path)
41
50
  output = snippet.result(binding)
42
- output = "# --- \n# #{self.class.to_s}\n# ---\n" + output if true
51
+ output = "# --- \n# #{self.class.to_s}\n# ---\n" + output unless opts[:skip_stamp]
43
52
  return output
44
53
  end
45
54
 
@@ -50,8 +59,12 @@ class Drone
50
59
  # DSL: Integration-specific options
51
60
  attr_accessor :params
52
61
  class << self
62
+ def param_with(drone_klass, name, type, *options)
63
+ param(name,type,options.first.merge({ with: drone_klass }))
64
+ end
65
+
53
66
  def param(name, type, *options)
54
- (@params ||= []) << Param.new(name, type, options)
67
+ (@params ||= []) << Param.new(name, type, options.first)
55
68
  end
56
69
  def params
57
70
  @params
@@ -64,7 +77,12 @@ class Drone
64
77
 
65
78
  def depends_on(*klass_symbols); @dependencies = klass_symbols end
66
79
  def dependencies
67
- (@dependencies || []).map { |k| ('AppDrone::' + k.to_s.classify).constantize }
80
+ (@dependencies || []).map(&:to_app_drone_class)
81
+ end
82
+
83
+ def pairs_with(*klass_symbols); @pairs = klass_symbols end
84
+ def pairs
85
+ (@pairs || []).map(&:to_app_drone_class)
68
86
  end
69
87
 
70
88
  def owns_generator_method(m); @generator_method = m end
@@ -13,19 +13,28 @@ class Drone
13
13
  setup
14
14
  end
15
15
 
16
+ def param(sym)
17
+ (@params || {})[sym]
18
+ end
19
+
16
20
  # DSL
17
- def ^; @template end
21
+ def ^; @template end # This is never used, not even sure if it works (something about a misplaced '.' error)
18
22
  def >>(klass); @template.hook(klass); end
19
23
 
20
24
  def method_missing(meth, *args, &block)
21
25
  if Drone.drones.include?(meth)
22
- klass = ('AppDrone::' + meth.to_s.classify).constantize
26
+ klass = meth.to_app_drone_class
23
27
  return (self >> klass)
24
28
  else
25
29
  super
26
30
  end
27
31
  end
28
32
 
33
+ def pair?(drone_symbol)
34
+ drone_klass = ('AppDrone::' + drone_symbol.to_s.classify).constantize
35
+ return @template.hook?(drone_klass)
36
+ end
37
+
29
38
  # Expected implementations
30
39
  def align; end
31
40
  def execute; end
@@ -33,13 +42,14 @@ class Drone
33
42
  # Optional implementations
34
43
  def setup; end
35
44
 
36
- def render(partial)
45
+ def render(partial, opts={})
46
+ return opts.to_s
37
47
  class_name = self.class.to_s.split('::').last.underscore
38
48
  template_path = "/drones/#{class_name}/#{partial}.erb"
39
49
  full_path = File.dirname(__FILE__) + template_path
40
50
  snippet = ERB.new File.read(full_path)
41
51
  output = snippet.result(binding)
42
- output = "# --- \n# #{self.class.to_s}\n# ---\n" + output if true
52
+ output = "# --- \n# #{self.class.to_s}\n# ---\n" + output unless opts[:skip_stamp]
43
53
  return output
44
54
  end
45
55
 
@@ -50,8 +60,12 @@ class Drone
50
60
  # DSL: Integration-specific options
51
61
  attr_accessor :params
52
62
  class << self
63
+ def param_with(drone_klass, name, type, *options)
64
+ param(name,type,options.first.merge({ with: drone_klass }))
65
+ end
66
+
53
67
  def param(name, type, *options)
54
- (@params ||= []) << Param.new(name, type, options)
68
+ (@params ||= []) << Param.new(name, type, options.first)
55
69
  end
56
70
  def params
57
71
  @params
@@ -64,7 +78,12 @@ class Drone
64
78
 
65
79
  def depends_on(*klass_symbols); @dependencies = klass_symbols end
66
80
  def dependencies
67
- (@dependencies || []).map { |k| ('AppDrone::' + k.to_s.classify).constantize }
81
+ (@dependencies || []).map(&:to_app_drone_class)
82
+ end
83
+
84
+ def pairs_with(*klass_symbols); @pairs = klass_symbols end
85
+ def pairs
86
+ (@pairs || []).map(&:to_app_drone_class)
68
87
  end
69
88
 
70
89
  def owns_generator_method(m); @generator_method = m end
@@ -0,0 +1,44 @@
1
+ # Incomplete
2
+ module AppDrone
3
+ class Bootstrap < Drone
4
+ desc "Installs Twitter Bootstrap stylesheets and javascripts"
5
+
6
+ param :vendor, :boolean, info: 'place a local copy of the files into the repo for customization'
7
+ param :responsive, :boolean, info: 'include responsive grid'
8
+ param :font_awesome, :boolean, info: 'use font-awesome for icons'
9
+
10
+ # TODO js import options
11
+
12
+ depends_on :bundle, :stylesheet, :javascript
13
+
14
+ def align
15
+ bundle.add 'compass_twitter_bootstrap', git: 'git://github.com/vwall/compass-twitter-bootstrap.git', group: :assets
16
+ param(:vendor) ? align_vendor : align_bundle
17
+ flair!
18
+ end
19
+
20
+ def execute
21
+ param(:vendor) ? execute_vendor : execute_bundle
22
+ end
23
+
24
+ private
25
+ def align_vendor
26
+ # TODO import paths for stylesheet (different to bundle)
27
+ # TODO js imports - based on options
28
+ end
29
+
30
+ def align_bundle
31
+ stylesheet.import param(:font_awesome) ? 'compass_twitter_bootstrap_awesome' : 'compass_twitter_bootstrap'
32
+ stylesheet.import 'compass_twitter_bootstrap_responsive' if param(:responsive)
33
+ # TODO js imports - based on options
34
+ end
35
+
36
+ def execute_vendor
37
+ # TODO pull files from git
38
+ end
39
+
40
+ def execute_bundle
41
+ # TODO nothing
42
+ end
43
+ end
44
+ end
@@ -0,0 +1,44 @@
1
+ # Incomplete
2
+ module AppDrone
3
+ class Bootstrap < Drone
4
+ desc "Installs Twitter Bootstrap stylesheets and javascripts"
5
+
6
+ param :vendor, :boolean, info: 'place a local copy of the files into the repo for customization'
7
+ param :responsive, :boolean, info: 'include responsive grid'
8
+ param :font_awesome, :boolean, info: 'use font-awesome for icons'
9
+
10
+ # TODO js import options
11
+
12
+ depends_on :bundle, :stylesheet, :javascript
13
+
14
+ def align
15
+ bundle.add 'compass_twitter_bootstrap', git: 'git://github.com/vwall/compass-twitter-bootstrap.git', group: :assets
16
+ param(:vendor) ? align_vendor : align_bundle
17
+ flair!
18
+ end
19
+
20
+ def execute
21
+ param(:vendor) ? execute_vendor : execute_bundle
22
+ end
23
+
24
+ private
25
+ def align_vendor
26
+ # TODO import paths for stylesheet (different to bundle)
27
+ # TODO js imports - based on options
28
+ end
29
+
30
+ def align_bundle
31
+ stylesheet.import param(:font_awesome) ? 'compass_twitter_bootstrap_awesome' : 'compass_twitter_bootstrap'
32
+ stylesheet.import 'compass_twitter_bootstrap_responsive' if param(:responsive)
33
+ # TODO js imports - based on options
34
+ end
35
+
36
+ def execute_vendor
37
+ # TODO pull files from git
38
+ end
39
+
40
+ def execute_bundle
41
+ # TODO nothing
42
+ end
43
+ end
44
+ end
@@ -0,0 +1,7 @@
1
+ a.btn.btn-primary.btn-large Shiny!
2
+ <% if param(:font_awesome) %>
3
+ br
4
+ a.btn.btn
5
+ i.icon-heart
6
+ | with Font Awesome!
7
+ <% end %>
@@ -0,0 +1,7 @@
1
+ a.btn.btn-primary.btn-large Shiny!
2
+ <% if param(:font_awesome) %>
3
+ br
4
+ a.btn.btn
5
+ i.icon-heart
6
+ | with Font Awesome!
7
+ <% end %>
@@ -2,6 +2,7 @@ module AppDrone
2
2
  class Chosen < Drone
3
3
  desc 'Installs the Chosen plugin by HarvestHQ'
4
4
  depends_on :bundle, :stylesheet, :javascript
5
+ pairs_with :flair
5
6
 
6
7
  def align
7
8
  bundle.add 'chosen-rails'
@@ -2,6 +2,7 @@ module AppDrone
2
2
  class Chosen < Drone
3
3
  desc 'Installs the Chosen plugin by HarvestHQ'
4
4
  depends_on :bundle, :stylesheet, :javascript
5
+ pairs_with :flair
5
6
 
6
7
  def align
7
8
  bundle.add 'chosen-rails'
@@ -10,7 +10,7 @@ class Flair < Drone
10
10
  end
11
11
 
12
12
  def add(klass)
13
- flairs << klass.class.to_s.gsub('AppDrone::','').underscore
13
+ flairs << klass.class.to_s.gsub('AppDrone::','').underscore.to_sym
14
14
  end
15
15
 
16
16
  def execute
@@ -18,15 +18,20 @@ class Flair < Drone
18
18
  end
19
19
 
20
20
  def flair_for(drone_name)
21
- flair_path = File.join File.dirname(__FILE__), '..', drone_name, 'flair.html.slim'
22
- snippet = ERB.new File.read(flair_path)
23
- return snippet.result(binding)
21
+ drone = send(drone_name)
22
+ return drone.render 'flair.html.slim', skip_stamp: true
24
23
  end
25
24
  end
26
25
 
26
+
27
+ # extend drones so they can call `flair!` rather than the verbose method
28
+ # this pattern is useful for drones that take a single boolean parameter
29
+ # e.g.
30
+ # flair: do / don't flair, as opposed to
31
+ # bootstrap: vendor, responsive, font_awesome...
27
32
  class Drone
28
33
  def flair!
29
- flair.add(self)
34
+ flair.add(self) if pair?(:flair)
30
35
  end
31
36
  end
32
37
 
@@ -10,7 +10,7 @@ class Flair < Drone
10
10
  end
11
11
 
12
12
  def add(klass)
13
- flairs << klass.class.to_s.gsub('AppDrone::','').underscore
13
+ flairs << klass.class.to_s.gsub('AppDrone::','').underscore.to_sym
14
14
  end
15
15
 
16
16
  def execute
@@ -18,15 +18,20 @@ class Flair < Drone
18
18
  end
19
19
 
20
20
  def flair_for(drone_name)
21
- flair_path = File.join File.dirname(__FILE__), '..', drone_name, 'flair.html.slim'
22
- snippet = ERB.new File.read(flair_path)
23
- return snippet.result(binding)
21
+ drone = send(drone_name)
22
+ return drone.render 'flair.html.slim', stamp: true
24
23
  end
25
24
  end
26
25
 
26
+
27
+ # extend drones so they can call `flair!` rather than the verbose method
28
+ # this pattern is useful for drones that take a single boolean parameter
29
+ # e.g.
30
+ # flair: do / don't flair, as opposed to
31
+ # bootstrap: vendor, responsive, font_awesome...
27
32
  class Drone
28
33
  def flair!
29
- flair.add(self)
34
+ flair.add(self) if pair?(:flair)
30
35
  end
31
36
  end
32
37
 
@@ -2,10 +2,7 @@
2
2
  h1 Flair!
3
3
 
4
4
  <% flairs.each do |drone_name| %>
5
+ h3 <%= drone_name.to_s.humanize.titleize %>
5
6
 
6
- h3 <%= drone_name.humanize.titleize %>
7
-
8
- <%= flair_for(drone_name) %>
9
-
10
- <% end %>
7
+ <%= flair_for(drone_name) %><% end %>
11
8
  FLAIR
@@ -2,10 +2,7 @@
2
2
  h1 Flair!
3
3
 
4
4
  <% flairs.each do |drone_name| %>
5
+ h3 <%= drone_name.to_s.humanize.titleize %>
5
6
 
6
- h3 <%= drone_name.humanize.titleize %>
7
-
8
- <%= flair_for(drone_name) %>
9
-
10
- <% end %>
7
+ <%= flair_for(drone_name) %><% end %>
11
8
  FLAIR
@@ -0,0 +1 @@
1
+ generate "simple_form:install<%= ' --bootstrap' if pair?(:bootstrap) %>"
@@ -0,0 +1 @@
1
+ generate "simple_form:install<%= ' --bootstrap' if pair?(:bootstrap) %>"
@@ -0,0 +1,20 @@
1
+ # Complete
2
+ module AppDrone
3
+ class SimpleForm < Drone
4
+ desc "Installs SimpleForm, with optional Country Select and automatic Twitter Bootstrap integration"
5
+
6
+ depends_on :bundle
7
+ pairs_with :bootstrap
8
+
9
+ param :add_country_select, :boolean, info: 'Add country_select for listing countries'
10
+
11
+ def align
12
+ bundle.add 'simple_form'
13
+ bundle.add 'country_select' if param(:add_country_select)
14
+ end
15
+
16
+ def execute
17
+ do! :install
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,20 @@
1
+ # Complete
2
+ module AppDrone
3
+ class SimpleForm < Drone
4
+ desc "Installs SimpleForm, with optional Country Select and automatic Twitter Bootstrap integration"
5
+
6
+ depends_on :bundle
7
+ pairs_with :bootstrap
8
+
9
+ param :add_country_select, :boolean, info: 'Add country_select for listing countries'
10
+
11
+ def align
12
+ bundle.add 'simple_form'
13
+ bundle.add 'country_select' if param(:add_country_select)
14
+ end
15
+
16
+ def execute
17
+ do! :install
18
+ end
19
+ end
20
+ end
@@ -9,3 +9,9 @@ class String
9
9
  self == ''
10
10
  end
11
11
  end
12
+
13
+ class Symbol
14
+ def to_app_drone_class
15
+ ('AppDrone::' + self.to_s.classify).constantize
16
+ end
17
+ end
@@ -3,3 +3,15 @@ class Class
3
3
  ObjectSpace.each_object(Class).select { |klass| klass < self }
4
4
  end
5
5
  end
6
+
7
+ class String
8
+ def blank?
9
+ self == ''
10
+ end
11
+ end
12
+
13
+ class Symbol
14
+ def to_app_drone_class
15
+ ('AppDrone::' + self.to_s.classify).constantize
16
+ end
17
+ end
@@ -8,7 +8,7 @@ class AppDrone::Template
8
8
 
9
9
  def drone_objects; @drones.values end
10
10
  def drone_classes; @drones.keys end
11
- def hook?(klass); @drones[klass].nil? end
11
+ def hook?(klass); !@drones[klass].nil? end
12
12
  def hook(klass)
13
13
  raise "No such drone: #{klass}" unless i_klass = @drones[klass]
14
14
  return i_klass
@@ -8,7 +8,7 @@ class AppDrone::Template
8
8
 
9
9
  def drone_objects; @drones.values end
10
10
  def drone_classes; @drones.keys end
11
- def hook?(klass); @drones[klass].nil? end
11
+ def hook?(klass); !@drones[klass].nil? end
12
12
  def hook(klass)
13
13
  raise "No such drone: #{klass}" unless i_klass = @drones[klass]
14
14
  return i_klass
@@ -1,3 +1,3 @@
1
1
  module AppDrone
2
- VERSION = "0.2.1"
2
+ VERSION = "0.3.1"
3
3
  end
@@ -1,3 +1,3 @@
1
1
  module AppDrone
2
- VERSION = "0.2.0"
2
+ VERSION = "0.3.1"
3
3
  end
data/out.rb CHANGED
@@ -27,6 +27,8 @@ class AppBuilder < Rails::AppBuilder
27
27
  @generator.gem 'compass-rails'
28
28
  @generator.gem 'slim-rails'
29
29
  @generator.gem 'high_voltage'
30
+ @generator.gem 'simple_form'
31
+ @generator.gem 'compass_twitter_bootstrap', :git=>"git://github.com/vwall/compass-twitter-bootstrap.git", :group=>:assets
30
32
  @generator.gem 'chosen-rails'
31
33
 
32
34
  run_bundle
@@ -68,6 +70,8 @@ COFFEE
68
70
  /*= require_self */
69
71
 
70
72
  @import 'compass'
73
+ @import 'compass_twitter_bootstrap_awesome'
74
+ @import 'compass_twitter_bootstrap_responsive'
71
75
 
72
76
  SASS
73
77
 
@@ -102,6 +106,15 @@ FileUtils.mkpath 'app/views/pages'
102
106
  h1 Flair!
103
107
 
104
108
 
109
+ h3 Bootstrap
110
+
111
+ a.btn.btn-primary.btn-large Shiny!
112
+
113
+ br
114
+ a.btn.btn
115
+ i.icon-heart
116
+ | with Font Awesome!
117
+
105
118
 
106
119
  h3 Chosen
107
120
 
@@ -110,10 +123,13 @@ select.chzn-select
110
123
  option Two
111
124
  option Three
112
125
 
113
-
114
-
115
126
  FLAIR
116
127
 
128
+ # ---
129
+ # AppDrone::SimpleForm
130
+ # ---
131
+ generate "simple_form:install --bootstrap"
132
+
117
133
  # ---
118
134
  # AppDrone::Cleanup
119
135
  # ---
data/out.rb~ ADDED
@@ -0,0 +1,144 @@
1
+ class AppBuilder < Rails::AppBuilder
2
+ include Thor::Actions
3
+ include Thor::Shell
4
+
5
+ # Express app templating for Rails
6
+ # ------------------------------------
7
+ # USAGE:
8
+ # 1. run: `rails new app_name --builder=path/to/builder.rb` (URI's work here too)
9
+ # 2. ???
10
+ # 3. PROFIT!
11
+
12
+ def test
13
+ return
14
+ # TODO
15
+ # skips test framework, but we can probably just bastardize the options in the same way as with :skip_bundle
16
+ # either make `test` build the actual directories etc., or use a script
17
+ # either way, this method is stupid.
18
+ end
19
+
20
+
21
+ def gemfile
22
+ super
23
+ # ---
24
+ # AppDrone::Bundle
25
+ # ---
26
+ @generator.gem 'therubyracer'
27
+ @generator.gem 'compass-rails'
28
+ @generator.gem 'slim-rails'
29
+ @generator.gem 'high_voltage'
30
+ @generator.gem 'simple_form'
31
+ @generator.gem 'compass_twitter_bootstrap', :git=>"git://github.com/vwall/compass-twitter-bootstrap.git", :group=>:assets
32
+ @generator.gem 'chosen-rails'
33
+
34
+ run_bundle
35
+ @generator.options = @generator.options.dup
36
+ @generator.options[:skip_bundle] = true
37
+ @generator.options.freeze
38
+
39
+ end
40
+
41
+
42
+ def leftovers
43
+ # ---
44
+ # AppDrone::Javascript
45
+ # ---
46
+ js_asset_path = File.join %w(app assets javascripts application.js)
47
+ @generator.remove_file(js_asset_path)
48
+ @coffee_asset_path = File.join %w(app assets javascripts application.js.coffee)
49
+ @generator.create_file @coffee_asset_path, <<-COFFEE
50
+ //= require jquery
51
+ //= require jquery_ujs
52
+ //= require chosen-jquery
53
+ //= require_tree .
54
+
55
+ $(document).ready ->
56
+ $('.chzn-select').chosen();
57
+
58
+
59
+ COFFEE
60
+
61
+ # ---
62
+ # AppDrone::Stylesheet
63
+ # ---
64
+ @css_asset_path = File.join %w(app assets stylesheets application.css)
65
+ @generator.remove_file(@css_asset_path)
66
+ @sass_asset_path = File.join %w(app assets stylesheets application.css.sass)
67
+
68
+ @generator.create_file @sass_asset_path, <<-SASS
69
+ /*= require chosen */
70
+ /*= require_self */
71
+
72
+ @import 'compass'
73
+ @import 'compass_twitter_bootstrap_awesome'
74
+ @import 'compass_twitter_bootstrap_responsive'
75
+
76
+ SASS
77
+
78
+ # ---
79
+ # AppDrone::SlimView
80
+ # ---
81
+ erb_index_path = File.join %w(app views layouts application.html.erb)
82
+ @generator.remove_file(erb_index_path)
83
+ slim_index_path = File.join %w(app views layouts application.html.slim)
84
+ @generator.create_file slim_index_path, <<-SLIM
85
+ doctype 5
86
+ html
87
+ head
88
+ title #{app_name}
89
+ = stylesheet_link_tag 'application', media: 'all'
90
+ = javascript_include_tag 'application'
91
+ = csrf_meta_tags
92
+
93
+ body class=controller_name
94
+ = yield
95
+ SLIM
96
+
97
+ # ---
98
+ # AppDrone::HighVoltage
99
+ # ---
100
+ FileUtils.mkpath 'app/views/pages'
101
+
102
+ # ---
103
+ # AppDrone::Flair
104
+ # ---
105
+ @generator.create_file 'app/views/pages/flair.html.slim', <<-FLAIR
106
+ h1 Flair!
107
+
108
+
109
+ h3 Bootstrap
110
+
111
+ a.btn.btn-primary.btn-large Shiny!
112
+
113
+ br
114
+ a.btn.btn
115
+ i.icon-heart
116
+ | with Font Awesome!
117
+
118
+
119
+ h3 Chosen
120
+
121
+ select.chzn-select
122
+ option One
123
+ option Two
124
+ option Three
125
+
126
+ FLAIR
127
+
128
+ # ---
129
+ # AppDrone::SimpleForm
130
+ # ---
131
+ generate "simple_form:install --bootstrap"
132
+
133
+ # ---
134
+ # AppDrone::Cleanup
135
+ # ---
136
+ @generator.remove_file File.join %w(public index.html)
137
+ @generator.remove_file File.join %w(app assets images rails.png)
138
+ @generator.remove_file File.join %w(README.rdoc)
139
+
140
+ rake 'db:migrate'
141
+ say "She's all yours, sparky!\n\n", :green
142
+ end
143
+
144
+ end
@@ -23,6 +23,8 @@ class AppDroneTest < Test::Unit::TestCase
23
23
  template.add :slim_view
24
24
  template.add :high_voltage
25
25
  template.add :flair
26
+ template.add :simple_form
27
+ template.add :bootstrap, font_awesome: true, responsive: true
26
28
  template.add :chosen
27
29
  template.add :cleanup
28
30
  template.render_to_file
@@ -23,6 +23,8 @@ class AppDroneTest < Test::Unit::TestCase
23
23
  template.add :slim_view
24
24
  template.add :high_voltage
25
25
  template.add :flair
26
+ template.add :simple_form
27
+ template.add :bootstrap, font_awesome: true, responsive: true
26
28
  template.add :chosen
27
29
  template.add :cleanup
28
30
  template.render_to_file
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: app_drone
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.3.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -13,7 +13,7 @@ date: 2012-04-21 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: activesupport
16
- requirement: &7019800 !ruby/object:Gem::Requirement
16
+ requirement: &17768680 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,7 +21,7 @@ dependencies:
21
21
  version: 3.2.0
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *7019800
24
+ version_requirements: *17768680
25
25
  description: Give your Rails apps a kickstart
26
26
  email:
27
27
  - whoisdanieldavey@gmail.com
@@ -37,6 +37,7 @@ files:
37
37
  - README.md~
38
38
  - Rakefile
39
39
  - Rakefile~
40
+ - TODO
40
41
  - TODO~
41
42
  - app_drone.gemspec
42
43
  - app_drone.gemspec~
@@ -44,6 +45,10 @@ files:
44
45
  - lib/app_drone.rb~
45
46
  - lib/app_drone/drone.rb
46
47
  - lib/app_drone/drone.rb~
48
+ - lib/app_drone/drones/bootstrap/bootstrap.rb
49
+ - lib/app_drone/drones/bootstrap/bootstrap.rb~
50
+ - lib/app_drone/drones/bootstrap/flair.html.slim.erb
51
+ - lib/app_drone/drones/bootstrap/flair.html.slim.erb~
47
52
  - lib/app_drone/drones/bundle/bundle.rb
48
53
  - lib/app_drone/drones/bundle/bundle.rb~
49
54
  - lib/app_drone/drones/bundle/gem.rb~
@@ -52,7 +57,7 @@ files:
52
57
  - lib/app_drone/drones/bundle/gems.rb~
53
58
  - lib/app_drone/drones/chosen/chosen.rb
54
59
  - lib/app_drone/drones/chosen/chosen.rb~
55
- - lib/app_drone/drones/chosen/flair.html.slim
60
+ - lib/app_drone/drones/chosen/flair.html.slim.erb
56
61
  - lib/app_drone/drones/chosen/showcase.html.slim~
57
62
  - lib/app_drone/drones/cleanup/cleanup.erb
58
63
  - lib/app_drone/drones/cleanup/cleanup.rb
@@ -72,6 +77,10 @@ files:
72
77
  - lib/app_drone/drones/javascript/javascript.rb
73
78
  - lib/app_drone/drones/javascript/javascript.rb~
74
79
  - lib/app_drone/drones/javascript/javascripts.rb~
80
+ - lib/app_drone/drones/simple_form/install.erb
81
+ - lib/app_drone/drones/simple_form/install.erb~
82
+ - lib/app_drone/drones/simple_form/simple_form.rb
83
+ - lib/app_drone/drones/simple_form/simple_form.rb~
75
84
  - lib/app_drone/drones/slim_view/application_slim.erb
76
85
  - lib/app_drone/drones/slim_view/application_slim.erb~
77
86
  - lib/app_drone/drones/slim_view/slim_view.rb
@@ -82,8 +91,6 @@ files:
82
91
  - lib/app_drone/drones/stylesheet/stylesheet.rb
83
92
  - lib/app_drone/drones/stylesheet/stylesheet.rb~
84
93
  - lib/app_drone/drones/stylesheet/stylesheets.rb~
85
- - lib/app_drone/drones/zzz/bootstrap/bootstrap.rb
86
- - lib/app_drone/drones/zzz/bootstrap/bootstrap.rb~
87
94
  - lib/app_drone/drones/zzz/factory_girl/factory_girl.rb
88
95
  - lib/app_drone/drones/zzz/factory_girl/factory_girl.rb~
89
96
  - lib/app_drone/drones/zzz/git/git.rb
@@ -96,10 +103,6 @@ files:
96
103
  - lib/app_drone/drones/zzz/rspec/install.erb
97
104
  - lib/app_drone/drones/zzz/rspec/rspec.rb
98
105
  - lib/app_drone/drones/zzz/rspec/rspec.rb~
99
- - lib/app_drone/drones/zzz/simple_form/install.erb
100
- - lib/app_drone/drones/zzz/simple_form/install.erb~
101
- - lib/app_drone/drones/zzz/simple_form/simple_form.rb
102
- - lib/app_drone/drones/zzz/simple_form/simple_form.rb~
103
106
  - lib/app_drone/integration.rb~
104
107
  - lib/app_drone/object_extensions.rb
105
108
  - lib/app_drone/object_extensions.rb~
@@ -110,6 +113,7 @@ files:
110
113
  - lib/app_drone/version.rb
111
114
  - lib/app_drone/version.rb~
112
115
  - out.rb
116
+ - out.rb~
113
117
  - test/app_drone_test.rb~
114
118
  - test/test_app_drone.rb
115
119
  - test/test_app_drone.rb~
@@ -133,7 +137,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
133
137
  version: '0'
134
138
  requirements: []
135
139
  rubyforge_project:
136
- rubygems_version: 1.8.15
140
+ rubygems_version: 1.8.10
137
141
  signing_key:
138
142
  specification_version: 3
139
143
  summary: Generates Rails templates to help start your app on good footing
@@ -1,29 +0,0 @@
1
- # Incomplete
2
- module AppDrone
3
- class Bootstrap < Drone
4
- desc "Installs Twitter Bootstrap stylesheets and javascripts"
5
- param :vendor, :boolean, info: 'download a local copy into the repo'
6
- param :responsive, :boolean, info: 'include responsive grid'
7
-
8
- depends_on :bundle, :stylesheet, :javascript
9
-
10
- def align
11
- bundle.add 'compass_twitter_bootstrap', group: :assets
12
-
13
- if params[:vendor]
14
- # TODO different require paths for stylesheet
15
- else
16
- stylesheet.import 'compass_twitter_bootstrap'
17
- stylesheet.import 'compass_twitter_bootstrap_responsive' if params[:responsive]
18
- # TODO js imports - based on options
19
- end
20
- end
21
-
22
- def execute
23
- if params[:vendor]
24
- # TODO pull files in via github
25
- end
26
- end
27
-
28
- end
29
- end
@@ -1,29 +0,0 @@
1
- # Incomplete
2
- module AppDrone
3
- class Bootstrap < Drone
4
- desc "Installs Twitter Bootstrap stylesheets and javascripts"
5
- param :vendor, :boolean, info: 'download a local copy into the repo'
6
- param :responsive, :boolean, info: 'include responsive grid'
7
-
8
- depends_on :bundle, :stylesheet, :javascript
9
-
10
- def align
11
- bundle.add 'compass_twitter_bootstrap', group: :assets
12
-
13
- if params[:vendor]
14
- # TODO different require paths for stylesheet
15
- else
16
- stylesheet.import 'compass_twitter_bootstrap'
17
- stylesheet.import 'compass_twitter_bootstrap_responsive' if params[:responsive]
18
- # TODO js imports - based on options
19
- end
20
- end
21
-
22
- def execute
23
- if params[:vendor]
24
- # TODO pull files in via github
25
- end
26
- end
27
-
28
- end
29
- end
@@ -1 +0,0 @@
1
- generate "simple_form:install<%= ' --bootstrap' if @use_bootstrap %>"
@@ -1 +0,0 @@
1
- generate "simple_form:install<%= ' --bootstrap' if @use_bootstrap %>"
@@ -1,17 +0,0 @@
1
- # Incomplete
2
- module AppDrone
3
- class SimpleForm < Drone
4
- desc "Installs SimpleForm (with custom Bootstrap integration)"
5
- param :country_select, :boolean, info: 'Add country_select for listing countries'
6
-
7
- def align
8
- bundle.add 'simple_form'
9
- bundle.add 'country_select' if params[:country_select]
10
- end
11
-
12
- def execute
13
- # TODO bootstrap cross-integration
14
- do! :install
15
- end
16
- end
17
- end
@@ -1,17 +0,0 @@
1
- # Incomplete
2
- module AppDrone
3
- class SimpleForm < Drone
4
- desc "Installs SimpleForm (with custom Bootstrap integration)"
5
- param :country_select, :boolean, info: 'Add country_select for listing countries'
6
-
7
- def align
8
- bundle.add 'simple_form'
9
- bundle.add 'country_select' if params[:country_select]
10
- end
11
-
12
- def execute
13
- # TODO bootstrap cross-integration
14
- do! :install
15
- end
16
- end
17
- end