modular_engine 0.9.0
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.
- checksums.yaml +7 -0
- data/.gitignore +22 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +33 -0
- data/Rakefile +2 -0
- data/lib/generators/modular/USAGE +8 -0
- data/lib/generators/modular/engine_generator.rb +308 -0
- data/lib/generators/modular/templates/%name%.gemspec +27 -0
- data/lib/generators/modular/templates/Gemfile +47 -0
- data/lib/generators/modular/templates/MIT-LICENSE +20 -0
- data/lib/generators/modular/templates/README.rdoc +3 -0
- data/lib/generators/modular/templates/Rakefile +20 -0
- data/lib/generators/modular/templates/app/controllers/%namespaced_name%/application_controller.rb.tt +5 -0
- data/lib/generators/modular/templates/app/helpers/%namespaced_name%/application_helper.rb.tt +5 -0
- data/lib/generators/modular/templates/app/mailers/.empty_directory +0 -0
- data/lib/generators/modular/templates/app/models/%namespaced_name%/.empty_directory +0 -0
- data/lib/generators/modular/templates/app/views/layouts/%namespaced_name%/application.html.erb.tt +14 -0
- data/lib/generators/modular/templates/bin/rails.tt +11 -0
- data/lib/generators/modular/templates/config/routes.rb +2 -0
- data/lib/generators/modular/templates/gitignore +3 -0
- data/lib/generators/modular/templates/lib/%engine_loader%.rb +2 -0
- data/lib/generators/modular/templates/lib/%namespaced_name%/engine.rb +6 -0
- data/lib/generators/modular/templates/lib/%namespaced_name%/version.rb +1 -0
- data/lib/generators/modular/templates/lib/%namespaced_name%.rb +1 -0
- data/lib/generators/modular/templates/lib/tasks/%namespaced_name%_tasks.rake +4 -0
- data/lib/generators/modular/templates/rails/application.rb +18 -0
- data/lib/generators/modular/templates/rails/boot.rb +5 -0
- data/lib/generators/modular/templates/rails/javascripts.js +13 -0
- data/lib/generators/modular/templates/rails/routes.rb +4 -0
- data/lib/generators/modular/templates/rails/stylesheets.css +14 -0
- data/lib/generators/modular/templates/test/%namespaced_name%_test.rb +7 -0
- data/lib/generators/modular/templates/test/integration/navigation_test.rb +12 -0
- data/lib/generators/modular/templates/test/test_helper.rb +25 -0
- data/lib/modular_engine/engine.rb +6 -0
- data/lib/modular_engine/version.rb +3 -0
- data/lib/modular_engine.rb +5 -0
- data/modular_engine.gemspec +23 -0
- metadata +110 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 081692dc1e4e910312395cc418deb878ea503913
|
4
|
+
data.tar.gz: e419379628560d122d8837f3b68418b3ffc2670d
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: c8e12fe9b07ebbc251e6e22c881dd9cde41e1ebc28f83841496c2d0dcd5ddf9326f9e92e1a83bab71ea12489be2ead24abf8dbbeb1865ac75320dd71ab5e5ff8
|
7
|
+
data.tar.gz: f4eeb3cb5a5ef22b6caf17bf1656e16d2c71fde7410a15d991d04e8d36a208d7a638d460f304c1e097deb39d1048decbf9f4a40706f507f6c9b45f1c6a6d2c65
|
data/.gitignore
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
*.gem
|
2
|
+
*.rbc
|
3
|
+
.bundle
|
4
|
+
.config
|
5
|
+
.yardoc
|
6
|
+
Gemfile.lock
|
7
|
+
InstalledFiles
|
8
|
+
_yardoc
|
9
|
+
coverage
|
10
|
+
doc/
|
11
|
+
lib/bundler/man
|
12
|
+
pkg
|
13
|
+
rdoc
|
14
|
+
spec/reports
|
15
|
+
test/tmp
|
16
|
+
test/version_tmp
|
17
|
+
tmp
|
18
|
+
*.bundle
|
19
|
+
*.so
|
20
|
+
*.o
|
21
|
+
*.a
|
22
|
+
mkmf.log
|
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2015 Thibault
|
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,33 @@
|
|
1
|
+
# ModularEngine
|
2
|
+
|
3
|
+
Engine generator heavily inspired from the official Plugin generator. It can be used to generate Modular Rails Engines with 2 level of namespace.
|
4
|
+
|
5
|
+
Created for Modular Rails (https://modularity.samurais.com).
|
6
|
+
|
7
|
+
## Installation
|
8
|
+
|
9
|
+
Add this line to your application's Gemfile:
|
10
|
+
|
11
|
+
gem 'modular_engine'
|
12
|
+
|
13
|
+
And then execute:
|
14
|
+
|
15
|
+
$ bundle
|
16
|
+
|
17
|
+
Or install it yourself as:
|
18
|
+
|
19
|
+
$ gem install modular_engine
|
20
|
+
|
21
|
+
## Usage
|
22
|
+
|
23
|
+
To generate a new modular engine, run the following command from a Ruby on Rails application:
|
24
|
+
|
25
|
+
$ rails generate modular:engine path/to/my_engine --namespace='my_namespace'
|
26
|
+
|
27
|
+
## Contributing
|
28
|
+
|
29
|
+
1. Fork it ( https://github.com/[my-github-username]/modular_engine/fork )
|
30
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
31
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
32
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
33
|
+
5. Create a new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1,8 @@
|
|
1
|
+
Description:
|
2
|
+
The 'rails modular_engine new' command creates a skeleton for developing an extendable modular engine.
|
3
|
+
|
4
|
+
Example:
|
5
|
+
rails modular_engine new ~/Code/Ruby/my_app/engines/blog 'Namespace1/Namespace2'
|
6
|
+
|
7
|
+
This generates a skeletal Rails engine in ~/Code/Ruby/my_app/engines/blog.
|
8
|
+
See the README in the newly created engine to get going.
|
@@ -0,0 +1,308 @@
|
|
1
|
+
#lib/generators/modular_engine_generator/install_generator.rb
|
2
|
+
require 'rails/generators'
|
3
|
+
require 'active_support/core_ext/hash/slice'
|
4
|
+
require "rails/generators/rails/app/app_generator"
|
5
|
+
#require "rails/generators/app_base"
|
6
|
+
require 'date'
|
7
|
+
|
8
|
+
module Modular
|
9
|
+
|
10
|
+
class EngineBuilder
|
11
|
+
def rakefile
|
12
|
+
template "Rakefile"
|
13
|
+
end
|
14
|
+
|
15
|
+
def app
|
16
|
+
directory 'app'
|
17
|
+
empty_directory_with_keep_file "app/assets/images/#{namespaced_name}"
|
18
|
+
directory "app/views/%namespaced_name%"
|
19
|
+
end
|
20
|
+
|
21
|
+
def readme
|
22
|
+
template "README.rdoc"
|
23
|
+
end
|
24
|
+
|
25
|
+
def gemfile
|
26
|
+
template "Gemfile"
|
27
|
+
end
|
28
|
+
|
29
|
+
def license
|
30
|
+
template "MIT-LICENSE"
|
31
|
+
end
|
32
|
+
|
33
|
+
def gemspec
|
34
|
+
template "%name%.gemspec"
|
35
|
+
end
|
36
|
+
|
37
|
+
def gitignore
|
38
|
+
template "gitignore", ".gitignore"
|
39
|
+
end
|
40
|
+
|
41
|
+
def lib
|
42
|
+
template "lib/%namespaced_name%.rb"
|
43
|
+
template "lib/%engine_loader%.rb"
|
44
|
+
template "lib/tasks/%namespaced_name%_tasks.rake"
|
45
|
+
template "lib/%namespaced_name%/version.rb"
|
46
|
+
template "lib/%namespaced_name%/engine.rb"
|
47
|
+
end
|
48
|
+
|
49
|
+
def config
|
50
|
+
template "config/routes.rb" if engine?
|
51
|
+
end
|
52
|
+
|
53
|
+
def test
|
54
|
+
template "test/test_helper.rb"
|
55
|
+
template "test/%namespaced_name%_test.rb"
|
56
|
+
append_file "Rakefile", <<-EOF
|
57
|
+
#{rakefile_test_tasks}
|
58
|
+
|
59
|
+
task default: :test
|
60
|
+
EOF
|
61
|
+
if engine?
|
62
|
+
template "test/integration/navigation_test.rb"
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
PASSTHROUGH_OPTIONS = [
|
67
|
+
:skip_active_record, :skip_action_mailer, :skip_javascript, :database,
|
68
|
+
:javascript, :quiet, :pretend, :force, :skip
|
69
|
+
]
|
70
|
+
|
71
|
+
def stylesheets
|
72
|
+
copy_file "rails/stylesheets.css",
|
73
|
+
"app/assets/stylesheets/#{namespaced_name}/application.css"
|
74
|
+
end
|
75
|
+
|
76
|
+
def javascripts
|
77
|
+
return if options.skip_javascript?
|
78
|
+
|
79
|
+
template "rails/javascripts.js",
|
80
|
+
"app/assets/javascripts/#{namespaced_name}/application.js"
|
81
|
+
end
|
82
|
+
|
83
|
+
def bin(force = false)
|
84
|
+
return unless engine?
|
85
|
+
|
86
|
+
directory "bin", force: force do |content|
|
87
|
+
"#{shebang}\n" + content
|
88
|
+
end
|
89
|
+
chmod "bin", 0755, verbose: false
|
90
|
+
end
|
91
|
+
|
92
|
+
def gemfile_entry
|
93
|
+
return unless inside_application?
|
94
|
+
|
95
|
+
gemfile_in_app_path = File.join(rails_app_path, "Gemfile")
|
96
|
+
if File.exist? gemfile_in_app_path
|
97
|
+
entry = "gem '#{name}', path: '#{relative_path}'"
|
98
|
+
append_file gemfile_in_app_path, entry
|
99
|
+
end
|
100
|
+
end
|
101
|
+
end
|
102
|
+
|
103
|
+
class EngineGenerator < ::Rails::Generators::AppBase # :nodoc:
|
104
|
+
source_root File.expand_path("../templates", __FILE__)
|
105
|
+
add_shared_options_for "engine"
|
106
|
+
|
107
|
+
remove_argument :app_path
|
108
|
+
argument :engine_path, type: :string
|
109
|
+
|
110
|
+
alias_method :app_path, :engine_path
|
111
|
+
|
112
|
+
class_option :namespace, type: :string, default: '',
|
113
|
+
desc: 'Add one or more namespace to your modular engine. Ex: namespace1::namespace2'
|
114
|
+
|
115
|
+
def initialize(*args)
|
116
|
+
super
|
117
|
+
|
118
|
+
unless engine_path
|
119
|
+
raise Error, "Engine name should be provided in arguments. For details run: rails g modular:engine --help"
|
120
|
+
end
|
121
|
+
end
|
122
|
+
|
123
|
+
public_task :set_default_accessors!
|
124
|
+
public_task :create_root
|
125
|
+
|
126
|
+
def create_root_files
|
127
|
+
build(:readme)
|
128
|
+
build(:rakefile)
|
129
|
+
build(:gemspec) unless options[:skip_gemspec]
|
130
|
+
build(:license)
|
131
|
+
build(:gitignore) unless options[:skip_git]
|
132
|
+
build(:gemfile) unless options[:skip_gemfile]
|
133
|
+
end
|
134
|
+
|
135
|
+
def create_app_files
|
136
|
+
build(:app)
|
137
|
+
end
|
138
|
+
|
139
|
+
def create_config_files
|
140
|
+
build(:config)
|
141
|
+
end
|
142
|
+
|
143
|
+
def create_lib_files
|
144
|
+
build(:lib)
|
145
|
+
end
|
146
|
+
|
147
|
+
def create_public_stylesheets_files
|
148
|
+
build(:stylesheets)
|
149
|
+
end
|
150
|
+
|
151
|
+
def create_javascript_files
|
152
|
+
build(:javascripts)
|
153
|
+
end
|
154
|
+
|
155
|
+
def create_images_directory
|
156
|
+
build(:images)
|
157
|
+
end
|
158
|
+
|
159
|
+
def create_bin_files
|
160
|
+
build(:bin)
|
161
|
+
end
|
162
|
+
|
163
|
+
def create_test_files
|
164
|
+
build(:test) unless options[:skip_test]
|
165
|
+
end
|
166
|
+
|
167
|
+
def update_gemfile
|
168
|
+
build(:gemfile_entry) unless options[:skip_gemfile_entry]
|
169
|
+
end
|
170
|
+
|
171
|
+
def finish_template
|
172
|
+
build(:leftovers)
|
173
|
+
end
|
174
|
+
|
175
|
+
public_task :apply_rails_template, :run_bundle
|
176
|
+
|
177
|
+
def name
|
178
|
+
@name ||= begin
|
179
|
+
# same as ActiveSupport::Inflector#underscore except not replacing '-'
|
180
|
+
underscored = original_name.dup
|
181
|
+
underscored.gsub!(/([A-Z]+)([A-Z][a-z])/,'\1_\2')
|
182
|
+
underscored.gsub!(/([a-z\d])([A-Z])/,'\1_\2')
|
183
|
+
underscored.downcase!
|
184
|
+
|
185
|
+
underscored
|
186
|
+
end
|
187
|
+
end
|
188
|
+
|
189
|
+
def underscored_name
|
190
|
+
@underscored_name ||= original_name.underscore
|
191
|
+
end
|
192
|
+
|
193
|
+
def namespaced_name
|
194
|
+
@namespaced_name ||= modules.join('/').downcase#name.gsub('-', '/')
|
195
|
+
end
|
196
|
+
|
197
|
+
protected
|
198
|
+
|
199
|
+
def app_templates_dir
|
200
|
+
"../app/templates"
|
201
|
+
end
|
202
|
+
|
203
|
+
def engine?
|
204
|
+
true
|
205
|
+
end
|
206
|
+
|
207
|
+
def skip_git?
|
208
|
+
options[:skip_git]
|
209
|
+
end
|
210
|
+
|
211
|
+
def self.banner
|
212
|
+
"rails generate modular:engine #{self.arguments.map(&:usage).join(' ')} [options]"
|
213
|
+
end
|
214
|
+
|
215
|
+
def original_name
|
216
|
+
@original_name ||= File.basename(destination_root)
|
217
|
+
end
|
218
|
+
|
219
|
+
def modules
|
220
|
+
@modules ||= options[:namespace].camelize.split('::').push(original_name.camelize)
|
221
|
+
end
|
222
|
+
|
223
|
+
def engine_loader
|
224
|
+
p options[:namespace].camelize.gsub('::', '/') + "/#{modules.join('_').downcase}"
|
225
|
+
@engine_loader ||= modules.join('_').downcase
|
226
|
+
end
|
227
|
+
|
228
|
+
def wrap_in_modules(content)
|
229
|
+
content = "#{content}".strip.gsub(/\W$\n/, '')
|
230
|
+
modules.reverse.inject(content) do |content, mod|
|
231
|
+
str = "module #{mod}\n"
|
232
|
+
str += content.lines.map { |line| " #{line}" }.join
|
233
|
+
str += content.present? ? "\nend" : "end"
|
234
|
+
end
|
235
|
+
end
|
236
|
+
|
237
|
+
def camelized_modules
|
238
|
+
@camelized_modules ||= namespaced_name.camelize
|
239
|
+
end
|
240
|
+
|
241
|
+
def humanized
|
242
|
+
@humanized ||= original_name.underscore.humanize
|
243
|
+
end
|
244
|
+
|
245
|
+
def camelized
|
246
|
+
@camelized ||= name.gsub(/\W/, '_').squeeze('_').camelize
|
247
|
+
end
|
248
|
+
|
249
|
+
def author
|
250
|
+
default = "TODO: Write your name"
|
251
|
+
if skip_git?
|
252
|
+
@author = default
|
253
|
+
else
|
254
|
+
@author = `git config user.name`.chomp rescue default
|
255
|
+
end
|
256
|
+
end
|
257
|
+
|
258
|
+
def email
|
259
|
+
default = "TODO: Write your email address"
|
260
|
+
if skip_git?
|
261
|
+
@email = default
|
262
|
+
else
|
263
|
+
@email = `git config user.email`.chomp rescue default
|
264
|
+
end
|
265
|
+
end
|
266
|
+
|
267
|
+
def valid_const?
|
268
|
+
if original_name =~ /-\d/
|
269
|
+
raise Rails::Generators::Error, "Invalid engine name #{original_name}. Please give a name which does not contain a namespace starting with numeric characters."
|
270
|
+
elsif original_name =~ /[^\w-]+/
|
271
|
+
raise Rails::Generators::Error, "Invalid engine name #{original_name}. Please give a name which uses only alphabetic, numeric, \"_\" or \"-\" characters."
|
272
|
+
elsif camelized =~ /^\d/
|
273
|
+
raise Rails::Generators::Error, "Invalid engine name #{original_name}. Please give a name which does not start with numbers."
|
274
|
+
elsif Rails::Generators::RESERVED_NAMES.include?(name)
|
275
|
+
raise Rails::Generators::Error, "Invalid engine name #{original_name}. Please give a name which does not match one of the reserved rails words."
|
276
|
+
elsif Object.const_defined?(camelized)
|
277
|
+
raise Rails::Generators::Error, "Invalid engine name #{original_name}, constant #{camelized} is already in use. Please choose another plugin name."
|
278
|
+
end
|
279
|
+
end
|
280
|
+
|
281
|
+
def get_builder_class
|
282
|
+
EngineBuilder
|
283
|
+
end
|
284
|
+
|
285
|
+
def mute(&block)
|
286
|
+
shell.mute(&block)
|
287
|
+
end
|
288
|
+
|
289
|
+
def rails_app_path
|
290
|
+
APP_PATH.sub("/config/application", "") if defined?(APP_PATH)
|
291
|
+
end
|
292
|
+
|
293
|
+
def inside_application?
|
294
|
+
rails_app_path && app_path =~ /^#{rails_app_path}/
|
295
|
+
end
|
296
|
+
|
297
|
+
def relative_path
|
298
|
+
return unless inside_application?
|
299
|
+
app_path.sub(/^#{rails_app_path}\//, '')
|
300
|
+
end
|
301
|
+
|
302
|
+
def rakefile_test_tasks
|
303
|
+
''
|
304
|
+
end
|
305
|
+
|
306
|
+
end
|
307
|
+
|
308
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
$:.push File.expand_path("../lib", __FILE__)
|
2
|
+
|
3
|
+
# Maintain your gem's version:
|
4
|
+
require "<%= namespaced_name %>/version"
|
5
|
+
|
6
|
+
# Describe your gem and declare its dependencies:
|
7
|
+
Gem::Specification.new do |s|
|
8
|
+
s.name = "<%= name %>"
|
9
|
+
s.version = <%= camelized_modules %>::VERSION
|
10
|
+
s.authors = ["<%= author %>"]
|
11
|
+
s.email = ["<%= email %>"]
|
12
|
+
s.homepage = "TODO"
|
13
|
+
s.summary = "TODO: Summary of <%= camelized_modules %>."
|
14
|
+
s.description = "TODO: Description of <%= camelized_modules %>."
|
15
|
+
s.license = "MIT"
|
16
|
+
|
17
|
+
s.files = Dir["{app,config,db,lib}/**/*", "MIT-LICENSE", "Rakefile", "README.rdoc"]
|
18
|
+
<% unless options.skip_test? -%>
|
19
|
+
s.test_files = Dir["test/**/*"]
|
20
|
+
<% end -%>
|
21
|
+
|
22
|
+
<%= '# ' if options.dev? || options.edge? -%>s.add_dependency "rails", "~> <%= Rails::VERSION::STRING %>"
|
23
|
+
<% unless options[:skip_active_record] -%>
|
24
|
+
|
25
|
+
s.add_development_dependency "<%= gem_for_database %>"
|
26
|
+
<% end -%>
|
27
|
+
end
|
@@ -0,0 +1,47 @@
|
|
1
|
+
source 'https://rubygems.org'
|
2
|
+
|
3
|
+
<% if options[:skip_gemspec] -%>
|
4
|
+
<%= '# ' if options.dev? || options.edge? -%>gem 'rails', '~> <%= Rails::VERSION::STRING %>'
|
5
|
+
<% else -%>
|
6
|
+
# Declare your gem's dependencies in <%= name %>.gemspec.
|
7
|
+
# Bundler will treat runtime dependencies like base dependencies, and
|
8
|
+
# development dependencies will be added by default to the :development group.
|
9
|
+
gemspec
|
10
|
+
<% end -%>
|
11
|
+
|
12
|
+
<% if options[:skip_gemspec] -%>
|
13
|
+
group :development do
|
14
|
+
gem '<%= gem_for_database %>'
|
15
|
+
end
|
16
|
+
<% else -%>
|
17
|
+
# Declare any dependencies that are still in development here instead of in
|
18
|
+
# your gemspec. These might include edge Rails or gems from your path or
|
19
|
+
# Git. Remember to move these dependencies to your gemspec before releasing
|
20
|
+
# your gem to rubygems.org.
|
21
|
+
<% end -%>
|
22
|
+
|
23
|
+
<% if options.dev? || options.edge? -%>
|
24
|
+
# Your gem is dependent on dev or edge Rails. Once you can lock this
|
25
|
+
# dependency down to a specific version, move it to your gemspec.
|
26
|
+
<% max_width = gemfile_entries.map { |g| g.name.length }.max -%>
|
27
|
+
<% gemfile_entries.each do |gem| -%>
|
28
|
+
<% if gem.comment -%>
|
29
|
+
|
30
|
+
# <%= gem.comment %>
|
31
|
+
<% end -%>
|
32
|
+
<%= gem.commented_out ? '# ' : '' %>gem '<%= gem.name %>'<%= %(, '#{gem.version}') if gem.version -%>
|
33
|
+
<% if gem.options.any? -%>
|
34
|
+
, <%= gem.options.map { |k,v|
|
35
|
+
"#{k}: #{v.inspect}" }.join(', ') %>
|
36
|
+
<% end -%>
|
37
|
+
<% end -%>
|
38
|
+
|
39
|
+
<% end -%>
|
40
|
+
<% if RUBY_ENGINE == 'ruby' -%>
|
41
|
+
# To use a debugger
|
42
|
+
# gem 'byebug', group: [:development, :test]
|
43
|
+
<% end -%>
|
44
|
+
|
45
|
+
<% if RUBY_PLATFORM.match(/bccwin|cygwin|emx|mingw|mswin|wince|java/) -%>
|
46
|
+
gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby]
|
47
|
+
<% end -%>
|
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright <%= Date.today.year %> <%= author %>
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
@@ -0,0 +1,20 @@
|
|
1
|
+
begin
|
2
|
+
require 'bundler/setup'
|
3
|
+
rescue LoadError
|
4
|
+
puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
|
5
|
+
end
|
6
|
+
|
7
|
+
require 'rdoc/task'
|
8
|
+
|
9
|
+
RDoc::Task.new(:rdoc) do |rdoc|
|
10
|
+
rdoc.rdoc_dir = 'rdoc'
|
11
|
+
rdoc.title = '<%= camelized_modules %>'
|
12
|
+
rdoc.options << '--line-numbers'
|
13
|
+
rdoc.rdoc_files.include('README.rdoc')
|
14
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
15
|
+
end
|
16
|
+
|
17
|
+
<% unless options[:skip_gemspec] -%>
|
18
|
+
|
19
|
+
Bundler::GemHelper.install_tasks
|
20
|
+
<% end %>
|
File without changes
|
File without changes
|
data/lib/generators/modular/templates/app/views/layouts/%namespaced_name%/application.html.erb.tt
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<title><%= humanized %></title>
|
5
|
+
<%%= stylesheet_link_tag "<%= namespaced_name %>/application", media: "all" %>
|
6
|
+
<%%= javascript_include_tag "<%= namespaced_name %>/application" %>
|
7
|
+
<%%= csrf_meta_tags %>
|
8
|
+
</head>
|
9
|
+
<body>
|
10
|
+
|
11
|
+
<%%= yield %>
|
12
|
+
|
13
|
+
</body>
|
14
|
+
</html>
|
@@ -0,0 +1,11 @@
|
|
1
|
+
# This command will automatically be run when you run "rails" with Rails 4 gems installed from the root of your application.
|
2
|
+
|
3
|
+
ENGINE_ROOT = File.expand_path('../..', __FILE__)
|
4
|
+
ENGINE_PATH = File.expand_path('../../lib/<%= namespaced_name -%>/engine', __FILE__)
|
5
|
+
|
6
|
+
# Set up gems listed in the Gemfile.
|
7
|
+
ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__)
|
8
|
+
require 'bundler/setup' if File.exist?(ENV['BUNDLE_GEMFILE'])
|
9
|
+
|
10
|
+
require 'rails/all'
|
11
|
+
require 'rails/engine/commands'
|
@@ -0,0 +1 @@
|
|
1
|
+
<%= wrap_in_modules 'VERSION = "0.0.1"' %>
|
@@ -0,0 +1 @@
|
|
1
|
+
<%= wrap_in_modules '' %>
|
@@ -0,0 +1,18 @@
|
|
1
|
+
require File.expand_path('../boot', __FILE__)
|
2
|
+
|
3
|
+
<% if include_all_railties? -%>
|
4
|
+
require 'rails/all'
|
5
|
+
<% else -%>
|
6
|
+
# Pick the frameworks you want:
|
7
|
+
<%= comment_if :skip_active_record %>require "active_record/railtie"
|
8
|
+
require "action_controller/railtie"
|
9
|
+
<%= comment_if :skip_action_mailer %>require "action_mailer/railtie"
|
10
|
+
require "action_view/railtie"
|
11
|
+
<%= comment_if :skip_sprockets %>require "sprockets/railtie"
|
12
|
+
<%= comment_if :skip_test %>require "rails/test_unit/railtie"
|
13
|
+
<% end -%>
|
14
|
+
|
15
|
+
Bundler.require(*Rails.groups)
|
16
|
+
require "<%= namespaced_name %>"
|
17
|
+
|
18
|
+
<%= application_definition %>
|
@@ -0,0 +1,13 @@
|
|
1
|
+
// This is a manifest file that'll be compiled into application.js, which will include all the files
|
2
|
+
// listed below.
|
3
|
+
//
|
4
|
+
// Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
|
5
|
+
// or any plugin's vendor/assets/javascripts directory can be referenced here using a relative path.
|
6
|
+
//
|
7
|
+
// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
|
8
|
+
// compiled file.
|
9
|
+
//
|
10
|
+
// Read Sprockets README (https://github.com/sstephenson/sprockets#sprockets-directives) for details
|
11
|
+
// about supported directives.
|
12
|
+
//
|
13
|
+
//= require_tree .
|
@@ -0,0 +1,14 @@
|
|
1
|
+
/*
|
2
|
+
* This is a manifest file that'll be compiled into application.css, which will include all the files
|
3
|
+
* listed below.
|
4
|
+
*
|
5
|
+
* Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
|
6
|
+
* or any plugin's vendor/assets/stylesheets directory can be referenced here using a relative path.
|
7
|
+
*
|
8
|
+
* You're free to add application-wide styles to this file and they'll appear at the bottom of the
|
9
|
+
* compiled file so the styles you add here take precedence over styles defined in any other CSS/SCSS
|
10
|
+
* files in this directory. It is generally better to create a new file per style scope.
|
11
|
+
*
|
12
|
+
*= require_tree .
|
13
|
+
*= require_self
|
14
|
+
*/
|
@@ -0,0 +1,25 @@
|
|
1
|
+
# Configure Rails Environment
|
2
|
+
ENV["RAILS_ENV"] = "test"
|
3
|
+
|
4
|
+
require File.expand_path("../../<%= options[:dummy_path] -%>/config/environment.rb", __FILE__)
|
5
|
+
<% unless options[:skip_active_record] -%>
|
6
|
+
ActiveRecord::Migrator.migrations_paths = [File.expand_path("../../<%= options[:dummy_path] -%>/db/migrate", __FILE__)]
|
7
|
+
<% if options[:mountable] -%>
|
8
|
+
ActiveRecord::Migrator.migrations_paths << File.expand_path('../../db/migrate', __FILE__)
|
9
|
+
<% end -%>
|
10
|
+
<% end -%>
|
11
|
+
require "rails/test_help"
|
12
|
+
|
13
|
+
# Filter out Minitest backtrace while allowing backtrace from other libraries
|
14
|
+
# to be shown.
|
15
|
+
Minitest.backtrace_filter = Minitest::BacktraceFilter.new
|
16
|
+
|
17
|
+
# Load support files
|
18
|
+
Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each { |f| require f }
|
19
|
+
|
20
|
+
# Load fixtures from the engine
|
21
|
+
if ActiveSupport::TestCase.respond_to?(:fixture_path=)
|
22
|
+
ActiveSupport::TestCase.fixture_path = File.expand_path("../fixtures", __FILE__)
|
23
|
+
ActiveSupport::TestCase.file_fixture_path = ActiveSupport::TestCase.fixture_path + "files"
|
24
|
+
ActiveSupport::TestCase.fixtures :all
|
25
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'modular_engine/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "modular_engine"
|
8
|
+
spec.version = ModularEngine::VERSION
|
9
|
+
spec.authors = ["Thibault"]
|
10
|
+
spec.email = ["thibault@appyhotel.com"]
|
11
|
+
spec.summary = 'Generate modular Rails engines.'
|
12
|
+
spec.description = 'This gem will generate modular engines as shown in the book Modular Rails at http://modularity.samurails.com.'
|
13
|
+
spec.homepage = "http://modularity.samurails.com"
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.files = `git ls-files -z`.split("\x0")
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
+
spec.require_paths = ["lib"]
|
20
|
+
|
21
|
+
spec.add_development_dependency "bundler", "~> 1.6"
|
22
|
+
spec.add_development_dependency "rake"
|
23
|
+
end
|
metadata
ADDED
@@ -0,0 +1,110 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: modular_engine
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.9.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Thibault
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2015-02-05 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.6'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.6'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
description: This gem will generate modular engines as shown in the book Modular Rails
|
42
|
+
at http://modularity.samurails.com.
|
43
|
+
email:
|
44
|
+
- thibault@appyhotel.com
|
45
|
+
executables: []
|
46
|
+
extensions: []
|
47
|
+
extra_rdoc_files: []
|
48
|
+
files:
|
49
|
+
- ".gitignore"
|
50
|
+
- Gemfile
|
51
|
+
- LICENSE.txt
|
52
|
+
- README.md
|
53
|
+
- Rakefile
|
54
|
+
- lib/generators/modular/USAGE
|
55
|
+
- lib/generators/modular/engine_generator.rb
|
56
|
+
- lib/generators/modular/templates/%name%.gemspec
|
57
|
+
- lib/generators/modular/templates/Gemfile
|
58
|
+
- lib/generators/modular/templates/MIT-LICENSE
|
59
|
+
- lib/generators/modular/templates/README.rdoc
|
60
|
+
- lib/generators/modular/templates/Rakefile
|
61
|
+
- lib/generators/modular/templates/app/controllers/%namespaced_name%/application_controller.rb.tt
|
62
|
+
- lib/generators/modular/templates/app/helpers/%namespaced_name%/application_helper.rb.tt
|
63
|
+
- lib/generators/modular/templates/app/mailers/.empty_directory
|
64
|
+
- lib/generators/modular/templates/app/models/%namespaced_name%/.empty_directory
|
65
|
+
- lib/generators/modular/templates/app/views/layouts/%namespaced_name%/application.html.erb.tt
|
66
|
+
- lib/generators/modular/templates/bin/rails.tt
|
67
|
+
- lib/generators/modular/templates/config/routes.rb
|
68
|
+
- lib/generators/modular/templates/gitignore
|
69
|
+
- lib/generators/modular/templates/lib/%engine_loader%.rb
|
70
|
+
- lib/generators/modular/templates/lib/%namespaced_name%.rb
|
71
|
+
- lib/generators/modular/templates/lib/%namespaced_name%/engine.rb
|
72
|
+
- lib/generators/modular/templates/lib/%namespaced_name%/version.rb
|
73
|
+
- lib/generators/modular/templates/lib/tasks/%namespaced_name%_tasks.rake
|
74
|
+
- lib/generators/modular/templates/rails/application.rb
|
75
|
+
- lib/generators/modular/templates/rails/boot.rb
|
76
|
+
- lib/generators/modular/templates/rails/javascripts.js
|
77
|
+
- lib/generators/modular/templates/rails/routes.rb
|
78
|
+
- lib/generators/modular/templates/rails/stylesheets.css
|
79
|
+
- lib/generators/modular/templates/test/%namespaced_name%_test.rb
|
80
|
+
- lib/generators/modular/templates/test/integration/navigation_test.rb
|
81
|
+
- lib/generators/modular/templates/test/test_helper.rb
|
82
|
+
- lib/modular_engine.rb
|
83
|
+
- lib/modular_engine/engine.rb
|
84
|
+
- lib/modular_engine/version.rb
|
85
|
+
- modular_engine.gemspec
|
86
|
+
homepage: http://modularity.samurails.com
|
87
|
+
licenses:
|
88
|
+
- MIT
|
89
|
+
metadata: {}
|
90
|
+
post_install_message:
|
91
|
+
rdoc_options: []
|
92
|
+
require_paths:
|
93
|
+
- lib
|
94
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
95
|
+
requirements:
|
96
|
+
- - ">="
|
97
|
+
- !ruby/object:Gem::Version
|
98
|
+
version: '0'
|
99
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - ">="
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '0'
|
104
|
+
requirements: []
|
105
|
+
rubyforge_project:
|
106
|
+
rubygems_version: 2.2.2
|
107
|
+
signing_key:
|
108
|
+
specification_version: 4
|
109
|
+
summary: Generate modular Rails engines.
|
110
|
+
test_files: []
|