rubysmith 0.9.1 → 0.10.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (57) hide show
  1. checksums.yaml +4 -4
  2. checksums.yaml.gz.sig +0 -0
  3. data.tar.gz.sig +0 -0
  4. data/bin/rubysmith +0 -1
  5. data/lib/rubysmith.rb +3 -2
  6. data/lib/rubysmith/builder.rb +13 -26
  7. data/lib/rubysmith/builders/bundler.rb +6 -8
  8. data/lib/rubysmith/builders/console.rb +6 -8
  9. data/lib/rubysmith/builders/core.rb +7 -8
  10. data/lib/rubysmith/builders/documentation.rb +16 -21
  11. data/lib/rubysmith/builders/git/commit.rb +7 -11
  12. data/lib/rubysmith/builders/git/setup.rb +6 -8
  13. data/lib/rubysmith/builders/guard.rb +9 -9
  14. data/lib/rubysmith/builders/pragma.rb +8 -13
  15. data/lib/rubysmith/builders/rake.rb +5 -7
  16. data/lib/rubysmith/builders/reek.rb +6 -8
  17. data/lib/rubysmith/builders/rspec/context.rb +10 -11
  18. data/lib/rubysmith/builders/rspec/helper.rb +6 -8
  19. data/lib/rubysmith/builders/rubocop/formatter.rb +5 -7
  20. data/lib/rubysmith/builders/rubocop/setup.rb +7 -9
  21. data/lib/rubysmith/builders/ruby_critic.rb +6 -8
  22. data/lib/rubysmith/builders/setup.rb +8 -8
  23. data/lib/rubysmith/cli/configuration/content.rb +69 -0
  24. data/lib/rubysmith/cli/{defaults.yml → configuration/defaults.yml} +0 -0
  25. data/lib/rubysmith/cli/configuration/loader.rb +35 -0
  26. data/lib/rubysmith/cli/parsers.rb +11 -0
  27. data/lib/rubysmith/cli/parsers/assembler.rb +10 -15
  28. data/lib/rubysmith/cli/parsers/build.rb +4 -6
  29. data/lib/rubysmith/cli/parsers/core.rb +5 -9
  30. data/lib/rubysmith/cli/processors/build.rb +9 -8
  31. data/lib/rubysmith/cli/processors/config.rb +3 -7
  32. data/lib/rubysmith/cli/shell.rb +7 -14
  33. data/lib/rubysmith/identity.rb +1 -1
  34. data/lib/rubysmith/pathway.rb +3 -9
  35. data/lib/rubysmith/renderers/erb.rb +7 -9
  36. data/lib/rubysmith/renderers/namespace.rb +1 -3
  37. data/lib/rubysmith/templates/%project_name%/.rubocop.yml.erb +1 -1
  38. data/lib/rubysmith/templates/%project_name%/CHANGES.adoc.erb +1 -1
  39. data/lib/rubysmith/templates/%project_name%/CHANGES.md.erb +1 -1
  40. data/lib/rubysmith/templates/%project_name%/CODE_OF_CONDUCT.adoc.erb +2 -2
  41. data/lib/rubysmith/templates/%project_name%/CODE_OF_CONDUCT.md.erb +1 -1
  42. data/lib/rubysmith/templates/%project_name%/Gemfile.erb +14 -14
  43. data/lib/rubysmith/templates/%project_name%/LICENSE-apache.adoc.erb +1 -1
  44. data/lib/rubysmith/templates/%project_name%/LICENSE-apache.md.erb +1 -1
  45. data/lib/rubysmith/templates/%project_name%/LICENSE-mit.adoc.erb +1 -1
  46. data/lib/rubysmith/templates/%project_name%/LICENSE-mit.md.erb +1 -1
  47. data/lib/rubysmith/templates/%project_name%/README.adoc.erb +5 -5
  48. data/lib/rubysmith/templates/%project_name%/README.md.erb +5 -5
  49. data/lib/rubysmith/templates/%project_name%/Rakefile.erb +15 -15
  50. data/lib/rubysmith/templates/%project_name%/bin/console.erb +1 -1
  51. data/lib/rubysmith/templates/%project_name%/lib/%project_name%.rb.erb +1 -1
  52. data/lib/rubysmith/templates/%project_name%/spec/spec_helper.rb.erb +6 -4
  53. data/lib/rubysmith/templates/%project_name%/spec/support/shared_contexts/temp_dir.rb.erb +3 -3
  54. metadata +7 -6
  55. metadata.gz.sig +0 -0
  56. data/lib/rubysmith/cli/configuration.rb +0 -30
  57. data/lib/rubysmith/realm.rb +0 -74
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: fc61b29f7631893021128bf858b1c47354185e7b14785b21d7efa6a3af8f96c4
4
- data.tar.gz: 1592e203b7d83a3a212611b01a968794d75dd463eaf786761733ba021f133d4b
3
+ metadata.gz: c99851111508a1453340fd292981281260eb2b197e1c3685fd40207078cfeee5
4
+ data.tar.gz: e5781a5bf2f57c8129b1049ac817abdb60a2a2548f7a52fcbd29596587f4701c
5
5
  SHA512:
