rubysmith 0.6.1 → 0.10.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (61) 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 +4 -2
  5. data/bin/rubysmith +0 -4
  6. data/lib/rubysmith.rb +4 -2
  7. data/lib/rubysmith/builder.rb +14 -30
  8. data/lib/rubysmith/builders/bundler.rb +11 -9
  9. data/lib/rubysmith/builders/console.rb +6 -8
  10. data/lib/rubysmith/builders/core.rb +7 -8
  11. data/lib/rubysmith/builders/documentation.rb +17 -22
  12. data/lib/rubysmith/builders/git/commit.rb +7 -11
  13. data/lib/rubysmith/builders/git/setup.rb +6 -8
  14. data/lib/rubysmith/builders/guard.rb +9 -9
  15. data/lib/rubysmith/builders/pragma.rb +9 -14
  16. data/lib/rubysmith/builders/rake.rb +5 -7
  17. data/lib/rubysmith/builders/reek.rb +6 -8
  18. data/lib/rubysmith/builders/rspec/context.rb +10 -11
  19. data/lib/rubysmith/builders/rspec/helper.rb +6 -8
  20. data/lib/rubysmith/builders/rubocop/formatter.rb +5 -7
  21. data/lib/rubysmith/builders/rubocop/setup.rb +7 -9
  22. data/lib/rubysmith/builders/ruby_critic.rb +25 -0
  23. data/lib/rubysmith/builders/setup.rb +8 -8
  24. data/lib/rubysmith/cli/configuration/content.rb +69 -0
  25. data/lib/rubysmith/cli/{defaults.yml → configuration/defaults.yml} +1 -0
  26. data/lib/rubysmith/cli/configuration/loader.rb +35 -0
  27. data/lib/rubysmith/cli/parsers.rb +11 -0
  28. data/lib/rubysmith/cli/parsers/assembler.rb +10 -15
  29. data/lib/rubysmith/cli/parsers/build.rb +11 -7
  30. data/lib/rubysmith/cli/parsers/core.rb +5 -9
  31. data/lib/rubysmith/cli/processors/build.rb +10 -8
  32. data/lib/rubysmith/cli/processors/config.rb +3 -7
  33. data/lib/rubysmith/cli/shell.rb +12 -18
  34. data/lib/rubysmith/identity.rb +1 -1
  35. data/lib/rubysmith/pathway.rb +3 -9
  36. data/lib/rubysmith/renderers/erb.rb +7 -9
  37. data/lib/rubysmith/renderers/namespace.rb +1 -3
  38. data/lib/rubysmith/templates/%project_name%/.rubocop.yml.erb +5 -5
  39. data/lib/rubysmith/templates/%project_name%/.rubycritic.yml.erb +3 -0
  40. data/lib/rubysmith/templates/%project_name%/CHANGES.adoc.erb +1 -1
  41. data/lib/rubysmith/templates/%project_name%/CHANGES.md.erb +1 -1
  42. data/lib/rubysmith/templates/%project_name%/CODE_OF_CONDUCT.adoc.erb +2 -2
  43. data/lib/rubysmith/templates/%project_name%/CODE_OF_CONDUCT.md.erb +1 -1
  44. data/lib/rubysmith/templates/%project_name%/Gemfile.erb +21 -16
  45. data/lib/rubysmith/templates/%project_name%/LICENSE-apache.adoc.erb +1 -1
  46. data/lib/rubysmith/templates/%project_name%/LICENSE-apache.md.erb +1 -1
  47. data/lib/rubysmith/templates/%project_name%/LICENSE-mit.adoc.erb +1 -1
  48. data/lib/rubysmith/templates/%project_name%/LICENSE-mit.md.erb +1 -1
  49. data/lib/rubysmith/templates/%project_name%/README.adoc.erb +5 -5
  50. data/lib/rubysmith/templates/%project_name%/README.md.erb +5 -5
  51. data/lib/rubysmith/templates/%project_name%/Rakefile.erb +19 -13
  52. data/lib/rubysmith/templates/%project_name%/bin/console.erb +1 -1
  53. data/lib/rubysmith/templates/%project_name%/bin/guard.erb +0 -1
  54. data/lib/rubysmith/templates/%project_name%/bin/rubocop.erb +0 -1
  55. data/lib/rubysmith/templates/%project_name%/lib/%project_name%.rb.erb +3 -0
  56. data/lib/rubysmith/templates/%project_name%/spec/spec_helper.rb.erb +8 -3
  57. data/lib/rubysmith/templates/%project_name%/spec/support/shared_contexts/temp_dir.rb.erb +4 -4
  58. metadata +28 -25
  59. metadata.gz.sig +0 -0
  60. data/lib/rubysmith/cli/configuration.rb +0 -29
  61. data/lib/rubysmith/realm.rb +0 -73
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 613f818841d26d35d707a4a014d7ce18f35b63167cc6e7f830ea045ee9987a53
4
- data.tar.gz: c755c4375d9e6f784a570bbe69189529fe5a57d8ee402bda473e1a69534d5baf
3
+ metadata.gz: c99851111508a1453340fd292981281260eb2b197e1c3685fd40207078cfeee5
4
+ data.tar.gz: e5781a5bf2f57c8129b1049ac817abdb60a2a2548f7a52fcbd29596587f4701c
5
5
  SHA512:
