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.
Files changed (72) hide show
  1. checksums.yaml +5 -5
  2. data/.circleci/config.yml +103 -0
  3. data/.circleci/setup-rubygems.sh +3 -0
  4. data/.coveralls.yml +1 -0
  5. data/.hound.yml +4 -0
  6. data/.rspec +2 -0
  7. data/.rubocop.yml +1038 -0
  8. data/.ruby-version +1 -0
  9. data/CHANGELOG.md +43 -0
  10. data/Gemfile +1 -1
  11. data/LICENSE.txt +1 -1
  12. data/README.md +39 -1
  13. data/bin/console +14 -0
  14. data/bin/setup +8 -0
  15. data/exe/gemaker +9 -0
  16. data/gemaker.gemspec +19 -10
  17. data/lib/gemaker.rb +23 -1
  18. data/lib/gemaker/cli.rb +64 -0
  19. data/lib/gemaker/commands/add_changelog.rb +10 -0
  20. data/lib/gemaker/commands/add_cli_structure.rb +12 -0
  21. data/lib/gemaker/commands/add_hound_rules.rb +12 -0
  22. data/lib/gemaker/commands/add_install_generator.rb +16 -0
  23. data/lib/gemaker/commands/add_license.rb +11 -0
  24. data/lib/gemaker/commands/add_readme.rb +16 -0
  25. data/lib/gemaker/commands/add_ruby_version.rb +10 -0
  26. data/lib/gemaker/commands/base.rb +24 -0
  27. data/lib/gemaker/commands/configure_git.rb +24 -0
  28. data/lib/gemaker/commands/configure_test_env.rb +29 -0
  29. data/lib/gemaker/commands/configure_travis.rb +15 -0
  30. data/lib/gemaker/commands/create_gem.rb +45 -0
  31. data/lib/gemaker/commands/customize_engine.rb +13 -0
  32. data/lib/gemaker/commands/customize_gemspec.rb +20 -0
  33. data/lib/gemaker/commands/customize_main_lib_file.rb +10 -0
  34. data/lib/gemaker/commands/customize_rakefile.rb +20 -0
  35. data/lib/gemaker/config.rb +66 -0
  36. data/lib/gemaker/templates/CHANGELOG.md +7 -0
  37. data/lib/gemaker/templates/LICENSE.txt.erb +21 -0
  38. data/lib/gemaker/templates/cli.rb.erb +19 -0
  39. data/lib/gemaker/templates/coveralls.yml +1 -0
  40. data/lib/gemaker/templates/engine/Guardfile +15 -0
  41. data/lib/gemaker/templates/engine/README.md.erb +55 -0
  42. data/lib/gemaker/templates/engine/Rakefile +10 -0
  43. data/lib/gemaker/templates/engine/engine.rb.erb +15 -0
  44. data/lib/gemaker/templates/engine/example_class.rb.erb +7 -0
  45. data/lib/gemaker/templates/engine/gemspec.erb +30 -0
  46. data/lib/gemaker/templates/engine/gitignore +9 -0
  47. data/lib/gemaker/templates/engine/initializer.rb.erb +2 -0
  48. data/lib/gemaker/templates/engine/install_generator.rb.erb +21 -0
  49. data/lib/gemaker/templates/engine/install_usage.erb +5 -0
  50. data/lib/gemaker/templates/engine/lib_main_file.rb.erb +25 -0
  51. data/lib/gemaker/templates/engine/rails_helper.rb.erb +48 -0
  52. data/lib/gemaker/templates/engine/rspec +3 -0
  53. data/lib/gemaker/templates/engine/spec_helper.rb.erb +9 -0
  54. data/lib/gemaker/templates/engine/test_example.rb.erb +16 -0
  55. data/lib/gemaker/templates/engine/travis.yml.erb +15 -0
  56. data/lib/gemaker/templates/exe.erb +9 -0
  57. data/lib/gemaker/templates/image.png +0 -0
  58. data/lib/gemaker/templates/normal/Guardfile +5 -0
  59. data/lib/gemaker/templates/normal/README.md.erb +53 -0
  60. data/lib/gemaker/templates/normal/Rakefile +1 -0
  61. data/lib/gemaker/templates/normal/gemspec.erb +30 -0
  62. data/lib/gemaker/templates/normal/spec_helper.rb.erb +24 -0
  63. data/lib/gemaker/templates/normal/test_example.rb.erb +15 -0
  64. data/lib/gemaker/templates/normal/travis.yml.erb +13 -0
  65. data/lib/gemaker/templates/ruby-version.erb +1 -0
  66. data/lib/gemaker/templates/test_helpers.rb +5 -0
  67. data/lib/gemaker/templates/video.mp4 +0 -0
  68. data/lib/gemaker/util.rb +77 -0
  69. data/lib/gemaker/version.rb +3 -2
  70. metadata +214 -18
  71. data/CODE_OF_CONDUCT.md +0 -49
  72. data/Guardfile +0 -46