6
- metadata.gz: f2e10c908b918b136141151257730dc990863e6cebb86f5d8475995d858cabdc89e0350d21903246fde8ec0d58b1013feae96b2cac7db06de151d3936d744569
7
- data.tar.gz: d656ebff7d7de45f21cceb610718bfb81cb796647fc325677075dcf6ea5ae2e7b348b770ec217c8b548096f1645a8dd40156d3a9b848b19044f93277e1f284a4
6
+ metadata.gz: 9dcbcf78f012f5fc4eb2409bd7d69ecb42e6033df93a227c510226621d56f8d291458c5528c33bf89673bf81f9849017a003fb8a8fdab649f706c725af862ffe
7
+ data.tar.gz: f6f050ce4b479505bbdff25a34a880e8ce72afc48524c283692f34d255686dd4eab037b365019b4fbd83fce9dccce9e1394ea1b47295908b0c29d7d27db56c55
checksums.yaml.gz.sig CHANGED
Binary file
data.tar.gz.sig CHANGED
Binary file
data/bin/rubysmith CHANGED
@@ -2,7 +2,6 @@
2
2
  # frozen_string_literal: true
3
3
 
4
4
  require "rubysmith"
5
- require "rubysmith/cli/shell"
6
5
 
7
6
  Process.setproctitle Rubysmith::Identity::VERSION_LABEL
8
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"
@@ -23,10 +22,12 @@ require "rubysmith/builders/pragma"
23
22
  require "rubysmith/builders/rubocop/setup"
24
23
  require "rubysmith/builders/rubocop/formatter"
25
24
  require "rubysmith/builders/ruby_critic"
25
+ require "rubysmith/cli/configuration/content"
26
+ require "rubysmith/cli/configuration/loader"
27
+ require "rubysmith/cli/parsers"
26
28
  require "rubysmith/cli/parsers/core"
27
29
  require "rubysmith/cli/parsers/build"
28
30
  require "rubysmith/cli/parsers/assembler"
29
31
  require "rubysmith/cli/processors/config"
30
32
  require "rubysmith/cli/processors/build"
31
- require "rubysmith/cli/configuration"
32
33
  require "rubysmith/cli/shell"
@@ -6,7 +6,7 @@ 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
 
@@ -19,12 +19,12 @@ module Rubysmith
19
19
  logger: LOGGER
20
20
  }.freeze
21
21
 
22
- def self.call realm, helpers: HELPERS
23
- new realm, helpers: helpers
22
+ def self.call configuration, helpers: HELPERS
23
+ new configuration, helpers: helpers
24
24
  end
25
25
 
26
- def initialize realm, helpers: HELPERS
27
- @realm = realm
26
+ def initialize configuration, helpers: HELPERS
27
+ @configuration = configuration
28
28
  @helpers = helpers
29
29
  end
30
30
 
@@ -102,7 +102,7 @@ module Rubysmith
102
102
 
103
103
  private
104
104
 
105
- attr_reader :realm, :helpers
105
+ attr_reader :configuration, :helpers
106
106
 
107
107
  def execute *command
108
108
  kernel.capture2e(*command).then do |result, status|
@@ -110,33 +110,20 @@ module Rubysmith
110
110
  end