6
- metadata.gz: 1c89a8f4692ec295585b752b14cb45ce3e20cece58287f98874ca65af25fd2ff87b227d862e880ceb6296eecd46f5aecb9825f43f5a87cf9a1a3cad05be6dc37
7
- data.tar.gz: 6d8f894ee75c1e840442982ffd2534c233ab97406e1f8f85c3a00e8fda8feab57e3fc5c1f248665bf85e59ab1e602c0557d8f7d5cac50d01fa6b64c59bfa7ef5
6
+ metadata.gz: 9dcbcf78f012f5fc4eb2409bd7d69ecb42e6033df93a227c510226621d56f8d291458c5528c33bf89673bf81f9849017a003fb8a8fdab649f706c725af862ffe
7
+ data.tar.gz: f6f050ce4b479505bbdff25a34a880e8ce72afc48524c283692f34d255686dd4eab037b365019b4fbd83fce9dccce9e1394ea1b47295908b0c29d7d27db56c55
checksums.yaml.gz.sig CHANGED
Binary file
data.tar.gz.sig CHANGED
Binary file
data/README.adoc CHANGED
@@ -23,7 +23,6 @@ toc::[]
23
23
  == Features
24
24
 
25
25
  * Builds a Ruby project skeleton for custom design and development.
26
- * Uses link:https://www.alchemists.io/projects/refinements[Refinements] Ruby core library enhancements.
27
26
  * Uses link:https://www.alchemists.io/projects/runcom[Runcom] for resource configuration management.
28
27
  * Uses link:https://www.alchemists.io/projects/pragmater[Pragmater] for Ruby source pragma directives.
29
28
  * Supports link:https://github.com/amazing-print/amazing_print[Amazing Print].
@@ -40,6 +39,7 @@ toc::[]
40
39
  * Supports link:https://docs.rubocop.org/rubocop-performance[Rubocop Performance].
41
40
  * Supports link:https://github.com/rubocop-hq/rubocop-rake[Rubocop Rake].
42
41
  * Supports link:https://github.com/rubocop-hq/rubocop-rspec[Rubocop RSpec].
42
+ * Supports link:https://github.com/whitesmith/RubyCritic[RubyCritic].
43
43
  * Supports link:https://github.com/simplecov-ruby/simplecov[SimpleCov].
44
44
  * Supports common settings and a structured layout for building projects.
45
45
  * Provides common documentation:
@@ -97,8 +97,9 @@ BUILD OPTIONS:
97
97
  --[no-]refinements Add Refinements.
98
98
  --[no-]rspec Add RSpec.
99
99
  --[no-]rubocop Add Rubocop.
100
+ --[no-]ruby_critic Add RubyCritic.
100
101
  --[no-]setup Add setup script.
101
- --[no-]simple_cov Add SimpleCov
102
+ --[no-]simple_cov Add SimpleCov.
102
103
  --min Use minimum/no options.
