nugem 0.8.3 → 0.9.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 (35) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +6 -3
  3. data/CHANGELOG.md +21 -0
  4. data/README.md +28 -17
  5. data/exe/nugem +5 -1
  6. data/lib/nugem/cli/cli_gem.rb +12 -11
  7. data/lib/nugem/cli/cli_jekyll.rb +23 -19
  8. data/lib/nugem/cli/cli_rails.rb +4 -3
  9. data/lib/nugem/cli.rb +19 -12
  10. data/lib/nugem/git.rb +6 -5
  11. data/lib/nugem/repository.rb +4 -3
  12. data/lib/nugem/version.rb +1 -1
  13. data/lib/nugem.rb +4 -2
  14. data/lib/util.rb +1 -1
  15. data/nugem.gemspec +22 -12
  16. data/spec/spec_helper.rb +1 -4
  17. data/templates/common/executable_scaffold/exe/%gem_name%.tt +2 -2
  18. data/templates/common/executable_scaffold/lib/%gem_name%/cli.rb.tt +17 -9
  19. data/templates/common/executable_scaffold/lib/%gem_name%/options.rb.tt +31 -0
  20. data/templates/common/gem_scaffold/%gem_name%.gemspec.tt +4 -3
  21. data/templates/common/gem_scaffold/.rspec +0 -2
  22. data/templates/common/gem_scaffold/.rubocop.yml.tt +1 -3
  23. data/templates/common/gem_scaffold/.vscode/launch.json +39 -2
  24. data/templates/common/gem_scaffold/Gemfile.tt +7 -5
  25. data/templates/jekyll/block_no_arg_scaffold/lib/%block_name%.rb.tt +1 -1
  26. data/templates/jekyll/block_scaffold/lib/%block_name%.rb.tt +32 -10
  27. data/templates/jekyll/demo/demo/_bin/debug +7 -16
  28. data/templates/jekyll/demo/demo/_layouts/default.html.tt +1 -1
  29. data/templates/jekyll/hooks_scaffold/lib/dumpers.rb +1 -1
  30. data/templates/jekyll/tag_no_arg_scaffold/lib/%tag_name%.rb.tt +1 -1
  31. data/templates/jekyll/tag_scaffold/lib/%tag_name%.rb.tt +38 -11
  32. data/templates/rails/plugin_scaffold/test/dummy/bin/setup +1 -1
  33. data/templates/rails/rails_scaffold/test/dummy/bin/setup +1 -1
  34. metadata +10 -8
  35. data/spec/status_persistence.txt +0 -0
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 86b9aac101ead8ba12ce81706c0f64f37ed979fa470d424083a8de6ae9635e5f
4
- data.tar.gz: 7f470f94df11340de30b1cba0e1d45b335b32f222fd823b676920a22ddff950e
3
+ metadata.gz: 4c209ec58ac03b1b550972ec5abe2fc6f3846b59dec92b9d8f84f1aedd6f1405
4
+ data.tar.gz: 525e8795a8b7b4217c0f92f2fc3c08084503f09e776f6e155c52a23afe8074f0
5
5
  SHA512:
6
- metadata.gz: 8ce715d8f39c3403b7febcec8d381b5de2d2792822cc408acc6fcb721e761249571da1db40dd9f19574eb24a899307590ee3d71663456752fb3ae33553616b06
7
- data.tar.gz: 987bee354b52ef35372251fcf68271cef7fef3c9e3e7e9f9b2ede36eb0049bdc3520e68b01e79d19dae54aab3757ebd21e881f27ee55075f3f3dc43e5fda2e0b
6
+ metadata.gz: 915b02fdcc9176e48ffd0ea85147545140fe5407c3da1a27fb22c02522252de88427b4d0aa4155bafa03214b494bf171778187f4d4745ad952c5d082cd7331c6
7
+ data.tar.gz: 1b036270d8ba39dbcc9ddf4b8188feb5a5c50c17761fb58c999c461bba369452a838b5b48a0aac451675ab12ec607d4a648facfd3a8eaabfe37dac9ba4dee0ff
data/.rubocop.yml CHANGED
@@ -23,6 +23,9 @@ Gemspec/DeprecatedAttributeAssignment:
23
23
  Gemspec/RequireMFA:
24
24
  Enabled: false
25
25
 
26
+ Gemspec/RequiredRubyVersion:
27
+ Enabled: false
28
+
26
29
  Layout/ArgumentAlignment:
27
30
  EnforcedStyle: with_first_argument
28
31
 
@@ -37,7 +40,8 @@ Layout/MultilineMethodCallIndentation:
37
40
  EnforcedStyle: indented_relative_to_receiver
38
41
 
39
42
  Metrics/AbcSize:
40
- Max: 45
43
+ Enabled: false
44
+ Max: 50
41
45
 
42
46
  Metrics/BlockLength:
43
47
  Exclude:
@@ -79,9 +83,8 @@ Style/TrailingCommaInHashLiteral:
79
83
  Style/TrailingCommaInArrayLiteral:
80
84
  EnforcedStyleForMultiline: comma
81
85
 
82
- RSpec/FilePath:
86
+ RSpec/SpecFilePathFormat:
83
87
  IgnoreMethods: true
84
- SpecSuffixOnly: true
85
88
 
86
89
  RSpec/ExampleLength:
87
90
  Enabled: false
data/CHANGELOG.md CHANGED
@@ -1,5 +1,26 @@
1
1
  # Change Log
2
2
 
3
+ ## 0.9.0
4
+
5
+ * Added `OptionParser` starter for gems in `templates/common/executable_scaffold/lib/%gem_name%/options.rb.tt`.
6
+ * Renamed 'plain' to 'gem'
7
+ * Reorganized generated gem files so they all enhance the same module
8
+ * All generated Ruby files are included on startup
9
+ * Rails apps are deprecated, will be removed soon
10
+
11
+
12
+ ## 0.8.5
13
+
14
+ * Added `-y` option to suppress confirmation messages and default to `yes`.
15
+ * Suppresses the huge chunk of JSON that used to be displayed after the remote repository was created.
16
+
17
+
18
+ ## 0.8.4
19
+
20
+ * Added `-o` option for specifying output directory
21
+ * Added aliases for class options
22
+
23
+
3
24
  ## 0.8.3
4
25
 
5
26
  * Added more files to generated projects.
data/README.md CHANGED
@@ -17,6 +17,9 @@ This gem generates a new working Visual Studio Code project with the following f
17
17
  - Can automatically create a public or private git repository on GitHub for your new gem.
18
18
  - Creates a test infrastructure based on `rspec`.
19
19
  - Your gem can be publicly released to `rubygems.org`.
20
+ - Optionally create the gem as:
21
+ - A plain old gem.
22
+ - A Jekyll plugin (tag or block tag).
20
23
 
21
24
  The following features are still in development, so they probably do not work yet:
22
25
 
@@ -25,8 +28,8 @@ The following features are still in development, so they probably do not work ye
25
28
  - Your gem can be privately released to a Geminabox gem server.
