rubysmith 0.2.0 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 6c642fd1a721b8b3255818b19493d421a08edbe62039f64dea424c15397a7474
4
- data.tar.gz: cd67f5bed50ab0c79febb6d50f5e2903ee4df094604cf93dc6f0f463f5e64004
3
+ metadata.gz: f7265bb4446630cf2295f79355fa890b515bc277271b51bdefb0130d35fb3502
4
+ data.tar.gz: f071cc6e0299ba74bf8515391857e54641c7d7bf9509a2a601059867fa3e69b8
5
5
  SHA512:
6
- metadata.gz: 42ae38a68784b2570bf5351d7a699e98db2b3edc1262ae4a6dce60690baabe1219587ff97c6cf8ff341381817061faff077d4a32befd8e1cffc82545379f3a72
7
- data.tar.gz: 5c2d97efa35f0a9c9bdfb4affc417fbef45af8d17fc9cd4bf3a1546ef4dbd3520736ef53bff67bfb465c836162f5195634b7ce8db2004964cc5b1c3237192350
6
+ metadata.gz: 7c3f3db7a06f7388fef2df0b4bf4df08d0b0baffd98e3bef05a9b3fc5e1cf3d21037f0cdef2b13b9cb4db0179c64c21ddfbe519fadb7f0003442a0c4b9a62296
7
+ data.tar.gz: 0d6a18e00d270fc3d520cfd1799c233e95a78340334f27788cb2ca876bd92c448e6c483da57a3312cc6e5735a38d0feec499adfdb2c872f4fb3466c0ae853e6a
Binary file
data.tar.gz.sig CHANGED
Binary file
@@ -56,8 +56,6 @@ toc::[]
56
56
 
57
57
  == Setup
58
58
 
59
- === Production
60
-
61
59
  To install, run:
62
60
 
63
61
  [source,bash]
@@ -65,24 +63,6 @@ To install, run:
65
63
  gem install rubysmith
66
64
  ----
67
65
 
68
- === Development
69
-
70
- To contribute, run:
71
-
72
- [source,bash]
73
- ----
74
- git clone https://github.com/bkuhlmann/rubysmith.git
75
- cd rubysmith
76
- bin/setup
77
- ----
78
-
79
- You can also use the IRB console for direct access to all objects:
80
-
81
- [source,bash]
82
- ----
83
- bin/console
84
- ----
85
-
86
66
  == Usage
87
67
 
88
68
  === Command Line Interface (CLI)
@@ -91,15 +71,12 @@ From the command line, type: `rubysmith --help`
91
71
 
92
72
  ....
93
73
  USAGE:
94
- -c, --config ACTION Manage gem configuration: edit or view.
95
- -b, --build NAME [options] Build new gem.
96
74
  -v, --version Show gem version.
97
75
  -h, --help Show this message.
76
+ -c, --config ACTION Manage gem configuration: edit or view.
77
+ -b, --build NAME [options] Build new project.
98
78
 
99
79
  BUILD OPTIONS:
100
- --[no-]bundler-audit Add Bundler Audit.
101
- --[no-]console Add console script.
102
- --[no-]documentation Add documentation.
103
80
  --[no-]git Add Git.
104
81
  --[no-]git-lint Add Git Lint.
105
82
  --[no-]guard Add Guard.
@@ -109,6 +86,10 @@ BUILD OPTIONS:
109
86
  --[no-]rubocop Add Rubocop.
110
87
  --[no-]setup Add setup script.
111
88
  --[no-]simple_cov Add SimpleCov.
89
+ --min Use minimum/no options.
90
+ --[no-]bundler-audit Add Bundler Audit.
91
+ --[no-]console Add console script.
92
+ --[no-]documentation Add documentation.
112
93
  ....
113
94
 
114
95
  === Building
@@ -122,16 +103,28 @@ rubysmith --build demo
122
103
  ----
123
104
 
124
105
  Running the above will generate a new `demo` Ruby project with all options enabled. Should you wish
125
- to disable certain options when building projects, you can prefix options with `--no-*`. Example:
106
+ to disable specific options, you can use the `--no-*` prefix. Example:
126
107
 
127
108
  [source,bash]
128
109
  ----
129
110
  rubysmith --build demo --no-pry --no-guard
130
111
  ----
131
112
 
132
- Should you wish to have certain options enabled/disabled _every time_ you build a new Ruby project,
133
- then you can edit your global configuration for making these settings permanent (see below for
134
- details).
113
+ With the above example, both Pry and Guard support would have been disabled when building the `demo`
114
+ project. Taking this a step further, you can also use the `--min` option to generate a project with
115
+ bare minimum of options. Example:
116
+
117
+ [source,bash]
118
+ ----
119
+ rubysmith --build demo --min
120
+ ----
121
+
122
+ The above is essentially the same as building with _all_ options disabled. This is handy in
123
+ situations where you need to quickly script something up for sharing with others yet still want to
124
+ avoid using a Bundler Inline script so gem dependencies are not installed each time the code is run.
125
+
126
+ To have specific options enabled/disabled _every time_ you build a new Ruby project, you can edit
127
+ your global configuration for making these settings permanent (see below for details).
135
128
 
136
129
  === Configuration
137
130
 
@@ -162,6 +155,7 @@ The default configuration is as follows:
162
155
  :git: true
163
156
  :git_lint: true
164
157
  :guard: true
158
+ :minimum: false
165
159
  :pry: true
166
160
  :reek: true
167
161
  :rspec: true
@@ -185,6 +179,24 @@ The default configuration is as follows:
185
179
  Feel free to take this default configuration, modify, and save as your own custom
186
180
  `configuration.yml`.
187
181
 
182
+ == Development
183
+
184
+ To contribute, run:
185
+
186
+ [source,bash]
187
+ ----
188
+ git clone https://github.com/bkuhlmann/rubysmith.git
189
+ cd rubysmith
190
+ bin/setup
191
+ ----
192
+
193
+ You can also use the IRB console for direct access to all objects:
194
+
195
+ [source,bash]
196
+ ----
197
+ bin/console
198
+ ----
199
+
188
200
  == Tests
189
201
 
190
202
  To test, run:
@@ -20,8 +20,11 @@ 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")
23
+ .replace(/\n\s*group/, "\n\ngroup")
24
24
  .replace(/\n\s*gem/, "\n gem")
25
+ .replace(/\s{4}\n/, "")
26
+ .replace(" end", "end")
27
+ .replace(/\n{1,}\Z/, "\n")
25
28
  Dir.chdir(realm.project_root) { runner.start %w[install --quiet] }
26
29
  nil
27
30
  end
@@ -1,12 +1,14 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require "rubocop"
4
- require "stringio"
4
+ require "refinements/ios"
5
5
 
6
6
  module Rubysmith
7
7
  module Builders
8
8
  # Builds project skeleton Rubocop code quality support.
9
9
  class Rubocop
10
+ using Refinements::IOs
11
+
10
12
  def self.call realm, builder: Builder
11
13
  new(realm, builder: builder).call
12
14
  end
@@ -33,10 +35,7 @@ module Rubysmith
33
35
  attr_reader :realm, :builder, :runner
34
36
 
35
37
  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
38
+ STDOUT.squelch { runner.run ["--auto-correct", realm.project_root.to_s] }
40
39
  end
41
40
  end
42
41
  end
@@ -14,6 +14,7 @@
14
14
  :git: true
15
15
  :git_lint: true
16
16
  :guard: true
17
+ :minimum: false
17
18
  :pry: true
18
19
  :reek: true
19
20
  :rspec: true
@@ -24,6 +24,12 @@ module Rubysmith
24
24
 
25
25
  attr_reader :client, :options
26
26
 
27
+ def add_minimum
28
+ client.on "--min", "Use minimum/no options." do |value|
29
+ options[:build_minimum] = value
30
+ end
31
+ end
32
+
27
33
  def add_bundler_audit
28
34
  client.on "--[no-]bundler-audit", "Add Bundler Audit." do |value|
29
35
  options[:build_bundler_audit] = value
@@ -3,27 +3,34 @@
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
+ ].freeze
14
+
15
+ # Order is important.
16
+ MAXIMUM = [
17
+ Builders::Core,
18
+ Builders::Documentation,
19
+ Builders::Git::Setup,
20
+ Builders::Bundler,
21
+ Builders::Rake,
22
+ Builders::Console,
23
+ Builders::Setup,
24
+ Builders::Guard,
25
+ Builders::Reek,
26
+ Builders::RSpec::Context,
27
+ Builders::RSpec::Helper,
28
+ Builders::Pragma,
29
+ Builders::Rubocop,
30
+ Builders::Git::Commit
31
+ ].freeze
32
+
33
+ def initialize builders: MAXIMUM
27
34
  @builders = builders
28
35
  end
29
36
 
@@ -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.new(builders: Processors::Build::MINIMUM),
15
+ build_maximum: Processors::Build.new
15
16
  }.freeze
16
17
 
17
18
  def initialize parser: Parsers::Assembler.new, processors: PROCESSORS
@@ -22,13 +23,16 @@ module Rubysmith
22
23
  def call arguments = []
23
24
  parse arguments
24
25
 
26
+ # rubocop:disable Style/MethodCallWithArgsParentheses
25
27
  case options
26
28
  in config: action, **remainder then config action
