gemaker 0.1.3 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rspec +2 -0
- data/.ruby-version +1 -0
- data/.travis.yml +13 -0
- data/CHANGELOG.md +11 -0
- data/Gemfile +1 -1
- data/LICENSE.txt +1 -1
- data/README.md +35 -1
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/exe/gemaker +9 -0
- data/gemaker.gemspec +23 -10
- data/lib/gemaker.rb +22 -1
- data/lib/gemaker/cli.rb +61 -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 +13 -0
- data/lib/gemaker/commands/configure_test_env.rb +27 -0
- data/lib/gemaker/commands/create_gem.rb +36 -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/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 +29 -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 +28 -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/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 +29 -0
- data/lib/gemaker/templates/normal/spec_helper.rb.erb +13 -0
- data/lib/gemaker/templates/normal/test_example.rb.erb +15 -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 +2 -2
- metadata +183 -18
- data/CODE_OF_CONDUCT.md +0 -49
- data/Guardfile +0 -46
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6cc6cc439336cb550c83e7bd327390c31a7b9988
|
4
|
+
data.tar.gz: 06da8061c2a0f87857b0ef1a0b8ef26538227556
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d08e3ac63ab745298312ec32e08dab6d45b294834ebce6f727b9e2348258f9d6bffd4969473a7a412db47e4db79267833c07d51908393c0f9c27567145595511
|
7
|
+
data.tar.gz: 49c8da9d2214bb6a79dea22022947364678b96cfc3ce0887191962979aa4b2e316b5a09232e3d59b4d50ecb5b81426371c44316ada0e8d08fe8d30c2c83f2dbc
|
data/.rspec
ADDED
data/.ruby-version
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
2.3
|
data/.travis.yml
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
sudo: false
|
2
|
+
language: ruby
|
3
|
+
rvm:
|
4
|
+
- 2.3.1
|
5
|
+
before_install: gem install bundler -v 1.12.5
|
6
|
+
deploy:
|
7
|
+
provider: rubygems
|
8
|
+
api_key:
|
9
|
+
secure: Ro/gJ2W3xBfeaqQPhZY4uud7VIDlJrDqtpaweHLlTgCxBBhNhZGD0VO65cL3Ay+nHvyhojuLrn/GFYRm0kAmqK95i5B0xERsakp5BQ51Wv+mcxv7ki9t3wiY0JOmmNUdXAChMgnpehGXqDnCfQ8RXauKmuCHO5z2+cR+ZcrkKDzJiSOlvksoFDtDcqiQ9XBRO8glVlg91gyRVFCJOYBgVPx3a+cdK9Ym3Mc0/cn1HUAOsSHG8+GeP4Njp6P8oOVQZu/3OLChYk7nkW9oqyKV8PX02cdd+3RCAilgSZQ18v0N/+FrXnOeudZcuNKlWhkg+Aw71WQv2fHvjgH2pD8gX2K13Yxkw3/C5BLoMrW1EbZjfgYC7nKEQYsBjjIjpeMsB8lNrEIQUiIN6Oz+lxzs/TVXOmHvMNd7TsrY2WS0JhuIsjtLmsotJrqzWp+VOblXoJ0i5ItkYo2mYiRMmpLp1fH10TG1c/W2X9ocwBhhYiLrqLLhyqzR1mYMWlSR0bETfRqBLcIzzzZtmi9vPjftXPHdWCdElssA9oRvc21zNuFQ5fxk0huXsJdlNlvxo+90dquN2o/l884WBoPfuyHTVlnnwVtWRhRSvI6ArlUijO/PbZROi6bK0fLockDix493e6u/nnSjx32WM7vWv4P7eNlhdItasNtN07H1MuT3KvA=
|
10
|
+
gem: gemaker
|
11
|
+
on:
|
12
|
+
tags: true
|
13
|
+
repo: platanus/gemaker
|
data/CHANGELOG.md
ADDED
@@ -0,0 +1,11 @@
|
|
1
|
+
# Change Log
|
2
|
+
All notable changes to this project will be documented in this file.
|
3
|
+
This project adheres to [Semantic Versioning](http://semver.org/).
|
4
|
+
|
5
|
+
#### v0.2.0
|
6
|
+
|
7
|
+
* Command to add hound.yml and rubocop style rules.
|
8
|
+
|
9
|
+
#### v0.1.0
|
10
|
+
|
11
|
+
* Initial release.
|
data/Gemfile
CHANGED
data/LICENSE.txt
CHANGED
data/README.md
CHANGED
@@ -1,3 +1,37 @@
|
|
1
1
|
# Gemaker
|
2
2
|
|
3
|
-
|
3
|
+
Ruby CLI created to build Platanus' gems.
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
```bash
|
8
|
+
$ gem install gemaker
|
9
|
+
```
|
10
|
+
|
11
|
+
## Usage
|
12
|
+
|
13
|
+
To build a new gem with all the configuration we use in Platanus, run the following command...
|
14
|
+
|
15
|
+
```bash
|
16
|
+
gemaker new my_gem
|
17
|
+
```
|
18
|
+
|
19
|
+
## Contributing
|
20
|
+
|
21
|
+
1. Fork it
|
22
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
23
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
24
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
25
|
+
5. Create new Pull Request
|
26
|
+
|
27
|
+
## Credits
|
28
|
+
|
29
|
+
Thank you [contributors](https://github.com/platanus/gemaker/graphs/contributors)!
|
30
|
+
|
31
|
+
<img src="http://platan.us/gravatar_with_text.png" alt="Platanus" width="250"/>
|
32
|
+
|
33
|
+
My Gem is maintained by [platanus](http://platan.us).
|
34
|
+
|
35
|
+
## License
|
36
|
+
|
37
|
+
Gemaker is © 2016 platanus, spa. It is free software and may be redistributed under the terms specified in the LICENSE file.
|
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "gemaker"
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
# require "pry"
|
11
|
+
# Pry.start
|
12
|
+
|
13
|
+
require "irb"
|
14
|
+
IRB.start
|
data/bin/setup
ADDED
data/exe/gemaker
ADDED
data/gemaker.gemspec
CHANGED
@@ -6,19 +6,32 @@ require 'gemaker/version'
|
|
6
6
|
Gem::Specification.new do |spec|
|
7
7
|
spec.name = "gemaker"
|
8
8
|
spec.version = Gemaker::VERSION
|
9
|
-
spec.authors = ["
|
10
|
-
spec.email = ["
|
9
|
+
spec.authors = ["Leandro Segovia"]
|
10
|
+
spec.email = ["ldlsegovia@gmail.com"]
|
11
11
|
|
12
|
-
spec.summary =
|
13
|
-
spec.description =
|
12
|
+
spec.summary = "Gem to build gems"
|
13
|
+
spec.description = "Ruby CLI created to build Platanus' gems"
|
14
14
|
spec.homepage = "https://github.com/platanus/gemaker"
|
15
|
-
spec.license = "MIT"
|
16
15
|
|
17
|
-
|
18
|
-
|
19
|
-
|
16
|
+
# Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
|
17
|
+
# to allow pushing to a single host or delete this section to allow pushing to any host.
|
18
|
+
if spec.respond_to?(:metadata)
|
19
|
+
spec.metadata['allowed_push_host'] = "TODO: Set to 'http://mygemserver.com'"
|
20
|
+
else
|
21
|
+
raise "RubyGems 2.0 or newer is required to protect against public gem pushes."
|
22
|
+
end
|
23
|
+
|
24
|
+
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
25
|
+
spec.bindir = "exe"
|
26
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
20
27
|
spec.require_paths = ["lib"]
|
21
28
|
|
22
|
-
spec.
|
23
|
-
spec.
|
29
|
+
spec.add_dependency "power-types", "~> 0.1", ">= 0.1.0"
|
30
|
+
spec.add_dependency "commander", "~> 4.4", ">= 4.4.0"
|
31
|
+
spec.add_dependency "activesupport", "~> 4.2", ">= 4.2.6"
|
32
|
+
spec.add_dependency "colorize", "~> 0.7", ">= 0.7.7"
|
33
|
+
spec.add_dependency "artii", "~> 2.1", ">= 2.1.1"
|
34
|
+
spec.add_development_dependency "bundler", "~> 1.12"
|
35
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
36
|
+
spec.add_development_dependency "rspec", "~> 3.0"
|
24
37
|
end
|
data/lib/gemaker.rb
CHANGED
@@ -1,5 +1,26 @@
|
|
1
|
+
require "power-types"
|
2
|
+
require "active_support/all"
|
3
|
+
require "colorize"
|
4
|
+
require "artii"
|
5
|
+
|
1
6
|
require "gemaker/version"
|
7
|
+
require "gemaker/util"
|
8
|
+
require "gemaker/config"
|
9
|
+
require "gemaker/commands/base"
|
10
|
+
require "gemaker/commands/create_gem"
|
11
|
+
require "gemaker/commands/add_readme"
|
12
|
+
require "gemaker/commands/add_changelog"
|
13
|
+
require "gemaker/commands/customize_gemspec"
|
14
|
+
require "gemaker/commands/add_license"
|
15
|
+
require "gemaker/commands/add_cli_structure"
|
16
|
+
require "gemaker/commands/configure_git"
|
17
|
+
require "gemaker/commands/configure_test_env"
|
18
|
+
require "gemaker/commands/add_ruby_version"
|
19
|
+
require "gemaker/commands/customize_engine"
|
20
|
+
require "gemaker/commands/customize_rakefile"
|
21
|
+
require "gemaker/commands/customize_main_lib_file"
|
22
|
+
require "gemaker/commands/add_install_generator"
|
23
|
+
require "gemaker/commands/add_hound_rules"
|
2
24
|
|
3
25
|
module Gemaker
|
4
|
-
# Kaboom
|
5
26
|
end
|
data/lib/gemaker/cli.rb
ADDED
@@ -0,0 +1,61 @@
|
|
1
|
+
module Gemaker
|
2
|
+
class Cli
|
3
|
+
include Commander::Methods
|
4
|
+
|
5
|
+
def run
|
6
|
+
config = Gemaker::Config.new
|
7
|
+
program :name, "Gemaker"
|
8
|
+
program :version, Gemaker::VERSION
|
9
|
+
program :description, "CLI to generate Platanus gems"
|
10
|
+
define_new_cmd(config)
|
11
|
+
run!
|
12
|
+
end
|
13
|
+
|
14
|
+
private
|
15
|
+
|
16
|
+
def define_new_cmd(config)
|
17
|
+
command("new") do |c|
|
18
|
+
c.syntax = "gemaker new"
|
19
|
+
c.description = "Create a new gem with Platanus configuration"
|
20
|
+
c.action do |args|
|
21
|
+
draw_artii("Platanus")
|
22
|
+
fill_config(args.first, config)
|
23
|
+
Gemaker::Cmd::CreateGem.for(config: config)
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
# rubocop:disable Metrics/MethodLength
|
29
|
+
def fill_config(gem_name, config)
|
30
|
+
config.gem_name = gem_name
|
31
|
+
|
32
|
+
if config.gem_name.blank?
|
33
|
+
config.gem_name = ask("Gem name it's mandatory. Please, enter name...")
|
34
|
+
end
|
35
|
+
|
36
|
+
config.human_gem_name = ask(
|
37
|
+
"Enter the human readable version of the name. e.g. \"#{config.human_gem_name}\":")
|
38
|
+
config.summary = ask("Enter gem's summary: ")
|
39
|
+
config.description = ask("Enter gem's description: ")
|
40
|
+
config.homepage = ask(
|
41
|
+
"Enter gem's homepage. e.g. https://github.com/platanus/#{config.gem_name}: ")
|
42
|
+
config.authors = ask("Enter gem's authors. e.g. Sherlock Holmes,James Moriarty: ")
|
43
|
+
config.emails = ask(
|
44
|
+
"Enter the authors' emails. e.g. sherlock@platan.us,james@platan.us: ")
|
45
|
+
config.engine = agree("Is the gem a Rails engine?")
|
46
|
+
|
47
|
+
if config.engine?
|
48
|
+
config.mountable = agree("Is the engine mountable?")
|
49
|
+
config.installable = agree("Need an installer?")
|
50
|
+
else
|
51
|
+
config.cli = agree("Is it a CLI (Command-line interface)?")
|
52
|
+
end
|
53
|
+
end
|
54
|
+
# rubocop:enable Metrics/MethodLength
|
55
|
+
|
56
|
+
def draw_artii(text)
|
57
|
+
a = Artii::Base.new font: 'slant'
|
58
|
+
puts a.asciify(text).yellow
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
module Gemaker
|
2
|
+
module Cmd
|
3
|
+
class AddCliStructure < Gemaker::Cmd::Base
|
4
|
+
def perform
|
5
|
+
return unless @config.cli?
|
6
|
+
copy_template("exe", "exe/#{@config.gem_name}", config: @config)
|
7
|
+
copy_template("cli.rb", "lib/#{@config.gem_name}/cli.rb", config: @config)
|
8
|
+
info "Add CLI structure"
|
9
|
+
end
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
module Gemaker
|
2
|
+
module Cmd
|
3
|
+
class AddInstallGenerator < Gemaker::Cmd::Base
|
4
|
+
def in_engine_context
|
5
|
+
return unless @config.installable?
|
6
|
+
copy_template("engine/initializer.rb",
|
7
|
+
"lib/generators/#{@config.gem_name}/install/templates/initializer.rb", config: @config)
|
8
|
+
copy_template("engine/install_generator.rb",
|
9
|
+
"lib/generators/#{@config.gem_name}/install/install_generator.rb", config: @config)
|
10
|
+
copy_template("engine/install_usage",
|
11
|
+
"lib/generators/#{@config.gem_name}/install/USAGE", config: @config)
|
12
|
+
info "Add Installer"
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
module Gemaker
|
2
|
+
module Cmd
|
3
|
+
class AddReadme < Gemaker::Cmd::Base
|
4
|
+
def in_normal_context
|
5
|
+
copy_template("normal/README.md", "README.md", config: @config)
|
6
|
+
info "Replace README.md"
|
7
|
+
end
|
8
|
+
|
9
|
+
def in_engine_context
|
10
|
+
remove_in_gem("README.rdoc")
|
11
|
+
copy_template("engine/README.md", "README.md", config: @config)
|
12
|
+
info "Replace README.md"
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
module Gemaker
|
2
|
+
module Cmd
|
3
|
+
class Base < PowerTypes::Command.new(:config)
|
4
|
+
include Gemaker::Util
|
5
|
+
|
6
|
+
def perform
|
7
|
+
if @config.engine?
|
8
|
+
in_engine_context
|
9
|
+
return
|
10
|
+
end
|
11
|
+
|
12
|
+
in_normal_context
|
13
|
+
end
|
14
|
+
|
15
|
+
def in_engine_context
|
16
|
+
# Override on child classes
|
17
|
+
end
|
18
|
+
|
19
|
+
def in_normal_context
|
20
|
+
# Override on child classes
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
module Gemaker
|
2
|
+
module Cmd
|
3
|
+
class ConfigureGit < Gemaker::Cmd::Base
|
4
|
+
def perform
|
5
|
+
remove_in_gem(".git") unless @config.engine?
|
6
|
+
execute_in_gem("git init")
|
7
|
+
execute_in_gem("bundle install")
|
8
|
+
execute_in_gem("git add .")
|
9
|
+
execute_in_gem("git commit -m 'Initial commit'")
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
module Gemaker
|
2
|
+
module Cmd
|
3
|
+
class ConfigureTestEnv < Gemaker::Cmd::Base
|
4
|
+
def in_normal_context
|
5
|
+
copy_template("normal/spec_helper.rb", "spec/spec_helper.rb", config: @config)
|
6
|
+
copy_file("test_helpers.rb", "spec/support/test_helpers.rb")
|
7
|
+
copy_template("normal/test_example.rb", "spec/#{@config.gem_name}_spec.rb", config: @config)
|
8
|
+
copy_file("normal/Guardfile", "Guardfile")
|
9
|
+
info "Configure Rspec"
|
10
|
+
end
|
11
|
+
|
12
|
+
def in_engine_context
|
13
|
+
copy_template("engine/spec_helper.rb", "spec/spec_helper.rb", config: @config)
|
14
|
+
copy_template("engine/rails_helper.rb", "spec/rails_helper.rb", config: @config)
|
15
|
+
copy_template("engine/test_example.rb",
|
16
|
+
"spec/dummy/spec/#{@config.gem_name}_spec.rb", config: @config)
|
17
|
+
create_dir("spec/dummy/spec/factories")
|
18
|
+
copy_file("test_helpers.rb", "spec/dummy/spec/support/test_helpers.rb")
|
19
|
+
copy_file("image.png", "spec/dummy/spec/assets/image.png")
|
20
|
+
copy_file("video.mp4", "spec/dummy/spec/assets/video.mp4")
|
21
|
+
copy_file("engine/rspec", ".rspec")
|
22
|
+
copy_file("engine/Guardfile", "Guardfile")
|
23
|
+
info "Configure Rspec"
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,36 @@
|
|
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
|
+
create_customized_gem(
|
7
|
+
"rails plugin new #{@config.gem_name} -T #{mountable_opt} --dummy-path=spec/dummy"
|
8
|
+
)
|
9
|
+
end
|
10
|
+
|
11
|
+
def in_normal_context
|
12
|
+
create_customized_gem("bundle gem #{@config.gem_name}")
|
13
|
+
end
|
14
|
+
|
15
|
+
private
|
16
|
+
|
17
|
+
def create_customized_gem(cmd)
|
18
|
+
execute(cmd)
|
19
|
+
Gemaker::Cmd::AddReadme.for(config: @config)
|
20
|
+
Gemaker::Cmd::AddChangelog.for(config: @config)
|
21
|
+
Gemaker::Cmd::CustomizeGemspec.for(config: @config)
|
22
|
+
Gemaker::Cmd::AddLicense.for(config: @config)
|
23
|
+
Gemaker::Cmd::AddCliStructure.for(config: @config)
|
24
|
+
Gemaker::Cmd::ConfigureTestEnv.for(config: @config)
|
25
|
+
Gemaker::Cmd::AddRubyVersion.for(config: @config)
|
26
|
+
Gemaker::Cmd::CustomizeEngine.for(config: @config)
|
27
|
+
Gemaker::Cmd::CustomizeRakefile.for(config: @config)
|
28
|
+
Gemaker::Cmd::CustomizeMainLibFile.for(config: @config)
|
29
|
+
Gemaker::Cmd::AddInstallGenerator.for(config: @config)
|
30
|
+
Gemaker::Cmd::AddHoundRules.for(config: @config)
|
31
|
+
Gemaker::Cmd::ConfigureGit.for(config: @config)
|
32
|
+
info("Done!")
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|