yard_ghurt 1.1.0 → 1.2.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: eabd1d16b12b7055c9ab9a5c0bdc460281cc3cfe63b7b4e207e086ed30de30a6
4
- data.tar.gz: 200b03f7a0a22016a8634dcb3b4d3e0854d97eb9714933ec6a339bb9651b281a
3
+ metadata.gz: 3d6655a3fefa8677dd2b00ea73dbd7b87cf1c6d13b888ed67c29feb899f2555e
4
+ data.tar.gz: 52ffccc6f6a7d98e7865396b1c8c3e2b8c9a58452d3e724b0d0eb0c75e3495ab
5
5
  SHA512:
6
- metadata.gz: acd5ef0039f8a3fce2f5c3ecf89a25259d38d2988585ac33a6aa1ad5540bae27ec1eb2833325c793f36df403f0db936576fce26e964750aea97fb2e8d8e67b0b
7
- data.tar.gz: b47d674b37f759696fa23bea3b5d145c7d2561679a104bf3335df1af06a2943174f4bcc9e998bb917c04e633b94c6d67d361d8b974e9b7200289e9cb26da675c
6
+ metadata.gz: bcab8039ee10ff48858cd161483bbbc32ebe23a038f32303defe23081932ab4bc97b7e0d64a4de15307c14993cdf4d311d7385ed00a920af324b641b3e11d110
7
+ data.tar.gz: 31b278e7cbc842b3431eda53f8737bf957ff7068c4796ca984c0362040777b31f8542270e0844942b7a47906b464a41be7cf155712f4a9f1a05b2a41c391ad93
@@ -2,7 +2,21 @@
2
2
 
3
3
  Format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
4
4
 
5
- ## [[Unreleased]](https://github.com/esotericpig/yard_ghurt/compare/v1.1.0...master)
5
+ ## [[Unreleased]](https://github.com/esotericpig/yard_ghurt/compare/v1.2.0...master)
6
+
7
+ ## [v1.2.0] - 2020-02-29
8
+ ### Added
9
+ - bin/yard_ghurt
10
+ - For getting the GitHub/YARDoc anchor link ID from a string
11
+ - App class
12
+ - AnchorLinks.escape()
13
+
14
+ ### Changed
15
+ - README to talk about bin/yard_ghurt
16
+
17
+ ### Fixed
18
+ - In AnchorLinks, don't use obsolete method URI.escape()/encode()
19
+ - This outputted a lot of warnings
6
20
 
7
21
  ## [v1.1.0] - 2019-07-31
8
22
  ### Added