26
29
  - Your gem can include a [Thor-based executable](https://github.com/rails/thor).
27
30
  - Optionally create the gem as:
31
+ - A Jekyll plugin (filter, generator, or hooks).
28
32
  - A Rails plugin, possibly with a mountable engine.
29
- - A Jekyll plugin (tag, block tag, filter, generator, or hooks).
30
33
 
31
34
 
32
35
  ## Installation
@@ -50,8 +53,9 @@ $ gem update nugem
50
53
 
51
54
  ## Subcommands and Options
52
55
 
53
- `Nugem` has 4 subcommands `plain`, `jekyll`, `help` and `rails`.
54
- Currently, only `plain` and `help` have been properly tested.
56
+ `Nugem` has 4 subcommands `gem`, `jekyll`, `help` and `rails`.
57
+ Currently, only `gem`, `jekyll` and `help` have been properly tested.
58
+
55
59
 
56
60
  ### `help` Subcommand
57
61
 
@@ -70,7 +74,7 @@ $ nugem help [SUBCOMMAND]
70
74
 
71
75
  ### Common Options
72
76
 
73
- The `plain`, `jekyll` and `rails` subcommands have common options.
77
+ The `gem`, `jekyll` and `rails` subcommands have common options.
74
78
 
75
79
  The default option values assume that:
76
80
 
@@ -78,7 +82,7 @@ The default option values assume that:
78
82
  - The gem project will be hosted on a public GitHub git repository
79
83
  - The gem will be released to `rubygems.org`
80
84
 
81
- Common options for the `plain`, `jekyll` and `rails` subcommands are:
85
+ Common options for the `gem`, `jekyll` and `rails` subcommands are:
82
86
 
83
87
  <dl>
84
88
  <dt><code>--executable</code></dt>
@@ -90,6 +94,12 @@ Common options for the `plain`, `jekyll` and `rails` subcommands are:
90
94
  <code>github</code> and <code>geminabox</code>.
91
95
  </dd>
92
96
 
97
+ <dt><code>--out_dir</code></dt>
98
+ <dd>
99
+ specifies the directory to write the generated gem to.
100
+ The default is <code>generated/</code>.
101
+ </dd>
102
+
93
103
  <dt><code>--private</code></dt>
94
104
  <dd>the remote repository is made private,
95
105
  and on release the gem will be pushed to a private Geminabox server.
@@ -105,7 +115,7 @@ Common options for the `plain`, `jekyll` and `rails` subcommands are:
105
115
 
106
116
  ### Common Behavior
107
117
 
108
- The `plain`, `jekyll` and `rails` subcommands have common behavior.
118
+ The `gem`, `jekyll` and `rails` subcommands have common behavior.
109
119
 
110
120
  Gem scaffolds are created within the `generated/` directory of the current directory.
111
121
 
@@ -118,25 +128,25 @@ Then commit the changes to git and invoke `rake release`,
118
128
  and your gem will be published.
119
129
 
120
130
 
121
- ### `plain` Subcommand
131
+ ### `gem` Subcommand
122
132
 
123
133
  ```shell
124
- $ nugem plain NAME [COMMON_OPTIONS] [--test-framework=minitest|rspec]
134
+ $ nugem gem NAME [COMMON_OPTIONS] [--test-framework=minitest|rspec]
125
135
  ```
126
136
 
127
137
  `NAME` is the name of the gem to be generated.
128
138
 
129
- The default test framework for the `plain` subcommand is `rspec`,
139
+ The default test framework for the `gem` subcommand is `rspec`,
130
140
  but you can specify `minitest` instead like this:
131
141
 
132
142
  ```shell
133
- $ nugem plain my_gem --test-framework=minitest
143
+ $ nugem gem my_gem --test-framework=minitest
134
144
  ```
135
145
 
136
146
 
137
147
  ### `jekyll` Subcommand
138
148
 
139
- The `jekyll` subcommand extends the `plain` subcommand and creates a new Jekyll plugin with the given NAME:
149
+ The `jekyll` subcommand extends the `gem` subcommand and creates a new Jekyll plugin with the given NAME:
140
150
 
141
151
  ```shell
142
152
  $ nugem jekyll NAME [OPTIONS]
@@ -148,12 +158,13 @@ In addition to the common options, the `jekyll`-specific `OPTIONS` are:
148
158
 
149
159
  `--block`, `--blockn`, `--filter`, `--hooks`, `--tag`, and `--tagn`.
150
160
 
161
+ (Warning: only `--block` and `--tag` been properly tested.)
162
+
151
163
  Each of these options causes `nugem` to prompt the user for additional input.
152
164
 
153
165
  The test framework for `jekyll` plugins is `rspec`.
154
166
 
155
- All of the above options can be specified more than once,
156
- except the `--hooks` option.
167
+ All of the above options can be specified more than once, except the `--hooks` option.
157
168
  For example:
158
169
 
159
170
  ```shell
@@ -171,7 +182,7 @@ my_tag2 usage: {% my_tag2 %}
171
182
  </pre>
172
183
  ```
173
184
 
174
- For more information, type
185
+ For more information, type:
175
186
 
176
187
  ```shell
177
188
  $ nugem help jekyll
@@ -180,7 +191,7 @@ $ nugem help jekyll
180
191
 
181
192
  ### `rails` Subcommand
182
193
 
183
- The `rails` subcommand extends the `plain` subcommand and creates a new Rails plugin with the given NAME:
194
+ The `rails` subcommand extends the `gem` subcommand and creates a new Rails plugin with the given NAME:
184
195
 
185
196
  ```shell
186
197
  $ nugem rails NAME [OPTIONS]
@@ -197,7 +208,7 @@ Each of these options causes `nugem` to prompt the user for additional input.
197
208
 
198
209
  The test framework for `rails` gems is `minitest`.
199
210
 
200
- For more information, type
211
+ For more information, type:
201
212
 
202
213
  ```shell
203
214
  $ nugem help rails
@@ -306,7 +317,7 @@ After checking out the repository, run `bin/setup` to install dependencies.
306
317
  Then, run `rake test` to run the tests.
307
318
  You can also run `bin/console` for an interactive prompt that will allow you to experiment.
308
319
 
309
- To install this gem onto your local machine, run
320
+ To install this gem onto your local machine, run:
310
321
 
311
322
  ```shell
312
323
  $ bundle exec rake install
data/exe/nugem CHANGED
@@ -1,5 +1,9 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
- require 'nugem'
3
+ if ENV['VO_DEBUGGING']
4
+ require_relative '../lib/nugem'
5
+ else
6
+ require 'nugem'
7
+ end
4
8
 
5
9
  Nugem::Cli.start
@@ -4,10 +4,10 @@ module Nugem
4
4
  class Cli < Thor
5
5
  include Thor::Actions
6
6
 
7
- desc 'plain NAME', 'Creates a new plain gem scaffold.'
7
+ desc 'gem NAME', 'Creates a new gem scaffold.'
8
8
 
9
9
  long_desc <<~END_DESC
10
- Creates a new plain gem scaffold with the given NAME,
10
+ Creates a new gem scaffold with the given NAME,
11
11
  by default hosted by GitHub and published on RubyGems.
12
12
  END_DESC
13
13
 
@@ -17,15 +17,18 @@ module Nugem
17
17
  method_option :private, type: :boolean, default: false,
18
18
  desc: 'Publish the gem in a private repository.'
19
19
 
20
- def plain(gem_name)
20
+ def gem(gem_name)
21
21
  # puts set_color("gem_name=#{gem_name}", :yellow)
22
22
  super if gem_name.empty?
23
23
 
24
- @dir = Nugem.dest_root gem_name
24
+ @executable = options[:executable]
25
+ @host = options[:host] # FIXME: conflicts with @host in create_gem_scaffold()
26
+ @out_dir = options[:out_dir]
27
+ @private = options[:private]
28
+ @test_framework = options[:test_framework]
29
+ @yes = options[:yes]
25
30
 
26
- @host = options['host']
27
- @private = options['private']
28
- @test_framework = options['test_framework']
31
+ @dir = Nugem.dest_root @out_dir, gem_name
29
32
 
30
33
  create_plain_scaffold gem_name
31
34
  initialize_repository gem_name
@@ -36,11 +39,8 @@ module Nugem
36
39
  # Defines globals for templates
37
40
  def create_plain_scaffold(gem_name)
38
41
  @gem_name = gem_name
39
- puts set_color("Creating a scaffold for a new plain Ruby gem named #{@gem_name} in #{@dir}.", :green)
40
42
  @class_name = Nugem.camel_case @gem_name
41
- @executable = options[:executable]
42
- @host = options[:bitbucket] ? :bitbucket : :github
43
- @private = options[:private]
43
+ @host = options[:bitbucket] ? :bitbucket : :github # FIXME: conflicts with @host in gem()
44
44
  @repository = Nugem::Repository.new(
45
45
  host: @host,
46
46
  user: git_repository_user_name(@host),
@@ -48,6 +48,7 @@ module Nugem
48
48
  gem_server_url: gem_server_url(@private),
49
49
  private: @private
50
50
  )
51
+ puts set_color("Creating a scaffold for a new Ruby gem named #{@gem_name} in #{@dir}.", :green)
51
52
  exclude_pattern = case @test_framework
52
53
  when 'minitest' then /spec.*/
53
54
  when 'rspec' then /test.*/
@@ -37,29 +37,33 @@ module Nugem
37
37
  test_option 'rspec'
38
38
 
39
39
  def jekyll(gem_name)
40
- @gem_name = gem_name
41
- @dir = Nugem.dest_root @gem_name
42
- @class_name = Nugem.camel_case @gem_name
43
- @jekyll = true
44
- @rspec = true
45
-
40
+ # options is frozen, so it cannot be modified.
41
+ # extracted values are ignored in the case statement below instead.
46
42
  @host = options['host']
43
+ @out_dir = options['out_dir']
47
44
  @private = options['private']
48
45
  @test_framework = options['test_framework']
49
46
  @todos = options['todos']
47
+ @yes = options['yes']
48
+
49
+ @gem_name = gem_name
50
+ @dir = Nugem.dest_root @out_dir, @gem_name
51
+ @class_name = Nugem.camel_case @gem_name
52
+ @jekyll = true
53
+ @rspec = true
50
54
 
51
55
  create_plain_scaffold @gem_name
52
56
  create_jekyll_scaffold
53
57
  options.each do |option|
54
58
  case option.first
55
- when 'block' then option[1].each { |name| create_jekyll_block_scaffold name }
56
- when 'blockn' then option[1].each { |name| create_jekyll_block_no_arg_scaffold name }
57
- when 'filter' then option[1].each { |name| create_jekyll_filter_scaffold name }
59
+ when 'block' then option[1].each { |name| create_jekyll_block_scaffold name }
60
+ when 'blockn' then option[1].each { |name| create_jekyll_block_no_arg_scaffold name }
61
+ when 'filter' then option[1].each { |name| create_jekyll_filter_scaffold name }
58
62
  when 'generator' then option[1].each { |name| create_jekyll_generator_scaffold name }
59
- when 'tag' then option[1].each { |name| create_jekyll_tag_scaffold name }
60
- when 'tagn' then option[1].each { |name| create_jekyll_tag_no_arg_scaffold name }
61
- when 'hooks' then create_jekyll_hooks_scaffold option[1]
62
- when 'host', 'executable', 'private', 'test_framework', 'todos', 'quiet' then next
63
+ when 'tag' then option[1].each { |name| create_jekyll_tag_scaffold name }
64
+ when 'tagn' then option[1].each { |name| create_jekyll_tag_no_arg_scaffold name }
65
+ when 'hooks' then create_jekyll_hooks_scaffold option[1]
66
+ when 'host', 'executable', 'out_dir', 'private', 'test_framework', 'todos', 'quiet' then next
63
67
  else puts "Warning: Unrecognized option: #{option}"
64
68
  end
65
69
  end
@@ -71,7 +75,7 @@ module Nugem
71
75
  # Invoked by directory action when processing Jekyll tags and block tags
72
76
  def parse_jekyll_parameters
73
77
  content = @jekyll_parameter_names_types.map do |name, _type|
74
- "@#{name} = @helper.parameter_specified? '#{name}' # Obtain the value of parameter #{name}"
78
+ "@#{name} = @helper.parameter_specified?('#{name}') || nil # Obtain the value of parameter #{name}"
75
79
  end
76
80
  content.join "\n "
77
81
  end
@@ -115,7 +119,7 @@ module Nugem
115
119
  puts set_color("Creating Jekyll block tag #{@block_name} scaffold within #{@jekyll_class_name}", :green)
116
120
  @mute = true
117
121
  directory 'jekyll/block_scaffold', @dir, force: true, mode: :preserve
118
- append_to_file "#{Nugem.dest_root gem_name}/demo/index.html", Cli.add_demo_example(block_name, @jekyll_parameter_names_types, :block)
122
+ append_to_file "#{Nugem.dest_root @out_dir, gem_name}/demo/index.html", Cli.add_demo_example(block_name, @jekyll_parameter_names_types, :block)
119
123
  end
120
124
 
121
125
  def create_jekyll_block_no_arg_scaffold(block_name)
@@ -124,7 +128,7 @@ module Nugem
124
128
  puts set_color("Creating Jekyll block tag no_arg #{@block_name} scaffold within #{@jekyll_class_name}", :green)
125
129
  @mute = true
126
130
  directory 'jekyll/block_no_arg_scaffold', @dir, force: true, mode: :preserve
127
- append_to_file "#{Nugem.dest_root gem_name}/demo/index.html", Cli.add_demo_example(block_name, @jekyll_parameter_names_types, :block)
131
+ append_to_file "#{Nugem.dest_root @out_dir, gem_name}/demo/index.html", Cli.add_demo_example(block_name, @jekyll_parameter_names_types, :block)
128
132
  end
129
133
 
130
134
  def create_jekyll_filter_scaffold(filter_name)
@@ -148,7 +152,7 @@ module Nugem
148
152
  directory 'jekyll/filter_scaffold', @dir, force: true, mode: :preserve
149
153
 
150
154
  tp = ': ' + @filter_params.map { |x| "'#{x}_value'" }.join(', ') unless @filter_params.empty?
151
- append_to_file "#{Nugem.dest_root gem_name}/demo/index.html", Cli.add_filter_example(filter_name, tp)
155
+ append_to_file "#{Nugem.dest_root @out_dir, gem_name}/demo/index.html", Cli.add_filter_example(filter_name, tp)
152
156
  # rubocop:enable Style/StringConcatenation
153
157
  end
154
158
 
@@ -174,7 +178,7 @@ module Nugem
174
178
  puts set_color("Creating Jekyll tag no_arg #{@tag_name} scaffold within #{@jekyll_class_name}", :green)
175
179
  @mute = true
176
180
  directory 'jekyll/tag_no_arg_scaffold', @dir, force: true, mode: :preserve
177
- append_to_file "#{Nugem.dest_root gem_name}/demo/index.html", Cli.add_demo_example(tag_name, @jekyll_parameter_names_types, :tag)
181
+ append_to_file "#{Nugem.dest_root @out_dir, gem_name}/demo/index.html", Cli.add_demo_example(tag_name, @jekyll_parameter_names_types, :tag)
178
182
  end
179
183
 
180
184
  def create_jekyll_tag_scaffold(tag_name)
@@ -186,7 +190,7 @@ module Nugem
186
190
  @mute = true
187
191
  # puts set_color("@jekyll_parameter_names_types=#{@jekyll_parameter_names_types}", :yellow)
188
192
  directory 'jekyll/tag_scaffold', @dir, force: true, mode: :preserve
189
- append_to_file "#{Nugem.dest_root gem_name}/demo/index.html", Cli.add_demo_example(tag_name, @jekyll_parameter_names_types, :tag)
193
+ append_to_file "#{Nugem.dest_root @out_dir, gem_name}/demo/index.html", Cli.add_demo_example(tag_name, @jekyll_parameter_names_types, :tag)
190
194
  end
191
195
  end
192
196
  end
@@ -4,10 +4,10 @@ module Nugem
4
4
  class Cli < Thor
5
5
  include Thor::Actions
6
6
 
7
- desc 'rails NAME', 'Creates a new Rails rails scaffold.'
7
+ desc 'rails NAME', 'Creates a new Rails scaffold.'
8
8
 
9
9
  long_desc <<~END_DESC
10
- Creates a new Rails rails scaffold with the given NAME,
10
+ Creates a new Rails scaffold with the given NAME,
11
11
  by default hosted by GitHub and published on RubyGems.
12
12
  END_DESC
13
13
 
@@ -24,8 +24,9 @@ module Nugem
24
24
  @mountable = options['mountable']
25
25
  @private = options['private']
26
26
  @test_framework = options['test_framework']
27
+ @yes = options['yes']
27
28
 
28
- @dir = Nugem.dest_root gem_name
29
+ @dir = Nugem.dest_root @out_dir, gem_name
29
30
  @engine = @host || @mountable
30
31
  @rails = true
31
32
 
data/lib/nugem/cli.rb CHANGED
@@ -19,20 +19,26 @@ module Nugem
19
19
 
20
20
  check_unknown_options!
21
21
 
22
+ class_option :out_dir, type: :string, default: 'generated',
23
+ desc: 'Output directory for the gem.', aliases: :o
24
+
22
25
  class_option :executable, type: :boolean, default: false,
23
- desc: 'Include an executable for the gem.'
26
+ desc: 'Include an executable for the gem.', aliases: :e
24
27
 
25
28
  class_option :host, type: :string, default: 'github',
26
- enum: %w[bitbucket github], desc: 'Repository host.'
29
+ enum: %w[bitbucket github], desc: 'Repository host.', aliases: :h
27
30
 
28
31
  class_option :private, type: :boolean, default: false,
29
- desc: 'Publish the gem on a private repository.'
32
+ desc: 'Publish the gem on a private repository.'
30
33
 
31
34
  class_option :quiet, type: :boolean, default: true,
32
- desc: 'Suppress detailed messages.', group: :runtime
35
+ desc: 'Suppress detailed messages.', group: :runtime, aliases: :q
33
36
 
34
37
  class_option :todos, type: :boolean, default: true,
35
- desc: 'Generate TODO: messages in generated code.', group: :runtime
38
+ desc: 'Generate TODO: messages in generated code.', group: :runtime, aliases: :t
39
+
40
+ class_option :yes, type: :boolean, default: false,
41
+ desc: 'Answer yes to all questions.', aliases: :y
36
42
 
37
43
  # Surround gem_name with percent symbols when using the property to name files
38
44
  # within the template directory
@@ -62,24 +68,25 @@ module Nugem
62
68
  require_relative 'cli/cli_jekyll'
63
69
  require_relative 'cli/cli_rails'
64
70
 
65
- no_tasks do
71
+ no_tasks do # rubocop:disable Metrics/BlockLength
66
72
  def count_todos(filename)
67
- filename_fq = "#{Nugem.dest_root gem_name}/#{filename}"
73
+ filename_fq = "#{Nugem.dest_root @out_dir, gem_name}/#{filename}"
68
74
  content = File.read filename_fq
69
75
  content.scan('TODO').length
70
76
  end
71
77
 
72
78
  def initialize_repository(gem_name)
73
- Dir.chdir Nugem.dest_root(gem_name) do
79
+ Dir.chdir Nugem.dest_root(@out_dir, gem_name) do
74
80
  # puts set_color("Working in #{Dir.pwd}", :green)
75
81
  run 'chmod +x bin/*'
76
82
  run 'chmod +x exe/*' if @executable
77
83
  create_local_git_repository
78
84
  FileUtils.rm_f 'Gemfile.lock'
79
- # puts set_color("Running 'bundle install'", :green)
85
+ # puts set_color("Running 'bundle'", :green)
80
86
  # run 'bundle', abort_on_failure: false
81
- create_remote_git_repository @repository \
82
- if yes? set_color("Do you want to create a repository on #{@repository.host.camel_case} named #{gem_name}? (y/N)", :green)
87
+ create_repo = @yes || yes?(set_color("Do you want to create a repository on #{@repository.host.camel_case} named #{gem_name}? (y/N)",
88
+ :green))
89
+ create_remote_git_repository @repository if create_repo
83
90
  end
84
91
  puts set_color("The #{gem_name} gem was successfully created.", :green)
85
92
  report_todos gem_name
@@ -89,7 +96,7 @@ module Nugem
89
96
  gemspec_todos = count_todos "#{gem_name}.gemspec"
90
97
  readme_todos = count_todos 'README.md'
91
98
  if readme_todos.zero? && gemspec_todos.zero?
92
- puts set_color("There are no TODOs. You can run 'bundle install' from within your new gem project now.", :blue)
99
+ puts set_color("There are no TODOs. You can run 'bundle' from within your new gem project now.", :blue)
93
100
  return
94
101
  end
95
102
 
data/lib/nugem/git.rb CHANGED
@@ -5,7 +5,7 @@ module Nugem
5
5
  class Cli < Thor
6
6
  include Thor::Actions
7
7
 
8
- no_tasks do
8
+ no_tasks do # rubocop:disable Metrics/BlockLength
9
9
  def create_local_git_repository
10
10
  puts set_color('Creating the local git repository', :green)
11
11
  run 'git init'
@@ -29,12 +29,13 @@ module Nugem
29
29
  token = gh_config&.dig('github.com', 'oauth_token')
30
30
 
31
31
  token ||= ask('What is your Github personal access token', echo: false)
32
- run <<~END_CURL
32
+ curl_command = <<~END_CURL
33
33
  curl --request POST \
34
34
  --user '#{repository.user}:#{token}' \
35
35
  https://api.github.com/user/repos \
36
36
  -d '{"name":"#{repository.name}", "private":#{repository.private?}}'
37
37
  END_CURL
38
+ run(curl_command, capture: true)
38
39
  else # BitBucket
39
40
  password = ask('Please enter your Bitbucket password', echo: false)
40
41
  fork_policy = repository.public? ? 'allow_forks' : 'no_public_forks'
@@ -64,14 +65,14 @@ module Nugem
64
65
  end
65
66
 
66
67
  def gem_server_url(private_)
67
- if private_
68
+ if private_ && Nugem::FEATURE_GEMINABOX
68
69
  global_config = Rugged::Config.global
69
70
  git_config_key = 'nugem.gemserver'
70
71
  url = global_config[git_config_key]
71
72
 
72
- if url.to_s.empty?
73
+ if url.to_s.strip.empty?
73
74
  url = ask('What is the url of your Geminabox server?')
74
- global_config[git_config_key] = url
75
+ global_config[git_config_key] = url unless url.to_s.strip.empty?
75
76
  end
76
77
  url
77
78
  else
@@ -1,7 +1,7 @@
1
1
  # Nugem::Repository contains informations about the git repository and the git user
2
2
  module Nugem
3
3
  class Repository
4
- attr_reader :gem_server_url, :global_config, :host, :name, :private, :user, :user_name, :user_email
4
+ attr_reader :gem_server_url, :global_config, :host, :name, :out_dir, :private, :user, :user_name, :user_email
5
5
 
6
6
  Host = Struct.new(:domain, :camel_case, :id, keyword_init: true)
7
7
  HOSTS = [
@@ -12,8 +12,9 @@ module Nugem
12
12
  def initialize(options)
13
13
  @host = HOSTS.find { |host| host.id == options[:host] }
14
14
  @private = options[:private]
15
- @name = options[:name]
16
- @user = options[:user]
15
+ @name = options[:name]
16
+ @user = options[:user]
17
+
17
18
  @global_config = Rugged::Config.global
18
19
  abort 'Git global config not found' if @global_config.nil?
19
20
 
data/lib/nugem/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Nugem
2
- VERSION = '0.8.3'.freeze
2
+ VERSION = '0.9.0'.freeze
3
3
  end
data/lib/nugem.rb CHANGED
@@ -5,9 +5,11 @@ Signal.trap('INT') { exit }
5
5
 
6
6
  module Nugem
7
7
  # @return Path to the generated gem
8
- def self.dest_root(gem_name)
9
- File.expand_path "generated/#{gem_name}"
8
+ def self.dest_root(out_dir, gem_name)
9
+ File.expand_path "#{out_dir}/#{gem_name}"
10
10
  end
11
+
12
+ FEATURE_GEMINABOX = false
11
13
  end
12
14
 
13
15
  require_relative 'nugem/git'
data/lib/util.rb CHANGED
@@ -28,7 +28,7 @@ module Nugem
28
28
  end
29
29
 
30
30
  def self.gem_path(file)
31
- spec = self.current_spec(file)
31
+ spec = current_spec(file)
32
32
  spec&.full_gem_path
33
33
  end
34
34
 
data/nugem.gemspec CHANGED
@@ -1,28 +1,38 @@
1
1
  require_relative 'lib/nugem/version'
2
2
 
3
3
  Gem::Specification.new do |spec|
4
+ host = 'https://github.com/mslinn/nugem'
5
+
6
+ spec.authors = ['Igor Jancev', 'Mike Slinn']
7
+ spec.bindir = 'exe'
4
8
  spec.description = <<~END_DESC
5
9
  Nugem creates a scaffold project for new gems. You can choose between Github and Bitbucket,
6
10
  Rubygems or Geminabox, with or without an executable, etc.
7
11
  END_DESC
8
- spec.authors = ['Igor Jancev', 'Mike Slinn']
9
- spec.bindir = 'exe'
10
12
  spec.email = ['igor@masterybits.com', 'mslinn@mslinn.com']
11
13
  spec.executables = %w[nugem]
12
14
  spec.files = Dir[
13
- '.rubocop.yml',
14
- 'Gemfile',
15
- 'LICENSE.*',
16
- 'Rakefile',
17
- '{lib,spec,templates}/**/*',
18
- 'templates/**/.*',
19
- 'templates/**/.*/*',
20
- '*.gemspec',
21
- '*.md'
22
- ]
15
+ '.rubocop.yml',
16
+ 'Gemfile',
17
+ 'LICENSE.*',
18
+ 'Rakefile',
19
+ '{lib,spec,templates}/**/*',
20
+ 'templates/**/.*',
21
+ 'templates/**/.*/*',
22
+ '*.gemspec',
23
+ '*.md'
24
+ ]
23
25
  spec.homepage = 'https://github.com/mslinn/nugem'
24
26
  spec.license = 'MIT'
27
+ spec.metadata = {
28
+ 'allowed_push_host' => 'https://rubygems.org',
29
+ 'bug_tracker_uri' => "#{host}/issues",
30
+ 'changelog_uri' => "#{host}/CHANGELOG.md",
31
+ 'homepage_uri' => spec.homepage,
32
+ 'source_code_uri' => host,
33
+ }
25
34
  spec.name = 'nugem'
35
+ spec.platform = Gem::Platform::RUBY
26
36
  spec.require_paths = ['lib']
27
37
  spec.required_ruby_version = '>= 3.1.0'
28
38
  spec.summary = 'Nugem creates a scaffold project for new gems.'
data/spec/spec_helper.rb CHANGED
@@ -1,12 +1,9 @@
1
1
  require_relative '../lib/nugem'
2
2
 
3
3
  RSpec.configure do |config|
4
- config.filter_run :focus
4
+ config.filter_run_when_matching focus: true
5
5
  # config.order = "random"
6
- config.run_all_when_everything_filtered = true
7
6
 
8
7
  # See https://relishapp.com/rspec/rspec-core/docs/command-line/only-failures
9
8
  config.example_status_persistence_file_path = '../spec/status_persistence.txt'
10
-
11
- config.filter_run_when_matching focus: true
12
9
  end
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
- require '<%= @gem_name %>/cli'
3
+ require_relative '../lib/<%= @gem_name %>'
4
4
 
5
- <%= @class_name %>::Cli.start
5
+ <%= @class_name %>.main
@@ -1,13 +1,21 @@
1
- require 'thor'
2
- require '<%= @gem_name %>'
1
+ require 'colorator'
2
+ require 'fileutils'
3
+ require 'pathname'
3
4
 
4
- module <%= @class_name %>
5
- class Cli < Thor
6
- include Thor::Actions
5
+ def require_subdirectory(dir)
6
+ Dir[File.join(dir, '*.rb')].each do |file|
7
+ require file unless file == __FILE__
8
+ end
9
+ end
7
10
 
8
- desc "do_something NAME", "<%= @todo %>task description"
9
- def do_something(name)
10
- puts "<%= @todo %>do something with: #{name}"
11
- end
11
+ require_subdirectory File.realpath(__dir__) # Require all Ruby files in 'lib/', except this file
12
+ Pathname(__dir__).children.select(&:directory?).each do |directory|
13
+ require_subdirectory directory.to_s
14
+ end
15
+
16
+ module <%= @class_name %>
17
+ def self.main
18
+ @options = parse_options
19
+ puts "TODO: write main implementation in lib/<%= @class_name %>/cli.rb".yellow
12
20
  end
13
21
  end
@@ -0,0 +1,31 @@
1
+ require 'colorator'
2
+ require 'optparse'
3
+
4
+ def help(msg = nil)
5
+ printf "Error: #{msg}\n\n".yellow unless msg.nil?
6
+ msg = <<~END_HELP
7
+ <%= @gem_name %>: Describe this executable.
8
+
9
+ Syntax: <%= @gem_name %> [Options]
10
+
11
+ Options:
12
+ -h Show this help message
13
+ END_HELP
14
+ printf msg.cyan
15
+ exit 1
16
+ end
17
+
18
+ def parse_options
19
+ options = { bpm: 120, overwrite: false }
20
+ OptionParser.new do |parser|
21
+ parser.program_name = File.basename __FILE__
22
+ @parser = parser
23
+
24
+ # parser.on('-b', '--bpm BPM', OptionParser::DecimalInteger, 'Specify BPM (default is 120 bpm)')
25
+ # parser.on('-f', '--overwrite', 'Overwrite output MIDI file if present') {% endcomment %}
26
+ parser.on_tail('-h', '--help', 'Show this message') do
27
+ help
28
+ end
29
+ end.order!(into: options)
30
+ options
31
+ end
@@ -9,7 +9,7 @@ Gem::Specification.new do |spec|
9
9
 
10
10
  spec.authors = ['<%= @repository.user_name %>']
11
11
  <%- if @executable -%>
12
- spec.bindir = 'binstub'
12
+ spec.bindir = 'exe'
13
13
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
14
14
  <%- end -%>
15
15
  spec.description = <<~END_DESC
@@ -46,12 +46,13 @@ Gem::Specification.new do |spec|
46
46
  <%- end -%>
47
47
  <%- if @jekyll -%>
48
48
  spec.add_dependency 'jekyll', '>= 3.5.0'
49
- spec.add_dependency 'jekyll_plugin_support', '>= 0.7.0'
49
+ spec.add_dependency 'jekyll_plugin_support', '>= 1.0.3'
50
50
  <%- end -%>
51
51
  <%- if @rails -%>
52
52
  spec.add_dependency 'rails', '~> 7.0.5'
53
53
  <%- end -%>
54
54
  <%- if @executable -%>
55
- spec.add_dependency 'thor', '~> 1.2.2'
55
+ spec.add_dependency 'colorator'
56
+ spec.add_dependency 'optparse'
56
57
  <%- end -%>
57
58
  end
@@ -1,4 +1,2 @@
1
1
  --color
2
2
  --format documentation
3
- --order defined
4
- --require spec_helper
@@ -19,7 +19,6 @@ AllCops:
19
19
  - vendor/**/*
20
20
  - Gemfile*
21
21
  NewCops: enable
22
- TargetRubyVersion: 3.1.3
23
22
 
24
23
  Gemspec/DeprecatedAttributeAssignment:
25
24
  Enabled: false
@@ -68,9 +67,8 @@ Style/TrailingCommaInHashLiteral:
68
67
  EnforcedStyleForMultiline: comma
69
68
  <%- if @test_framework == 'rspec' -%>
70
69
 
71
- RSpec/FilePath:
70
+ RSpec/SpecFilePathFormat:
72
71
  IgnoreMethods: true
73
- SpecSuffixOnly: true
74
72
 
75
73
  RSpec/ExampleLength:
76
74
  Max: 30
@@ -4,14 +4,51 @@
4
4
  // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
5
5
  "version": "0.2.0",
6
6
  "configurations": [
7
+ <%- if @jekyll -%>
7
8
  {
8
- "name": "Run selected Ruby file",
9
+ "args": [
10
+ "serve",
11
+ "--livereload_port", "35721",
12
+ "--force_polling",
13
+ "--host", "0.0.0.0",
14
+ "--port", "4001",
15
+ "--future",
16
+ "--incremental",
17
+ "--livereload",
18
+ "--drafts",
19
+ "--unpublished"
20
+ ],
21
+ "cwd": "${workspaceRoot}/demo",
22
+ "debugPort": "0",
23
+ "name": "Debug Demo",
24
+ "request": "launch",
25
+ "script": "${workspaceRoot}/binstub/jekyll",
26
+ "type": "rdbg",
27
+ },
28
+ <%- end -%>
29
+ {
30
+ "args": [],
31
+ "debugPort": "0",
32
+ "name": "Debug current file with rdbg",
33
+ "script": "${file}",
34
+ "request": "launch",
35
+ "type": "rdbg",
36
+ "useBundler": true,
37
+ },
38
+ {
39
+ "name": "Run selected Ruby file with ruby_lsp",
9
40
  "program": "ruby ${file}",
10
41
  "request": "launch",
11
42
  "type": "ruby_lsp"
12
43
  },
13
44
  {
14
- "name": "Attach rdebug-ide",
45
+ "debugPort": "0",
46
+ "name": "Attach with rdbg",
47
+ "request": "attach",
48
+ "type": "rdbg",
49
+ },
50
+ {
51
+ "name": "Attach with ruby_lsp",
15
52
  "request": "attach",
16
53
  "type": "ruby_lsp",
17
54
  },
@@ -6,9 +6,8 @@ gemspec
6
6
  group :test, :development do
7
7
  gem 'debug', '>= 1.0.0', require: false
8
8
  gem 'gem-release', '>= 2.2.2', require: false
9
- <%- if @jekyll -%>
10
9
  gem 'rake', require: false
11
- <%- end -%>
10
+ gem 'rspec', require: false
12
11
  gem 'rubocop', require: false
13
12
  gem 'rubocop-md', require: false
14
13
  <%- if @minitest -%>
@@ -19,7 +18,10 @@ group :test, :development do
19
18
  <%- if @rspec -%>
20
19
  gem 'rubocop-rspec', require: false
21
20
  <%- end -%>
22
- <%- if @rails -%>
21
+ end
22
+ <%- if @rails -%>
23
+
24
+ group :test, :development do
23
25
  gem 'capybara', '~> 3.39.1', require: false
24
26
  gem 'capybara_minitest_spec', '~> 1.0.7', require: false
25
27
  <%- if @repository.public? -%>
@@ -36,8 +38,8 @@ group :test, :development do
36
38
  gem 'quiet_assets'
37
39
  gem 'selenium-webdriver', '~> 4.9.1', require: false
38
40
  gem 'sqlite3'
39
- <%- end -%>
40
- end
41
+ end
42
+ <%- end -%>
41
43
 
42
44
  group :test do
43
45
  gem 'rspec-match_ignoring_whitespace'
@@ -1,5 +1,5 @@
1
1
  require 'jekyll_plugin_support'
2
- require_relative '<%= @gem_name %>/version.rb'
2
+ require_relative '<%= @gem_name %>/version'
3
3
 
4
4
  module <%= @class_name %>
5
5
  PLUGIN_NAME = '<%= @block_name %>'.freeze unless defined? PLUGIN_NAME
@@ -1,8 +1,7 @@
1
1
  require 'jekyll_plugin_support'
2
- require_relative '<%= @gem_name %>/version.rb'
2
+ require 'helper/jekyll_plugin_helper'
3
+ require_relative '<%= @gem_name %>/version'
3
4
 
4
- # This Jekyll block tag plugin is a minimal example.
5
- #
6
5
  # See https://www.mslinn.com/jekyll/10200-jekyll-plugin-background.html
7
6
  # See https://www.mslinn.com/jekyll/10400-jekyll-plugin-template-collection.html
8
7
  #
@@ -16,23 +15,46 @@ require_relative '<%= @gem_name %>/version.rb'
16
15
  # You can control the log level when you start Jekyll.
17
16
  # To set the log level to :debug, write an entery into _config.yml, like this:
18
17
  # plugin_loggers:
19
- # MyBlockTag: debug
18
+ # <%= @jekyll_class_name %>: debug
20
19
 
21
20
  module <%= @class_name %>
22
- # This class implements the Jekyll block tag functionality
21
+ # This class implements the Jekyll <%= @tag_name %> functionality
23
22
  class <%= @jekyll_class_name %> < JekyllSupport::JekyllBlock
24
23
  PLUGIN_NAME = '<%= @block_name %>'.freeze
25
24
  VERSION = <%= @class_name %>::VERSION
26
25
 
27
- # Put your plugin logic here.
26
+ # See https://github.com/mslinn/jekyll_plugin_support#argument-parsing
27
+ #
28
28
  # The following variables are predefined:
29
- # @argument_string, @block_name, @config, @envs, @helper, @layout, @logger, @mode, @page, @paginator, @site and @theme
29
+ # @argument_string, @config, @envs, @helper, @layout, @logger, @mode, @page, @paginator, @site and @theme
30
+ # @tag_name [String] is the name of the tag, which we already know.
31
+ # @argument_string [String] the arguments from the web page.
32
+ # @tokens [Liquid::ParseContext] tokenized command line
30
33
  #
31
- # @return [String]
34
+ # @helper provides these read-only attributes:
35
+ # argv, attribution, keys_values, liquid_context, logger, markup, no_arg_parsing, params, tag_name,
36
+ # argv_original, excerpt_caller, keys_values_original, params_original
37
+ # @helper provides these class methods:
38
+ # expand_env, register, remove_quotes
39
+ # @helper provides these instance methods:
40
+ # attribution_string
41
+ # default_attribution
42
+ # delete_parameter
43
+ # dereference_include_variable
44
+ # dereference_variable
45
+ # lookup_variable
46
+ # parameter_specified?('option/keyword name') || 'default value' # parse option value/keyword
47
+ # gem_file __FILE__ # Enables attribution
48
+ # remaining_markup # unparsed markup passed to this plugin
49
+ # reinitialize # Returns markup remaining after `parameter_specified?` has been invoked.
50
+ # remaining_markup_original
51
+ #
52
+ # @return [string] markup to be rendered on web page
32
53
  def render_impl(content)
33
54
  <%= parse_jekyll_parameters %>
34
55
 
35
- # Compute the return value of this Jekyll tag
56
+ # Put your plugin logic here and modify the following return value.
57
+
36
58
  <<~HEREDOC
37
59
  <pre class="example">
38
60
  content = '#{content}'
@@ -45,6 +67,6 @@ module <%= @class_name %>
45
67
  exit 3
46
68
  end
47
69
 
48
- JekyllPluginHelper.register(self, PLUGIN_NAME)
70
+ ::JekyllSupport::JekyllPluginHelper.register(self, PLUGIN_NAME)
49
71
  end
50
72
  end
@@ -1,12 +1,10 @@
1
1
  #!/bin/bash
2
2
 
3
- # shellcheck disable=SC2086,SC2155,SC2059
4
-
5
3
  function help {
6
4
  echo "
7
5
  $(basename $0) - Run the demo Jekyll website.
8
- By default the demo Jekyll website runs without restriction under `debug`,
9
- and listens on 0.0.0.0:1234.
6
+ By default the demo Jekyll website runs without restriction under debug,
7
+ and listens on 0.0.0.0.
10
8
  Options:
11
9
  -h Show this error message
12
10
  -r Run freely, without a debugger
@@ -38,12 +36,10 @@ while [ -L "$SOURCE" ]; do # resolve $SOURCE until the file is no longer a symli
38
36
  [[ $SOURCE != /* ]] && SOURCE=$DIR/$SOURCE # if $SOURCE was a relative symlink, we need to resolve it relative to the path where the symlink file was located
39
37
  done
40
38
  DIR=$( cd -P "$( dirname "$SOURCE" )" >/dev/null 2>&1 && pwd )
41
- cd "$DIR/.."
42
-
43
- # dispatcher-port and dispatcher-port are arbitrarily chosen to prevent conflicts with other instances.
39
+ cd "$DIR/.." || exit
44
40
 
45
41
  run="serve \
46
- --livereload_port 25721 \
42
+ --livereload-port 25721 \
47
43
  --force_polling \
48
44
  --host 0.0.0.0 \
49
45
  --port 4444 \
@@ -53,19 +49,14 @@ run="serve \
53
49
  --drafts \
54
50
  --unpublished"
55
51
 
56
- ../bin/setup
57
-
52
+ export BUNDLE_WITH=development
58
53
  rm -f Gemfile.lock
59
54
  bundle
60
55
  bundle exec ../binstub/jekyll clean # Ensure all hooks get called
61
56
 
62
57
  if [ "$RUN_FREE" ]; then
63
- bundle exec ../binstub/jekyll $run
58
+ bundle exec jekyll $run
64
59
  else
65
- bundle exec ../binstub/rdebug-ide \
66
- --host 0.0.0.0 \
67
- --port 1234 \
68
- --dispatcher-port 26162 \
69
- -- \
60
+ bundle exec rdbg -O --port=0 -- \
70
61
  ../binstub/jekyll $run
71
62
  fi
@@ -49,7 +49,7 @@ layout: compress
49
49
  <p class="copyright" id="copyright" xmlns:dct="http://purl.org/dc/terms/" xmlns:vcard="http://www.w3.org/2001/vcard-rdf/3.0#">
50
50
  <a rel="license" style="float: left; margin-right: 1em; padding-top: 9px; padding-bottom: 2em;"
51
51
  href="http://creativecommons.org/publicdomain/zero/1.0/">
52
- <img src="http://i.creativecommons.org/p/zero/1.0/88x31.png" style="border-style: none;" alt="CC0" />
52
+ <img src="/assets/images/favicon.png" style="border-style: none;" alt="CC0" />
53
53
  </a>
54
54
  To the extent possible under law,
55
55
  <a rel="dct:publisher"
@@ -117,7 +117,7 @@ module Dumpers
117
117
  # :unpublished
118
118
  # attr_reader :cache_dir, :config, :dest, :filter_cache, :includes_load_paths,
119
119
  # :liquid_renderer, :profiler, :regenerator, :source
120
- def dump_site(logger, msg, site) # rubocop:disable Metrics/AbcSize
120
+ def dump_site(logger, msg, site)
121
121
  logger.info do
122
122
  <<~END_INFO
123
123
  #{msg} site
@@ -1,5 +1,5 @@
1
1
  require 'jekyll_plugin_support'
2
- require_relative '<%= @gem_name %>/version.rb'
2
+ require_relative '<%= @gem_name %>/version'
3
3
 
4
4
  module <%= @class_name %>
5
5
  class <%= @jekyll_class_name %> < JekyllTag
@@ -1,8 +1,7 @@
1
1
  require 'jekyll_plugin_support'
2
- require_relative '<%= @gem_name %>/version.rb'
2
+ require 'helper/jekyll_plugin_helper'
3
+ require_relative '<%= @gem_name %>/version'
3
4
 
4
- # This Jekyll tag plugin is a minimal example.
5
- #
6
5
  # See https://www.mslinn.com/jekyll/10200-jekyll-plugin-background.html
7
6
  # See https://www.mslinn.com/jekyll/10400-jekyll-plugin-template-collection.html
8
7
  #
@@ -14,30 +13,58 @@ require_relative '<%= @gem_name %>/version.rb'
14
13
  # To set the log level to :debug, write an entry into _config.yml, like this:
15
14
  # plugin_loggers:
16
15
  # <%= @jekyll_class_name %>: debug
16
+ #
17
17
  module <%= class_name %>
18
+ <%= @class_name %>Error = ::JekyllSupport.define_error unless const_defined?(:<%= @class_name %>Error)
19
+
18
20
  # This class implements the Jekyll <%= @tag_name %> functionality
19
21
  class <%= @jekyll_class_name %> < JekyllSupport::JekyllTag
20
- PLUGIN_NAME = '<%= @tag_name %>'.freeze
22
+ PLUGIN_NAME = '<%= @tag_name %>'.freeze unless const_defined?(:PLUGIN_NAME)
21
23
  VERSION = <%= @class_name %>::VERSION
22
24
 
23
- # Put your plugin logic here.
25
+ # See https://github.com/mslinn/jekyll_plugin_support#argument-parsing
26
+ #
24
27
  # The following variables are predefined:
25
- # @argument_string, @config, @envs, @helper, @layout, @logger, @mode, @page, @paginator, @site, @tag_name and @theme
28
+ # @argument_string, @config, @envs, @helper, @layout, @logger, @mode, @page, @paginator, @site and @theme
29
+ # @tag_name [String] is the name of the tag, which we already know.
30
+ # @argument_string [String] the arguments from the web page.
31
+ # @tokens [Liquid::ParseContext] tokenized command line
26
32
  #
27
- # @param tag_name [String] is the name of the tag, which we already know.
28
- # @param argument_string [String] the arguments from the web page.
29
- # @param tokens [Liquid::ParseContext] tokenized command line
30
- # @return [void]
33
+ # @helper provides these read-only attributes:
34
+ # argv, attribution, keys_values, liquid_context, logger, markup, no_arg_parsing, params, tag_name,
35
+ # argv_original, excerpt_caller, keys_values_original, params_original
36
+ # @helper provides these class methods:
37
+ # expand_env, register, remove_quotes
38
+ # @helper provides these instance methods:
39
+ # attribution_string
40
+ # default_attribution
41
+ # delete_parameter
42
+ # dereference_include_variable
43
+ # dereference_variable
44
+ # lookup_variable
45
+ # parameter_specified?('option/keyword name') || 'default value' # parse option value/keyword
46
+ # gem_file __FILE__ # Enables attribution
47
+ # remaining_markup # unparsed markup passed to this plugin
48
+ # reinitialize # Returns markup remaining after `parameter_specified?` has been invoked.
49
+ # remaining_markup_original
50
+ #
51
+ # @return [string] markup to be rendered on web page
31
52
  def render_impl
32
53
  <%= parse_jekyll_parameters %>
54
+
55
+ # Put your plugin logic here and modify the following return value.
56
+
33
57
  <<~END_OUTPUT
34
58
  <pre class="example">
35
59
  <%= dump_jekyll_parameters %>
36
60
  Remaining markup: '#{@helper.remaining_markup}'.
37
61
  </pre>
38
62
  END_OUTPUT
63
+ rescue StandardError => e
64
+ @logger.error { "#{self.class} died with a #{e.full_message}" }
65
+ exit 3
39
66
  end
40
67
 
41
- JekyllPluginHelper.register(self, PLUGIN_NAME)
68
+ ::JekyllSupport::JekyllPluginHelper.register(self, PLUGIN_NAME)
42
69
  end
43
70
  end
@@ -11,7 +11,7 @@ Dir.chdir APP_ROOT do
11
11
 
12
12
  puts '== Installing dependencies =='
13
13
  system 'gem install bundler --conservative'
14
- system 'bundle check || bundle install'
14
+ system 'bundle check || bundle'
15
15
 
16
16
  # unless File.exist?('config/database.yml')
17
17
  # puts "\n== Copying sample files =="
@@ -11,7 +11,7 @@ Dir.chdir APP_ROOT do
11
11
 
12
12
  puts '== Installing dependencies =='
13
13
  system 'gem install bundler --conservative'
14
- system 'bundle check || bundle install'
14
+ system 'bundle check || bundle'
15
15
 
16
16
  # unless File.exist?('config/database.yml')
17
17
  # puts "\n== Copying sample files =="
metadata CHANGED
@@ -1,15 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: nugem
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.3
4
+ version: 0.9.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Igor Jancev
8
8
  - Mike Slinn
9
- autorequire:
10
9
  bindir: exe
11
10
  cert_chain: []
12
- date: 2023-11-05 00:00:00.000000000 Z
11
+ date: 2024-12-21 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
14
  name: jekyll
@@ -83,10 +82,10 @@ files:
83
82
  - nugem.gemspec
84
83
  - spec/jekyll_tag_spec.rb
85
84
  - spec/spec_helper.rb
86
- - spec/status_persistence.txt
87
85
  - templates/common/LICENCE.txt.tt
88
86
  - templates/common/executable_scaffold/exe/%gem_name%.tt
89
87
  - templates/common/executable_scaffold/lib/%gem_name%/cli.rb.tt
88
+ - templates/common/executable_scaffold/lib/%gem_name%/options.rb.tt
90
89
  - templates/common/gem_scaffold/%gem_name%.gemspec.tt
91
90
  - templates/common/gem_scaffold/.bundle/config
92
91
  - templates/common/gem_scaffold/.gitignore.tt
@@ -254,8 +253,12 @@ files:
254
253
  homepage: https://github.com/mslinn/nugem
255
254
  licenses:
256
255
  - MIT
257
- metadata: {}
258
- post_install_message:
256
+ metadata:
257
+ allowed_push_host: https://rubygems.org
258
+ bug_tracker_uri: https://github.com/mslinn/nugem/issues
259
+ changelog_uri: https://github.com/mslinn/nugem/CHANGELOG.md
260
+ homepage_uri: https://github.com/mslinn/nugem
261
+ source_code_uri: https://github.com/mslinn/nugem
259
262
  rdoc_options: []
260
263
  require_paths:
261
264
  - lib
@@ -270,8 +273,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
270
273
  - !ruby/object:Gem::Version
271
274
  version: '0'
272
275
  requirements: []
273
- rubygems_version: 3.3.3
274
- signing_key:
276
+ rubygems_version: 3.6.0
275
277
  specification_version: 4
276
278
  summary: Nugem creates a scaffold project for new gems.
277
279
  test_files: []
File without changes