data/.ruby-version ADDED
@@ -0,0 +1 @@
1
+ 2.7
data/CHANGELOG.md ADDED
@@ -0,0 +1,43 @@
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
+ ### 0.6.0
6
+
7
+ ##### Changed
8
+
9
+ * Replace travis with circleci.
10
+
11
+ ### v0.5.0
12
+
13
+ ##### Added
14
+
15
+ * Replace factory_girl with factory_bot.
16
+ * Generate engines with Rails 5.
17
+
18
+ ### v0.4.0
19
+
20
+ ##### Added
21
+
22
+ * Add command to configure Travis CI.
23
+ * Change test command to configure coveralls.
24
+
25
+ ##### Fixed
26
+
27
+ * Run engine creation with specific Rails version to avoid unsupported Rails 5 structure.
28
+
29
+ ### v0.3.0
30
+
31
+ ##### Added
32
+
33
+ * Add Hound configuration.
34
+ * Deploy with Travis CI.
35
+ * Configure coveralls.
36
+
37
+ #### v0.2.0
38
+
39
+ * Command to add hound.yml and rubocop style rules.
40
+
41
+ #### v0.1.0
42
+
43
+ * Initial release.
data/Gemfile CHANGED
@@ -1,4 +1,4 @@
1
1
  source 'https://rubygems.org'
2
2
 
3
- # Specify your gem's dependencies in elastic.gemspec
3
+ # Specify your gem's dependencies in gemaker.gemspec
4
4
  gemspec
data/LICENSE.txt CHANGED
@@ -1,6 +1,6 @@
1
1
  The MIT License (MIT)
2
2
 
3
- Copyright (c) 2016 Ignacio Baixas
3
+ Copyright 2016 Platanus
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
data/README.md CHANGED
@@ -1,3 +1,41 @@
1
1
  # Gemaker
2
2
 