27
- in build:, **remainder then build options.rekey(build: :project_name).merge now: Time.now
29
+ in build_minimum: true, **remainder then build(:build_minimum, options)
30
+ in build:, **remainder then build(:build_maximum, options)
28
31
  in version:, **remainder then puts version
29
32
  in help:, **remainder then usage
30
33
  else usage
31
34
  end
35
+ # rubocop:enable Style/MethodCallWithArgsParentheses
32
36
  end
33
37
 
34
38
  private
@@ -45,8 +49,8 @@ module Rubysmith
45
49
  processors.fetch(__method__).call action
46
50
  end
47
51
 
48
- def build settings
49
- processors.fetch(__method__).call settings
52
+ def build kind, settings
53
+ processors.fetch(kind).call settings.rekey(build: :project_name).merge(now: Time.now)
50
54
  end
51
55
 
52
56
  def options
@@ -4,7 +4,7 @@ module Rubysmith
4
4
  module Identity
5
5
  NAME = "rubysmith"
6
6
  LABEL = "Rubysmith"
7
- VERSION = "0.2.0"
7
+ VERSION = "0.3.0"
8
8
  VERSION_LABEL = "#{LABEL} #{VERSION}"
9
9
  SUMMARY = "A command line interface for smithing Ruby projects."
10
10
  end
@@ -16,6 +16,7 @@ module Rubysmith
16
16
  now
17
17
  documentation_format
18
18
  documentation_license
19
+ build_minimum
19
20
  build_bundler_audit
20
21
  build_console
21
22
  build_documentation
@@ -1,33 +1,35 @@
1
1
  source "https://rubygems.org"
2
2
 
3
- group :development do
4
- <% if realm.build_bundler_audit %>
5
- gem "bundler-audit", "~> 0.7"
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
3
+ <% unless realm.build_minimum %>
4
+ group :development do
5
+ <% if realm.build_bundler_audit %>
6
+ gem "bundler-audit", "~> 0.7"
7
+ <% end %>
8
+ <% if realm.build_git && realm.build_git_lint %>
9
+ gem "git-lint", "~> 1.0"
10
+ <% end %>
11
+ <% if realm.build_guard %>
12
+ gem "guard-rspec", "~> 4.7"
13
+ <% end %>
14
+ <% if realm.build_pry %>
15
+ gem "pry", "~> 0.13"
16
+ gem "pry-byebug", "~> 3.9"
17
+ <% end %>
18
+ gem "rake", "~> 13.0"
19
+ <% if realm.build_reek %>
20
+ gem "reek", "~> 6.0"
21
+ <% end %>
22
+ <% if realm.build_rspec %>
23
+ gem "rspec", "~> 3.9"
24
+ <% end %>
25
+ <% if realm.build_rubocop %>
26
+ gem "rubocop", "~> 0.92"
27
+ gem "rubocop-performance", "~> 1.8"
28
+ gem "rubocop-rake", "~> 0.5"
29
+ gem "rubocop-rspec", "~> 1.43"
30
+ <% end %>
31
+ <% if realm.build_simple_cov %>
32
+ gem "simplecov", "~> 0.19"
33
+ <% end %>
34
+ end
35
+ <% end %>
@@ -26,11 +26,11 @@ bin/setup
26
26
  <% end %>
27
27
 
28
28
  == Usage
29
- <% if realm.build_console %>
30
29
 
31
- === Console
30
+ == Development
31
+ <% if realm.build_console %>
32
32
 
33
- To use the IRB console to invesitage and/or experiment with all project objects, run:
33
+ You can also use the IRB console for direct access to all objects:
34
34
 
35
35
  [source,bash]
36
36
  ----
@@ -20,11 +20,11 @@ To set up the project, run:
20
20
  <% end %>
21
21
 
22
22
  ## Usage
23
- <% if realm.build_console %>
24
23
 
25
- ### Console
24
+ ## Development
25
+ <% if realm.build_console %>
26
26
 
27
- To use the IRB console to invesitage and/or experiment with all project objects, run:
27
+ You can also use the IRB console for direct access to all objects:
28
28
 
29
29
  bin/console
30
30
  <% 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.2.0
4
+ version: 0.3.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-10-04 00:00:00.000000000 Z
31
+ date: 2020-10-18 00:00:00.000000000 Z
32
32
  dependencies:
33
33
  - !ruby/object:Gem::Dependency
34
34
  name: pragmater
@@ -50,14 +50,14 @@ dependencies:
50
50
  requirements:
51
51
  - - "~>"
52
52
  - !ruby/object:Gem::Version
53
- version: '7.10'
53
+ version: '7.11'
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.11'
61
61
  - !ruby/object:Gem::Dependency
62
62
  name: rubocop
63
63
  requirement: !ruby/object:Gem::Requirement
metadata.gz.sig CHANGED
Binary file