gemaker 0.1.3 → 0.6.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 +5 -5
- data/.circleci/config.yml +103 -0
- data/.circleci/setup-rubygems.sh +3 -0
- data/.coveralls.yml +1 -0
- data/.hound.yml +4 -0
- data/.rspec +2 -0
- data/.rubocop.yml +1038 -0
- data/.ruby-version +1 -0
- data/CHANGELOG.md +43 -0
- data/Gemfile +1 -1
- data/LICENSE.txt +1 -1
- data/README.md +39 -1
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/exe/gemaker +9 -0
- data/gemaker.gemspec +19 -10
- data/lib/gemaker.rb +23 -1
- data/lib/gemaker/cli.rb +64 -0
- data/lib/gemaker/commands/add_changelog.rb +10 -0
- data/lib/gemaker/commands/add_cli_structure.rb +12 -0
- data/lib/gemaker/commands/add_hound_rules.rb +12 -0
- data/lib/gemaker/commands/add_install_generator.rb +16 -0
- data/lib/gemaker/commands/add_license.rb +11 -0
- data/lib/gemaker/commands/add_readme.rb +16 -0
- data/lib/gemaker/commands/add_ruby_version.rb +10 -0
- data/lib/gemaker/commands/base.rb +24 -0
- data/lib/gemaker/commands/configure_git.rb +24 -0
- data/lib/gemaker/commands/configure_test_env.rb +29 -0
- data/lib/gemaker/commands/configure_travis.rb +15 -0
- data/lib/gemaker/commands/create_gem.rb +45 -0
- data/lib/gemaker/commands/customize_engine.rb +13 -0
- data/lib/gemaker/commands/customize_gemspec.rb +20 -0
- data/lib/gemaker/commands/customize_main_lib_file.rb +10 -0
- data/lib/gemaker/commands/customize_rakefile.rb +20 -0
- data/lib/gemaker/config.rb +66 -0
- data/lib/gemaker/templates/CHANGELOG.md +7 -0
- data/lib/gemaker/templates/LICENSE.txt.erb +21 -0
- data/lib/gemaker/templates/cli.rb.erb +19 -0
- data/lib/gemaker/templates/coveralls.yml +1 -0
- data/lib/gemaker/templates/engine/Guardfile +15 -0
- data/lib/gemaker/templates/engine/README.md.erb +55 -0
- data/lib/gemaker/templates/engine/Rakefile +10 -0
- data/lib/gemaker/templates/engine/engine.rb.erb +15 -0
- data/lib/gemaker/templates/engine/example_class.rb.erb +7 -0
- data/lib/gemaker/templates/engine/gemspec.erb +30 -0
- data/lib/gemaker/templates/engine/gitignore +9 -0
- data/lib/gemaker/templates/engine/initializer.rb.erb +2 -0
- data/lib/gemaker/templates/engine/install_generator.rb.erb +21 -0
- data/lib/gemaker/templates/engine/install_usage.erb +5 -0
- data/lib/gemaker/templates/engine/lib_main_file.rb.erb +25 -0
- data/lib/gemaker/templates/engine/rails_helper.rb.erb +48 -0
- data/lib/gemaker/templates/engine/rspec +3 -0
- data/lib/gemaker/templates/engine/spec_helper.rb.erb +9 -0
- data/lib/gemaker/templates/engine/test_example.rb.erb +16 -0
- data/lib/gemaker/templates/engine/travis.yml.erb +15 -0
- data/lib/gemaker/templates/exe.erb +9 -0
- data/lib/gemaker/templates/image.png +0 -0
- data/lib/gemaker/templates/normal/Guardfile +5 -0
- data/lib/gemaker/templates/normal/README.md.erb +53 -0
- data/lib/gemaker/templates/normal/Rakefile +1 -0
- data/lib/gemaker/templates/normal/gemspec.erb +30 -0
- data/lib/gemaker/templates/normal/spec_helper.rb.erb +24 -0
- data/lib/gemaker/templates/normal/test_example.rb.erb +15 -0
- data/lib/gemaker/templates/normal/travis.yml.erb +13 -0
- data/lib/gemaker/templates/ruby-version.erb +1 -0
- data/lib/gemaker/templates/test_helpers.rb +5 -0
- data/lib/gemaker/templates/video.mp4 +0 -0
- data/lib/gemaker/util.rb +77 -0
- data/lib/gemaker/version.rb +3 -2
- metadata +214 -18
- data/CODE_OF_CONDUCT.md +0 -49
- data/Guardfile +0 -46
@@ -0,0 +1,15 @@
|
|
1
|
+
module Gemaker
|
2
|
+
module Cmd
|
3
|
+
class ConfigureTravis < Gemaker::Cmd::Base
|
4
|
+
def in_normal_context
|
5
|
+
copy_template("normal/travis.yml", ".travis.yml", config: @config)
|
6
|
+
info "Configure Tavis"
|
7
|
+
end
|
8
|
+
|
9
|
+
def in_engine_context
|
10
|
+
copy_template("engine/travis.yml", ".travis.yml", config: @config)
|
11
|
+
info "Configure Tavis"
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,45 @@
|
|
1
|
+
module Gemaker
|
2
|
+
module Cmd
|
3
|
+
class CreateGem < Gemaker::Cmd::Base
|
4
|
+
def in_engine_context
|
5
|
+
mountable_opt = "--mountable" if @config.mountable?
|
6
|
+
|
7
|
+
commands = [
|
8
|
+
"echo \"source 'https://rubygems.org'\" > GemakerGemfile",
|
9
|
+
"echo \"gem 'rails', '~> #{Gemaker::RAILS_VERSION}'\" > GemakerGemfile",
|
10
|
+
"BUNDLE_GEMFILE=GemakerGemfile bundle install",
|
11
|
+
"BUNDLE_GEMFILE=GemakerGemfile bundle exec rails plugin new #{@config.gem_name} -T #{mountable_opt} --dummy-path=spec/dummy", # rubocop:disable Metrics/LineLength
|
12
|
+
"rm -f GemakerGemfile GemakerGemfile.lock"
|
13
|
+
]
|
14
|
+
|
15
|
+
create_customized_gem(commands.join('; '))
|
16
|
+
end
|
17
|
+
|
18
|
+
def in_normal_context
|
19
|
+
create_customized_gem("bundle gem #{@config.gem_name}")
|
20
|
+
end
|
21
|
+
|
22
|
+
private
|
23
|
+
|
24
|
+
# rubocop:disable Metrics/MethodLength
|
25
|
+
def create_customized_gem(cmd)
|
26
|
+
execute(cmd)
|
27
|
+
Gemaker::Cmd::AddReadme.for(config: @config)
|
28
|
+
Gemaker::Cmd::AddChangelog.for(config: @config)
|
29
|
+
Gemaker::Cmd::CustomizeGemspec.for(config: @config)
|
30
|
+
Gemaker::Cmd::AddLicense.for(config: @config)
|
31
|
+
Gemaker::Cmd::AddCliStructure.for(config: @config)
|
32
|
+
Gemaker::Cmd::ConfigureTestEnv.for(config: @config)
|
33
|
+
Gemaker::Cmd::AddRubyVersion.for(config: @config)
|
34
|
+
Gemaker::Cmd::CustomizeEngine.for(config: @config)
|
35
|
+
Gemaker::Cmd::CustomizeRakefile.for(config: @config)
|
36
|
+
Gemaker::Cmd::CustomizeMainLibFile.for(config: @config)
|
37
|
+
Gemaker::Cmd::AddInstallGenerator.for(config: @config)
|
38
|
+
Gemaker::Cmd::AddHoundRules.for(config: @config)
|
39
|
+
Gemaker::Cmd::ConfigureTravis.for(config: @config)
|
40
|
+
Gemaker::Cmd::ConfigureGit.for(config: @config)
|
41
|
+
info("Done!")
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
module Gemaker
|
2
|
+
module Cmd
|
3
|
+
class CustomizeEngine < Gemaker::Cmd::Base
|
4
|
+
def in_engine_context
|
5
|
+
copy_template("engine/engine.rb",
|
6
|
+
"lib/#{@config.gem_name}/engine.rb", config: @config)
|
7
|
+
copy_template("engine/example_class.rb",
|
8
|
+
"lib/#{@config.gem_name}/example_class.rb", config: @config)
|
9
|
+
info "Customize engine.rb"
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
module Gemaker
|
2
|
+
module Cmd
|
3
|
+
class CustomizeGemspec < Gemaker::Cmd::Base
|
4
|
+
def in_normal_context
|
5
|
+
copy_gempsec("normal/gemspec")
|
6
|
+
end
|
7
|
+
|
8
|
+
def in_engine_context
|
9
|
+
copy_gempsec("engine/gemspec")
|
10
|
+
end
|
11
|
+
|
12
|
+
private
|
13
|
+
|
14
|
+
def copy_gempsec(template)
|
15
|
+
copy_template(template, "#{@config.gem_name}.gemspec", config: @config)
|
16
|
+
info "Customize #{@config.gem_name}.gemspec"
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,10 @@
|
|
1
|
+
module Gemaker
|
2
|
+
module Cmd
|
3
|
+
class CustomizeMainLibFile < Gemaker::Cmd::Base
|
4
|
+
def in_engine_context
|
5
|
+
copy_template("engine/lib_main_file.rb", "lib/#{@config.gem_name}.rb", config: @config)
|
6
|
+
info "Customize \"lib/#{@config.gem_name}.rb\""
|
7
|
+
end
|
8
|
+
end
|
9
|
+
end
|
10
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
module Gemaker
|
2
|
+
module Cmd
|
3
|
+
class CustomizeRakefile < Gemaker::Cmd::Base
|
4
|
+
def in_normal_context
|
5
|
+
customize_rakefile("normal/Rakefile")
|
6
|
+
end
|
7
|
+
|
8
|
+
def in_engine_context
|
9
|
+
customize_rakefile("engine/Rakefile")
|
10
|
+
end
|
11
|
+
|
12
|
+
private
|
13
|
+
|
14
|
+
def customize_rakefile(template)
|
15
|
+
copy_file(template, "Rakefile")
|
16
|
+
info "Customize Rakefile"
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,66 @@
|
|
1
|
+
module Gemaker
|
2
|
+
class Config
|
3
|
+
RUBY_VERSION = 2.3
|
4
|
+
|
5
|
+
attr_accessor :gem_name, :summary, :engine, :cli, :mountable, :installable
|
6
|
+
attr_reader :authors, :emails
|
7
|
+
attr_writer :human_gem_name, :description, :homepage
|
8
|
+
|
9
|
+
def initialize
|
10
|
+
self.engine = :normal
|
11
|
+
end
|
12
|
+
|
13
|
+
def human_gem_name
|
14
|
+
return gem_name.titleize if @human_gem_name.blank?
|
15
|
+
@human_gem_name
|
16
|
+
end
|
17
|
+
|
18
|
+
def gem_class
|
19
|
+
gem_name.classify
|
20
|
+
end
|
21
|
+
|
22
|
+
def description
|
23
|
+
return summary if @description.blank?
|
24
|
+
@description
|
25
|
+
end
|
26
|
+
|
27
|
+
def homepage
|
28
|
+
return "https://github.com/platanus/#{gem_name}/master" if @homepage.blank?
|
29
|
+
@homepage
|
30
|
+
end
|
31
|
+
|
32
|
+
def authors=(value)
|
33
|
+
@authors = ["Platanus"] + string_to_array(value)
|
34
|
+
end
|
35
|
+
|
36
|
+
def emails=(value)
|
37
|
+
@emails = ["rubygems@platan.us"] + string_to_array(value)
|
38
|
+
end
|
39
|
+
|
40
|
+
def engine?
|
41
|
+
!!engine
|
42
|
+
end
|
43
|
+
|
44
|
+
def cli?
|
45
|
+
!!cli
|
46
|
+
end
|
47
|
+
|
48
|
+
def mountable?
|
49
|
+
!!mountable
|
50
|
+
end
|
51
|
+
|
52
|
+
def installable?
|
53
|
+
!!installable
|
54
|
+
end
|
55
|
+
|
56
|
+
def ruby_version
|
57
|
+
RUBY_VERSION
|
58
|
+
end
|
59
|
+
|
60
|
+
private
|
61
|
+
|
62
|
+
def string_to_array(value)
|
63
|
+
value.split(",").map(&:strip).reject(&:blank?)
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright <%= Time.now.year %> Platanus
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
@@ -0,0 +1,19 @@
|
|
1
|
+
module <%= config.gem_class %>
|
2
|
+
class Cli
|
3
|
+
include Commander::Methods
|
4
|
+
|
5
|
+
def run
|
6
|
+
program :name, "<%= config.human_gem_name %>"
|
7
|
+
program :version, <%= config.gem_class %>::VERSION
|
8
|
+
program :description, "<%= config.description.blank? ? "TODO: add description" : config.description %>"
|
9
|
+
|
10
|
+
command("hello") do |c|
|
11
|
+
c.syntax = "<%= config.gem_name %> hello"
|
12
|
+
c.description = "Just a command example"
|
13
|
+
c.action { puts "Hello Platanus!" }
|
14
|
+
end
|
15
|
+
|
16
|
+
run!
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1 @@
|
|
1
|
+
service_name: travis-ci
|
@@ -0,0 +1,15 @@
|
|
1
|
+
guard :rspec, cmd: "bundle exec rspec" do
|
2
|
+
spec_dic = "spec/dummy/spec"
|
3
|
+
# RSpec files
|
4
|
+
watch("spec/spec_helper.rb") { spec_dic }
|
5
|
+
watch("spec/rails_helper.rb") { spec_dic }
|
6
|
+
watch(%r{^spec\/dummy\/spec\/support\/(.+)\.rb$}) { spec_dic }
|
7
|
+
watch(%r{^spec\/dummy\/spec\/.+_spec\.rb$})
|
8
|
+
# Engine files
|
9
|
+
watch(%r{^lib/(.+)\.rb$}) { |m| "spec/dummy/spec/lib/#{m[1]}_spec.rb" }
|
10
|
+
watch(%r{^app/(.+)\.rb$}) { |m| "spec/dummy/spec/#{m[1]}_spec.rb" }
|
11
|
+
watch(%r{^app/(.*)(\.erb)$}) { |m| "spec/dummy/spec/#{m[1]}#{m[2]}_spec.rb" }
|
12
|
+
# Dummy app files
|
13
|
+
watch(%r{^spec\/dummy\/app/(.+)\.rb$}) { |m| "spec/dummy/spec/#{m[1]}_spec.rb" }
|
14
|
+
watch(%r{^spec\/dummy\/app/(.*)(\.erb)$}) { |m| "spec/dummy/spec/#{m[1]}#{m[2]}_spec.rb" }
|
15
|
+
end
|
@@ -0,0 +1,55 @@
|
|
1
|
+
# <%= config.human_gem_name %>
|
2
|
+
|
3
|
+
<%= config.description.blank? ? "TODO" : config.description %>
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add to your Gemfile:
|
8
|
+
|
9
|
+
```ruby
|
10
|
+
gem "<%= config.gem_name %>"
|
11
|
+
```
|
12
|
+
|
13
|
+
```bash
|
14
|
+
bundle install
|
15
|
+
```
|
16
|
+
|
17
|
+
Then, run the installer:
|
18
|
+
|
19
|
+
```bash
|
20
|
+
rails generate <%= @config.gem_name %>:install
|
21
|
+
```
|
22
|
+
|
23
|
+
## Usage
|
24
|
+
|
25
|
+
TODO
|
26
|
+
|
27
|
+
## Testing
|
28
|
+
|
29
|
+
To run the specs you need to execute, **in the root path of the gem**, the following command:
|
30
|
+
|
31
|
+
```bash
|
32
|
+
bundle exec guard
|
33
|
+
```
|
34
|
+
|
35
|
+
You need to put **all your tests** in the `/<%= config.gem_name %>/spec/dummy/spec/` directory.
|
36
|
+
|
37
|
+
## Contributing
|
38
|
+
|
39
|
+
1. Fork it
|
40
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
41
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
42
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
43
|
+
5. Create new Pull Request
|
44
|
+
|
45
|
+
## Credits
|
46
|
+
|
47
|
+
Thank you [contributors](https://github.com/platanus/<%= config.gem_name %>/graphs/contributors)!
|
48
|
+
|
49
|
+
<img src="http://platan.us/gravatar_with_text.png" alt="Platanus" width="250"/>
|
50
|
+
|
51
|
+
<%= config.human_gem_name %> is maintained by [platanus](http://platan.us).
|
52
|
+
|
53
|
+
## License
|
54
|
+
|
55
|
+
<%= config.human_gem_name %> is © <%= Time.now.year %> platanus, spa. It is free software and may be redistributed under the terms specified in the LICENSE file.
|
@@ -0,0 +1,10 @@
|
|
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
|
+
APP_RAKEFILE = File.expand_path("../spec/dummy/Rakefile", __FILE__)
|
8
|
+
load "rails/tasks/engine.rake"
|
9
|
+
load "rails/tasks/statistics.rake"
|
10
|
+
Bundler::GemHelper.install_tasks
|
@@ -0,0 +1,15 @@
|
|
1
|
+
module <%= config.gem_class %>
|
2
|
+
class Engine < ::Rails::Engine
|
3
|
+
isolate_namespace <%= config.gem_class %>
|
4
|
+
|
5
|
+
config.generators do |g|
|
6
|
+
g.test_framework :rspec, fixture: false
|
7
|
+
g.fixture_replacement :factory_bot, dir: "spec/factories"
|
8
|
+
end
|
9
|
+
|
10
|
+
initializer "initialize" do
|
11
|
+
# Require here all your engine's classes.
|
12
|
+
require_relative "./example_class"
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
$:.push File.expand_path("../lib", __FILE__)
|
2
|
+
|
3
|
+
# Maintain your gem"s version:
|
4
|
+
require "<%= config.gem_name %>/version"
|
5
|
+
|
6
|
+
# Describe your gem and declare its dependencies:
|
7
|
+
Gem::Specification.new do |s|
|
8
|
+
s.name = "<%= config.gem_name %>"
|
9
|
+
s.version = <%= config.gem_class %>::VERSION
|
10
|
+
s.authors = <%= config.authors.to_s %>
|
11
|
+
s.email = <%= config.emails.to_s %>
|
12
|
+
s.homepage = "<%= config.homepage %>"
|
13
|
+
s.summary = "<%= config.summary %>"
|
14
|
+
s.description = "<%= config.description %>"
|
15
|
+
s.license = "MIT"
|
16
|
+
|
17
|
+
s.files = `git ls-files`.split($/).reject { |fn| fn.start_with? "spec" }
|
18
|
+
s.bindir = "exe"
|
19
|
+
s.executables = s.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
20
|
+
s.test_files = Dir["spec/**/*"]
|
21
|
+
|
22
|
+
s.add_dependency "rails", ">= 4.2.0"
|
23
|
+
s.add_development_dependency "pry"
|
24
|
+
s.add_development_dependency "pry-rails"
|
25
|
+
s.add_development_dependency "sqlite3"
|
26
|
+
s.add_development_dependency "rspec-rails"
|
27
|
+
s.add_development_dependency "guard-rspec"
|
28
|
+
s.add_development_dependency "factory_bot_rails"
|
29
|
+
s.add_development_dependency "coveralls"
|
30
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
class <%= config.gem_class %>::InstallGenerator < Rails::Generators::Base
|
2
|
+
source_root File.expand_path('../templates', __FILE__)
|
3
|
+
|
4
|
+
def create_initializer
|
5
|
+
template "initializer.rb", "config/initializers/<%= config.gem_name %>.rb"
|
6
|
+
end
|
7
|
+
|
8
|
+
<% if config.mountable? -%>
|
9
|
+
def mount_routes
|
10
|
+
line = "Rails.application.routes.draw do\n"
|
11
|
+
inject_into_file "config/routes.rb", after: line do <<-"HERE".gsub(/^ {4}/, '')
|
12
|
+
mount <%= config.gem_class %>::Engine => "/<%= config.gem_name %>"
|
13
|
+
HERE
|
14
|
+
end
|
15
|
+
end
|
16
|
+
<% end -%>
|
17
|
+
|
18
|
+
def copy_engine_migrations
|
19
|
+
rake "railties:install:migrations"
|
20
|
+
end
|
21
|
+
end
|