3
- Makes your gems come true
3
+ [![Gem Version](https://badge.fury.io/rb/gemaker.svg)](https://badge.fury.io/rb/gemaker)
4
+ [![CircleCI](https://circleci.com/gh/platanus/gemaker.svg?style=shield)](https://app.circleci.com/pipelines/github/platanus/gemaker)
5
+ [![Coverage Status](https://coveralls.io/repos/github/platanus/gemaker/badge.svg)](https://coveralls.io/github/platanus/gemaker)
6
+
7
+ Ruby CLI created to build Platanus' gems.
8
+
9
+ ## Installation
10
+
11
+ ```bash
12
+ $ gem install gemaker
13
+ ```
14
+
15
+ ## Usage
16
+
17
+ To build a new gem with all the configuration we use in Platanus, run the following command...
18
+
19
+ ```bash
20
+ gemaker new my_gem
21
+ ```
22
+
23
+ ## Contributing
24
+
25
+ 1. Fork it
26
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
27
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
28
+ 4. Push to the branch (`git push origin my-new-feature`)
29
+ 5. Create new Pull Request
30
+
31
+ ## Credits
32
+
33
+ Thank you [contributors](https://github.com/platanus/gemaker/graphs/contributors)!
34
+
35
+ <img src="http://platan.us/gravatar_with_text.png" alt="Platanus" width="250"/>
36
+
37
+ My Gem is maintained by [platanus](http://platan.us).
38
+
39
+ ## License
40
+
41
+ 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
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
data/exe/gemaker ADDED
@@ -0,0 +1,9 @@
1
+ #!/usr/bin/env ruby
2
+ lib = File.expand_path(File.dirname(__FILE__) + "/../lib")
3
+ $LOAD_PATH.unshift(lib) if File.directory?(lib) && !$LOAD_PATH.include?(lib)
4
+
5
+ require "commander"
6
+ require "gemaker"
7
+ require "gemaker/cli"
8
+
9
+ Gemaker::Cli.new.run
data/gemaker.gemspec CHANGED
@@ -6,19 +6,28 @@ require 'gemaker/version'
6
6
  Gem::Specification.new do |spec|
7
7
  spec.name = "gemaker"
8
8
  spec.version = Gemaker::VERSION
9
- spec.authors = ["The Gem Maker"]
10
- spec.email = ["maker@platan.us"]
9
+ spec.authors = ["Leandro Segovia"]
10
+ spec.email = ["ldlsegovia@gmail.com"]
11
11
 
12
- spec.summary = %q{gemaker is da booomb}
13
- spec.description = %q{gemaker is da booomb}
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
- spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
18
- spec.bindir = "exe"
19
- spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
16
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
17
+ spec.bindir = "exe"
18
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
20
19
  spec.require_paths = ["lib"]
21
20
 
22
- spec.add_development_dependency "bundler", "~> 1.6"
23
- spec.add_development_dependency "rake", "~> 10.4"
21
+ spec.add_dependency "power-types"
22
+ spec.add_dependency "commander"
23
+ spec.add_dependency "activesupport"
24
+ spec.add_dependency "colorize", "~> 0.7", ">= 0.7.7"
25
+ spec.add_dependency "artii", "~> 2.1", ">= 2.1.1"
26
+
27
+ spec.add_development_dependency "bundler", "~> 2.2.15"
28
+ spec.add_development_dependency "rake", "~> 10.0"
29
+ spec.add_development_dependency "rspec", "~> 3.0"
30
+ spec.add_development_dependency "rspec_junit_formatter"
31
+ spec.add_development_dependency "rubocop", "~> 0.65.0"
32
+ spec.add_development_dependency "coveralls"
24
33
  end
data/lib/gemaker.rb CHANGED
@@ -1,5 +1,27 @@
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"
24
+ require "gemaker/commands/configure_travis"
2
25
 
3
26
  module Gemaker
4
- # Kaboom
5
27
  end
@@ -0,0 +1,64 @@
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
+ )
39
+ config.summary = ask("Enter gem's summary: ")
40
+ config.description = ask("Enter gem's description: ")
41
+ config.homepage = ask(
42
+ "Enter gem's homepage. e.g. https://github.com/platanus/#{config.gem_name}: "
43
+ )
44
+ config.authors = ask("Enter gem's authors. e.g. Sherlock Holmes,James Moriarty: ")
45
+ config.emails = ask(
46
+ "Enter the authors' emails. e.g. sherlock@platan.us,james@platan.us: "
47
+ )
48
+ config.engine = agree("Is the gem a Rails engine?")
49
+
50
+ if config.engine?
51
+ config.mountable = agree("Is the engine mountable?")
52
+ config.installable = agree("Need an installer?")
53
+ else
54
+ config.cli = agree("Is it a CLI (Command-line interface)?")
55
+ end
56
+ end
57
+ # rubocop:enable Metrics/MethodLength
58
+
59
+ def draw_artii(text)
60
+ a = Artii::Base.new font: 'slant'
61
+ puts a.asciify(text).yellow
62
+ end
63
+ end
64
+ end
@@ -0,0 +1,10 @@
1
+ module Gemaker
2
+ module Cmd
3
+ class AddChangelog < Gemaker::Cmd::Base
4
+ def perform
5
+ copy_file("CHANGELOG.md", "CHANGELOG.md")
6
+ info "Create CHANGELOG.md"
7
+ end
8
+ end
9
+ end
10
+ 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,12 @@
1
+ module Gemaker
2
+ module Cmd
3
+ class AddHoundRules < Gemaker::Cmd::Base
4
+ def perform
5
+ execute_in_gem(
6
+ "hound rules update ruby --local",
7
+ "Missing tool. Please run `gem install hound-cli`."
8
+ )
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,11 @@
1
+ module Gemaker
2
+ module Cmd
3
+ class AddLicense < Gemaker::Cmd::Base
4
+ def perform
5
+ copy_template("LICENSE.txt", "LICENSE.txt")
6
+ remove_in_gem("MIT-LICENSE") if @config.engine?
7
+ info "Add LICENSE.txt"
8
+ end
9
+ end
10
+ end
11
+ 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,10 @@
1
+ module Gemaker
2
+ module Cmd
3
+ class AddRubyVersion < Gemaker::Cmd::Base
4
+ def perform
5
+ copy_template("ruby-version", ".ruby-version", config: @config)
6
+ info "Add .ruby-version file"
7
+ end
8
+ end
9
+ end
10
+ 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,24 @@
1
+ module Gemaker
2
+ module Cmd
3
+ class ConfigureGit < Gemaker::Cmd::Base
4
+ def in_normal_context
5
+ remove_in_gem(".git")
6
+ do_initial_commit
7
+ end
8
+
9
+ def in_engine_context
10
+ copy_file("engine/gitignore", ".gitignore")
11
+ do_initial_commit
12
+ end
13
+
14
+ private
15
+
16
+ def do_initial_commit
17
+ execute_in_gem("git init")
18
+ execute_in_gem("bundle install")
19
+ execute_in_gem("git add .")
20
+ execute_in_gem("git commit -m 'Initial commit'")
21
+ end
22
+ end
23
+ end
24
+ end
@@ -0,0 +1,29 @@
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_file("coveralls.yml", ".coveralls.yml")
8
+ copy_template("normal/test_example.rb", "spec/#{@config.gem_name}_spec.rb", config: @config)
9
+ copy_file("normal/Guardfile", "Guardfile")
10
+ info "Configure Rspec"
11
+ end
12
+
13
+ def in_engine_context
14
+ copy_template("engine/spec_helper.rb", "spec/spec_helper.rb", config: @config)
15
+ copy_template("engine/rails_helper.rb", "spec/rails_helper.rb", config: @config)
16
+ copy_template("engine/test_example.rb",
17
+ "spec/dummy/spec/#{@config.gem_name}_spec.rb", config: @config)
18
+ create_dir("spec/dummy/spec/factories")
19
+ copy_file("test_helpers.rb", "spec/dummy/spec/support/test_helpers.rb")
20
+ copy_file("coveralls.yml", ".coveralls.yml")
21
+ copy_file("image.png", "spec/dummy/spec/assets/image.png")
22
+ copy_file("video.mp4", "spec/dummy/spec/assets/video.mp4")
23
+ copy_file("engine/rspec", ".rspec")
24
+ copy_file("engine/Guardfile", "Guardfile")
25
+ info "Configure Rspec"
26
+ end
27
+ end
28
+ end
29
+ end