jill 0.0.1 → 0.0.3
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/lib/jill/commands/star.rb +30 -7
- data/lib/jill/version.rb +1 -1
- metadata +3 -3
    
        checksums.yaml
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            ---
         | 
| 2 2 | 
             
            SHA1:
         | 
| 3 | 
            -
              metadata.gz:  | 
| 4 | 
            -
              data.tar.gz:  | 
| 3 | 
            +
              metadata.gz: 98576f624de44652f3601b1e5eb087ccda242915
         | 
| 4 | 
            +
              data.tar.gz: 12aeb6ad050690c947959614e5fec1dc2d6c3f9d
         | 
| 5 5 | 
             
            SHA512:
         | 
| 6 | 
            -
              metadata.gz:  | 
| 7 | 
            -
              data.tar.gz:  | 
| 6 | 
            +
              metadata.gz: 55bb0d812d748fb4a3f310d0455f767c3a753b1bb760de4a6fefb7e66a2d68a07f0c45cabf5ecaf290cd45f7beee2a3c7db1fc17ebaa8d6d021cf995915a358b
         | 
| 7 | 
            +
              data.tar.gz: 47c1729b7944c936ca6a86d18b18b0fdfd260d7c5a3bf491429b38a6b37cbc4bbeae0ab3217c29d5171874457e99ec741b51e09c41f7a8c6c51333244e194bba
         | 
    
        data/lib/jill/commands/star.rb
    CHANGED
    
    | @@ -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). | 
| 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 = "#{$ | 
| 36 | 
            -
                          rest = $ | 
| 48 | 
            +
                          ghslug = "#{$3}/#{$4}"
         | 
| 49 | 
            +
                          rest = $5.chomp
         | 
| 37 50 | 
             
                          # remove existing stars if existing
         | 
| 38 | 
            -
                          name = $ | 
| 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 | 
            -
                           | 
| 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
         | 
    
        data/lib/jill/version.rb
    CHANGED
    
    
    
        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. | 
| 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- | 
| 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. | 
| 180 | 
            +
            rubygems_version: 2.5.1
         | 
| 181 181 | 
             
            signing_key: 
         | 
| 182 182 | 
             
            specification_version: 4
         | 
| 183 183 | 
             
            summary: Jill is your README.md assistant
         |