103
104
  ....
104
105
 
@@ -173,6 +174,7 @@ The default configuration is as follows:
173
174
  :refinements: true
174
175
  :rspec: true
175
176
  :rubocop: true
177
+ :ruby_critic: true
176
178
  :setup: true
177
179
  :simple_cov: true
178
180
  :builders:
data/bin/rubysmith CHANGED
@@ -1,11 +1,7 @@
1
1
  #! /usr/bin/env ruby
2
2
  # frozen_string_literal: true
3
3
 
4
- # TODO: Remove once the Pattern Matching feature is fully supported.
5
- Warning[:experimental] = false
6
-
7
4
  require "rubysmith"
8
- require "rubysmith/cli/shell"
9
5
 
10
6
  Process.setproctitle Rubysmith::Identity::VERSION_LABEL
11
7
  Rubysmith::CLI::Shell.new.call ARGV
data/lib/rubysmith.rb CHANGED
@@ -2,7 +2,6 @@
2
2
 
3
3
  require "rubysmith/identity"
4
4
  require "rubysmith/pathway"
5
- require "rubysmith/realm"
6
5
  require "rubysmith/renderers/namespace"
7
6
  require "rubysmith/renderers/erb"
8
7
  require "rubysmith/text/inserter"
@@ -22,10 +21,13 @@ require "rubysmith/builders/rspec/helper"
22
21
  require "rubysmith/builders/pragma"
23
22
  require "rubysmith/builders/rubocop/setup"
24
23
  require "rubysmith/builders/rubocop/formatter"
24
+ require "rubysmith/builders/ruby_critic"
25
+ require "rubysmith/cli/configuration/content"
26
+ require "rubysmith/cli/configuration/loader"
27
+ require "rubysmith/cli/parsers"
25
28
  require "rubysmith/cli/parsers/core"
26
29
  require "rubysmith/cli/parsers/build"
27
30
  require "rubysmith/cli/parsers/assembler"
28
31
  require "rubysmith/cli/processors/config"
29
32
  require "rubysmith/cli/processors/build"
30
- require "rubysmith/cli/configuration"
31
33
  require "rubysmith/cli/shell"
@@ -6,14 +6,11 @@ require "logger"
6
6
 
7
7
  module Rubysmith
8
8
  # :reek:TooManyMethods
9
- # rubocop:disable Metrics/ClassLength
9
+ # Provides common functionality necessary for all builders.
10
10
  class Builder
11
11
  using Refinements::Pathnames
12
12
 
13
- LOGGER = Logger.new(
14
- STDOUT,
15
- formatter: ->(severity, _at, _program, message) { "#{severity} #{message}\n" }
16
- )
13
+ LOGGER = Logger.new(STDOUT, formatter: ->(_severity, _at, _program, message) { "#{message}\n" })
17
14
 
18
15
  HELPERS = {
19
16
  inserter: Text::Inserter,
@@ -22,12 +19,12 @@ module Rubysmith
22
19
  logger: LOGGER
23
20
  }.freeze
24
21
 
25
- def self.call realm, helpers: HELPERS
26
- new realm, helpers: helpers
22
+ def self.call configuration, helpers: HELPERS
23
+ new configuration, helpers: helpers
27
24
  end
28
25
 
29
- def initialize realm, helpers: HELPERS
30
- @realm = realm
26
+ def initialize configuration, helpers: HELPERS
27
+ @configuration = configuration
31
28
  @helpers = helpers
32
29
  end
33
30
 
@@ -105,7 +102,7 @@ module Rubysmith
105
102
 
106
103
  private
107
104
 
108
- attr_reader :realm, :helpers
105
+ attr_reader :configuration, :helpers
109
106
 
110
107
  def execute *command
111
108
  kernel.capture2e(*command).then do |result, status|
@@ -113,33 +110,20 @@ module Rubysmith
113
110
  end
114
111
  end
115
112
 
116
- def inserter
117
- helpers.fetch __method__
118
- end
113
+ def inserter = helpers.fetch(__method__)
119
114
 
120
- def renderer
121
- helpers.fetch(__method__).new realm
122
- end
115
+ def renderer = helpers.fetch(__method__).new(configuration)
123
116
 
124
- def kernel
125
- helpers.fetch __method__
126
- end
117
+ def kernel = helpers.fetch(__method__)
127
118
 
128
- def logger
129
- helpers.fetch __method__
130
- end
119
+ def logger = helpers.fetch(__method__)
131
120
 
132
- def relative_build_path
133
- build_path.relative_path_from realm.build_root
134
- end
121
+ def relative_build_path = build_path.relative_path_from(configuration.build_root)
135
122
 
136
123
  def build_path
137
- pathway.end_path.gsub("%project_name%", realm.project_name).sub(".erb", "")
124
+ pathway.end_path.gsub("%project_name%", configuration.project_name).sub ".erb", ""
138
125
  end
139
126
 
140
- def pathway
141
- realm.to_pathway
142
- end
127
+ def pathway = configuration.to_pathway
143
128
  end
144
- # rubocop:enable Metrics/ClassLength
145
129
  end
@@ -2,23 +2,24 @@
2
2
 
3
3
  require "bundler"
4
4
  require "bundler/cli"
5
+ require "refinements/pathnames"
5
6
 
6
7
  module Rubysmith
7
8
  module Builders
8
9
  # Builds Bundler Gemfile configuration and installs gem dependencies for project skeleton.
9
10
  class Bundler
10
- def self.call realm, builder: Builder
11
- new(realm, builder: builder).call
12
- end
11
+ using Refinements::Pathnames
12
+
13
+ def self.call(configuration, builder: Builder) = new(configuration, builder: builder).call
13
14
 
14
- def initialize realm, builder: Builder, runner: ::Bundler::CLI
15
- @realm = realm
15
+ def initialize configuration, builder: Builder, client: ::Bundler::CLI
16
+ @configuration = configuration
16
17
  @builder = builder
17
- @runner = runner
18
+ @client = client
18
19
  end
19
20
 
20
21
  def call
21
- builder.call(realm.with(template_path: "%project_name%/Gemfile.erb"))
22
+ builder.call(configuration.with(template_path: "%project_name%/Gemfile.erb"))
22
23
  .render
23
24
  .replace(/\n\s+group/, "\n\ngroup")
24
25
  .replace(/\n\s+gem/, "\n gem")
@@ -26,13 +27,14 @@ module Rubysmith
26
27
  .replace(/(\n+|\s+)end/, "\nend")
27
28
  .replace(/\n\ngroup :(code_quality|test|tools) do\nend/, "")
28
29
  .replace(/org"\n+/, "org\"\n\n")
29
- Dir.chdir(realm.project_root) { runner.start %w[install --quiet] }
30
+
31
+ configuration.project_root.change_dir { client.start %w[install --quiet] }
30
32
  nil
31
33
  end
32
34
 
33
35
  private
34
36
 
35
- attr_reader :realm, :builder, :runner
37
+ attr_reader :configuration, :builder, :client
36
38
  end
37
39
  end
38
40
  end
@@ -4,26 +4,24 @@ module Rubysmith
4
4
  module Builders
5
5
  # Builds project skeleton console for object inspection and exploration.
6
6
  class Console
7
- def self.call realm, builder: Builder
8
- new(realm, builder: builder).call
9
- end
7
+ def self.call(configuration, builder: Builder) = new(configuration, builder: builder).call
10
8
 
11
- def initialize realm, builder: Builder
12
- @realm = realm
9
+ def initialize configuration, builder: Builder
10
+ @configuration = configuration
13
11
  @builder = builder
14
12
  end
15
13
 
16
14
  def call
17
- return unless realm.build_console
15
+ return unless configuration.build_console
18
16
 
19
- builder.call(realm.with(template_path: "%project_name%/bin/console.erb"))
17
+ builder.call(configuration.with(template_path: "%project_name%/bin/console.erb"))
20
18
  .render
21
19
  .permit 0o755
22
20
  end
23
21
 
24
22
  private
25
23
 
26
- attr_reader :realm, :builder
24
+ attr_reader :configuration, :builder
27
25
  end
28
26
  end
