app_drone 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +17 -0
- data/Gemfile +4 -0
- data/Gemfile~ +4 -0
- data/LICENSE +22 -0
- data/README.md +205 -0
- data/README.md~ +205 -0
- data/Rakefile +11 -0
- data/Rakefile~ +11 -0
- data/TODO~ +7 -0
- data/app_drone.gemspec +20 -0
- data/app_drone.gemspec~ +20 -0
- data/lib/app_drone/drone.rb +81 -0
- data/lib/app_drone/drone.rb~ +81 -0
- data/lib/app_drone/drones/bundle/bundle.rb +23 -0
- data/lib/app_drone/drones/bundle/bundle.rb~ +23 -0
- data/lib/app_drone/drones/bundle/gem.rb~ +23 -0
- data/lib/app_drone/drones/bundle/gem_entries.erb +6 -0
- data/lib/app_drone/drones/bundle/gem_entries.erb~ +6 -0
- data/lib/app_drone/drones/bundle/gems.rb~ +23 -0
- data/lib/app_drone/drones/cleanup/cleanup.erb +3 -0
- data/lib/app_drone/drones/cleanup/cleanup.rb +9 -0
- data/lib/app_drone/drones/cleanup/cleanup.rb~ +9 -0
- data/lib/app_drone/drones/javascript/application_coffee.erb +12 -0
- data/lib/app_drone/drones/javascript/javascript.rb +25 -0
- data/lib/app_drone/drones/javascript/javascript.rb~ +25 -0
- data/lib/app_drone/drones/javascript/javascripts.rb~ +23 -0
- data/lib/app_drone/drones/slim_view/application_slim.erb +15 -0
- data/lib/app_drone/drones/slim_view/slim_view.rb +15 -0
- data/lib/app_drone/drones/slim_view/slim_view.rb~ +15 -0
- data/lib/app_drone/drones/slim_view/slim_views.rb~ +14 -0
- data/lib/app_drone/drones/stylesheet/application_sass.erb +12 -0
- data/lib/app_drone/drones/stylesheet/application_sass.erb~ +12 -0
- data/lib/app_drone/drones/stylesheet/stylesheet.rb +29 -0
- data/lib/app_drone/drones/stylesheet/stylesheet.rb~ +29 -0
- data/lib/app_drone/drones/stylesheet/stylesheets.rb~ +30 -0
- data/lib/app_drone/drones/zzz/bootstrap/bootstrap.rb +29 -0
- data/lib/app_drone/drones/zzz/bootstrap/bootstrap.rb~ +29 -0
- data/lib/app_drone/drones/zzz/chosen/chosen.rb +13 -0
- data/lib/app_drone/drones/zzz/chosen/chosen.rb~ +13 -0
- data/lib/app_drone/drones/zzz/factory_girl/factory_girl.rb +13 -0
- data/lib/app_drone/drones/zzz/factory_girl/factory_girl.rb~ +13 -0
- data/lib/app_drone/drones/zzz/git/git.rb +9 -0
- data/lib/app_drone/drones/zzz/git/git.rb~ +8 -0
- data/lib/app_drone/drones/zzz/git/install.erb +3 -0
- data/lib/app_drone/drones/zzz/guard/guard.rb +16 -0
- data/lib/app_drone/drones/zzz/guard/guard.rb~ +15 -0
- data/lib/app_drone/drones/zzz/ranked_model/ranked_model.rb +9 -0
- data/lib/app_drone/drones/zzz/ranked_model/ranked_model.rb~ +9 -0
- data/lib/app_drone/drones/zzz/rspec/install.erb +1 -0
- data/lib/app_drone/drones/zzz/rspec/rspec.rb +13 -0
- data/lib/app_drone/drones/zzz/rspec/rspec.rb~ +13 -0
- data/lib/app_drone/drones/zzz/simple_form/install.erb +1 -0
- data/lib/app_drone/drones/zzz/simple_form/simple_form.rb +15 -0
- data/lib/app_drone/drones/zzz/simple_form/simple_form.rb~ +15 -0
- data/lib/app_drone/integration.rb~ +48 -0
- data/lib/app_drone/object_extensions.rb +11 -0
- data/lib/app_drone/object_extensions.rb~ +5 -0
- data/lib/app_drone/template.erb +33 -0
- data/lib/app_drone/template.erb~ +33 -0
- data/lib/app_drone/template.rb +62 -0
- data/lib/app_drone/template.rb~ +62 -0
- data/lib/app_drone/version.rb +3 -0
- data/lib/app_drone/version.rb~ +3 -0
- data/lib/app_drone.rb +17 -0
- data/lib/app_drone.rb~ +17 -0
- data/out.rb +93 -0
- data/test/app_drone_test.rb~ +19 -0
- data/test/test_app_drone.rb +30 -0
- data/test/test_app_drone.rb~ +30 -0
- metadata +128 -0
data/.gitignore
ADDED
data/Gemfile
ADDED
data/Gemfile~
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2012 Daniel Davey
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,205 @@
|
|
1
|
+
# AppDrone
|
2
|
+
|
3
|
+
**Avoid the mundane.**
|
4
|
+
|
5
|
+
## Overview
|
6
|
+
|
7
|
+
AppDrone aims to take the bore out of setting up a Rails app just the way you like it. It's a code library that builds generator code that builds your Rails app code - R A I L S C E P T I O N!
|
8
|
+
|
9
|
+
*If you're super lazy, a shiny UI for choosing and configuring drones is coming soon! Right now, it's CLI only :P*
|
10
|
+
|
11
|
+
|
12
|
+
## Installation
|
13
|
+
|
14
|
+
Add this line to your application's `Gemfile`:
|
15
|
+
|
16
|
+
gem 'app_drone'
|
17
|
+
|
18
|
+
And then execute:
|
19
|
+
|
20
|
+
$ bundle
|
21
|
+
|
22
|
+
Or install it yourself:
|
23
|
+
|
24
|
+
$ gem install app_drone
|
25
|
+
|
26
|
+
|
27
|
+
## Usage
|
28
|
+
|
29
|
+
### Create a new template
|
30
|
+
|
31
|
+
require 'app_drone'
|
32
|
+
t = AppDrone::Template.new
|
33
|
+
|
34
|
+
### Add drones
|
35
|
+
|
36
|
+
t.add AppDrone::Bundle
|
37
|
+
t.add AppDrone::StyleSheet
|
38
|
+
|
39
|
+
Parameters can be used to modify drone behavior:
|
40
|
+
|
41
|
+
t.add AppDrone::Bootstrap, vendor: true
|
42
|
+
|
43
|
+
To list parameters for a specific drone:
|
44
|
+
|
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"}]>
|
48
|
+
|
49
|
+
For readability, you can use the symbol shorthand instead of full class name:
|
50
|
+
|
51
|
+
t.add :factory_girl # adds AppDrone::FactoryGirl
|
52
|
+
|
53
|
+
|
54
|
+
### Render template
|
55
|
+
|
56
|
+
Once you've loaded and configured your drones, the template can be rendered to screen or file:
|
57
|
+
|
58
|
+
t.render_to_file
|
59
|
+
# => out.rb
|
60
|
+
|
61
|
+
Dependencies are automatically checked, and a template will not render unless the drone requirements are all satisfied.
|
62
|
+
|
63
|
+
AppDrone::Bootstrap.dependencies
|
64
|
+
# => [AppDrone::Bundle, AppDrone::Stylesheet, AppDrone::Javascript]
|
65
|
+
|
66
|
+
*Note that most drones depend on `Bundle`, `Stylesheet` and `Javascript`.*
|
67
|
+
|
68
|
+
|
69
|
+
### Active drones
|
70
|
+
|
71
|
+
To list all available drones:
|
72
|
+
|
73
|
+
Drone.drones
|
74
|
+
# => [:stylesheet, :javascript, :slim_view, :cleanup, :bundle]
|
75
|
+
|
76
|
+
*Note: these are the underscored versions, not the class names.*
|
77
|
+
|
78
|
+
|
79
|
+
## Underneath the hood
|
80
|
+
|
81
|
+
Drones are simple classes that implement `align` and `execute` methods. When a template is rendered, `align` is called on each included drone in turn (to set up inter-dependencies), and then `execute` outputs drone code for the generator file.
|
82
|
+
|
83
|
+
Each drone lives in it's own folder in `lib/app_drone/drones`, and can include `.erb` templates that are rendered into the main generator template by calling `do! :template_name`. Usually, this would happen in the `execute` function.
|
84
|
+
|
85
|
+
Optionally, a `setup` method can be defined to set up variables etc. when a drone instance is created.
|
86
|
+
|
87
|
+
|
88
|
+
### Describing a drone
|
89
|
+
|
90
|
+
You can use `desc` in the class declaration to explain what the drone does (mostly for shiny UI purposes)
|
91
|
+
|
92
|
+
class AppDrone::MyDrone < AppDrone::Drone
|
93
|
+
desc 'Kills all humans.'
|
94
|
+
end
|
95
|
+
|
96
|
+
|
97
|
+
### Drone dependencies
|
98
|
+
|
99
|
+
class AppDrone::MyDrone < AppDrone::Drone
|
100
|
+
depends_on DeathRay, YourMom
|
101
|
+
end
|
102
|
+
|
103
|
+
AppDrone::MyDrone.dependencies
|
104
|
+
# => [AppDrone::DeathRay, AppDrone::YourMom]
|
105
|
+
|
106
|
+
### Drone behavior parameters
|
107
|
+
|
108
|
+
class AppDrone::MyDrone < AppDrone::Drone
|
109
|
+
param :lazer_color, :string, rainbow: ['all','teh','colors!']
|
110
|
+
end
|
111
|
+
|
112
|
+
AppDrone::MyDrone.params
|
113
|
+
# => [#<struct Struct::Param name=:lazer_color, type=:string, options=[{:rainbow=>["all","teh","colors!"]}]>]
|
114
|
+
|
115
|
+
t = AppDrone::Template.new
|
116
|
+
t.add :my_drone, lazer_color: 'teh'
|
117
|
+
|
118
|
+
|
119
|
+
### Drone communication
|
120
|
+
|
121
|
+
Drones can talk to eachother via a proxy on the template they are included in, using the class name as a reference:
|
122
|
+
|
123
|
+
class AppDrone::MyDrone < AppDrone::Drone
|
124
|
+
def align
|
125
|
+
(self >> Bundle).add 'my_gem'
|
126
|
+
(self >> Stylesheet).add_import 'shiny_sheet'
|
127
|
+
end
|
128
|
+
end
|
129
|
+
|
130
|
+
*Note that the class instance of the parent template is messaged, not the static class.*
|
131
|
+
|
132
|
+
For convenience, `method_missing` is used to allow you to use the underscore'd name of a class to talk to it's template instance directly:
|
133
|
+
|
134
|
+
class AppDrone::MyDrone < AppDrone::Drone
|
135
|
+
def align
|
136
|
+
bundle.add 'my_gem'
|
137
|
+
stylesheet.add_import 'shiny_sheet'
|
138
|
+
end
|
139
|
+
end
|
140
|
+
|
141
|
+
|
142
|
+
**Take a look at existing drones for more info!**
|
143
|
+
|
144
|
+
|
145
|
+
### An important reminder
|
146
|
+
|
147
|
+
AppDrone is not for everyone. It's highly opinionated about how a Rails app should be laid out, but is the fruit of tons of research into best practices and maintainability. AppDrone leans especially heavily on Sass, Compass, Coffeescript and Slim. Buyer beware.
|
148
|
+
|
149
|
+
|
150
|
+
|
151
|
+
## Drones
|
152
|
+
|
153
|
+
### Active drones (put 'em to work!)
|
154
|
+
|
155
|
+
- Bundle
|
156
|
+
- Stylesheet
|
157
|
+
- Javascript
|
158
|
+
- SlimView
|
159
|
+
- Cleanup
|
160
|
+
|
161
|
+
|
162
|
+
### Frozen drones (currently in development)
|
163
|
+
|
164
|
+
- Bootstrap
|
165
|
+
- Chosen
|
166
|
+
- Cleanup
|
167
|
+
- FactoryGirl
|
168
|
+
- Git
|
169
|
+
- Guard
|
170
|
+
- RankedModel
|
171
|
+
- RSpec
|
172
|
+
- SimpleForm
|
173
|
+
|
174
|
+
|
175
|
+
### Future drones (TODO - I'll get there some day!)
|
176
|
+
|
177
|
+
- SlimViews: Add browser-specific classes to <html>
|
178
|
+
- UserAgent blocking script
|
179
|
+
- Responders
|
180
|
+
- HasScope
|
181
|
+
- Pagination
|
182
|
+
- CarrierWave (and optional cloud resizing thingy)
|
183
|
+
- Airbrake + API Key
|
184
|
+
- rails-best-practices (and the other output gem for debugging)
|
185
|
+
- NewRelic
|
186
|
+
- EngineYard for deployment
|
187
|
+
- jQuery shims
|
188
|
+
- Backbone integration + Skim
|
189
|
+
- Ember.js integration
|
190
|
+
- Pivotal tracker
|
191
|
+
- pie.htc for IE
|
192
|
+
- HTML5 shim for IE
|
193
|
+
|
194
|
+
|
195
|
+
## Contributing
|
196
|
+
|
197
|
+
I'd love it if you could get involved! Feel free to suggest improvements, drones you'd like developed, or help me get test coverage up to scratch :)
|
198
|
+
|
199
|
+
1. Fork it
|
200
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
201
|
+
3. Commit your changes (`git commit -am 'Added some feature'`)
|
202
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
203
|
+
5. Create new Pull Request
|
204
|
+
|
205
|
+
=======
|
data/README.md~
ADDED
@@ -0,0 +1,205 @@
|
|
1
|
+
# AppDrone
|
2
|
+
|
3
|
+
**Avoid the mundane.**
|
4
|
+
|
5
|
+
## Overview
|
6
|
+
|
7
|
+
AppDrone aims to take the bore out of setting up a Rails app just the way you like it. It's a code library that builds generator code that builds your Rails app code - R A I L S C E P T I O N!
|
8
|
+
|
9
|
+
*If you're super lazy, a shiny UI for choosing and configuring drones is coming soon! Right now, it's CLI only :P*
|
10
|
+
|
11
|
+
|
12
|
+
## Installation
|
13
|
+
|
14
|
+
Add this line to your application's `Gemfile`:
|
15
|
+
|
16
|
+
gem 'app_drone'
|
17
|
+
|
18
|
+
And then execute:
|
19
|
+
|
20
|
+
$ bundle
|
21
|
+
|
22
|
+
Or install it yourself:
|
23
|
+
|
24
|
+
$ gem install app_drone
|
25
|
+
|
26
|
+
|
27
|
+
## Usage
|
28
|
+
|
29
|
+
### Create a new template
|
30
|
+
|
31
|
+
require 'app_drone'
|
32
|
+
t = AppDrone::Template.new
|
33
|
+
|
34
|
+
### Add drones
|
35
|
+
|
36
|
+
t.add AppDrone::Bundle
|
37
|
+
t.add AppDrone::StyleSheet
|
38
|
+
|
39
|
+
Parameters can be used to modify drone behavior:
|
40
|
+
|
41
|
+
t.add AppDrone::Bootstrap, vendor: true
|
42
|
+
|
43
|
+
To list parameters for a specific drone:
|
44
|
+
|
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"}]>
|
48
|
+
|
49
|
+
For readability, you can use the symbol shorthand instead of full class name:
|
50
|
+
|
51
|
+
t.add :factory_girl # adds AppDrone::FactoryGirl
|
52
|
+
|
53
|
+
|
54
|
+
### Render template
|
55
|
+
|
56
|
+
Once you've loaded and configured your drones, the template can be rendered to screen or file:
|
57
|
+
|
58
|
+
t.render_to_file
|
59
|
+
# => out.rb
|
60
|
+
|
61
|
+
Dependencies are automatically checked, and a template will not render unless the drone requirements are all satisfied.
|
62
|
+
|
63
|
+
AppDrone::Bootstrap.dependencies
|
64
|
+
# => [AppDrone::Bundle, AppDrone::Stylesheet, AppDrone::Javascript]
|
65
|
+
|
66
|
+
*Note that most drones depend on `Bundle`, `Stylesheet` and `Javascript`.*
|
67
|
+
|
68
|
+
|
69
|
+
### Active drones
|
70
|
+
|
71
|
+
To list all available drones:
|
72
|
+
|
73
|
+
Drone.drones
|
74
|
+
# => [:stylesheet, :javascript, :slim_view, :cleanup, :bundle]
|
75
|
+
|
76
|
+
*Note: these are the underscored versions, not the class names.*
|
77
|
+
|
78
|
+
|
79
|
+
## Underneath the hood
|
80
|
+
|
81
|
+
Drones are simple classes that implement `align` and `execute` methods. When a template is rendered, `align` is called on each included drone in turn (to set up inter-dependencies), and then `execute` outputs drone code for the generator file.
|
82
|
+
|
83
|
+
Each drone lives in it's own folder in `lib/app_drone/drones`, and can include `.erb` templates that are rendered into the main generator template by calling `do! :template_name`. Usually, this would happen in the `execute` function.
|
84
|
+
|
85
|
+
Optionally, a `setup` method can be defined to set up variables etc. when a drone instance is created.
|
86
|
+
|
87
|
+
|
88
|
+
### Describing a drone
|
89
|
+
|
90
|
+
You can use `desc` in the class declaration to explain what the drone does (mostly for shiny UI purposes)
|
91
|
+
|
92
|
+
class AppDrone::MyDrone < AppDrone::Drone
|
93
|
+
desc 'Kills all humans.'
|
94
|
+
end
|
95
|
+
|
96
|
+
|
97
|
+
### Drone dependencies
|
98
|
+
|
99
|
+
class AppDrone::MyDrone < AppDrone::Drone
|
100
|
+
depends_on DeathRay, YourMom
|
101
|
+
end
|
102
|
+
|
103
|
+
AppDrone::MyDrone.dependencies
|
104
|
+
# => [AppDrone::DeathRay, AppDrone::YourMom]
|
105
|
+
|
106
|
+
### Drone behavior parameters
|
107
|
+
|
108
|
+
class AppDrone::MyDrone < AppDrone::Drone
|
109
|
+
param :lazer_color, :string, rainbow: ['all','teh','colors!']
|
110
|
+
end
|
111
|
+
|
112
|
+
AppDrone::MyDrone.params
|
113
|
+
# => [#<struct Struct::Param name=:lazer_color, type=:string, options=[{:rainbow=>["all","teh","colors!"]}]>]
|
114
|
+
|
115
|
+
t = AppDrone::Template.new
|
116
|
+
t.add :my_drone, lazer_color: 'teh'
|
117
|
+
|
118
|
+
|
119
|
+
### Drone communication
|
120
|
+
|
121
|
+
Drones can talk to eachother via a proxy on the template they are included in, using the class name as a reference:
|
122
|
+
|
123
|
+
class AppDrone::MyDrone < AppDrone::Drone
|
124
|
+
def align
|
125
|
+
(self >> Bundle).add 'my_gem'
|
126
|
+
(self >> Stylesheet).add_import 'shiny_sheet'
|
127
|
+
end
|
128
|
+
end
|
129
|
+
|
130
|
+
*Note that the class instance of the parent template is messaged, not the static class.*
|
131
|
+
|
132
|
+
For convenience, `method_missing` is used to allow you to use the underscore'd name of a class to talk to it's template instance directly:
|
133
|
+
|
134
|
+
class AppDrone::MyDrone < AppDrone::Drone
|
135
|
+
def align
|
136
|
+
bundle.add 'my_gem'
|
137
|
+
stylesheet.add_import 'shiny_sheet'
|
138
|
+
end
|
139
|
+
end
|
140
|
+
|
141
|
+
|
142
|
+
**Take a look at existing drones for more info!**
|
143
|
+
|
144
|
+
|
145
|
+
### An important reminder
|
146
|
+
|
147
|
+
AppDrone is not for everyone. It's highly opinionated about how a Rails app should be laid out, but is the fruit of tons of research into best practices and maintainability. AppDrone leans especially heavily on Sass, Compass, Coffeescript and Slim. Buyer beware.
|
148
|
+
|
149
|
+
|
150
|
+
|
151
|
+
## Drones
|
152
|
+
|
153
|
+
### Active drones (put 'em to work!)
|
154
|
+
|
155
|
+
- Bundle
|
156
|
+
- Stylesheet
|
157
|
+
- Javascript
|
158
|
+
- SlimView
|
159
|
+
- Cleanup
|
160
|
+
|
161
|
+
|
162
|
+
### Frozen drones (currently in development)
|
163
|
+
|
164
|
+
- Bootstrap
|
165
|
+
- Chosen
|
166
|
+
- Cleanup
|
167
|
+
- FactoryGirl
|
168
|
+
- Git
|
169
|
+
- Guard
|
170
|
+
- RankedModel
|
171
|
+
- RSpec
|
172
|
+
- SimpleForm
|
173
|
+
|
174
|
+
|
175
|
+
### Future drones (TODO - I'll get there some day!)
|
176
|
+
|
177
|
+
- SlimViews: Add browser-specific classes to <html>
|
178
|
+
- UserAgent blocking script
|
179
|
+
- Responders
|
180
|
+
- HasScope
|
181
|
+
- Pagination
|
182
|
+
- CarrierWave (and optional cloud resizing thingy)
|
183
|
+
- Airbrake + API Key
|
184
|
+
- rails-best-practices (and the other output gem for debugging)
|
185
|
+
- NewRelic
|
186
|
+
- EngineYard for deployment
|
187
|
+
- jQuery shims
|
188
|
+
- Backbone integration + Skim
|
189
|
+
- Ember.js integration
|
190
|
+
- Pivotal tracker
|
191
|
+
- pie.htc for IE
|
192
|
+
- HTML5 shim for IE
|
193
|
+
|
194
|
+
|
195
|
+
## Contributing
|
196
|
+
|
197
|
+
I'd love it if you could get involved! Feel free to suggest improvements, drones you'd like developed, or help me get test coverage up to scratch :)
|
198
|
+
|
199
|
+
1. Fork it
|
200
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
201
|
+
3. Commit your changes (`git commit -am 'Added some feature'`)
|
202
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
203
|
+
5. Create new Pull Request
|
204
|
+
|
205
|
+
=======
|
data/Rakefile
ADDED
data/Rakefile~
ADDED
data/TODO~
ADDED
@@ -0,0 +1,7 @@
|
|
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
|
7
|
+
|
data/app_drone.gemspec
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
require File.expand_path('../lib/app_drone/version', __FILE__)
|
3
|
+
|
4
|
+
Gem::Specification.new do |gem|
|
5
|
+
gem.authors = ['Daniel Davey']
|
6
|
+
gem.email = ['whoisdanieldavey@gmail.com']
|
7
|
+
gem.description = %q{Give your Rails apps a kickstart}
|
8
|
+
gem.summary = %q{Generates Rails templates to help start your app on good footing}
|
9
|
+
gem.homepage = 'https://github.com/jeriko/app_drone'
|
10
|
+
|
11
|
+
gem.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
12
|
+
gem.files = `git ls-files`.split("\n")
|
13
|
+
gem.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
14
|
+
gem.name = 'app_drone'
|
15
|
+
gem.require_paths = ['lib']
|
16
|
+
gem.version = AppDrone::VERSION
|
17
|
+
|
18
|
+
gem.add_dependency('activesupport', '>= 3.2.0')
|
19
|
+
|
20
|
+
end
|
data/app_drone.gemspec~
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
require File.expand_path('../lib/app_drone/version', __FILE__)
|
3
|
+
|
4
|
+
Gem::Specification.new do |gem|
|
5
|
+
gem.authors = ['Daniel Davey']
|
6
|
+
gem.email = ['whoisdanieldavey@gmail.com']
|
7
|
+
gem.description = %q{Give your rails apps a kickstart}
|
8
|
+
gem.summary = %q{Generates rails templates to help start your app on good footing}
|
9
|
+
gem.homepage = 'https://github.com/jeriko/app_drone'
|
10
|
+
|
11
|
+
gem.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
12
|
+
gem.files = `git ls-files`.split("\n")
|
13
|
+
gem.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
14
|
+
gem.name = 'app_drone'
|
15
|
+
gem.require_paths = ['lib']
|
16
|
+
gem.version = AppDrone::VERSION
|
17
|
+
|
18
|
+
gem.add_dependency('activesupport', '>= 3.2.0')
|
19
|
+
|
20
|
+
end
|
@@ -0,0 +1,81 @@
|
|
1
|
+
module AppDrone
|
2
|
+
|
3
|
+
Param = Struct.new('Param',:name,:type,:options)
|
4
|
+
|
5
|
+
class Drone
|
6
|
+
# align: set up variables, pass off to other scripts
|
7
|
+
# execute: actual install process
|
8
|
+
|
9
|
+
# New
|
10
|
+
def initialize(template,*params)
|
11
|
+
@template = template
|
12
|
+
@params = params.first # weird.. no idea why
|
13
|
+
setup
|
14
|
+
end
|
15
|
+
|
16
|
+
# DSL
|
17
|
+
def ^; @template end
|
18
|
+
def >>(klass); @template.hook(klass); end
|
19
|
+
|
20
|
+
def method_missing(meth, *args, &block)
|
21
|
+
if Drone.drones.include?(meth)
|
22
|
+
klass = ('AppDrone::' + meth.to_s.classify).constantize
|
23
|
+
return (self >> klass)
|
24
|
+
else
|
25
|
+
super
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
# Expected implementations
|
30
|
+
def align; end
|
31
|
+
def execute; end
|
32
|
+
|
33
|
+
# Optional implementations
|
34
|
+
def setup; end
|
35
|
+
|
36
|
+
def render(partial)
|
37
|
+
class_name = self.class.to_s.split('::').last.underscore
|
38
|
+
template_path = "/drones/#{class_name}/#{partial}.erb"
|
39
|
+
full_path = File.dirname(__FILE__) + template_path
|
40
|
+
snippet = ERB.new File.read(full_path)
|
41
|
+
output = snippet.result(binding)
|
42
|
+
output = "# --- \n# #{self.class.to_s}\n# ---\n" + output if true
|
43
|
+
return output
|
44
|
+
end
|
45
|
+
|
46
|
+
def do!(partial)
|
47
|
+
@template.do! render(partial), self
|
48
|
+
end
|
49
|
+
|
50
|
+
# DSL: Integration-specific options
|
51
|
+
attr_accessor :params
|
52
|
+
class << self
|
53
|
+
def param(name, type, *options)
|
54
|
+
(@params ||= []) << Param.new(name, type, options)
|
55
|
+
end
|
56
|
+
def params
|
57
|
+
@params
|
58
|
+
end
|
59
|
+
|
60
|
+
def desc(d='')
|
61
|
+
return @description if d.blank?
|
62
|
+
@description = d
|
63
|
+
end
|
64
|
+
|
65
|
+
def depends_on(*klass_symbols); @dependencies = klass_symbols end
|
66
|
+
def dependencies
|
67
|
+
(@dependencies || []).map { |k| ('AppDrone::' + k.to_s.classify).constantize }
|
68
|
+
end
|
69
|
+
|
70
|
+
def owns_generator_method(m); @generator_method = m end
|
71
|
+
def generator_method; @generator_method end
|
72
|
+
|
73
|
+
def drones
|
74
|
+
self.descendants.map { |d| d.to_s.split('::').last.underscore.to_sym }
|
75
|
+
end
|
76
|
+
|
77
|
+
end
|
78
|
+
|
79
|
+
end
|
80
|
+
|
81
|
+
end
|
@@ -0,0 +1,81 @@
|
|
1
|
+
module AppDrone
|
2
|
+
|
3
|
+
Param = Struct.new('Param',:name,:type,:options)
|
4
|
+
|
5
|
+
class Drone
|
6
|
+
# align: set up variables, pass off to other scripts
|
7
|
+
# execute: actual install process
|
8
|
+
|
9
|
+
# New
|
10
|
+
def initialize(template,*params)
|
11
|
+
@template = template
|
12
|
+
@params = params.first # weird.. no idea why
|
13
|
+
setup
|
14
|
+
end
|
15
|
+
|
16
|
+
# DSL
|
17
|
+
def ^; @template end
|
18
|
+
def >>(klass); @template.hook(klass); end
|
19
|
+
|
20
|
+
def method_missing(meth, *args, &block)
|
21
|
+
if Drone.drones.include?(meth)
|
22
|
+
klass = ('AppDrone::' + meth.to_s.classify).constantize
|
23
|
+
return (self >> klass)
|
24
|
+
else
|
25
|
+
super
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
# Expected implementations
|
30
|
+
def align; end
|
31
|
+
def execute; end
|
32
|
+
|
33
|
+
# Optional implementations
|
34
|
+
def setup; end
|
35
|
+
|
36
|
+
def render(partial)
|
37
|
+
class_name = self.class.to_s.split('::').last.underscore
|
38
|
+
template_path = "/drones/#{class_name}/#{partial}.erb"
|
39
|
+
full_path = File.dirname(__FILE__) + template_path
|
40
|
+
snippet = ERB.new File.read(full_path)
|
41
|
+
output = snippet.result(binding)
|
42
|
+
output = "# --- \n# #{self.class.to_s}\n# ---\n" + output if true
|
43
|
+
return output
|
44
|
+
end
|
45
|
+
|
46
|
+
def do!(partial)
|
47
|
+
@template.do! render(partial), self
|
48
|
+
end
|
49
|
+
|
50
|
+
# DSL: Integration-specific options
|
51
|
+
attr_accessor :params
|
52
|
+
class << self
|
53
|
+
def param(name, type, *options)
|
54
|
+
(@params ||= []) << Param.new(name, type, options)
|
55
|
+
end
|
56
|
+
def params
|
57
|
+
@params
|
58
|
+
end
|
59
|
+
|
60
|
+
def desc(d='')
|
61
|
+
return @description if d.blank?
|
62
|
+
@description = d
|
63
|
+
end
|
64
|
+
|
65
|
+
def depends_on(*klass_symbols); @dependencies = klass_symbols end
|
66
|
+
def dependencies
|
67
|
+
(@dependencies || []).map { |k| ('AppDrone::' + k.to_s.classify).constantize }
|
68
|
+
end
|
69
|
+
|
70
|
+
def owns_generator_method(m); @generator_method = m end
|
71
|
+
def generator_method; @generator_method end
|
72
|
+
|
73
|
+
def drones
|
74
|
+
self.descendants.map { |d| d.to_s.split('::').last.underscore.to_sym }
|
75
|
+
end
|
76
|
+
|
77
|
+
end
|
78
|
+
|
79
|
+
end
|
80
|
+
|
81
|
+
end
|