rubysmith 0.1.1 → 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 (32) hide show
  1. checksums.yaml +4 -4
  2. checksums.yaml.gz.sig +0 -0
  3. data.tar.gz.sig +0 -0
  4. data/README.adoc +86 -36
  5. data/lib/rubysmith.rb +2 -1
  6. data/lib/rubysmith/builders/bundler.rb +6 -2
  7. data/lib/rubysmith/builders/core.rb +0 -2
  8. data/lib/rubysmith/builders/documentation.rb +4 -2
  9. data/lib/rubysmith/builders/rake.rb +2 -2
  10. data/lib/rubysmith/builders/rspec/context.rb +4 -3
  11. data/lib/rubysmith/builders/rspec/helper.rb +1 -2
  12. data/lib/rubysmith/builders/rubocop/formatter.rb +33 -0
  13. data/lib/rubysmith/builders/rubocop/setup.rb +33 -0
  14. data/lib/rubysmith/cli/defaults.yml +4 -0
  15. data/lib/rubysmith/cli/parsers/build.rb +26 -1
  16. data/lib/rubysmith/cli/parsers/core.rb +6 -2
  17. data/lib/rubysmith/cli/processors/build.rb +33 -20
  18. data/lib/rubysmith/cli/shell.rb +9 -7
  19. data/lib/rubysmith/identity.rb +1 -1
  20. data/lib/rubysmith/realm.rb +4 -0
  21. data/lib/rubysmith/templates/%project_name%/Gemfile.erb +53 -30
  22. data/lib/rubysmith/templates/%project_name%/README.adoc.erb +8 -3
  23. data/lib/rubysmith/templates/%project_name%/README.md.erb +7 -3
  24. data/lib/rubysmith/templates/%project_name%/Rakefile.erb +9 -1
  25. data/lib/rubysmith/templates/%project_name%/bin/console.erb +3 -5
  26. data/lib/rubysmith/templates/%project_name%/lib/%project_name%.rb.erb +0 -1
  27. data/lib/rubysmith/templates/%project_name%/spec/spec_helper.rb.erb +11 -5
  28. data/lib/rubysmith/templates/%project_name%/spec/support/shared_contexts/temp_dir.rb.erb +5 -3
  29. metadata +12 -194
  30. metadata.gz.sig +0 -0
  31. data/lib/rubysmith/builders/rubocop.rb +0 -43
  32. data/lib/rubysmith/templates/%project_name%/lib/%project_name%/identity.rb.erb +0 -8
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 380101c84537fa203d854153516c427b08b601d2e74c6e368a0efc04d614dc27
4
- data.tar.gz: 45e762503cd4fab3363c770db57cb90817af1bb60016c127ec846e2470fe6cca
3
+ metadata.gz: f85dc46b117c0698caa1f0904db283ea628813000bf452172917ff287696e51e
4
+ data.tar.gz: 98e68d55fcbcc04f1cd01366ecd7891ca2692f627df94d7d1c6ee03f0189475f
5
5
  SHA512:
6
- metadata.gz: 4a9909ac824ad0aa4a7ca4a8a161d1e32e6f49121cccc2f25f03fd3ca5ec79381818d72a9c65730bdeca971b70299cefc79b5b07c2c3b50289eebdf46cf112bb
7
- data.tar.gz: 28ae633b10861b7d94b401580829ca9af4b0f60927e34734bc48699b22dddbcd5603768d6f8f8bab617a29519105a92602454e0a850fa52a898c79d991d45342
6
+ metadata.gz: 122ca78a91a27293ab325bce3e8064f0c4be2d99d0f4b755bd5be309f2283fb421f872d0247ec7d4cde3f3d0d3c139b44e368584b20575ea45a16463e39d0651
7
+ data.tar.gz: e6af238bccd4ae8ca0cd19939be559bd11f0138d61f47fca0b71dcbeb1534550d0ac00cf5c05f2dad999a058fa0cbd9ae5addd8e3e97e7e3f5ee6b7847494698
Binary file
data.tar.gz.sig CHANGED
Binary file
@@ -6,12 +6,17 @@
6
6
 