29
27
  end
@@ -4,24 +4,23 @@ module Rubysmith
4
4
  module Builders
5
5
  # Builds project skeleton core structure and minimum file support.
6
6
  class Core
7
- def self.call realm, builder: Builder
8
- new(realm, builder: builder).call
9
- end
7
+ def self.call(configuration, builder: Builder) = new(configuration, builder: builder).call
10
8
 
11
- def initialize realm, builder: Builder
12
- @realm = realm
9
+ def initialize configuration, builder: Builder
10
+ @configuration = configuration
13
11
  @builder = builder
14
12
  end
15
13
 
16
14
  def call
17
- builder.call(realm.with(template_path: "%project_name%/lib/%project_name%.rb.erb")).render
18
- builder.call(realm.with(template_path: "%project_name%/.ruby-version.erb")).render
15
+ builder.call(configuration.with(template_path: "%project_name%/lib/%project_name%.rb.erb"))
16
+ .render
17
+ builder.call(configuration.with(template_path: "%project_name%/.ruby-version.erb")).render
19
18
  nil
20
19
  end
21
20
 
22
21
  private
23
22
 
24
- attr_reader :realm, :builder
23
+ attr_reader :configuration, :builder
25
24
  end
26
25
  end
27
26
  end
@@ -4,59 +4,54 @@ module Rubysmith
4
4
  module Builders
5
5
  # Builds project skeleton documentation.
6
6
  class Documentation
7
- def self.call realm, builder: Builder
8
- new(realm, builder: builder).call
9
- end
7
+ def self.call(configuration, builder: Builder) = new(configuration, builder: builder).call
10
8
 
11
- def initialize realm, builder: Builder
12
- @realm = realm
9
+ def initialize configuration, builder: Builder
10
+ @configuration = configuration
13
11
  @builder = builder
14
12
  end
15
13
 
16
14
  def call
17
- return unless realm.build_documentation
15
+ return unless configuration.build_documentation
18
16
 
19
- private_methods.grep(/render_/).each { |method| __send__ method }
17
+ private_methods.sort.grep(/render_/).each { |method| __send__ method }
20
18
  end
21
19
 
22
20
  private
23
21
 
24
- attr_reader :realm, :builder
22
+ attr_reader :configuration, :builder
25
23
 
26
24
  def render_changes
27
- builder.call(realm.with(template_path: "%project_name%/CHANGES.#{kind}.erb"))
25
+ builder.call(configuration.with(template_path: "%project_name%/CHANGES.#{kind}.erb"))
28
26
  .render
29
27
  end
30
28
 
31
29
  def render_conduct
32
- builder.call(realm.with(template_path: "%project_name%/CODE_OF_CONDUCT.#{kind}.erb"))
33
- .render
30
+ configuration.with(template_path: "%project_name%/CODE_OF_CONDUCT.#{kind}.erb")
31
+ .then { |updated_configuration| builder.call(updated_configuration).render }
34
32
  end
35
33
 
36
34
  def render_contributions
37
- builder.call(realm.with(template_path: "%project_name%/CONTRIBUTING.#{kind}.erb"))
35
+ builder.call(configuration.with(template_path: "%project_name%/CONTRIBUTING.#{kind}.erb"))
38
36
  .render
39
37
  end
40
38
 
41
39
  def render_license
42
- builder.call(realm.with(template_path: "%project_name%/LICENSE-#{license}.#{kind}.erb"))
43
- .render
44
- .rename "LICENSE.#{kind}"
40
+ configuration.with(template_path: "%project_name%/LICENSE-#{license}.#{kind}.erb")
41
+ .then do |updated_configuration|
42
+ builder.call(updated_configuration).render.rename "LICENSE.#{kind}"
43
+ end
45
44
  end
46
45
 
47
46
  def render_readme
48
- builder.call(realm.with(template_path: "%project_name%/README.#{kind}.erb"))
47
+ builder.call(configuration.with(template_path: "%project_name%/README.#{kind}.erb"))
49
48
  .render
50
49
  .replace("\n\n\n", "\n\n")
51
50
  end
52
51
 
