gem-gratitude 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: e6e0df38ab77aaad1839d6bd7430460ab3aa6219
4
+ data.tar.gz: 7ee7a242f2bbbfff8eeabea882f6688e018f4c1c
5
+ SHA512:
6
+ metadata.gz: 3e22d369ab0d42f01de4d926e9880a1ef6d9679627f3eca600b5d60c7e633a8aba3b9a9f912f0f0cf0946ece665b9a9f5bc33c94131c77ad8b1a9e33c869d655
7
+ data.tar.gz: 8572a745a497dec321bc00a6874ebbfa020a988a1b29d501e6efe5e0c9ac1a27e6abd8c5c723a2df512a9b802d29d762ee137adfaa008c8a4ed53afc92644d3c
data/bin/gem-gratitude ADDED
@@ -0,0 +1,4 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'gem-gratitude'
4
+ Issue.list
@@ -0,0 +1,74 @@
1
+ require 'rubygems'
2
+ require 'httparty'
3
+ require 'json'
4
+ require 'erb'
5
+ require 'redcarpet'
6
+
7
+ class Issue
8
+ def self.list
9
+ # Initializes a Markdown parser
10
+ @markdown = Redcarpet::Markdown.new(Redcarpet::Render::HTML, autolink: true, hard_wrap: true, fenced_code_blocks: true)
11
+
12
+ # Load Gemfile
13
+ gemfile_path="#{Dir.pwd}/Gemfile"
14
+
15
+ if !File.exist?(gemfile_path)
16
+ puts "Couldn't find a Gemfile in this directory"
17
+ exit
18
+ end
19
+
20
+ # List of all gems
21
+ @gem_list = []
22
+
23
+ # Characters to remove to get the pure gem name
24
+ replacements = [ '\'', '"', ',' ]
25
+
26
+ # Parse the gem names from the Gemfile
27
+ File.open(gemfile_path).read.each_line do |line|
28
+ parts = line.split
29
+ if parts[0] == "gem" && parts[0].start_with?("gem")
30
+ gem_name = parts[1]
31
+ replacements.each {|r| gem_name.gsub!(r, '')}
32
+ next if parts[2] == 'github:'
33
+ gem_spec = Gem::Specification.find_by_name(gem_name)
34
+ @gem_list << {name: gem_name, homepage: gem_spec.homepage}
35
+ end
36
+ end
37
+
38
+ # Not every gem_spec.homepage is a GitHub repo; try and find a GitHub link
39
+ # Maybe via the GitHub Search API
40
+ @gem_list.each do
41
+ # if !(g[:homepage] =~ /https:\/\/github.com\//)
42
+ end
43
+
44
+ # Open HTML output file for writing
45
+ tmp_html = '/tmp/giveback.html'
46
+ file = File.open(tmp_html, 'w')
47
+
48
+ # Find all open issues via the GitHub API
49
+ @html_content = ''
50
+ @issue_count = 0
51
+ @gem_list.each do |g|
52
+ github_url = g[:homepage].split('/')
53
+ response = HTTParty.get("https://api.github.com/repos/#{github_url[-2]}/#{github_url[-1]}/issues?state=open")
54
+ json = JSON.parse(response.body)
55
+ if response.code == 200
56
+ puts "#{g[:name]}: #{g[:homepage]} - #{json.count} open issues!"
57
+ json.each do |issue|
58
+ @issue_count += 1
59
+ @html_content <<
60
+ "<h3>[#{g[:name]}] #{issue['title']}</h3>"\
61
+ "<div><a class='github_link' href=\"#{issue['html_url']}\">View on GitHub: #{issue['title']}</a>"\
62
+ "#{@markdown.render(issue['body'])}</div>"
63
+ end
64
+ end
65
+ end
66
+
67
+ # Write to ERB template
68
+ erb = ERB.new(File.read('template.erb'))
69
+ file.write erb.result(binding)
70
+
71
+ # Open up the resulting HTML file
72
+ `open #{tmp_html}`
73
+ end
74
+ end
metadata ADDED
@@ -0,0 +1,76 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: gem-gratitude
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.1
5
+ platform: ruby
6
+ authors:
7
+ - Dan Bartlett
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-12-01 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: httparty
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: redcarpet
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ description: Give back to gems you depend on! Show all open GitHub issues for gems
42
+ you require in your projects
43
+ email: danbartlett@gmail.com
44
+ executables:
45
+ - gem-gratitude
46
+ extensions: []
47
+ extra_rdoc_files: []
48
+ files:
49
+ - bin/gem-gratitude
50
+ - lib/gem-gratitude.rb
51
+ homepage: http://rubygems.org/gems/gem-gratitude
52
+ licenses:
53
+ - MIT
54
+ metadata: {}
55
+ post_install_message:
56
+ rdoc_options: []
57
+ require_paths:
58
+ - lib
59
+ required_ruby_version: !ruby/object:Gem::Requirement
60
+ requirements:
61
+ - - ">="
62
+ - !ruby/object:Gem::Version
63
+ version: '0'
64
+ required_rubygems_version: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ requirements: []
70
+ rubyforge_project:
71
+ rubygems_version: 2.2.2
72
+ signing_key:
73
+ specification_version: 4
74
+ summary: Show all open GitHub issues for gems you require in your projects
75
+ test_files: []
76
+ has_rdoc: