jill 0.0.1 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: e41b93b0c457ab82f85eff9c1cdc4c75a2b30f15
4
- data.tar.gz: 24ff8e783950271c862c234866361c423f8b7634
3
+ metadata.gz: 98576f624de44652f3601b1e5eb087ccda242915
4
+ data.tar.gz: 12aeb6ad050690c947959614e5fec1dc2d6c3f9d
5
5
  SHA512:
6
- metadata.gz: bd33c61de6261033108b49fd76cbe1f7bae5a90fe73bad7b7898328061711355b39a02812a3dfb2f390efc256eec326ea2c7581d96ee968897d4e4144cfdfaed
7
- data.tar.gz: 991826e6c6d49ac7a1576caabce4358c96f32139eae52f652d2b9d0aa17e2e1a470b0d0f3bb7ae69c454b67ca8e35cbf2357032f26d649450dc988245cc7682c
6
+ metadata.gz: 55bb0d812d748fb4a3f310d0455f767c3a753b1bb760de4a6fefb7e66a2d68a07f0c45cabf5ecaf290cd45f7beee2a3c7db1fc17ebaa8d6d021cf995915a358b
7
+ data.tar.gz: 47c1729b7944c936ca6a86d18b18b0fdfd260d7c5a3bf491429b38a6b37cbc4bbeae0ab3217c29d5171874457e99ec741b51e09c41f7a8c6c51333244e194bba
@@ -12,6 +12,7 @@ module Jill
12
12
  super
13
13
  o.string "--star-in", "Star input file", default: "README.md"
14
14
  o.string "--star-out", "Star output file", default: "README.md"
15
+ o.string "--freshness", "Freshness", default: "0"
15
16
  end
16
17
 
17
18
  def help
@@ -21,30 +22,43 @@ module Jill
21
22
  def run_if_switched(opts)
22
23
  file = opts[:star_in]
23
24
  file_out = opts[:star_out]
25
+ freshness_secs = opts[:freshness].to_i
26
+
24
27
  out = ""
25
28
  puts "Starring #{file}..."
26
29
 
27
30
  # do this serially as to not piss off github
28
- File.read(file).each_line do |line|
31
+ File.read(file).lines.each_with_index do |line, idx|
29
32
  # is a bullet,
30
33
  # starts with github.com,
31
34
  # has only 2 segments in path,
32
35
  # remove trailing slashes.
33
- if line =~ /^- \[(.*?)\]\(https?:\/\/github\.com\/([^\/]+?)\/([^\/]+?)\/?\)(\s+.*)$/
36
+ if line =~ /^- (.*?)\[(.*?)\]\(https?:\/\/github\.com\/([^\/]+?)\/([^\/]+?)\/?\)(\s+.*)$/
37
+ badges = $1.split
38
+
39
+ if freshness_secs > 0
40
+ badges = badges.reject{|b| b.start_with?(':pineapple:')}
41
+ if fresh?(file, idx, freshness_secs)
42
+ badges << ':pineapple:'
43
+ end
44
+ end
45
+ tag = badges.join(' ')
46
+
34
47
  begin
35
- ghslug = "#{$2}/#{$3}"
36
- rest = $4
48
+ ghslug = "#{$3}/#{$4}"
49
+ rest = $5.chomp
37
50
  # remove existing stars if existing
38
- name = $1.gsub(/\s?#{STAR}\d+/, '')
51
+ name = $2.gsub(/\s?#{STAR}\d+/, '')
39
52
 
40
53
  doc = Nokogiri::HTML(open("https://github.com/#{ghslug}").read)
41
54
  stars = doc.css('.js-social-count').text.strip.gsub(',','')
42
55
 
43
- out << "- [#{name} #{STAR}#{stars}](https://github.com/#{ghslug})#{rest}\n"
56
+ out << "- #{tag}[#{name} #{STAR}#{stars}](https://github.com/#{ghslug})#{rest}\n"
44
57
  rescue
45
58
  out << line
46
- out << "<!-- error fetching stars for #{ghslug}: #{$!} -->\n"
59
+ puts "<!-- error fetching stars for #{ghslug}: #{$!} -->"
47
60
  end
61
+
48
62
  putc "."
49
63
 
50
64
  else
@@ -56,6 +70,15 @@ module Jill
56
70
 
57
71
  return true
58
72
  end
73
+
74
+ private
75
+
76
+ def fresh?(file, ln, fresh_time)
77
+ out = `git blame #{file} -L #{ln+1},#{ln+1} -p`
78
+ ts = out.lines.find{|ln| ln.start_with?('author-time')}.split('author-time ')[1].to_i
79
+ (Time.now - Time.at(ts)) < fresh_time
80
+ end
81
+
59
82
  end
60
83
  end
61
84
  end
@@ -1,3 +1,3 @@
1
1
  module Jill
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.3"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jill
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dotan Nahum
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-01-20 00:00:00.000000000 Z
11
+ date: 2016-09-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: slop
@@ -177,7 +177,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
177
177
  version: '0'
178
178
  requirements: []
179
179
  rubyforge_project:
180
- rubygems_version: 2.4.5.1
180
+ rubygems_version: 2.5.1
181
181
  signing_key:
182
182
  specification_version: 4
183
183
  summary: Jill is your README.md assistant