53
- def kind
54
- realm.documentation_format || "md"
55
- end
52
+ def kind = configuration.documentation_format || "md"
56
53
 
57
- def license
58
- realm.documentation_license || "mit"
59
- end
54
+ def license = configuration.documentation_license || "mit"
60
55
  end
61
56
  end
62
57
  end
@@ -5,19 +5,17 @@ module Rubysmith
5
5
  module Git
6
6
  # Builds project skeleton initial Git commit message.
7
7
  class Commit
8
- def self.call realm, builder: Builder
9
- new(realm, builder: builder).call
10
- end
8
+ def self.call(configuration, builder: Builder) = new(configuration, builder: builder).call
11
9
 
12
- def initialize realm, builder: Builder
13
- @realm = realm
10
+ def initialize configuration, builder: Builder
11
+ @configuration = configuration
14
12
  @builder = builder
15
13
  end
16
14
 
17
15
  def call
18
- return unless realm.build_git
16
+ return unless configuration.build_git
19
17
 
20
- builder.call(realm)
18
+ builder.call(configuration)
21
19
  .run("git add .", chdir: project_name)
22
20
  .run(
23
21
  %(git commit --all --message "Added project skeleton" --message "#{body}"),
@@ -27,7 +25,7 @@ module Rubysmith
27
25
 
28
26
  private
29
27
 
30
- attr_reader :realm, :builder
28
+ attr_reader :configuration, :builder
31
29
 
32
30
  def body
33
31
  <<~CONTENT
@@ -36,9 +34,7 @@ module Rubysmith
36
34
  CONTENT
37
35
  end
38
36
 
39
- def project_name
40
- realm.project_name
41
- end
37
+ def project_name = configuration.project_name
42
38
  end
43
39
  end
44
40
  end
@@ -5,24 +5,22 @@ module Rubysmith
5
5
  module Git
6
6
  # Initializes project skeleton as a Git repository.
7
7
  class Setup
8
- def self.call realm, builder: Builder
9
- new(realm, builder: builder).call
10
- end
8
+ def self.call(configuration, builder: Builder) = new(configuration, builder: builder).call
11
9
 
12
- def initialize realm, builder: Builder
13
- @realm = realm
10
+ def initialize configuration, builder: Builder
11
+ @configuration = configuration
14
12
  @builder = builder
15
13
  end
16
14
 
17
15
  def call
18
- return unless realm.build_git
16
+ return unless configuration.build_git
19
17
 
20
- builder.call(realm).run("git init", chdir: realm.project_name)
18
+ builder.call(configuration).run("git init", chdir: configuration.project_name)
21
19
  end
22
20
 
23
21
  private
24
22
 
25
- attr_reader :realm, :builder
23
+ attr_reader :configuration, :builder
26
24
  end
27
25
  end
28
26
  end
@@ -4,25 +4,25 @@ module Rubysmith
4
4
  module Builders
5
5
  # Builds project skeleton Guard support for a red, green, refactor loop.
6
6
  class Guard
7
- def self.call realm, builder: Builder
8
- new(realm, builder: builder).call
9
- end
7
+ def self.call(configuration, builder: Builder) = new(configuration, builder: builder).call
10
8
 
11
- def initialize realm, builder: Builder
12
- @realm = realm
9
+ def initialize configuration, builder: Builder
10
+ @configuration = configuration
13
11
  @builder = builder
14
12
  end
15
13
 
16
14
  def call
17
- return unless realm.build_guard
15
+ return unless configuration.build_guard
18
16
 
19
- builder.call(realm.with(template_path: "%project_name%/bin/guard.erb")).render.permit 0o755
20
- builder.call(realm.with(template_path: "%project_name%/Guardfile.erb")).render
17
+ builder.call(configuration.with(template_path: "%project_name%/bin/guard.erb"))
18
+ .render
19
+ .permit 0o755
20
+ builder.call(configuration.with(template_path: "%project_name%/Guardfile.erb")).render
21
21
  end
22
22
 
23
23
  private
24
24
 
25
- attr_reader :realm, :builder
25
+ attr_reader :configuration, :builder
26
26
  end
27
27
  end
28
28
  end