7
7
  [link=http://badge.fury.io/rb/rubysmith]
8
8
  image::https://badge.fury.io/rb/rubysmith.svg[Gem Version]
9
+ [link=https://www.alchemists.io/projects/code_quality]
10
+ image::https://img.shields.io/badge/code_style-alchemists-brightgreen.svg[Alchemists Style Guide]
9
11
  [link=https://circleci.com/gh/bkuhlmann/rubysmith]
10
12
  image::https://circleci.com/gh/bkuhlmann/rubysmith.svg?style=svg[Circle CI Status]
11
13
 
12
- A command line interface for smithing Ruby projects. Handy for situations in which you need
13
- something more sophisticated than a Bundler Inline script but less complicated than a Ruby Gem as
14
- provided by link:https://www.alchemists.io/projects/gemsmith[Gemsmith].
14
+ Rubysmith is a command line interface for smithing Ruby projects.
15
+
16
+ This gem is useful in situations in which you need something more sophisticated than a
17
+ link:https://bundler.io/guides/bundler_in_a_single_file_ruby_script.html[Bundler Inline] script but
18
+ less complicated than a Ruby Gem as provided by
19
+ link:https://www.alchemists.io/projects/gemsmith[Gemsmith].
15
20
 
16
21
  toc::[]
17
22
 
@@ -21,14 +26,19 @@ toc::[]
21
26
  * Uses link:https://www.alchemists.io/projects/refinements[Refinements] Ruby core library enhancements.
22
27
  * Uses link:https://www.alchemists.io/projects/runcom[Runcom] for resource configuration management.
23
28
  * Uses link:https://www.alchemists.io/projects/pragmater[Pragmater] for Ruby source pragma directives.
29
+ * Supports link:https://github.com/amazing-print/amazing_print[Amazing Print].
24
30
  * Supports link:https://github.com/rubysec/bundler-audit[Bundler Audit].
31
+ * Supports link:https://github.com/rubymem/bundler-leak[Bundler Leak].
25
32
  * Supports link:https://git-scm.com[Git].
26
33
  * Supports link:https://www.alchemists.io/projects/git-lint[Git Lint].
27
34
  * Supports link:https://github.com/guard/guard[Guard].
28
35
  * Supports link:http://pryrepl.org[Pry].
29
36
  * Supports link:https://github.com/troessner/reek[Reek].
37
+ * Supports link:https://www.alchemists.io/projects/refinements[Refinements].
30
38
  * Supports link:https://rspec.info[RSpec].
31
39
  * Supports link:https://github.com/rubocop-hq/rubocop[Rubocop].
40
+ * Supports link:https://docs.rubocop.org/rubocop-performance[Rubocop Performance].
41
+ * Supports link:https://github.com/rubocop-hq/rubocop-rake[Rubocop Rake].
32
42
  * Supports link:https://github.com/rubocop-hq/rubocop-rspec[Rubocop RSpec].
33
43
  * Supports link:https://github.com/simplecov-ruby/simplecov[SimpleCov].
34
44
  * Supports common settings and a structured layout for building projects.
@@ -53,8 +63,6 @@ toc::[]
53
63
 
54
64
  == Setup
55
65
 
56
- === Production
57
-
58
66
  To install, run:
59
67
 
60
68
  [source,bash]
@@ -62,51 +70,71 @@ To install, run:
62
70
  gem install rubysmith
63
71
  ----
64
72
 
65
- === Development
73
+ == Usage
66
74
 
67
- To contribute, run:
75
+ === Command Line Interface (CLI)
76
+
77
+ From the command line, type: `rubysmith --help`
78
+
79
+ ....
80
+ USAGE:
81
+ -b, --build NAME [options] Build new project.
82
+ -v, --version Show gem version.
83
+ -h, --help Show this message.
84
+ -c, --config ACTION Manage gem configuration: edit or view.
85
+
86
+ BUILD OPTIONS:
87
+ --[no-]amazing_print Add Amazing Print.
88
+ --[no-]bundler-audit Add Bundler Audit.
89
+ --[no-]bundler-leak Add Bundler Leak.
90
+ --[no-]console Add console script.
91
+ --[no-]documentation Add documentation.
92
+ --[no-]git Add Git.
93
+ --[no-]git-lint Add Git Lint.
94
+ --[no-]guard Add Guard.
95
+ --[no-]pry Add Pry.
96
+ --[no-]reek Add Reek.
97
+ --[no-]refinements Add Refinements.
98
+ --[no-]rspec Add RSpec.
99
+ --[no-]rubocop Add Rubocop.
100
+ --[no-]setup Add setup script.
101
+ --[no-]simple_cov Add SimpleCov
102
+ --min Use minimum/no options.
103
+ ....
104
+
105
+ === Building
106
+
107
+ The core functionality of this gem centers around the `--build` command with optional customization
108
+ provided via build options. By default, all build options are enabled. Example:
68
109
 
69
110
  [source,bash]
70
111
  ----
71
- git clone https://github.com/bkuhlmann/rubysmith.git
72
- cd rubysmith
73
- bin/setup
112
+ rubysmith --build demo
74
113
  ----
75
114
 
76
- You can also use the IRB console for direct access to all objects:
115
+ Running the above will generate a new `demo` Ruby project with all options enabled. Should you wish
116
+ to disable specific options, you can use the `--no-*` prefix. Example:
77
117
 
78
118
  [source,bash]
79
119
  ----
80
- bin/console
120
+ rubysmith --build demo --no-pry --no-guard
81
121
  ----
82
122
 
83
- == Usage
84
-
85
- === Command Line Interface (CLI)
123
+ With the above example, both Pry and Guard support would have been disabled when building the `demo`
124
+ project. Taking this a step further, you can also use the `--min` option to generate a project with
125
+ bare minimum of options. Example:
86
126
 
87
- From the command line, type: `rubysmith --help`
127
+ [source,bash]
128
+ ----
129
+ rubysmith --build demo --min
130
+ ----
88
131
 
89
- ....
90
- USAGE:
91
- -c, --config ACTION Manage gem configuration: edit or view.
92
- -b, --build NAME [options] Build new gem.
93
- -v, --version Show gem version.
94
- -h, --help Show this message.
132
+ The above is essentially the same as building with _all_ options disabled. This is handy in
133
+ situations where you need to quickly script something up for sharing with others yet still want to
134
+ avoid using a Bundler Inline script so gem dependencies are not installed each time the code is run.
95
135
 
96
- BUILD OPTIONS:
97
- --[no-]bundler-audit Add Bundler Audit.
98
- --[no-]console Add console script.
99
- --[no-]documentation Add documentation.
100
- --[no-]git Add Git.
101
- --[no-]git-lint Add Git Lint.
102
- --[no-]guard Add Guard.
103
- --[no-]pry Add Pry.
104
- --[no-]reek Add Reek.
105
- --[no-]rspec Add RSpec.
106
- --[no-]rubocop Add Rubocop.
107
- --[no-]setup Add setup script.
108
- --[no-]simple_cov Add SimpleCov.
109
- ....
136
+ To have specific options enabled/disabled _every time_ you build a new Ruby project, you can edit
137
+ your global configuration for making these settings permanent (see below for details).
110
138
 
111
139
  === Configuration
112
140
 
@@ -131,14 +159,18 @@ The default configuration is as follows:
131
159
  :format: "md"
132
160
  :license: "mit"
133
161
  :build:
162
+ :amazing_print: true
134
163
  :bundler_audit: true
164
+ :bundler_leak: true
135
165
  :console: true
136
166
  :documentation: true
137
167
  :git: true
138
168
  :git_lint: true
139
169
  :guard: true
170
+ :minimum: false
140
171
  :pry: true
141
172
  :reek: true
173
+ :refinements: true
142
174
  :rspec: true
143
175
  :rubocop: true
144
176
  :setup: true
@@ -160,6 +192,24 @@ The default configuration is as follows:
160
192
  Feel free to take this default configuration, modify, and save as your own custom
161
193
  `configuration.yml`.
162
194
 
195
+ == Development
196
+
197
+ To contribute, run:
198
+
199
+ [source,bash]
200
+ ----
201
+ git clone https://github.com/bkuhlmann/rubysmith.git
202
+ cd rubysmith
203
+ bin/setup
204
+ ----
205
+
206
+ You can also use the IRB console for direct access to all objects:
207
+
208
+ [source,bash]
209
+ ----
210
+ bin/console
211
+ ----
212
+
163
213
  == Tests
164
214
 
165
215
  To test, run:
@@ -20,7 +20,8 @@ require "rubysmith/builders/reek"
20
20
  require "rubysmith/builders/rspec/context"
21
21
  require "rubysmith/builders/rspec/helper"
22
22
  require "rubysmith/builders/pragma"
23
- require "rubysmith/builders/rubocop"
23
+ require "rubysmith/builders/rubocop/setup"
24
+ require "rubysmith/builders/rubocop/formatter"
24
25
  require "rubysmith/cli/parsers/core"
25
26
  require "rubysmith/cli/parsers/build"
26
27
  require "rubysmith/cli/parsers/assembler"
@@ -20,8 +20,12 @@ module Rubysmith
20
20
  def call
21
21
  builder.call(realm.with(template_path: "%project_name%/Gemfile.erb"))
22
22
  .render
23
- .replace(/"\n\s{2,}/, "\"\n")
24
- .replace(/\n\s*gem/, "\n gem")
23
+ .replace(/\n\s+group/, "\n\ngroup")
24
+ .replace(/\n\s+gem/, "\n gem")
25
+ .replace(/ (?=.+refinements)/, "")
26
+ .replace(/(\n+|\s+)end/, "\nend")
27
+ .replace(/\n\ngroup :(code_quality|test|tools) do\nend/, "")
28
+ .replace(/org"\n+/, "org\"\n\n")
25
29
  Dir.chdir(realm.project_root) { runner.start %w[install --quiet] }
26
30
  nil
27
31
  end
@@ -14,8 +14,6 @@ module Rubysmith
14
14
  end
15
15
 
16
16
  def call
17
- builder.call(realm.with(template_path: "%project_name%/lib/%project_name%/identity.rb.erb"))
18
- .render
19
17
  builder.call(realm.with(template_path: "%project_name%/lib/%project_name%.rb.erb")).render
20
18
  builder.call(realm.with(template_path: "%project_name%/.ruby-version.erb")).render
21
19
  nil
@@ -16,7 +16,7 @@ module Rubysmith
16
16
  def call
17
17
  return unless realm.build_documentation
18
18
 
19
- private_methods.grep(/render_/).each(&method(:__send__))
19
+ private_methods.grep(/render_/).each { |method| __send__ method }
20
20
  end
21
21
 
22
22
  private
@@ -45,7 +45,9 @@ module Rubysmith
45
45
  end
46
46
 
47
47
  def render_readme
48
- builder.call(realm.with(template_path: "%project_name%/README.#{kind}.erb")).render
48
+ builder.call(realm.with(template_path: "%project_name%/README.#{kind}.erb"))
49
+ .render
50
+ .replace("\n\n\n", "\n\n")
49
51
  end
50
52
 
51
53
  def kind
@@ -16,11 +16,11 @@ module Rubysmith
16
16
  def call
17
17
  builder.call(realm.with(template_path: "%project_name%/Rakefile.erb"))
18
18
  .render
19
- .replace(/\A\n+/, "")
20
19
  .replace(/\[\s+/, "[")
21
20
  .replace(/\s+\]/, "]")
22
- .replace(/\n{2,}/, "\n\n")
23
21
  .replace(" ", "")
22
+ .replace(/\n+(?=require)/, "\n")
23
+ .replace(/\n{2,}/, "\n\n")
24
24
  nil
25
25
  end
26
26
 
@@ -17,9 +17,10 @@ module Rubysmith
17
17
  def call
18
18
  return unless realm.build_rspec
19
19
 
20
- builder.call(
21
- realm.with(template_path: "%project_name%/spec/support/shared_contexts/temp_dir.rb.erb")
22
- ).render
20
+ realm.with(template_path: "%project_name%/spec/support/shared_contexts/temp_dir.rb.erb")
21
+ .then { |new_realm| builder.call new_realm }
22
+ .render
23
+ .replace(/\n\s+\n\s+/, "\n ")
23
24
  end
24
25
 
25
26
  private
@@ -20,8 +20,7 @@ module Rubysmith
20
20
  builder.call(realm.with(template_path: "%project_name%/spec/spec_helper.rb.erb"))
21
21
  .render
22
22
  .replace(/\n{3,}/, "\n\n")
23
- .replace(" require", "require")
24
- .replace(" Simple", "Simple")
23
+ .replace(/\n\s{2}(?=(require|Simple|using|Pathname|Dir))/, "\n")
25
24
  end
26
25
 
27
26
  private
@@ -0,0 +1,33 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "rubocop"
4
+ require "refinements/ios"
5
+
6
+ module Rubysmith
7
+ module Builders
8
+ module Rubocop
9
+ # Executes Rubocop auto-correct on newly generated project.
10
+ class Formatter
11
+ using Refinements::IOs
12
+
13
+ def self.call realm
14
+ new(realm).call
15
+ end
16
+
17
+ def initialize realm, client: RuboCop::CLI.new
18
+ @realm = realm
19
+ @client = client
20
+ end
21
+
22
+ def call
23
+ STDOUT.squelch { client.run ["--auto-correct", realm.project_root.to_s] }
24
+ nil
25
+ end
26
+
27
+ private
28
+
29
+ attr_reader :realm, :client
30
+ end
31
+ end
32
+ end
33
+ end
@@ -0,0 +1,33 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Rubysmith
4
+ module Builders
5
+ module Rubocop
6
+ # Builds project skeleton for Rubocop code quality support.
7
+ class Setup
8
+ def self.call realm, builder: Builder
9
+ new(realm, builder: builder).call
10
+ end
11
+
12
+ def initialize realm, builder: Builder
13
+ @realm = realm
14
+ @builder = builder
15
+ end
16
+
17
+ def call
18
+ return unless realm.build_rubocop
19
+
20
+ builder.call(realm.with(template_path: "%project_name%/bin/rubocop.erb"))
21
+ .render
22
+ .permit 0o755
23
+
24
+ builder.call(realm.with(template_path: "%project_name%/.rubocop.yml.erb")).render
25
+ end
26
+
27
+ private
28
+
29
+ attr_reader :realm, :builder
30
+ end
31
+ end
32
+ end
33
+ end
@@ -8,14 +8,18 @@
8
8
  :format: "md"
9
9
  :license: "mit"
10
10
  :build:
11
+ :amazing_print: true
11
12
  :bundler_audit: true
13
+ :bundler_leak: true
12
14
  :console: true
13
15
  :documentation: true
14
16
  :git: true
15
17
  :git_lint: true
16
18
  :guard: true
19
+ :minimum: false
17
20
  :pry: true
18
21
  :reek: true
22
+ :refinements: true
19
23
  :rspec: true
20
24
  :rubocop: true
21
25
  :setup: true
@@ -4,6 +4,7 @@ module Rubysmith
4
4
  module CLI
5
5
  module Parsers
6
6
  # Handles parsing of Command Line Interface (CLI) build options.
7
+ # :reek:TooManyMethods
7
8
  class Build
8
9
  def self.call client:, options:
9
10
  new(client: client, options: options).call
@@ -16,7 +17,7 @@ module Rubysmith
16
17
 
17
18
  def call arguments = []
18
19
  client.separator "\nBUILD OPTIONS:\n"
19
- private_methods.grep(/add_/).each(&method(:__send__))
20
+ private_methods.grep(/add_/).each { |method| __send__ method }
20
21
  arguments.empty? ? arguments : client.parse!(arguments)
21
22
  end
22
23
 
@@ -24,12 +25,30 @@ module Rubysmith
24
25
 
25
26
  attr_reader :client, :options
26
27
 
28
+ def add_minimum
29
+ client.on "--min", "Use minimum/no options." do |value|
30
+ options[:build_minimum] = value
31
+ end
32
+ end
33
+
34
+ def add_amazing_print
35
+ client.on "--[no-]amazing_print", "Add Amazing Print." do |value|
36
+ options[:build_amazing_print] = value
37
+ end
38
+ end
39
+
27
40
  def add_bundler_audit
28
41
  client.on "--[no-]bundler-audit", "Add Bundler Audit." do |value|
29
42
  options[:build_bundler_audit] = value
30
43
  end
31
44
  end
32
45
 
46
+ def add_bundler_leak
47
+ client.on "--[no-]bundler-leak", "Add Bundler Leak." do |value|
48
+ options[:build_bundler_leak] = value
49
+ end
50
+ end
51
+
33
52
  def add_console
34
53
  client.on "--[no-]console", "Add console script." do |value|
35
54
  options[:build_console] = value
@@ -72,6 +91,12 @@ module Rubysmith
72
91
  end
73
92
  end
74
93
 
94
+ def add_refinements
95
+ client.on "--[no-]refinements", "Add Refinements." do |value|
96
+ options[:build_refinements] = value
97
+ end
98
+ end
99
+
75
100
  def add_rspec
76
101
  client.on "--[no-]rspec", "Add RSpec." do |value|
77
102
  options[:build_rspec] = value
@@ -19,7 +19,7 @@ module Rubysmith
19
19
  def call arguments = []
20
20
  client.banner = "#{Identity::LABEL} - #{Identity::SUMMARY}"
21
21
  client.separator "\nUSAGE:\n"
22
- private_methods.grep(/add_/).each(&method(:__send__))
22
+ collate
23
23
  arguments.empty? ? arguments : client.parse!(arguments)
24
24
  end
25
25
 
@@ -27,6 +27,10 @@ module Rubysmith
27
27
 
28
28
  attr_reader :client, :options
29
29
 
30
+ def collate
31
+ private_methods.grep(/add_/).each { |method| __send__ method }
32
+ end
33
+
30
34
  def add_config
31
35
  client.on "-c",
32
36
  "--config ACTION",
@@ -37,7 +41,7 @@ module Rubysmith
37
41
  end
38
42
 
39
43
  def add_build
40
- client.on "-b", "--build NAME [options]", "Build new gem." do |value|
44
+ client.on "-b", "--build NAME [options]", "Build new project." do |value|
41
45
  options[:build] = value
42
46
  end
43
47
  end
@@ -3,32 +3,45 @@
3
3
  module Rubysmith
4
4
  module CLI
5
5
  module Processors
6
- # Order is important.
7
- BUILDERS = [
8
- Builders::Core,
9
- Builders::Documentation,
10
- Builders::Git::Setup,
11
- Builders::Bundler,
12
- Builders::Rake,
13
- Builders::Console,
14
- Builders::Setup,
15
- Builders::Guard,
16
- Builders::Reek,
17
- Builders::RSpec::Context,
18
- Builders::RSpec::Helper,
19
- Builders::Pragma,
20
- Builders::Rubocop,
21
- Builders::Git::Commit
22
- ].freeze
23
-
24
6
  # Handles the Command Line Interface (CLI) for building of a project skeleton.
25
7
  class Build
26
- def initialize builders: BUILDERS
8
+ # Order is important.
9
+ MINIMUM = [
10
+ Builders::Core,
11
+ Builders::Bundler,
12
+ Builders::Pragma,
13
+ Builders::Rubocop::Formatter
14
+ ].freeze
15
+
16
+ # Order is important.
17
+ MAXIMUM = [
18
+ Builders::Core,
19
+ Builders::Documentation,
20
+ Builders::Git::Setup,
21
+ Builders::Bundler,
22
+ Builders::Rake,
23
+ Builders::Console,
24
+ Builders::Setup,
25
+ Builders::Guard,
26
+ Builders::Reek,
27
+ Builders::RSpec::Context,
28
+ Builders::RSpec::Helper,
29
+ Builders::Pragma,
30
+ Builders::Rubocop::Setup,
31
+ Builders::Rubocop::Formatter,
32
+ Builders::Git::Commit
33
+ ].freeze
34
+
35
+ def self.with_minimum
36
+ new builders: MINIMUM
37
+ end
38
+
39
+ def initialize builders: MAXIMUM
27
40
  @builders = builders
28
41
  end
29
42
 
30
43
  def call options
31
- Realm[**options].then(&method(:process))
44
+ Realm[**options].then { |realm| process realm }
32
45
  end
33
46
 
34
47
  private
@@ -11,7 +11,8 @@ module Rubysmith
11
11
 
12
12
  PROCESSORS = {
13
13
  config: Processors::Config.new,
14
- build: Processors::Build.new
14
+ build_minimum: Processors::Build.with_minimum,
15
+ build_maximum: Processors::Build.new
15
16
  }.freeze
16
17
 
17
18
  def initialize parser: Parsers::Assembler.new, processors: PROCESSORS
@@ -23,8 +24,9 @@ module Rubysmith
23
24
  parse arguments
24
25
 
25
26
  case options
26
- in config: action, **remainder then config action
27
- in build:, **remainder then build options.rekey(build: :project_name).merge now: Time.now
27
+ in config: action, **remainder then process_config action
28
+ in build_minimum: true, **remainder then process_build :build_minimum, options
29
+ in build:, **remainder then process_build :build_maximum, options
28
30
  in version:, **remainder then puts version
29
31
  in help:, **remainder then usage
30
32
  else usage
@@ -41,12 +43,12 @@ module Rubysmith
41
43
  puts error.message
42
44
  end
43
45
 
44
- def config action
45
- processors.fetch(__method__).call action
46
+ def process_config action
47
+ processors.fetch(:config).call action
46
48
  end
47
49
 
48
- def build settings
49
- processors.fetch(__method__).call settings
50
+ def process_build kind, settings
51
+ processors.fetch(kind).call settings.rekey(build: :project_name).merge(now: Time.now)
50
52
  end
51
53
 
52
54
  def options
@@ -4,7 +4,7 @@ module Rubysmith
4
4
  module Identity
5
5
  NAME = "rubysmith"
6
6
  LABEL = "Rubysmith"
7
- VERSION = "0.1.1"
7
+ VERSION = "0.6.0"
8
8
  VERSION_LABEL = "#{LABEL} #{VERSION}"
9
9
  SUMMARY = "A command line interface for smithing Ruby projects."
10
10
  end
@@ -16,7 +16,10 @@ module Rubysmith
16
16
  now
17
17
  documentation_format
18
18
  documentation_license
19
+ build_minimum
20
+ build_amazing_print
19
21
  build_bundler_audit
22
+ build_bundler_leak
20
23
  build_console
21
24
  build_documentation
22
25
  build_git
@@ -24,6 +27,7 @@ module Rubysmith
24
27
  build_guard
25
28
  build_pry
26
29
  build_reek
30
+ build_refinements
27
31
  build_rspec
28
32
  build_rubocop
29
33
  build_setup
@@ -1,33 +1,56 @@
1
1
  source "https://rubygems.org"
2
2
 
3
- group :development do
4
- <% if realm.build_bundler_audit %>
5
- gem "bundler-audit", "~> 0.7"
3
+ <% unless realm.build_minimum %>
4
+ <% if realm.build_refinements %>
5
+ gem "refinements", "~> 7.16"
6
6
  <% end %>
7
- <% if realm.build_git && realm.build_git_lint %>
8
- gem "git-lint", "~> 1.0"
9
- <% end %>
10
- <% if realm.build_guard %>
11
- gem "guard-rspec", "~> 4.7"
12
- <% end %>
13
- <% if realm.build_pry %>
14
- gem "pry", "~> 0.13"
15
- gem "pry-byebug", "~> 3.9"
16
- <% end %>
17
- gem "rake", "~> 13.0"
18
- <% if realm.build_reek %>
19
- gem "reek", "~> 6.0"
20
- <% end %>
21
- <% if realm.build_rspec %>
22
- gem "rspec", "~> 3.9"
23
- <% end %>
24
- <% if realm.build_rubocop %>
25
- gem "rubocop", "~> 0.92"
26
- gem "rubocop-performance", "~> 1.8"
27
- gem "rubocop-rake", "~> 0.5"
28
- gem "rubocop-rspec", "~> 1.43"
29
- <% end %>
30
- <% if realm.build_simple_cov %>
31
- gem "simplecov", "~> 0.19"
32
- <% end %>
33
- end
7
+
8
+ group :code_quality do
9
+ <% if realm.build_bundler_audit %>
10
+ gem "bundler-audit", "~> 0.7"
11
+ <% end %>
12
+ <% if realm.build_bundler_leak %>
13
+ gem "bundler-leak", "~> 0.2"
14
+ <% end %>
15
+ <% if realm.build_git && realm.build_git_lint %>
16
+ gem "git-lint", "~> 1.3"
17
+ <% end %>
18
+ <% if realm.build_reek %>
19
+ gem "reek", "~> 6.0"
20
+ <% end %>
21
+ <% if realm.build_rubocop %>
22
+ gem "rubocop", "~> 1.5"
23
+ gem "rubocop-performance", "~> 1.9"
24
+ gem "rubocop-rake", "~> 0.5"
25
+ <% end %>
26
+ <% if realm.build_rspec && realm.build_rubocop %>
27
+ gem "rubocop-rspec", "~> 2.0"
28
+ <% end %>
29
+ end
30
+
31
+ group :development do
32
+ <% if realm.build_guard %>
33
+ gem "guard-rspec", "~> 4.7", require: false
34
+ <% end %>
35
+ gem "rake", "~> 13.0"
36
+ end
37
+
38
+ group :test do
39
+ <% if realm.build_rspec %>
40
+ gem "rspec", "~> 3.10"
41
+ <% end %>
42
+ <% if realm.build_simple_cov %>
43
+ gem "simplecov", "~> 0.20"
44
+ <% end %>
45
+ end
46
+
47
+ group :tools do
48
+ <% if realm.build_amazing_print %>
49
+ gem "amazing_print", "~> 1.2"
50
+ <% end %>
51
+ <% if realm.build_pry %>
52
+ gem "pry", "~> 0.13"
53
+ gem "pry-byebug", "~> 3.9"
54
+ <% end %>
55
+ end
56
+ <% end %>
@@ -4,6 +4,11 @@
4
4
 
5
5
  = <%= realm.project_label %>
6
6
 
7
+ <% if realm.build_rubocop %>
8
+ [link=https://www.alchemists.io/projects/code_quality]
9
+ image::https://img.shields.io/badge/code_style-alchemists-brightgreen.svg[Alchemists Style Guide]
10
+ <% end %>
11
+
7
12
  toc::[]
8
13
 
9
14
  == Features
@@ -26,11 +31,11 @@ bin/setup
26
31
  <% end %>
27
32
 
28
33
  == Usage
29
- <% if realm.build_console %>
30
34
 
31
- === Console
35
+ == Development
36
+ <% if realm.build_console %>
32
37
 
33
- To use the IRB console to invesitage and/or experiment with all project objects, run:
38
+ You can also use the IRB console for direct access to all objects:
34
39
 
35
40
  [source,bash]
36
41
  ----
@@ -1,5 +1,9 @@
1
1
  # <%= realm.project_label %>
2
2
 
3
+ <% if realm.build_rubocop %>
4
+ [![Alchemists Style Guide](https://img.shields.io/badge/code_style-alchemists-brightgreen.svg)](https://www.alchemists.io/projects/code_quality)
5
+ <% end %>
6
+
3
7
  <!-- Tocer[start]: Auto-generated, don't remove. -->
4
8
  <!-- Tocer[finish]: Auto-generated, don't remove. -->
5
9
 
@@ -20,11 +24,11 @@ To set up the project, run:
20
24
  <% end %>
21
25
 
22
26
  ## Usage
23
- <% if realm.build_console %>
24
27
 
25
- ### Console
28
+ ## Development
29
+ <% if realm.build_console %>
26
30
 
27
- To use the IRB console to invesitage and/or experiment with all project objects, run:
31
+ You can also use the IRB console for direct access to all objects:
28
32
 
29
33
  bin/console
30
34
  <% end %>
@@ -1,6 +1,11 @@
1
+ require "bundler/setup"
2
+
1
3
  <% if realm.build_bundler_audit %>
2
4
  require "bundler/audit/task"
3
5
  <% end %>
6
+ <% if realm.build_bundler_leak %>
7
+ require "bundler/plumber/task"
8
+ <% end %>
4
9
  <% if realm.build_git && realm.build_git_lint %>
5
10
  require "git/lint/rake/setup"
6
11
  <% end %>
@@ -17,6 +22,9 @@
17
22
  <% if realm.build_bundler_audit %>
18
23
  Bundler::Audit::Task.new
19
24
  <% end %>
25
+ <% if realm.build_bundler_leak %>
26
+ Bundler::Plumber::Task.new
27
+ <% end %>
20
28
  <% if realm.build_reek %>
21
29
  Reek::Rake::Task.new
22
30
  <% end %>
@@ -28,6 +36,6 @@
28
36
  <% end %>
29
37
 
30
38
  desc "Run code quality checks"
31
- task code_quality: %i[<% if realm.build_bundler_audit %>bundle:audit<% end %> <% if realm.build_git && realm.build_git_lint %>git_lint<% end %> <% if realm.build_reek %>reek<% end %> <% if realm.build_rubocop %>rubocop<% end %>]
39
+ task code_quality: %i[<% if realm.build_bundler_audit %>bundle:audit<% end %> <% if realm.build_bundler_leak %>bundle:leak<% end %> <% if realm.build_git && realm.build_git_lint %>git_lint<% end %> <% if realm.build_reek %>reek<% end %> <% if realm.build_rubocop %>rubocop<% end %>]
32
40
 
33
41
  task default: %i[code_quality <% if realm.build_rspec %>spec<% end %>]
@@ -1,11 +1,9 @@
1
1
  #! /usr/bin/env ruby
2
2
 
3
3
  require "bundler/setup"
4
- require "<%= realm.project_name %>"
5
- <% if realm.build_pry %>
6
- require "pry"
7
- require "pry-byebug"
8
- <% end %>
4
+ Bundler.require :tools
5
+
6
+ require_relative "../lib/<%= realm.project_name %>"
9
7
  require "irb"
10
8
 
11
9
  IRB.start __FILE__
@@ -1 +0,0 @@
1
- require "<%= realm.project_name %>/identity"
@@ -1,16 +1,22 @@
1
1
  require "bundler/setup"
2
+ Bundler.require :test, :tools
2
3
 
3
4
  <% if realm.build_simple_cov %>
4
5
  require "simplecov"
5
6
  SimpleCov.start { enable_coverage :branch }
6
7
  <% end %>
7
8
 
8
- <% if realm.build_pry %>
9
- require "pry"
10
- require "pry-byebug"
11
- <% end %>
9
+ require "<%= realm.project_name %>"
10
+ <% if realm.build_refinements %>
11
+ require "refinements"
12
+
13
+ using Refinements::Pathnames
12
14
 
13
- Dir[File.join(__dir__, "support", "shared_contexts", "**/*.rb")].sort.each(&method(:require))
15
+ Pathname.require_tree __dir__, "support/shared_contexts/**/*.rb"
16
+ <% else %>
17
+
18
+ Dir[File.join(__dir__, "support", "shared_contexts", "**/*.rb")].sort.each { |path| require path }
19
+ <% end %>
14
20
 
15
21
  RSpec.configure do |config|
16
22
  config.color = true
@@ -1,9 +1,11 @@
1
1
  RSpec.shared_context "with temporary directory", :temp_dir do
2
- let(:temp_dir) { Bundler.root.join "tmp", "rspec" }
2
+ <% if realm.build_refinements %>using Refinements::Pathnames<% end %>
3
+
4
+ let(:temp_dir) { Bundler.root.join "tmp/rspec" }
3
5
 
4
6
  around do |example|
5
- FileUtils.mkdir_p temp_dir
7
+ <%= realm.build_refinements ? "temp_dir.make_path" : "FileUtils.mkdir_p temp_dir" %>
6
8
  example.run
7
- FileUtils.rm_rf temp_dir
9
+ <%= realm.build_refinements ? "temp_dir.remove_tree" : "FileUtils.rm_rf temp_dir" %>
8
10
  end
9
11
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rubysmith
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Brooke Kuhlmann
@@ -28,7 +28,7 @@ cert_chain:
28
28
  2XV8FRa7/JimI07sPLC13eLY3xd/aYTi85Z782KIA4j0G8XEEWAX0ouBhlXPocZv
29
29
  QWc=
30
30
  -----END CERTIFICATE-----
31
- date: 2020-09-29 00:00:00.000000000 Z
31
+ date: 2020-12-07 00:00:00.000000000 Z
32
32
  dependencies:
33
33
  - !ruby/object:Gem::Dependency
34
34
  name: pragmater
@@ -36,238 +36,56 @@ dependencies:
36
36
  requirements:
37
37
  - - "~>"
38
38
  - !ruby/object:Gem::Version
39
- version: '8.0'
39
+ version: '8.1'
40
40
  type: :runtime
41
41
  prerelease: false
42
42
  version_requirements: !ruby/object:Gem::Requirement
43
43
  requirements:
44
44
  - - "~>"
45
45
  - !ruby/object:Gem::Version
46
- version: '8.0'
46
+ version: '8.1'
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: refinements
49
49
  requirement: !ruby/object:Gem::Requirement
50
50
  requirements:
51
51
  - - "~>"
52
52
  - !ruby/object:Gem::Version
53
- version: '7.10'
53
+ version: '7.16'
54
54
  type: :runtime
55
55
  prerelease: false
56
56
  version_requirements: !ruby/object:Gem::Requirement
57
57
  requirements:
58
58
  - - "~>"
59
59
  - !ruby/object:Gem::Version
60
- version: '7.10'
60
+ version: '7.16'
61
61
  - !ruby/object:Gem::Dependency
62
62
  name: rubocop
63
63
  requirement: !ruby/object:Gem::Requirement
64
64
  requirements:
65
65
  - - "~>"
66
66
  - !ruby/object:Gem::Version
67
- version: '0.92'
67
+ version: '1.5'
68
68
  type: :runtime
69
69
  prerelease: false
70
70
  version_requirements: !ruby/object:Gem::Requirement
71
71
  requirements:
72
72
  - - "~>"
73
73
  - !ruby/object:Gem::Version
74
- version: '0.92'
74
+ version: '1.5'
75
75
  - !ruby/object:Gem::Dependency
76
76
  name: runcom
77
77
  requirement: !ruby/object:Gem::Requirement
78
78
  requirements:
79
79
  - - "~>"
80
80
  - !ruby/object:Gem::Version
81
- version: '6.2'
81
+ version: '6.4'
82
82
  type: :runtime
83
83
  prerelease: false
84
84
  version_requirements: !ruby/object:Gem::Requirement
85
85
  requirements:
86
86
  - - "~>"
87
87
  - !ruby/object:Gem::Version
88
- version: '6.2'
89
- - !ruby/object:Gem::Dependency
90
- name: bundler-audit
91
- requirement: !ruby/object:Gem::Requirement
92
- requirements:
93
- - - "~>"
94
- - !ruby/object:Gem::Version
95
- version: '0.7'
96
- type: :development
97
- prerelease: false
98
- version_requirements: !ruby/object:Gem::Requirement
99
- requirements:
100
- - - "~>"
101
- - !ruby/object:Gem::Version
102
- version: '0.7'
103
- - !ruby/object:Gem::Dependency
104
- name: gemsmith
105
- requirement: !ruby/object:Gem::Requirement
106
- requirements:
107
- - - "~>"
108
- - !ruby/object:Gem::Version
109
- version: '14.6'
110
- type: :development
111
- prerelease: false
112
- version_requirements: !ruby/object:Gem::Requirement
113
- requirements:
114
- - - "~>"
115
- - !ruby/object:Gem::Version
116
- version: '14.6'
117
- - !ruby/object:Gem::Dependency
118
- name: git-lint
119
- requirement: !ruby/object:Gem::Requirement
120
- requirements:
121
- - - "~>"
122
- - !ruby/object:Gem::Version
123
- version: '1.0'
124
- type: :development
125
- prerelease: false
126
- version_requirements: !ruby/object:Gem::Requirement
127
- requirements:
128
- - - "~>"
129
- - !ruby/object:Gem::Version
130
- version: '1.0'
131
- - !ruby/object:Gem::Dependency
132
- name: guard-rspec
133
- requirement: !ruby/object:Gem::Requirement
134
- requirements:
135
- - - "~>"
136
- - !ruby/object:Gem::Version
137
- version: '4.7'
138
- type: :development
139
- prerelease: false
140
- version_requirements: !ruby/object:Gem::Requirement
141
- requirements:
142
- - - "~>"
143
- - !ruby/object:Gem::Version
144
- version: '4.7'
145
- - !ruby/object:Gem::Dependency
146
- name: pry
147
- requirement: !ruby/object:Gem::Requirement
148
- requirements:
149
- - - "~>"
150
- - !ruby/object:Gem::Version
151
- version: '0.13'
152
- type: :development
153
- prerelease: false
154
- version_requirements: !ruby/object:Gem::Requirement
155
- requirements:
156
- - - "~>"
157
- - !ruby/object:Gem::Version
158
- version: '0.13'
159
- - !ruby/object:Gem::Dependency
160
- name: pry-byebug
161
- requirement: !ruby/object:Gem::Requirement
162
- requirements:
163
- - - "~>"
164
- - !ruby/object:Gem::Version
165
- version: '3.9'
166
- type: :development
167
- prerelease: false
168
- version_requirements: !ruby/object:Gem::Requirement
169
- requirements:
170
- - - "~>"
171
- - !ruby/object:Gem::Version
172
- version: '3.9'
173
- - !ruby/object:Gem::Dependency
174
- name: rake
175
- requirement: !ruby/object:Gem::Requirement
176
- requirements:
177
- - - "~>"
178
- - !ruby/object:Gem::Version
179
- version: '13.0'
180
- type: :development
181
- prerelease: false
182
- version_requirements: !ruby/object:Gem::Requirement
183
- requirements:
184
- - - "~>"
185
- - !ruby/object:Gem::Version
186
- version: '13.0'
187
- - !ruby/object:Gem::Dependency
188
- name: reek
189
- requirement: !ruby/object:Gem::Requirement
190
- requirements:
191
- - - "~>"
192
- - !ruby/object:Gem::Version
193
- version: '6.0'
194
- type: :development
195
- prerelease: false
196
- version_requirements: !ruby/object:Gem::Requirement
197
- requirements:
198
- - - "~>"
199
- - !ruby/object:Gem::Version
200
- version: '6.0'
201
- - !ruby/object:Gem::Dependency
202
- name: rspec
203
- requirement: !ruby/object:Gem::Requirement
204
- requirements:
205
- - - "~>"
206
- - !ruby/object:Gem::Version
207
- version: '3.9'
208
- type: :development
209
- prerelease: false
210
- version_requirements: !ruby/object:Gem::Requirement
211
- requirements:
212
- - - "~>"
213
- - !ruby/object:Gem::Version
214
- version: '3.9'
215
- - !ruby/object:Gem::Dependency
216
- name: rubocop-performance
217
- requirement: !ruby/object:Gem::Requirement
218
- requirements:
219
- - - "~>"
220
- - !ruby/object:Gem::Version
221
- version: '1.8'
222
- type: :development
223
- prerelease: false
224
- version_requirements: !ruby/object:Gem::Requirement
225
- requirements:
226
- - - "~>"
227
- - !ruby/object:Gem::Version
228
- version: '1.8'
229
- - !ruby/object:Gem::Dependency
230
- name: rubocop-rake
231
- requirement: !ruby/object:Gem::Requirement
232
- requirements:
233
- - - "~>"
234
- - !ruby/object:Gem::Version
235
- version: '0.5'
236
- type: :development
237
- prerelease: false
238
- version_requirements: !ruby/object:Gem::Requirement
239
- requirements:
240
- - - "~>"
241
- - !ruby/object:Gem::Version
242
- version: '0.5'
243
- - !ruby/object:Gem::Dependency
244
- name: rubocop-rspec
245
- requirement: !ruby/object:Gem::Requirement
246
- requirements:
247
- - - "~>"
248
- - !ruby/object:Gem::Version
249
- version: '1.43'
250
- type: :development
251
- prerelease: false
252
- version_requirements: !ruby/object:Gem::Requirement
253
- requirements:
254
- - - "~>"
255
- - !ruby/object:Gem::Version
256
- version: '1.43'
257
- - !ruby/object:Gem::Dependency
258
- name: simplecov
259
- requirement: !ruby/object:Gem::Requirement
260
- requirements:
261
- - - "~>"
262
- - !ruby/object:Gem::Version
263
- version: '0.19'
264
- type: :development
265
- prerelease: false
266
- version_requirements: !ruby/object:Gem::Requirement
267
- requirements:
268
- - - "~>"
269
- - !ruby/object:Gem::Version
270
- version: '0.19'
88
+ version: '6.4'
271
89
  description:
272
90
  email:
273
91
  - brooke@alchemists.io
@@ -295,7 +113,8 @@ files:
295
113
  - lib/rubysmith/builders/reek.rb
296
114
  - lib/rubysmith/builders/rspec/context.rb
297
115
  - lib/rubysmith/builders/rspec/helper.rb
298
- - lib/rubysmith/builders/rubocop.rb
116
+ - lib/rubysmith/builders/rubocop/formatter.rb
117
+ - lib/rubysmith/builders/rubocop/setup.rb
299
118
  - lib/rubysmith/builders/setup.rb
300
119
  - lib/rubysmith/cli/configuration.rb
301
120
  - lib/rubysmith/cli/defaults.yml
@@ -333,7 +152,6 @@ files:
333
152
  - lib/rubysmith/templates/%project_name%/bin/rubocop.erb
334
153
  - lib/rubysmith/templates/%project_name%/bin/setup.erb
335
154
  - lib/rubysmith/templates/%project_name%/lib/%project_name%.rb.erb
336
- - lib/rubysmith/templates/%project_name%/lib/%project_name%/identity.rb.erb
337
155
  - lib/rubysmith/templates/%project_name%/spec/spec_helper.rb.erb
338
156
  - lib/rubysmith/templates/%project_name%/spec/support/shared_contexts/temp_dir.rb.erb
339
157
  - lib/rubysmith/text/inserter.rb
metadata.gz.sig CHANGED
Binary file
@@ -1,43 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require "rubocop"
4
- require "stringio"
5
-
6
- module Rubysmith
7
- module Builders
8
- # Builds project skeleton Rubocop code quality support.
9
- class Rubocop
10
- def self.call realm, builder: Builder
11
- new(realm, builder: builder).call
12
- end
13
-
14
- def initialize realm, builder: Builder, runner: RuboCop::CLI.new
15
- @realm = realm
16
- @builder = builder
17
- @runner = runner
18
- end
19
-
20
- def call
21
- return unless realm.build_rubocop
22
-
23
- builder.call(realm.with(template_path: "%project_name%/bin/rubocop.erb"))
24
- .render
25
- .permit 0o755
26
-
27
- builder.call(realm.with(template_path: "%project_name%/.rubocop.yml.erb")).render
28
- auto_correct
29
- end
30
-
31
- private
32
-
33
- attr_reader :realm, :builder, :runner
34
-
35
- def auto_correct
36
- backup = $stdout
37
- $stdout = StringIO.new
38
- runner.run ["--auto-correct", "--format", "quiet", realm.project_root.to_s]
39
- $stdout = backup
40
- end
41
- end
42
- end
43
- end
@@ -1,8 +0,0 @@
1
- <% namespace do %>
2
- module Identity
3
- NAME = "<%= realm.project_name %>"
4
- LABEL = "<%= realm.project_label %>"
5
- VERSION = "0.1.0"
6
- VERSION_LABEL = "#{LABEL} #{VERSION}"
7
- end
8
- <% end %>