data/README.md CHANGED
@@ -20,6 +20,7 @@
20
20
  - [GHPSyncTask](#ghpsynctask)
21
21
  - [Util / YardGhurt](#util--yardghurt)
22
22
  - [AnchorLinks](#anchorlinks)
23
+ - [CLI App](#cli-app)
23
24
  - [Hacking](#hacking)
24
25
  - [Testing](#testing)
25
26
  - [Tests](#tests)
@@ -244,6 +245,33 @@ puts al.to_github_anchor_id(name) # this-is-another-test-1
244
245
  puts al.to_github_anchor_id(name) # this-is-another-test-1
245
246
  ```
246
247
 
248
+ ## [CLI App](#contents)
249
+ A CLI app has been added for convenience for when writing your own README.
250
+
251
+ On the command line:
252
+ ```
253
+ $ yard_ghurt -g "What's this ID?"
254
+ # => whats-this-id
255
+
256
+ $ yard_ghurt -y "What's this ID?"
257
+ # => What_s_this_ID_
258
+
259
+ $ yard_ghurt -a "What's this ID?"
260
+ # => GitHub: whats-this-id
261
+ # YARDoc: What_s_this_ID_
262
+ ```
263
+
264
+ Help:
265
+ ```
266
+ Usage: yard_ghurt [options]
267
+ -a, --anchor <string> Print GitHub & YARDoc anchor link IDs of <string>
268
+ -g, --github <string> Print GitHub anchor link ID of <string>
269
+ -y, --yard <string> Print YARDoc anchor link ID of <string>
270
+ ---
271
+ -h, --help Print this help
272
+ -v, --version Print the version
273
+ ```
274
+
247
275
  ## [Hacking](#contents)
248
276
 
249
277
  ```
@@ -324,7 +352,7 @@ Newline
324
352
  [GNU LGPL v3+](LICENSE.txt)
325
353
 
326
354
  > YardGhurt (<https://github.com/esotericpig/yard_ghurt>)
327
- > Copyright (c) 2019 Jonathan Bradley Whited (@esotericpig)
355
+ > Copyright (c) 2019-2020 Jonathan Bradley Whited (@esotericpig)
328
356
  >
329
357
  > YardGhurt is free software: you can redistribute it and/or modify
330
358
  > it under the terms of the GNU Lesser General Public License as published by
@@ -0,0 +1,29 @@
1
+ #!/usr/bin/env ruby
2
+ # encoding: UTF-8
3
+ # frozen_string_literal: true
4
+
5
+ #--
6
+ # This file is part of YardGhurt.
7
+ # Copyright (c) 2020 Jonathan Bradley Whited (@esotericpig)
8
+ #
9
+ # YardGhurt is free software: you can redistribute it and/or modify
10
+ # it under the terms of the GNU Lesser General Public License as published by
11
+ # the Free Software Foundation, either version 3 of the License, or
12
+ # (at your option) any later version.
13
+ #
14
+ # YardGhurt is distributed in the hope that it will be useful,
15
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
16
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17
+ # GNU Lesser General Public License for more details.
18
+ #
19
+ # You should have received a copy of the GNU Lesser General Public License
20
+ # along with YardGhurt. If not, see <https://www.gnu.org/licenses/>.
21
+ #++
22
+
23
+
24
+ require 'yard_ghurt'
25
+
26
+
27
+ # @since 1.2.0
28
+ yg = YardGhurt::App.new()
29
+ yg.run()
@@ -4,7 +4,7 @@
4
4
 
5
5
  #--
6
6
  # This file is part of YardGhurt.
7
- # Copyright (c) 2019 Jonathan Bradley Whited (@esotericpig)
7
+ # Copyright (c) 2019-2020 Jonathan Bradley Whited (@esotericpig)
8
8
  #
9
9
  # YardGhurt is free software: you can redistribute it and/or modify
10
10
  # it under the terms of the GNU Lesser General Public License as published by
@@ -21,12 +21,14 @@
21
21
  #++
22
22
 
23
23
 
24
+ require 'optparse'
24
25
  require 'yard_ghurt/anchor_links'
25
26
  require 'yard_ghurt/gfm_fix_task'
26
27
  require 'yard_ghurt/ghp_sync_task'
27
28
  require 'yard_ghurt/util'
28
29
  require 'yard_ghurt/version'
29
30
 
31
+
30
32
  ###
31
33
  # YARDoc GitHub Rake Tasks
32
34
  #
@@ -37,4 +39,62 @@ module YardGhurt
37
39
  # Internal code should use +Util.+!
38
40
  # See {Util} for details.
39
41
  include Util
42
+
43
+ ###
44
+ # A simple CLI app used in file +bin/yard_ghurt+.
45
+ #
46
+ # Mainly for getting GitHub/YARDoc anchor link IDs.
47
+ #
48
+ # @author Jonathan Bradley Whited (@esotericpig)
49
+ # @since 1.2.0
50
+ ###
51
+ class App
52
+ attr_reader :args
53
+
54
+ def initialize(args=ARGV)
55
+ super()
56
+
57
+ @args = args
58
+ end
59
+
60
+ def run()
61
+ parser = OptionParser.new() do |op|
62
+ op.program_name = 'yard_ghurt'
63
+ op.version = VERSION
64
+
65
+ op.banner = "Usage: #{op.program_name} [options]"
66
+
67
+ op.on('-a','--anchor <string>','Print GitHub & YARDoc anchor link IDs of <string>') do |str|
68
+ al = AnchorLinks.new()
69
+ puts "GitHub: #{al.to_github_anchor_id(str)}"
70
+ puts "YARDoc: #{al.to_yard_anchor_id(str)}"
71
+ exit
72
+ end
73
+ op.on('-g','--github <string>','Print GitHub anchor link ID of <string>') do |str|
74
+ al = AnchorLinks.new()
75
+ puts al.to_github_anchor_id(str)
76
+ exit
77
+ end
78
+ op.on('-y','--yard <string>','Print YARDoc anchor link ID of <string>') do |str|
79
+ al = AnchorLinks.new()
80
+ puts al.to_yard_anchor_id(str)
81
+ exit
82
+ end
83
+
84
+ op.separator op.summary_indent + '---'
85
+
86
+ op.on_tail('-h','--help','Print this help') do
87
+ puts op
88
+ exit
89
+ end
90
+ op.on_tail('-v','--version','Print the version') do
91
+ puts "#{op.program_name} v#{op.version}"
92
+ exit
93
+ end
94
+ end
95
+
96
+ parser.parse!(@args)
97
+ puts parser # Print help if nothing was parsed
98
+ end
99
+ end
40
100
  end
@@ -4,7 +4,7 @@
4
4
 
5
5
  #--
6
6
  # This file is part of YardGhurt.
7
- # Copyright (c) 2019 Jonathan Bradley Whited (@esotericpig)
7
+ # Copyright (c) 2019-2020 Jonathan Bradley Whited (@esotericpig)
8
8
  #
9
9
  # YardGhurt is free software: you can redistribute it and/or modify
10
10
  # it under the terms of the GNU Lesser General Public License as published by
@@ -119,6 +119,20 @@ module YardGhurt
119
119
  return self
120
120
  end
121
121
 
122
+ # Escape +str+ for the web (e.g., "%20" for a space).
123
+ #
124
+ # Mainly used for non-English languages.
125
+ #
126
+ # @param str [String] the string to escape
127
+ #
128
+ # @return [String] the escaped string
129
+ #
130
+ # @since 1.2.0
131
+ def self.escape(str)
132
+ # URI.escape()/encode() is obsolete
133
+ return URI.encode_www_form_component(str)
134
+ end
135
+
122
136
  # Merge +anchor_ids+ with {anchor_ids} and {yard_anchor_ids}.
123
137
  #
124
138
  # @param anchor_ids [Hash] the anchor IDs (of GFM anchor IDs to YARDoc anchor IDs) to merge
@@ -198,7 +212,7 @@ module YardGhurt
198
212
  id.downcase!()
199
213
  end
200
214
 
201
- id = URI.escape(id) # For non-English languages
215
+ id = self.class.escape(id) # For non-English languages
202
216
 
203
217
  # Duplicates
204
218
  dup_num = 1
@@ -246,7 +260,7 @@ module YardGhurt
246
260
  id.strip!()
247
261
  id.gsub!(/&[^;]+;/,'_') # Replace entities: &...;
248
262
  id.gsub!(/[^a-z0-9-]/i,'_')
249
- id = URI.escape(id) # For non-English languages
263
+ id = self.class.escape(id) # For non-English languages
250
264
 
251
265
  # Duplicates
252
266
  orig_id = id.dup()
@@ -22,5 +22,5 @@
22
22
 
23
23
 
24
24
  module YardGhurt
25
- VERSION = '1.1.0'
25
+ VERSION = '1.2.0'
26
26
  end
@@ -3,7 +3,7 @@
3
3
 
4
4
  #--
5
5
  # This file is part of YardGhurt.
6
- # Copyright (c) 2019 Jonathan Bradley Whited (@esotericpig)
6
+ # Copyright (c) 2019-2020 Jonathan Bradley Whited (@esotericpig)
7
7
  #
8
8
  # YardGhurt is free software: you can redistribute it and/or modify
9
9
  # it under the terms of the GNU Lesser General Public License as published by
@@ -44,8 +44,11 @@ Gem::Specification.new() do |spec|
44
44
  }
45
45
 
46
46
  spec.require_paths = ['lib']
47
+ spec.bindir = 'bin'
48
+ spec.executables = [spec.name]
47
49
 
48
50
  spec.files = Dir.glob(File.join("{#{spec.require_paths.join(',')}}",'**','*.{erb,rb}')) +
51
+ Dir.glob(File.join(spec.bindir,'**',"{#{spec.executables.join(',')}}")) +
49
52
  Dir.glob(File.join('{test,yard}','**','*.{erb,rb}')) +
50
53
  %W( Gemfile #{spec.name}.gemspec Rakefile ) +
51
54
  %w( CHANGELOG.md LICENSE.txt README.md )
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: yard_ghurt
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.0
4
+ version: 1.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jonathan Bradley Whited (@esotericpig)
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-07-31 00:00:00.000000000 Z
11
+ date: 2020-02-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake
@@ -83,7 +83,8 @@ dependencies:
83
83
  description: YARDoc GitHub Rake Tasks. Fix GitHub Flavored Markdown (GFM) files.
84
84
  email:
85
85
  - bradley@esotericpig.com
86
- executables: []
86
+ executables:
87
+ - yard_ghurt
87
88
  extensions: []
88
89
  extra_rdoc_files: []
89
90
  files:
@@ -92,6 +93,7 @@ files:
92
93
  - LICENSE.txt
93
94
  - README.md
94
95
  - Rakefile
96
+ - bin/yard_ghurt
95
97
  - lib/yard_ghurt.rb
96
98
  - lib/yard_ghurt/anchor_links.rb
97
99
  - lib/yard_ghurt/gfm_fix_task.rb
@@ -124,7 +126,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
124
126
  - !ruby/object:Gem::Version
125
127
  version: '0'
126
128
  requirements: []
127
- rubygems_version: 3.0.4
129
+ rubygems_version: 3.1.2
128
130
  signing_key:
129
131
  specification_version: 4
130
132
  summary: YARDoc GitHub Rake Tasks