111
111
  end
112
112
 
113
- def inserter
114
- helpers.fetch __method__
115
- end
113
+ def inserter = helpers.fetch(__method__)
116
114
 
117
- def renderer
118
- helpers.fetch(__method__).new realm
119
- end
115
+ def renderer = helpers.fetch(__method__).new(configuration)
120
116
 
121
- def kernel
122
- helpers.fetch __method__
123
- end
117
+ def kernel = helpers.fetch(__method__)
124
118
 
125
- def logger
126
- helpers.fetch __method__
127
- end
119
+ def logger = helpers.fetch(__method__)
128
120
 
129
- def relative_build_path
130
- build_path.relative_path_from realm.build_root
131
- end
121
+ def relative_build_path = build_path.relative_path_from(configuration.build_root)
132
122
 
133
123
  def build_path
134
- pathway.end_path.gsub("%project_name%", realm.project_name).sub(".erb", "")
124
+ pathway.end_path.gsub("%project_name%", configuration.project_name).sub ".erb", ""
135
125
  end
136
126
 
137
- def pathway
138
- realm.to_pathway
139
- end
127
+ def pathway = configuration.to_pathway
140
128
  end
141
- # rubocop:enable Metrics/ClassLength
142
129
  end
@@ -10,18 +10,16 @@ module Rubysmith
10
10
  class Bundler
11
11
  using Refinements::Pathnames
12
12
 
13
- def self.call realm, builder: Builder
14
- new(realm, builder: builder).call
15
- end
13
+ def self.call(configuration, builder: Builder) = new(configuration, builder: builder).call
16
14
 
17
- def initialize realm, builder: Builder, client: ::Bundler::CLI
18
- @realm = realm
15
+ def initialize configuration, builder: Builder, client: ::Bundler::CLI
16
+ @configuration = configuration
19
17
  @builder = builder
20
18
  @client = client
21
19
  end
22
20
 
23
21
  def call
24
- builder.call(realm.with(template_path: "%project_name%/Gemfile.erb"))
22
+ builder.call(configuration.with(template_path: "%project_name%/Gemfile.erb"))
25
23
  .render
26
24
  .replace(/\n\s+group/, "\n\ngroup")
27
25
  .replace(/\n\s+gem/, "\n gem")
@@ -30,13 +28,13 @@ module Rubysmith
30
28
  .replace(/\n\ngroup :(code_quality|test|tools) do\nend/, "")
31
29
  .replace(/org"\n+/, "org\"\n\n")
32
30
 
33
- realm.project_root.change_dir { client.start %w[install --quiet] }
31
+ configuration.project_root.change_dir { client.start %w[install --quiet] }
34
32
  nil
35
33
  end
36
34
 
37
35
  private
38
36
 
39
- attr_reader :realm, :builder, :client
37
+ attr_reader :configuration, :builder, :client
40
38
  end
41
39
  end
42
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
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
@@ -6,30 +6,25 @@ module Rubysmith
6
6
  module Builders
7
7
  # Builds project skeleton pragmas so all Ruby strings are frozen by default.
8
8
  class Pragma
9
- def self.call realm
10
- new(realm).call
11
- end
9
+ def self.call(configuration) = new(configuration).call
12
10
 
13
- def initialize realm, client: Pragmater::Runner
14
- @realm = realm
11
+ def initialize configuration, client: Pragmater::Runner
12
+ @configuration = configuration
15
13
  @client = client
16
14
  end
17
15
 
18
- def call
19
- client.for(**attributes).call
20
- nil
21
- end
16
+ def call = client.for(**attributes).call && nil
22
17
 
23
18
  private
24
19
 
25
- attr_reader :realm, :client
20
+ attr_reader :configuration, :client
26
21
 
27
22
  def attributes
28
23
  {
29
24
  action: :insert,
30
- root_dir: realm.project_root,
31
- comments: realm.builders_pragmater_comments,
32
- includes: realm.builders_pragmater_includes
25
+ root_dir: configuration.project_root,
26
+ comments: configuration.builders_pragmater_comments,
27
+ includes: configuration.builders_pragmater_includes
33
28
  }
34
29
  end
35
30
  end