jtag 0.1.10 → 0.1.12
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 +7 -0
- data/bin/jtag +209 -42
- data/lib/jtag.rb +2 -3
- data/lib/jtag/config_files/config.yml +2 -0
- data/lib/jtag/jekylltag.rb +75 -9
- data/lib/jtag/version.rb +1 -1
- metadata +31 -45
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: db1f81c4454558bb43b86b14534a46106fffd94a
|
4
|
+
data.tar.gz: bbdbb8861c0be80a8199f019e586ddad637a3500
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: e9a3aa5f5d9123c3d94a3a63d972781f3289267badac6ea367d3ac7b5242bc7d0a240af242985b7b42a1944dde1655582ab1d8daf17c099e3df7636c2aac9af7
|
7
|
+
data.tar.gz: a3bb2004a8e9e6760abb2c28ab5edec017eba25a4c213a4509efc59bd663132f1f43b9a7a4f311b52bb3ba78ba4deac88e1197bf2732ecde80eb6a3203b27152
|
data/bin/jtag
CHANGED
@@ -22,19 +22,33 @@ end
|
|
22
22
|
desc 'Debug level'
|
23
23
|
default_value '0'
|
24
24
|
arg_name 'debug_level'
|
25
|
-
flag [:d,:debug]
|
25
|
+
flag [:d,:debug], :must_match => /\d+/, :type => Integer, :default_value => 0
|
26
26
|
|
27
27
|
desc 'Run silently'
|
28
|
-
switch [:s
|
28
|
+
switch [:s,:silent]
|
29
29
|
|
30
|
-
desc
|
30
|
+
desc 'Perform case-insensitive matches and searches'
|
31
|
+
switch [:i,:case_insensitive]
|
32
|
+
|
33
|
+
desc "Test (dry run, don't update files)"
|
31
34
|
long_desc "Run all commands and show results on the command line, but don't overwrite/update any files"
|
32
35
|
default_value false
|
33
|
-
switch [:t
|
36
|
+
switch [:t,:test]
|
34
37
|
|
35
38
|
def console_log(msg="", options={})
|
36
|
-
return if @silent
|
37
39
|
err = options[:err] || false
|
40
|
+
options[:log] ||= false
|
41
|
+
|
42
|
+
if options[:log]
|
43
|
+
if err
|
44
|
+
@log.warn(msg)
|
45
|
+
else
|
46
|
+
@log.info(msg)
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
return if @silent
|
51
|
+
|
38
52
|
unless err
|
39
53
|
$stdout.puts msg
|
40
54
|
else
|
@@ -106,8 +120,8 @@ command :search do |c|
|
|
106
120
|
c.action do |global_options,options,args|
|
107
121
|
tags = @jt.get_tags({:counts => true})
|
108
122
|
if args.length > 0
|
123
|
+
re = args.join("|")
|
109
124
|
tags.delete_if {|tag|
|
110
|
-
re = args.join("|")
|
111
125
|
if tag && tag['name'] =~ /(#{re})/i
|
112
126
|
false
|
113
127
|
else
|
@@ -158,10 +172,15 @@ command :posts_tagged do |c|
|
|
158
172
|
if File.exists?(arg)
|
159
173
|
files.push(arg)
|
160
174
|
else
|
161
|
-
exit_now! "No valid filename in arguments" if files.empty?
|
162
175
|
tags.push(arg)
|
163
176
|
end
|
164
177
|
end
|
178
|
+
if files.empty?
|
179
|
+
if @jt.default_post_location && File.exists?(File.dirname(@jt.default_post_location))
|
180
|
+
files = Dir.glob(@jt.default_post_location)
|
181
|
+
end
|
182
|
+
end
|
183
|
+
exit_now! "No valid filename in arguments" if files.empty?
|
165
184
|
files.each {|file|
|
166
185
|
if File.exists?(file)
|
167
186
|
post_tags = @jt.post_tags(file)
|
@@ -200,9 +219,116 @@ command :posts_tagged do |c|
|
|
200
219
|
end
|
201
220
|
end
|
202
221
|
|
222
|
+
desc 'Show tags with fewer than X posts attached to them, optionally removing them from specified posts'
|
223
|
+
arg_name 'file_pattern', :multiple
|
224
|
+
command :loners do |c|
|
225
|
+
c.desc 'Format to use when outputting tags to console: list, json, plist, csv or yaml. Defaults to yaml.'
|
226
|
+
c.arg_name 'output_format'
|
227
|
+
c.default_value 'yaml'
|
228
|
+
c.flag [:f,:format], :must_match => /^(csv|list|yaml|json|plist)$/, :type => String
|
229
|
+
|
230
|
+
c.desc 'Upper limit for how many posts a tag can be attached to and still be a loner'
|
231
|
+
c.arg_name 'max'
|
232
|
+
c.default_value '2'
|
233
|
+
c.flag [:m,:max], :default_value => 2, :must_match => /^\d+$/
|
234
|
+
|
235
|
+
c.desc "Remove tags with fewer than X posts attached"
|
236
|
+
c.switch [:r,:remove], :default_value => false
|
237
|
+
|
238
|
+
c.desc "Display output without attached occurence counts"
|
239
|
+
c.switch [:no_counts], :default_value => false
|
240
|
+
|
241
|
+
c.desc 'Output a file list of tags that can be edited and passed back in for removing'
|
242
|
+
c.arg_name 'filename'
|
243
|
+
c.flag [:e,:edit], :default_value => false, :type => String
|
244
|
+
|
245
|
+
c.action do |global_options,options,args|
|
246
|
+
max = options[:m].to_i
|
247
|
+
loner_tags = @jt.get_tags({:counts => true})
|
248
|
+
loner_tags.delete_if { |tag|
|
249
|
+
tag.class == FalseClass || tag['count'] > max
|
250
|
+
}
|
251
|
+
loner_tags.sort_by! {|tag| tag['count']}
|
252
|
+
|
253
|
+
exit_now! "No tags matched the criteria" if loner_tags.empty? || loner_tags.nil?
|
254
|
+
|
255
|
+
if options[:e]
|
256
|
+
path = File.expand_path(options[:e])
|
257
|
+
while File.exists?(path)
|
258
|
+
if path =~ /(\d+)(\.[^\.]+?)?$/
|
259
|
+
path.sub!(/(\d+)(\.[^\.]+?)?$/) do |m|
|
260
|
+
$1.next! + $2
|
261
|
+
end
|
262
|
+
else
|
263
|
+
path.sub!(/(\.[^\.]+?)?$/,'01\1')
|
264
|
+
end
|
265
|
+
end
|
266
|
+
File.open(path, 'w+') do |f|
|
267
|
+
f.puts "# Edit this file to remove tags you want to keep,"
|
268
|
+
f.puts "# then run `jtag remove -p '#{path}' [/path/to/posts/*.md]`"
|
269
|
+
f.puts "# to remove any tags left in the file."
|
270
|
+
f.puts "#"
|
271
|
+
f.puts "# The post counts are included for your convenience, and will"
|
272
|
+
f.puts "# be automatically ignored when reading the list back in."
|
273
|
+
f.puts "#"
|
274
|
+
f.puts "# Lines beginning with a # are comments (ignored), but you probably figured that out."
|
275
|
+
loner_tags.each{ |t|
|
276
|
+
f.printf "% 3d |\t%s\n", t['count'], t['name']
|
277
|
+
}
|
278
|
+
end
|
279
|
+
|
280
|
+
console_log "A list of results and instructions for use have been written to #{path}."
|
281
|
+
if ENV['EDITOR']
|
282
|
+
console_log
|
283
|
+
print "Would you like to open the file in #{ENV['EDITOR']} now? (y/N) "
|
284
|
+
input = STDIN.gets
|
285
|
+
if input =~ /^y/i
|
286
|
+
system "#{ENV['EDITOR']} '#{path}'"
|
287
|
+
end
|
288
|
+
end
|
289
|
+
elsif options[:r]
|
290
|
+
files = []
|
291
|
+
args.length.times do
|
292
|
+
arg = args.pop
|
293
|
+
files.push(arg) if File.exists?(arg)
|
294
|
+
end
|
295
|
+
if files.empty?
|
296
|
+
if @jt.default_post_location && File.exists?(File.dirname(@jt.default_post_location))
|
297
|
+
files = Dir.glob(@jt.default_post_location)
|
298
|
+
end
|
299
|
+
end
|
300
|
+
exit_now! "No valid filename in arguments" if files.empty?
|
301
|
+
files.each {|file|
|
302
|
+
tags = @jt.post_tags(file)
|
303
|
+
loner_tags.each { |d|
|
304
|
+
tags.delete_if { |tag|
|
305
|
+
if global_options[:i]
|
306
|
+
tag.downcase == d.downcase
|
307
|
+
else
|
308
|
+
tag == d
|
309
|
+
end
|
310
|
+
}
|
311
|
+
}
|
312
|
+
unless global_options[:t]
|
313
|
+
@jt.update_file_tags(file,tags)
|
314
|
+
console_log "Updated tags for #{file}", :log => true
|
315
|
+
end
|
316
|
+
|
317
|
+
console_log
|
318
|
+
console_log File.basename(file) + ":"
|
319
|
+
output_tags(tags, :format => options[:format], :filename => file )
|
320
|
+
}
|
321
|
+
else
|
322
|
+
output_tags(loner_tags.map{|tag|
|
323
|
+
count = options[:no_counts] ? "" : " (#{tag['count']})"
|
324
|
+
"#{tag['name']}#{count}"}, :format => options[:format] )
|
325
|
+
end
|
326
|
+
end
|
327
|
+
end
|
328
|
+
|
203
329
|
|
204
330
|
desc 'Show the current tags for posts'
|
205
|
-
arg_name '
|
331
|
+
arg_name 'file_pattern', :multiple
|
206
332
|
command :tags do |c|
|
207
333
|
c.desc 'Format to use when outputting tags to console: list, json, plist, csv or yaml. Defaults to yaml.'
|
208
334
|
c.arg_name 'output_format'
|
@@ -233,7 +359,7 @@ command :tags do |c|
|
|
233
359
|
if tags.empty? || tags.nil?
|
234
360
|
console_log "No tags in post", {:err => true}
|
235
361
|
else
|
236
|
-
output_tags(tags,{ :format => options[:format] })
|
362
|
+
output_tags(tags,{ :format => options[:format], :filename => file })
|
237
363
|
end
|
238
364
|
else
|
239
365
|
raise "File not found: #{file}"
|
@@ -244,7 +370,7 @@ end
|
|
244
370
|
|
245
371
|
|
246
372
|
desc 'Sort the existing tags for posts'
|
247
|
-
arg_name '
|
373
|
+
arg_name 'file_pattern', :multiple
|
248
374
|
command :sort do |c|
|
249
375
|
c.desc 'Format to use when outputting tags to console: list, json, plist, csv or yaml. Defaults to yaml.'
|
250
376
|
c.arg_name 'output_format'
|
@@ -259,14 +385,13 @@ command :sort do |c|
|
|
259
385
|
unless global_options[:t]
|
260
386
|
@jt.update_file_tags(file, tags)
|
261
387
|
end
|
262
|
-
|
263
|
-
|
264
|
-
|
265
|
-
end
|
388
|
+
console_log
|
389
|
+
console_log File.basename(file) + ":"
|
390
|
+
|
266
391
|
if tags.empty? || tags.nil?
|
267
392
|
console_log "No tags in post", {:err => true}
|
268
393
|
else
|
269
|
-
output_tags(tags,{ :format => options[:format] })
|
394
|
+
output_tags(tags,{ :format => options[:format], :filename => file })
|
270
395
|
end
|
271
396
|
}
|
272
397
|
end
|
@@ -289,11 +414,15 @@ command :merge do |c|
|
|
289
414
|
if File.exists?(arg)
|
290
415
|
files.push(arg)
|
291
416
|
else
|
292
|
-
exit_now! "No valid filename in arguments" if files.empty?
|
293
417
|
tags.push(arg)
|
294
418
|
end
|
295
419
|
end
|
296
|
-
|
420
|
+
if files.empty?
|
421
|
+
if @jt.default_post_location && File.exists?(File.dirname(@jt.default_post_location))
|
422
|
+
files = Dir.glob(@jt.default_post_location)
|
423
|
+
end
|
424
|
+
end
|
425
|
+
exit_now! "No valid filename in arguments" if files.empty?
|
297
426
|
exit_now! "Needs at least two tag inputs, one or more to merge, one to merge to" if tags.length < 2
|
298
427
|
tags.reverse!
|
299
428
|
merge_tag = tags.pop
|
@@ -304,11 +433,13 @@ command :merge do |c|
|
|
304
433
|
unless global_options[:t]
|
305
434
|
@jt.update_file_tags(file, new_tags)
|
306
435
|
console_log
|
307
|
-
console_log "Updated tags for #{file}"
|
436
|
+
console_log "Updated tags for #{file}", :log => true
|
308
437
|
end
|
438
|
+
|
309
439
|
console_log
|
310
440
|
console_log File.basename(file) + ":"
|
311
|
-
output_tags(new_tags,{ :format => options[:format] })
|
441
|
+
output_tags(new_tags,{ :format => options[:format], :filename => file })
|
442
|
+
|
312
443
|
}
|
313
444
|
end
|
314
445
|
end
|
@@ -333,6 +464,7 @@ end
|
|
333
464
|
|
334
465
|
desc 'Add tags to post(s)'
|
335
466
|
arg_name 'tags', :multiple
|
467
|
+
arg_name 'file_pattern'
|
336
468
|
command :add do |c|
|
337
469
|
c.desc 'Format to use when outputting tags to console: list, json, plist, csv or yaml. Defaults to yaml.'
|
338
470
|
c.arg_name 'output_format'
|
@@ -348,11 +480,15 @@ command :add do |c|
|
|
348
480
|
if File.exists?(arg)
|
349
481
|
files.push(arg)
|
350
482
|
else
|
351
|
-
exit_now! "No valid filename in arguments" if files.empty?
|
352
483
|
new_tags.push(arg)
|
353
484
|
end
|
354
485
|
end
|
355
|
-
|
486
|
+
if files.empty?
|
487
|
+
if @jt.default_post_location && File.exists?(File.dirname(@jt.default_post_location))
|
488
|
+
files = Dir.glob(@jt.default_post_location)
|
489
|
+
end
|
490
|
+
end
|
491
|
+
exit_now! "No valid filename in arguments" if files.empty?
|
356
492
|
exit_now! "No tags found in arguments" if new_tags.empty?
|
357
493
|
|
358
494
|
files.each {|file|
|
@@ -362,12 +498,12 @@ command :add do |c|
|
|
362
498
|
tags.sort!
|
363
499
|
unless global_options[:t]
|
364
500
|
@jt.update_file_tags(file,tags)
|
365
|
-
console_log "Updated tags for #{file}"
|
501
|
+
console_log "Updated tags for #{file}", :log => true
|
366
502
|
end
|
367
503
|
|
368
504
|
console_log
|
369
505
|
console_log File.basename(file) + ":"
|
370
|
-
output_tags(tags,
|
506
|
+
output_tags(tags, :format => options[:format], :filename => file)
|
371
507
|
}
|
372
508
|
end
|
373
509
|
end
|
@@ -380,6 +516,11 @@ command :remove do |c|
|
|
380
516
|
c.default_value 'yaml'
|
381
517
|
c.flag [:f,:format], :must_match => /^(csv|list|yaml|json|plist)$/, :type => String
|
382
518
|
|
519
|
+
c.desc 'A filepath to a list of tags to be removed'
|
520
|
+
c.long_desc 'One tag per line, and leading numbers and pipes (|) will be ignored. This file format is generated automatically by the `loners` command, but any text file will do the trick.'
|
521
|
+
c.arg_name 'input_file'
|
522
|
+
c.flag [:p,:path], :type => String
|
523
|
+
|
383
524
|
c.action do |global_options,options,args|
|
384
525
|
files = []
|
385
526
|
remove_tags = []
|
@@ -388,32 +529,55 @@ command :remove do |c|
|
|
388
529
|
if File.exists?(arg)
|
389
530
|
files.push(arg)
|
390
531
|
else
|
391
|
-
|
392
|
-
|
532
|
+
remove_tags.push(arg) unless options[:p]
|
533
|
+
end
|
534
|
+
end
|
535
|
+
if files.empty?
|
536
|
+
if @jt.default_post_location && File.exists?(File.dirname(@jt.default_post_location))
|
537
|
+
files = Dir.glob(@jt.default_post_location)
|
393
538
|
end
|
394
539
|
end
|
540
|
+
exit_now! "No valid filename in arguments" if files.empty?
|
541
|
+
|
542
|
+
if options[:p]
|
543
|
+
path = File.expand_path(options[:p])
|
544
|
+
exit_now! "Input file does not appear to be where you think it is." unless File.exists?(path)
|
545
|
+
IO.read(path).each_line {|l|
|
546
|
+
next if l =~ /^\s*#/
|
547
|
+
if l =~ /^(?:[\s\d])*(?:\|\s*)?(\S.*?)$/
|
548
|
+
remove_tags.push($1.strip)
|
549
|
+
end
|
550
|
+
}
|
551
|
+
console_log "Found #{remove_tags.length} tags in #{File.basename(path)}..."
|
552
|
+
end
|
395
553
|
|
396
|
-
exit_now! "No tags found in
|
554
|
+
exit_now! "No tags found in input, my work here is done" if remove_tags.empty?
|
397
555
|
|
398
556
|
files.each {|file|
|
399
557
|
tags = @jt.post_tags(file)
|
400
558
|
remove_tags.each { |d|
|
401
|
-
tags.delete_if { |tag|
|
559
|
+
tags.delete_if { |tag|
|
560
|
+
if global_options[:i]
|
561
|
+
tag.downcase == d.downcase
|
562
|
+
else
|
563
|
+
tag == d
|
564
|
+
end
|
565
|
+
}
|
402
566
|
}
|
403
567
|
unless global_options[:t]
|
404
568
|
@jt.update_file_tags(file,tags)
|
405
|
-
console_log "Updated tags for #{file}"
|
569
|
+
console_log "Updated tags for #{file}", :log => true
|
406
570
|
end
|
407
571
|
|
408
572
|
console_log
|
409
573
|
console_log File.basename(file) + ":"
|
410
|
-
output_tags(tags,{ :format => options[:format] })
|
574
|
+
output_tags(tags,{ :format => options[:format], :filename => file })
|
411
575
|
}
|
412
576
|
end
|
413
577
|
end
|
414
578
|
|
415
579
|
desc 'Generate a list of recommended tags, optionally updating the file'
|
416
|
-
arg_name '
|
580
|
+
arg_name 'file_pattern', :multiple
|
417
581
|
command :tag do |c|
|
418
582
|
c.desc 'Format to use when outputting tags to console: list, json, plist, csv or yaml. Defaults to yaml.'
|
419
583
|
c.arg_name 'output_format'
|
@@ -426,9 +590,9 @@ command :tag do |c|
|
|
426
590
|
if !global_options[:s] || global_options[:t]
|
427
591
|
if args.length > 1
|
428
592
|
console_log
|
429
|
-
console_log "STDIN:",
|
593
|
+
console_log "STDIN:", :err => true
|
430
594
|
end
|
431
|
-
output_tags(suggestions,
|
595
|
+
output_tags(suggestions, :format => options[:format], :filename => file )
|
432
596
|
end
|
433
597
|
end
|
434
598
|
args.each {|file|
|
@@ -439,18 +603,18 @@ command :tag do |c|
|
|
439
603
|
unless global_options[:t]
|
440
604
|
if @jt.update_file_tags(file, suggestions)
|
441
605
|
console_log
|
442
|
-
console_log "Updated file #{file} with:"
|
606
|
+
console_log "Updated file #{file} with:", :log => true
|
443
607
|
else
|
444
608
|
console_log
|
445
|
-
console_log "Failed to update #{file} with:"
|
609
|
+
console_log "Failed to update #{file} with:", :log => true
|
446
610
|
end
|
447
611
|
end
|
448
612
|
if !global_options[:s] || global_options[:t]
|
449
613
|
if args.length > 1
|
450
614
|
console_log
|
451
|
-
console_log File.basename(file) + ":",
|
615
|
+
console_log File.basename(file) + ":", :err => true, :log => true
|
452
616
|
end
|
453
|
-
output_tags(suggestions,
|
617
|
+
output_tags(suggestions, :format => options[:format], :filename => file )
|
454
618
|
end
|
455
619
|
suggestions = nil
|
456
620
|
else
|
@@ -463,7 +627,7 @@ end
|
|
463
627
|
def output_tags(tags,options)
|
464
628
|
format = options[:format] || 'yaml'
|
465
629
|
print0 = options[:print0] || false
|
466
|
-
|
630
|
+
filename = options[:filename] || false
|
467
631
|
case format
|
468
632
|
when 'list'
|
469
633
|
unless print0
|
@@ -482,12 +646,14 @@ def output_tags(tags,options)
|
|
482
646
|
when 'json'
|
483
647
|
out = {}
|
484
648
|
out['tags'] = tags
|
649
|
+
out['path'] = filename if filename
|
485
650
|
console_log out.to_json
|
486
651
|
when 'plist'
|
487
652
|
out = {}
|
653
|
+
out['path'] = filename if filename
|
488
654
|
console_log tags.to_plist
|
489
655
|
else
|
490
|
-
|
656
|
+
out = {}
|
491
657
|
options[:grouping] ||= "tags"
|
492
658
|
out[options[:grouping]] = tags
|
493
659
|
console_log out.to_yaml
|
@@ -505,16 +671,17 @@ end
|
|
505
671
|
# end
|
506
672
|
|
507
673
|
pre do |global,command,options,args|
|
508
|
-
# Pre logic here
|
509
|
-
# Return true to proceed; false to abort and not call the
|
510
|
-
# chosen command
|
511
674
|
# Use skips_pre before a command to skip this block
|
512
675
|
# on that command only
|
513
676
|
@silent = global[:silent]
|
514
677
|
|
678
|
+
@logfile = File.open(File.join(Dir.tmpdir, "jtag_actions.log"), 'a')
|
679
|
+
|
680
|
+
@log = Logger.new(@logfile, shift_age = 7, shift_size = 1048576)
|
681
|
+
|
515
682
|
unless config_files_complete?
|
516
683
|
write_config
|
517
|
-
console_log "Missing config files written to #{@config_target}. Please check your configuration."
|
684
|
+
console_log "Missing config files written to #{@config_target}. Please check your configuration.", {:err => true}
|
518
685
|
return false
|
519
686
|
end
|
520
687
|
|
data/lib/jtag.rb
CHANGED
@@ -9,6 +9,5 @@ require 'jtag/version.rb'
|
|
9
9
|
require 'jtag/string.rb'
|
10
10
|
require 'jtag/porter_stemming.rb'
|
11
11
|
require 'jtag/jekylltag.rb'
|
12
|
-
|
13
|
-
|
14
|
-
# you just need to require this one file in your bin file
|
12
|
+
require 'tmpdir'
|
13
|
+
require 'logger'
|
data/lib/jtag/jekylltag.rb
CHANGED
@@ -1,13 +1,32 @@
|
|
1
1
|
# encoding: utf-8
|
2
|
+
|
2
3
|
class JTag
|
4
|
+
attr_reader :default_post_location
|
5
|
+
attr_accessor :tags_key
|
3
6
|
|
4
7
|
def initialize(support_dir, config)
|
5
8
|
@support = support_dir
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
+
begin
|
10
|
+
@tags_loc = config['tags_location']
|
11
|
+
@tags_loc.sub!(/^https?:\/\//,'')
|
12
|
+
rescue
|
13
|
+
raise "No tags location in configuration."
|
14
|
+
end
|
15
|
+
@min_matches = config['min_matches'] || 2
|
16
|
+
@tags_key = config['tags_key'] || 'tags'
|
17
|
+
|
18
|
+
if config.has_key? 'default_post_location'
|
19
|
+
@default_post_location = File.expand_path(config['default_post_location']) || false
|
20
|
+
else
|
21
|
+
console_log "#{color('yellow')}No #{color('boldyellow')}default_post_location#{color('yellow')} set.", :err => true
|
22
|
+
console_log "If you commonly work on the same posts you can add the path and *.ext", :err => true
|
23
|
+
console_log "to this key in ~/.jtag/config.yml. Then, if you don't specify files", :err => true
|
24
|
+
console_log "to act on in a command, it will fall back to those. Nice!#{color('default')}", :err => true
|
25
|
+
@default_post_location = false
|
26
|
+
end
|
27
|
+
@blacklistfile = File.join(@support,'blacklist.txt')
|
9
28
|
@blacklist = IO.read(@blacklistfile).split("\n") || []
|
10
|
-
@skipwords = IO.read(File.join(support_dir,
|
29
|
+
@skipwords = IO.read(File.join(support_dir,'stopwords.txt')).split("\n") || []
|
11
30
|
remote_tags = get_tags
|
12
31
|
@tags = {}
|
13
32
|
remote_tags.each {|tag| @tags[Text::PorterStemming.stem(tag).downcase] = tag if tag}
|
@@ -72,11 +91,11 @@ class JTag
|
|
72
91
|
[yaml, after]
|
73
92
|
end
|
74
93
|
|
75
|
-
def post_tags(file,piped=false)
|
94
|
+
def post_tags(file, piped=false)
|
76
95
|
begin
|
77
96
|
input = piped ? file : IO.read(file)
|
78
97
|
yaml = YAML::load(input)
|
79
|
-
return yaml[
|
98
|
+
return yaml[@tags_key] || []
|
80
99
|
rescue
|
81
100
|
return []
|
82
101
|
end
|
@@ -103,7 +122,7 @@ class JTag
|
|
103
122
|
if parts.length >= 2
|
104
123
|
begin
|
105
124
|
yaml = YAML::load(parts[1])
|
106
|
-
current_tags = yaml[
|
125
|
+
current_tags = yaml[@tags_key] || []
|
107
126
|
title = yaml["title"] || ""
|
108
127
|
rescue
|
109
128
|
current_tags = []
|
@@ -175,7 +194,7 @@ class JTag
|
|
175
194
|
begin
|
176
195
|
if File.exists?(file)
|
177
196
|
yaml, after = split_post(file)
|
178
|
-
yaml[
|
197
|
+
yaml[@tags_key] = tags
|
179
198
|
File.open(file,'w+') do |f|
|
180
199
|
f.puts yaml.to_yaml
|
181
200
|
f.puts "---"
|
@@ -190,5 +209,52 @@ class JTag
|
|
190
209
|
return false
|
191
210
|
end
|
192
211
|
end
|
193
|
-
end
|
194
212
|
|
213
|
+
private
|
214
|
+
|
215
|
+
def color(name)
|
216
|
+
color = {}
|
217
|
+
color['black'] = "\033[0;30m"
|
218
|
+
color['red'] = "\033[0;31m"
|
219
|
+
color['green'] = "\033[0;32m"
|
220
|
+
color['yellow'] = "\033[0;33m"
|
221
|
+
color['blue'] = "\033[0;34m"
|
222
|
+
color['magenta'] = "\033[0;35m"
|
223
|
+
color['cyan'] = "\033[0;36m"
|
224
|
+
color['white'] = "\033[0;37m"
|
225
|
+
color['bgblack'] = "\033[0;40m"
|
226
|
+
color['bgred'] = "\033[0;41m"
|
227
|
+
color['bggreen'] = "\033[0;42m"
|
228
|
+
color['bgyellow'] = "\033[0;43m"
|
229
|
+
color['bgblue'] = "\033[0;44m"
|
230
|
+
color['bgmagenta'] = "\033[0;45m"
|
231
|
+
color['bgcyan'] = "\033[0;46m"
|
232
|
+
color['bgwhite'] = "\033[0;47m"
|
233
|
+
color['boldblack'] = "\033[1;30m"
|
234
|
+
color['boldred'] = "\033[1;31m"
|
235
|
+
color['boldgreen'] = "\033[1;32m"
|
236
|
+
color['boldyellow'] = "\033[1;33m"
|
237
|
+
color['boldblue'] = "\033[1;34m"
|
238
|
+
color['boldmagenta'] = "\033[1;35m"
|
239
|
+
color['boldcyan'] = "\033[1;36m"
|
240
|
+
color['boldwhite'] = "\033[1;37m"
|
241
|
+
color['boldbgblack'] = "\033[1;40m"
|
242
|
+
color['boldbgred'] = "\033[1;41m"
|
243
|
+
color['boldbggreen'] = "\033[1;42m"
|
244
|
+
color['boldbgyellow'] = "\033[1;43m"
|
245
|
+
color['boldbgblue'] = "\033[1;44m"
|
246
|
+
color['boldbgmagenta'] = "\033[1;45m"
|
247
|
+
color['boldbgcyan'] = "\033[1;46m"
|
248
|
+
color['boldbgwhite'] = "\033[1;47m"
|
249
|
+
color['default'] = "\033[0;39m"
|
250
|
+
color['warning'] = color['yellow']
|
251
|
+
color['warningb'] = color['boldyellow']
|
252
|
+
color['success'] = color['green']
|
253
|
+
color['successb'] = color['boldgreen']
|
254
|
+
color['neutral'] = color['white']
|
255
|
+
color['neutralb'] = color['boldwhite']
|
256
|
+
color['info'] = color['cyan']
|
257
|
+
color['infob'] = color['boldcyan']
|
258
|
+
color[name]
|
259
|
+
end
|
260
|
+
end
|
data/lib/jtag/version.rb
CHANGED
metadata
CHANGED
@@ -1,110 +1,97 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: jtag
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
5
|
-
prerelease:
|
4
|
+
version: 0.1.12
|
6
5
|
platform: ruby
|
7
6
|
authors:
|
8
7
|
- Brett Terpstra
|
9
8
|
autorequire:
|
10
9
|
bindir: bin
|
11
10
|
cert_chain: []
|
12
|
-
date:
|
11
|
+
date: 2017-11-24 00:00:00.000000000 Z
|
13
12
|
dependencies:
|
14
13
|
- !ruby/object:Gem::Dependency
|
15
14
|
name: rake
|
16
15
|
requirement: !ruby/object:Gem::Requirement
|
17
|
-
none: false
|
18
16
|
requirements:
|
19
|
-
- -
|
17
|
+
- - ">="
|
20
18
|
- !ruby/object:Gem::Version
|
21
19
|
version: '0'
|
22
20
|
type: :development
|
23
21
|
prerelease: false
|
24
22
|
version_requirements: !ruby/object:Gem::Requirement
|
25
|
-
none: false
|
26
23
|
requirements:
|
27
|
-
- -
|
24
|
+
- - ">="
|
28
25
|
- !ruby/object:Gem::Version
|
29
26
|
version: '0'
|
30
27
|
- !ruby/object:Gem::Dependency
|
31
28
|
name: rdoc
|
32
29
|
requirement: !ruby/object:Gem::Requirement
|
33
|
-
none: false
|
34
30
|
requirements:
|
35
|
-
- -
|
31
|
+
- - ">="
|
36
32
|
- !ruby/object:Gem::Version
|
37
33
|
version: '0'
|
38
34
|
type: :development
|
39
35
|
prerelease: false
|
40
36
|
version_requirements: !ruby/object:Gem::Requirement
|
41
|
-
none: false
|
42
37
|
requirements:
|
43
|
-
- -
|
38
|
+
- - ">="
|
44
39
|
- !ruby/object:Gem::Version
|
45
40
|
version: '0'
|
46
41
|
- !ruby/object:Gem::Dependency
|
47
42
|
name: aruba
|
48
43
|
requirement: !ruby/object:Gem::Requirement
|
49
|
-
none: false
|
50
44
|
requirements:
|
51
|
-
- -
|
45
|
+
- - ">="
|
52
46
|
- !ruby/object:Gem::Version
|
53
47
|
version: '0'
|
54
48
|
type: :development
|
55
49
|
prerelease: false
|
56
50
|
version_requirements: !ruby/object:Gem::Requirement
|
57
|
-
none: false
|
58
51
|
requirements:
|
59
|
-
- -
|
52
|
+
- - ">="
|
60
53
|
- !ruby/object:Gem::Version
|
61
54
|
version: '0'
|
62
55
|
- !ruby/object:Gem::Dependency
|
63
56
|
name: gli
|
64
57
|
requirement: !ruby/object:Gem::Requirement
|
65
|
-
none: false
|
66
58
|
requirements:
|
67
|
-
- -
|
59
|
+
- - "~>"
|
68
60
|
- !ruby/object:Gem::Version
|
69
|
-
version: 2.
|
61
|
+
version: 2.17.1
|
70
62
|
type: :runtime
|
71
63
|
prerelease: false
|
72
64
|
version_requirements: !ruby/object:Gem::Requirement
|
73
|
-
none: false
|
74
65
|
requirements:
|
75
|
-
- -
|
66
|
+
- - "~>"
|
76
67
|
- !ruby/object:Gem::Version
|
77
|
-
version: 2.
|
68
|
+
version: 2.17.1
|
78
69
|
- !ruby/object:Gem::Dependency
|
79
70
|
name: json
|
80
71
|
requirement: !ruby/object:Gem::Requirement
|
81
|
-
none: false
|
82
72
|
requirements:
|
83
|
-
- -
|
73
|
+
- - "~>"
|
84
74
|
- !ruby/object:Gem::Version
|
85
|
-
version:
|
75
|
+
version: 1.8.1
|
86
76
|
type: :runtime
|
87
77
|
prerelease: false
|
88
78
|
version_requirements: !ruby/object:Gem::Requirement
|
89
|
-
none: false
|
90
79
|
requirements:
|
91
|
-
- -
|
80
|
+
- - "~>"
|
92
81
|
- !ruby/object:Gem::Version
|
93
|
-
version:
|
82
|
+
version: 1.8.1
|
94
83
|
- !ruby/object:Gem::Dependency
|
95
84
|
name: plist
|
96
85
|
requirement: !ruby/object:Gem::Requirement
|
97
|
-
none: false
|
98
86
|
requirements:
|
99
|
-
- -
|
87
|
+
- - ">="
|
100
88
|
- !ruby/object:Gem::Version
|
101
89
|
version: '0'
|
102
90
|
type: :runtime
|
103
91
|
prerelease: false
|
104
92
|
version_requirements: !ruby/object:Gem::Requirement
|
105
|
-
none: false
|
106
93
|
requirements:
|
107
|
-
- -
|
94
|
+
- - ">="
|
108
95
|
- !ruby/object:Gem::Version
|
109
96
|
version: '0'
|
110
97
|
description:
|
@@ -116,46 +103,45 @@ extra_rdoc_files:
|
|
116
103
|
- README.rdoc
|
117
104
|
- jtag.rdoc
|
118
105
|
files:
|
106
|
+
- README.rdoc
|
119
107
|
- bin/jtag
|
120
|
-
-
|
108
|
+
- jtag.rdoc
|
109
|
+
- lib/jtag.rb
|
121
110
|
- lib/jtag/config_files/blacklist.txt
|
122
111
|
- lib/jtag/config_files/config.yml
|
123
112
|
- lib/jtag/config_files/stopwords.txt
|
124
113
|
- lib/jtag/config_files/synonyms.yml
|
125
|
-
- lib/jtag/porter_stemming.rb
|
126
114
|
- lib/jtag/jekylltag.rb
|
115
|
+
- lib/jtag/porter_stemming.rb
|
127
116
|
- lib/jtag/string.rb
|
128
|
-
- lib/jtag.rb
|
129
|
-
- README.rdoc
|
130
|
-
- jtag.rdoc
|
117
|
+
- lib/jtag/version.rb
|
131
118
|
homepage: http://brettterpstra.com
|
132
119
|
licenses: []
|
120
|
+
metadata: {}
|
133
121
|
post_install_message:
|
134
122
|
rdoc_options:
|
135
|
-
- --title
|
123
|
+
- "--title"
|
136
124
|
- jtag
|
137
|
-
- --main
|
125
|
+
- "--main"
|
138
126
|
- README.rdoc
|
139
|
-
- -ri
|
127
|
+
- "-ri"
|
140
128
|
require_paths:
|
141
129
|
- lib
|
142
130
|
- lib
|
143
131
|
required_ruby_version: !ruby/object:Gem::Requirement
|
144
|
-
none: false
|
145
132
|
requirements:
|
146
|
-
- -
|
133
|
+
- - ">="
|
147
134
|
- !ruby/object:Gem::Version
|
148
135
|
version: '0'
|
149
136
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
150
|
-
none: false
|
151
137
|
requirements:
|
152
|
-
- -
|
138
|
+
- - ">="
|
153
139
|
- !ruby/object:Gem::Version
|
154
140
|
version: '0'
|
155
141
|
requirements: []
|
156
142
|
rubyforge_project:
|
157
|
-
rubygems_version:
|
143
|
+
rubygems_version: 2.6.13
|
158
144
|
signing_key:
|
159
|
-
specification_version:
|
145
|
+
specification_version: 4
|
160
146
|
summary: Auto-tagging and tagging tools for Jekyll
|
161
147
|
test_files: []
|