jtag 0.1.25 → 0.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 +4 -4
- data/bin/jtag +271 -378
- data/lib/jtag/config_files/config.yml +2 -3
- data/lib/jtag/jekylltag.rb +224 -294
- data/lib/jtag/string.rb +42 -240
- data/lib/jtag/version.rb +1 -1
- data/lib/jtag.rb +13 -19
- metadata +41 -47
- data/.irbrc +0 -6
- data/CHANGELOG.md +0 -23
- data/Gemfile +0 -3
- data/Jekyll/plugins/autotag_gen.rb +0 -58
- data/Jekyll/source/_layouts/tags_json.html +0 -11
- data/README.md +0 -159
- data/Rakefile +0 -110
- data/jtag.completion.bash +0 -9
- data/jtag.gemspec +0 -27
- data/lib/jtag/array.rb +0 -48
- data/lib/jtag/errors.rb +0 -31
- data/lib/jtag/hash.rb +0 -103
- data/lib/jtag/stupid_json.rb +0 -319
- data/lib/jtag/util.rb +0 -244
- data/mise.toml +0 -2
data/lib/jtag/string.rb
CHANGED
|
@@ -1,246 +1,48 @@
|
|
|
1
|
-
#
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
##
|
|
11
|
-
def to_bool
|
|
12
|
-
case self.downcase
|
|
13
|
-
when /^a/i
|
|
14
|
-
:and
|
|
15
|
-
when /^o/i
|
|
16
|
-
:or
|
|
17
|
-
when /^n/i
|
|
18
|
-
:not
|
|
19
|
-
else
|
|
20
|
-
raise ArgumentError, "Invalid boolean string: #{self}"
|
|
21
|
-
end
|
|
22
|
-
end
|
|
23
|
-
|
|
24
|
-
##
|
|
25
|
-
## Convert a string to a format symbol (:list, :csv, :complete, :json, :plist, :yaml)
|
|
26
|
-
##
|
|
27
|
-
## @return [Symbol] format symbol
|
|
28
|
-
##
|
|
29
|
-
def to_format
|
|
30
|
-
case self.downcase
|
|
31
|
-
when /^j/i
|
|
32
|
-
:json
|
|
33
|
-
when /^p/i
|
|
34
|
-
:plist
|
|
35
|
-
when /^y/i
|
|
36
|
-
:yaml
|
|
37
|
-
when /^cs/i
|
|
38
|
-
:csv
|
|
39
|
-
when /^c/i
|
|
40
|
-
:complete
|
|
41
|
-
when /^l/i
|
|
42
|
-
:list
|
|
43
|
-
else
|
|
44
|
-
raise ArgumentError, "Invalid format string: #{self}"
|
|
45
|
-
end
|
|
46
|
-
end
|
|
47
|
-
|
|
48
|
-
## Check if a string is a list of files
|
|
49
|
-
##
|
|
50
|
-
## @param null [Boolean] check for null-delimited list
|
|
51
|
-
##
|
|
52
|
-
## @example Check if a string is a list of files
|
|
53
|
-
## "file1\nfile2\nfile3".file_list?
|
|
54
|
-
## # => true
|
|
55
|
-
##
|
|
56
|
-
## @return [Boolean]
|
|
57
|
-
def file_list?(null = false)
|
|
58
|
-
self.strip.split(null ? "\x00" : "\n").each do |line|
|
|
59
|
-
return false unless File.exist?(line)
|
|
60
|
-
end
|
|
61
|
-
true
|
|
62
|
-
end
|
|
63
|
-
|
|
64
|
-
##
|
|
65
|
-
## Check if string is YAML
|
|
66
|
-
##
|
|
67
|
-
## @example Check if a string is YAML
|
|
68
|
-
## "tags:\n - tag1\n - tag2".yaml?
|
|
69
|
-
## # => true
|
|
70
|
-
##
|
|
71
|
-
## @example Check if a string is not YAML
|
|
72
|
-
## "test string".yaml?
|
|
73
|
-
## # => false
|
|
74
|
-
##
|
|
75
|
-
## @return [Boolean]
|
|
76
|
-
##
|
|
77
|
-
def yaml?
|
|
78
|
-
begin
|
|
79
|
-
YAML.load(self)
|
|
80
|
-
rescue
|
|
81
|
-
return false
|
|
82
|
-
end
|
|
83
|
-
true
|
|
84
|
-
end
|
|
85
|
-
|
|
86
|
-
##
|
|
87
|
-
## Matches the string against a given keyword based on various options.
|
|
88
|
-
##
|
|
89
|
-
## @param keyword [String] the keyword to match against the string.
|
|
90
|
-
## @param options [Hash] a hash of options to customize the matching behavior.
|
|
91
|
-
## @option options [Boolean] :case_sensitive (false) whether the match should be case-sensitive.
|
|
92
|
-
## @option options [Boolean] :starts_with (false) whether the match should check if the string starts with the keyword.
|
|
93
|
-
## @option options [Boolean] :exact (false) whether the match should be exact.
|
|
94
|
-
## @option options [Boolean] :fuzzy (true) whether the match should be fuzzy.
|
|
95
|
-
## @option options [Integer] :distance (2) the maximum distance between characters for a fuzzy match.
|
|
96
|
-
##
|
|
97
|
-
## @return [Boolean] true if the string matches the keyword based on the given options, false otherwise.
|
|
98
|
-
##
|
|
99
|
-
def match_keyword(keyword, options = {})
|
|
100
|
-
options = {
|
|
101
|
-
case_sensitive: false,
|
|
102
|
-
starts_with: false,
|
|
103
|
-
exact: false,
|
|
104
|
-
fuzzy: false,
|
|
105
|
-
contains: false,
|
|
106
|
-
distance: 2,
|
|
107
|
-
}.merge(options)
|
|
108
|
-
|
|
109
|
-
keyword = Regexp.escape(keyword)
|
|
110
|
-
|
|
111
|
-
if options[:exact]
|
|
112
|
-
re = "^#{keyword}$"
|
|
113
|
-
elsif options[:starts_with]
|
|
114
|
-
re = "^#{keyword}"
|
|
115
|
-
elsif options[:fuzzy]
|
|
116
|
-
re = ".*#{keyword.split(//).join(".{,#{options[:distance] - 1}}")}.*"
|
|
117
|
-
else
|
|
118
|
-
re = ".*#{keyword}.*"
|
|
119
|
-
end
|
|
120
|
-
|
|
121
|
-
if options[:case_sensitive]
|
|
122
|
-
self.match?(/#{re}/)
|
|
123
|
-
else
|
|
124
|
-
self.match?(/#{re}/i)
|
|
125
|
-
end
|
|
126
|
-
end
|
|
127
|
-
|
|
128
|
-
##
|
|
129
|
-
## Check if a string is JSON
|
|
130
|
-
##
|
|
131
|
-
## @example Check if a string is JSON
|
|
132
|
-
## '{"tags": ["tag1", "tag2"]}'.json?
|
|
133
|
-
## # => true
|
|
134
|
-
##
|
|
135
|
-
## @example Check if a string is not JSON
|
|
136
|
-
## "test string".json?
|
|
137
|
-
## # => false
|
|
138
|
-
##
|
|
139
|
-
## @return [Boolean]
|
|
140
|
-
##
|
|
141
|
-
## @note JSON must be a hash or array
|
|
142
|
-
##
|
|
143
|
-
def json?
|
|
144
|
-
begin
|
|
145
|
-
JSON.parse(self).is_a?(Hash) || JSON.parse(self).is_a?(Array)
|
|
146
|
-
rescue
|
|
147
|
-
return false
|
|
148
|
-
end
|
|
149
|
-
true
|
|
150
|
-
end
|
|
151
|
-
|
|
152
|
-
##
|
|
153
|
-
## Convert parenthetical count to hash
|
|
154
|
-
##
|
|
155
|
-
## @example Convert a string to a hash
|
|
156
|
-
## "tag (5)".to_count
|
|
157
|
-
## # => { "name" => "tag", "count" => 5 }
|
|
158
|
-
##
|
|
159
|
-
## @example Convert a string to a hash with no count
|
|
160
|
-
## "tag".to_count
|
|
161
|
-
## # => { "name" => "tag", "count" => 0 }
|
|
162
|
-
##
|
|
163
|
-
## @return [Hash] hash with name and count
|
|
164
|
-
##
|
|
165
|
-
def to_count
|
|
166
|
-
tag = dup.strip.sub(/^[[:punct:]] /, "")
|
|
167
|
-
if tag =~ /(.*) \((\d+)\)/
|
|
168
|
-
{ "name" => $1, "count" => $2.to_i }
|
|
169
|
-
else
|
|
170
|
-
{ "name" => tag, "count" => 0 }
|
|
171
|
-
end
|
|
172
|
-
end
|
|
173
|
-
|
|
174
|
-
##
|
|
175
|
-
## Check if a string is a list of tags
|
|
176
|
-
##
|
|
177
|
-
## @example Check if a string is a list of tags
|
|
178
|
-
## "tag1\ntag2".tag_list?
|
|
179
|
-
## # => true
|
|
180
|
-
##
|
|
181
|
-
## @return [Boolean]
|
|
182
|
-
##
|
|
183
|
-
## @note One tag per line
|
|
184
|
-
## Tags are assumed to be alphanumeric and lowercase
|
|
185
|
-
## (spaces, underscores, and dashes allowed) with no
|
|
186
|
-
## leading or preceding or trailing punctuation
|
|
187
|
-
##
|
|
188
|
-
def tag_list?
|
|
189
|
-
self.strip.split("\n").each do |tag|
|
|
190
|
-
return false unless tag.match?(/^(?![[:punct:]] )[a-z0-9 -_]+(?<![[:punct:]]) *$/)
|
|
191
|
-
end
|
|
192
|
-
true
|
|
193
|
-
end
|
|
194
|
-
|
|
195
|
-
def root_words
|
|
196
|
-
words = break_camel.split("[\s-]")
|
|
197
|
-
words.delete_if { |word| word =~ /^[^a-z]+$/i || word.length < 4 }
|
|
198
|
-
words.map { |word| word = Text::PorterStemming.stem(word).downcase }.join(" ")
|
|
199
|
-
end
|
|
200
|
-
|
|
201
|
-
# convert "WikiLink" to "Wiki link"
|
|
202
|
-
def break_camel
|
|
203
|
-
return downcase if match(/\A[A-Z]+\z/)
|
|
204
|
-
gsub(/([A-Z]+)([A-Z][a-z])/, '\1 \2').
|
|
205
|
-
gsub(/([a-z])([A-Z])/, '\1 \2').
|
|
206
|
-
downcase
|
|
207
|
-
end
|
|
1
|
+
# encoding: utf-8
|
|
2
|
+
class String
|
|
3
|
+
# convert "WikiLink" to "Wiki link"
|
|
4
|
+
def break_camel
|
|
5
|
+
return downcase if match(/\A[A-Z]+\z/)
|
|
6
|
+
gsub(/([A-Z]+)([A-Z][a-z])/, '\1 \2').
|
|
7
|
+
gsub(/([a-z])([A-Z])/, '\1 \2').
|
|
8
|
+
downcase
|
|
9
|
+
end
|
|
208
10
|
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
11
|
+
def strip_markdown
|
|
12
|
+
# strip all Markdown and Liquid tags
|
|
13
|
+
gsub(/\{%.*?%\}/,'').
|
|
14
|
+
gsub(/\[\^.+?\](\: .*?$)?/,'').
|
|
15
|
+
gsub(/\s{0,2}\[.*?\]: .*?$/,'').
|
|
16
|
+
gsub(/\!\[.*?\][\[\(].*?[\]\)]/,"").
|
|
17
|
+
gsub(/\[(.*?)\][\[\(].*?[\]\)]/,"\\1").
|
|
18
|
+
gsub(/^\s{1,2}\[(.*?)\]: (\S+)( ".*?")?\s*$/,'').
|
|
19
|
+
gsub(/^\#{1,6}\s*/,'').
|
|
20
|
+
gsub(/(\*{1,2})(\S.*?\S)\1/,"\\2").
|
|
21
|
+
gsub(/(`{3,})(.*?)\1/m,"\\2").
|
|
22
|
+
gsub(/^-{3,}\s*$/,"").
|
|
23
|
+
gsub(/`(.+)`/,"\\1").
|
|
24
|
+
gsub(/\n{2,}/,"\n\n")
|
|
25
|
+
end
|
|
224
26
|
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
27
|
+
def strip_tags
|
|
28
|
+
return CGI.unescapeHTML(
|
|
29
|
+
gsub(/<(script|style|pre|code|figure).*?>.*?<\/\1>/im, '').
|
|
30
|
+
gsub(/<!--.*?-->/m, '').
|
|
31
|
+
gsub(/<(img|hr|br).*?>/i, " ").
|
|
32
|
+
gsub(/<(dd|a|h\d|p|small|b|i|blockquote|li)( [^>]*?)?>(.*?)<\/\1>/i, " \\3 ").
|
|
33
|
+
gsub(/<\/?(dt|a|ul|ol)( [^>]+)?>/i, " ").
|
|
34
|
+
gsub(/<[^>]+?>/, '').
|
|
35
|
+
gsub(/\[\d+\]/, '').
|
|
36
|
+
gsub(/’/,"'").gsub(/&.*?;/,' ').gsub(/;/,' ')
|
|
37
|
+
).lstrip.gsub("\xE2\x80\x98","'").gsub("\xE2\x80\x99","'").gsub("\xCA\xBC","'").gsub("\xE2\x80\x9C",'"').gsub("\xE2\x80\x9D",'"').gsub("\xCB\xAE",'"').squeeze(" ")
|
|
38
|
+
end
|
|
237
39
|
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
40
|
+
def strip_urls
|
|
41
|
+
gsub(/(https?:\/\/)?([\da-z\.-]+)\.([a-z\.]{2,6})([\/\w \.-]*)*\/?/i,"")
|
|
42
|
+
end
|
|
241
43
|
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
end
|
|
44
|
+
def strip_all
|
|
45
|
+
strip_tags.strip_markdown.strip
|
|
245
46
|
end
|
|
47
|
+
|
|
246
48
|
end
|
data/lib/jtag/version.rb
CHANGED
data/lib/jtag.rb
CHANGED
|
@@ -1,19 +1,13 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
require
|
|
4
|
-
require
|
|
5
|
-
require
|
|
6
|
-
require
|
|
7
|
-
require
|
|
8
|
-
require
|
|
9
|
-
require
|
|
10
|
-
require
|
|
11
|
-
require
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
require_relative "jtag/hash.rb"
|
|
15
|
-
require_relative "jtag/version.rb"
|
|
16
|
-
require_relative "jtag/string.rb"
|
|
17
|
-
require_relative "jtag/porter_stemming.rb"
|
|
18
|
-
require_relative "jtag/jekylltag.rb"
|
|
19
|
-
require_relative "jtag/util.rb"
|
|
1
|
+
require 'net/http'
|
|
2
|
+
require 'cgi'
|
|
3
|
+
require 'fileutils'
|
|
4
|
+
require 'yaml'
|
|
5
|
+
require 'csv'
|
|
6
|
+
require 'json'
|
|
7
|
+
require 'plist'
|
|
8
|
+
require 'jtag/version.rb'
|
|
9
|
+
require 'jtag/string.rb'
|
|
10
|
+
require 'jtag/porter_stemming.rb'
|
|
11
|
+
require 'jtag/jekylltag.rb'
|
|
12
|
+
require 'tmpdir'
|
|
13
|
+
require 'logger'
|
metadata
CHANGED
|
@@ -1,100 +1,112 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: jtag
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.2.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Brett Terpstra
|
|
8
|
-
autorequire:
|
|
9
8
|
bindir: bin
|
|
10
9
|
cert_chain: []
|
|
11
|
-
date:
|
|
10
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
|
12
11
|
dependencies:
|
|
13
12
|
- !ruby/object:Gem::Dependency
|
|
14
13
|
name: rake
|
|
15
14
|
requirement: !ruby/object:Gem::Requirement
|
|
16
15
|
requirements:
|
|
17
|
-
- - "
|
|
16
|
+
- - ">="
|
|
18
17
|
- !ruby/object:Gem::Version
|
|
19
|
-
version: '
|
|
18
|
+
version: '0'
|
|
20
19
|
type: :development
|
|
21
20
|
prerelease: false
|
|
22
21
|
version_requirements: !ruby/object:Gem::Requirement
|
|
23
22
|
requirements:
|
|
24
|
-
- - "
|
|
23
|
+
- - ">="
|
|
25
24
|
- !ruby/object:Gem::Version
|
|
26
|
-
version: '
|
|
25
|
+
version: '0'
|
|
27
26
|
- !ruby/object:Gem::Dependency
|
|
28
27
|
name: rdoc
|
|
29
28
|
requirement: !ruby/object:Gem::Requirement
|
|
30
29
|
requirements:
|
|
31
|
-
- - "
|
|
30
|
+
- - ">="
|
|
32
31
|
- !ruby/object:Gem::Version
|
|
33
|
-
version: '
|
|
32
|
+
version: '0'
|
|
34
33
|
type: :development
|
|
35
34
|
prerelease: false
|
|
36
35
|
version_requirements: !ruby/object:Gem::Requirement
|
|
37
36
|
requirements:
|
|
38
|
-
- - "
|
|
37
|
+
- - ">="
|
|
39
38
|
- !ruby/object:Gem::Version
|
|
40
|
-
version: '
|
|
39
|
+
version: '0'
|
|
41
40
|
- !ruby/object:Gem::Dependency
|
|
42
41
|
name: aruba
|
|
43
42
|
requirement: !ruby/object:Gem::Requirement
|
|
44
43
|
requirements:
|
|
45
|
-
- - "
|
|
44
|
+
- - ">="
|
|
46
45
|
- !ruby/object:Gem::Version
|
|
47
|
-
version: '
|
|
46
|
+
version: '0'
|
|
48
47
|
type: :development
|
|
49
48
|
prerelease: false
|
|
50
49
|
version_requirements: !ruby/object:Gem::Requirement
|
|
51
50
|
requirements:
|
|
52
|
-
- - "
|
|
51
|
+
- - ">="
|
|
53
52
|
- !ruby/object:Gem::Version
|
|
54
|
-
version: '
|
|
53
|
+
version: '0'
|
|
55
54
|
- !ruby/object:Gem::Dependency
|
|
56
55
|
name: gli
|
|
57
56
|
requirement: !ruby/object:Gem::Requirement
|
|
58
57
|
requirements:
|
|
59
|
-
- -
|
|
58
|
+
- - "~>"
|
|
60
59
|
- !ruby/object:Gem::Version
|
|
61
60
|
version: 2.20.0
|
|
62
61
|
type: :runtime
|
|
63
62
|
prerelease: false
|
|
64
63
|
version_requirements: !ruby/object:Gem::Requirement
|
|
65
64
|
requirements:
|
|
66
|
-
- -
|
|
65
|
+
- - "~>"
|
|
67
66
|
- !ruby/object:Gem::Version
|
|
68
67
|
version: 2.20.0
|
|
69
68
|
- !ruby/object:Gem::Dependency
|
|
70
69
|
name: plist
|
|
71
70
|
requirement: !ruby/object:Gem::Requirement
|
|
72
71
|
requirements:
|
|
73
|
-
- - "
|
|
72
|
+
- - ">="
|
|
74
73
|
- !ruby/object:Gem::Version
|
|
75
|
-
version: '
|
|
74
|
+
version: '0'
|
|
76
75
|
type: :runtime
|
|
77
76
|
prerelease: false
|
|
78
77
|
version_requirements: !ruby/object:Gem::Requirement
|
|
79
78
|
requirements:
|
|
80
|
-
- - "
|
|
79
|
+
- - ">="
|
|
81
80
|
- !ruby/object:Gem::Version
|
|
82
|
-
version: '
|
|
81
|
+
version: '0'
|
|
83
82
|
- !ruby/object:Gem::Dependency
|
|
84
83
|
name: csv
|
|
85
84
|
requirement: !ruby/object:Gem::Requirement
|
|
86
85
|
requirements:
|
|
87
|
-
- - "
|
|
86
|
+
- - ">="
|
|
88
87
|
- !ruby/object:Gem::Version
|
|
89
|
-
version: '
|
|
88
|
+
version: '0'
|
|
90
89
|
type: :runtime
|
|
91
90
|
prerelease: false
|
|
92
91
|
version_requirements: !ruby/object:Gem::Requirement
|
|
93
92
|
requirements:
|
|
94
|
-
- - "
|
|
93
|
+
- - ">="
|
|
94
|
+
- !ruby/object:Gem::Version
|
|
95
|
+
version: '0'
|
|
96
|
+
- !ruby/object:Gem::Dependency
|
|
97
|
+
name: ostruct
|
|
98
|
+
requirement: !ruby/object:Gem::Requirement
|
|
99
|
+
requirements:
|
|
100
|
+
- - ">="
|
|
95
101
|
- !ruby/object:Gem::Version
|
|
96
|
-
version: '
|
|
97
|
-
|
|
102
|
+
version: '0'
|
|
103
|
+
type: :runtime
|
|
104
|
+
prerelease: false
|
|
105
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
106
|
+
requirements:
|
|
107
|
+
- - ">="
|
|
108
|
+
- !ruby/object:Gem::Version
|
|
109
|
+
version: '0'
|
|
98
110
|
email: me@brettterpstra.com
|
|
99
111
|
executables:
|
|
100
112
|
- jtag
|
|
@@ -103,38 +115,21 @@ extra_rdoc_files:
|
|
|
103
115
|
- README.rdoc
|
|
104
116
|
- jtag.rdoc
|
|
105
117
|
files:
|
|
106
|
-
- ".irbrc"
|
|
107
|
-
- CHANGELOG.md
|
|
108
|
-
- Gemfile
|
|
109
|
-
- Jekyll/plugins/autotag_gen.rb
|
|
110
|
-
- Jekyll/source/_layouts/tags_json.html
|
|
111
|
-
- README.md
|
|
112
118
|
- README.rdoc
|
|
113
|
-
- Rakefile
|
|
114
119
|
- bin/jtag
|
|
115
|
-
- jtag.completion.bash
|
|
116
|
-
- jtag.gemspec
|
|
117
120
|
- jtag.rdoc
|
|
118
121
|
- lib/jtag.rb
|
|
119
|
-
- lib/jtag/array.rb
|
|
120
122
|
- lib/jtag/config_files/blacklist.txt
|
|
121
123
|
- lib/jtag/config_files/config.yml
|
|
122
124
|
- lib/jtag/config_files/stopwords.txt
|
|
123
125
|
- lib/jtag/config_files/synonyms.yml
|
|
124
|
-
- lib/jtag/errors.rb
|
|
125
|
-
- lib/jtag/hash.rb
|
|
126
126
|
- lib/jtag/jekylltag.rb
|
|
127
127
|
- lib/jtag/porter_stemming.rb
|
|
128
128
|
- lib/jtag/string.rb
|
|
129
|
-
- lib/jtag/stupid_json.rb
|
|
130
|
-
- lib/jtag/util.rb
|
|
131
129
|
- lib/jtag/version.rb
|
|
132
|
-
- mise.toml
|
|
133
130
|
homepage: http://brettterpstra.com
|
|
134
|
-
licenses:
|
|
135
|
-
-
|
|
131
|
+
licenses: []
|
|
136
132
|
metadata: {}
|
|
137
|
-
post_install_message:
|
|
138
133
|
rdoc_options:
|
|
139
134
|
- "--title"
|
|
140
135
|
- jtag
|
|
@@ -147,15 +142,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
|
147
142
|
requirements:
|
|
148
143
|
- - ">="
|
|
149
144
|
- !ruby/object:Gem::Version
|
|
150
|
-
version: '
|
|
145
|
+
version: '0'
|
|
151
146
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
152
147
|
requirements:
|
|
153
148
|
- - ">="
|
|
154
149
|
- !ruby/object:Gem::Version
|
|
155
150
|
version: '0'
|
|
156
151
|
requirements: []
|
|
157
|
-
rubygems_version: 3.
|
|
158
|
-
signing_key:
|
|
152
|
+
rubygems_version: 3.6.7
|
|
159
153
|
specification_version: 4
|
|
160
154
|
summary: Auto-tagging and tagging tools for Jekyll
|
|
161
155
|
test_files: []
|
data/.irbrc
DELETED
data/CHANGELOG.md
DELETED
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
### 0.1.25
|
|
2
|
-
|
|
3
|
-
2026-11-04 10:03
|
|
4
|
-
|
|
5
|
-
#### FIXED
|
|
6
|
-
|
|
7
|
-
- Errors updating deprecated config location
|
|
8
|
-
|
|
9
|
-
### 0.1.19
|
|
10
|
-
|
|
11
|
-
2024-09-16 13:15
|
|
12
|
-
|
|
13
|
-
#### NEW
|
|
14
|
-
|
|
15
|
-
- Allows piping of file lists. For actions to which it applies, you can pipe a file list, either from a previous jtag command or from another source (newline separated) to act on only those files, e.g. `jtag posts_tagged keyboard | jtag tags`
|
|
16
|
-
|
|
17
|
-
#### FIXED
|
|
18
|
-
|
|
19
|
-
- File.exists? => File.exist? for Ruby 3
|
|
20
|
-
|
|
21
|
-
### 1.0
|
|
22
|
-
|
|
23
|
-
Initial release
|
data/Gemfile
DELETED
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
#
|
|
2
|
-
# Author: Brett Terpstra
|
|
3
|
-
# Page generator for /data/tags.json, a list of all the tags on your blog and a list of the top 50 tags.
|
|
4
|
-
# Part of the AutoTag tool for Jekyll, but usable in other applications
|
|
5
|
-
#
|
|
6
|
-
# Looks for a tags_json.html template in your _layouts folder, see the example provided.
|
|
7
|
-
# Provides page.json_tags and page.json_tags_count as arrays for looping
|
|
8
|
-
#
|
|
9
|
-
# Config options for _config.yml
|
|
10
|
-
# tag_excludes: array of tags to exclude from all listings
|
|
11
|
-
# tags_json_dir: alternate of folder for the data.json file. Set to blank for root, defaults to 'data'
|
|
12
|
-
#
|
|
13
|
-
# If using tags.json with a javascript application, be sure you have the proper headers defined in .htaccess:
|
|
14
|
-
# AddType application/json json
|
|
15
|
-
# ExpiresByType application/json "access plus 0 seconds"
|
|
16
|
-
|
|
17
|
-
require 'json'
|
|
18
|
-
|
|
19
|
-
module Jekyll
|
|
20
|
-
|
|
21
|
-
class AutoTag < Page
|
|
22
|
-
def initialize(site, base, dir)
|
|
23
|
-
@site = site
|
|
24
|
-
@base = base
|
|
25
|
-
@dir = dir
|
|
26
|
-
@name = 'tags.json'
|
|
27
|
-
self.process(@name)
|
|
28
|
-
self.read_yaml(File.join(base, '_layouts'), 'tags_json.html')
|
|
29
|
-
tags_with_counts = site.tags.delete_if {|k,v|
|
|
30
|
-
site.config['tag_excludes'].include?(k) unless site.config['tag_excludes'].nil?
|
|
31
|
-
}.sort_by { |k,v| v.count }.reverse
|
|
32
|
-
|
|
33
|
-
self.data['json_tags'] = tags_with_counts.sort {|a,b| a[0].downcase <=> b[0].downcase }.map {|k,v| k }
|
|
34
|
-
self.data['json_tags_count'] = []
|
|
35
|
-
tags_with_counts.each { |k,v|
|
|
36
|
-
self.data['json_tags_count'] << {
|
|
37
|
-
"name" => k,
|
|
38
|
-
"count" => v.count
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
end
|
|
42
|
-
end
|
|
43
|
-
class AutoTagGenerator < Generator
|
|
44
|
-
safe true
|
|
45
|
-
def generate(site)
|
|
46
|
-
if site.layouts.key? 'tags_json'
|
|
47
|
-
dir = site.config['tag_json_dir'] || 'data'
|
|
48
|
-
write_tag_json(site, dir)
|
|
49
|
-
end
|
|
50
|
-
end
|
|
51
|
-
def write_tag_json(site, dir)
|
|
52
|
-
index = AutoTag.new(site, site.source, dir)
|
|
53
|
-
index.render(site.layouts, site.site_payload)
|
|
54
|
-
index.write(site.dest)
|
|
55
|
-
site.pages << index
|
|
56
|
-
end
|
|
57
|
-
end
|
|
58
|
-
end
|