beginning_open_source 0.1.3 → 0.1.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/README.md +2 -0
- data/lib/beginning_open_source.rb +0 -11
- data/lib/beginning_open_source/github_api.rb +38 -62
- data/lib/beginning_open_source/version.rb +1 -1
- data/lib/cli.rb +28 -35
- data/lib/secrets.rb +10 -2
- metadata +3 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9080dd808b86a35b70ae58dfa5eeefee91d897ba
|
4
|
+
data.tar.gz: decb69565e105679ebdded0767aee804b2c8c689
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c25e77c425fc2e2009967923211d90498c5eecf45df518716a86710d609ea815ef4d569f173c7999984a2aee7b4fc4cd8aecd435be8cfafb3a2d6fbda31240bd
|
7
|
+
data.tar.gz: 585c9e7db35e0404e0e1b92a6de598910310fbb2be4a48c6824e16568b070163c1ad63f8a146296cfd7219c426ee921dadc805cc3f35666a5f99a5175f2263f0
|
data/.gitignore
CHANGED
data/README.md
CHANGED
@@ -2,19 +2,8 @@ require_relative "beginning_open_source/version"
|
|
2
2
|
require_relative "beginning_open_source/github_api.rb"
|
3
3
|
require_relative "beginning_open_source/issues.rb"
|
4
4
|
|
5
|
-
# File.open("../lib/secrets.rb", 'w'){|f| f.write("class BeginningOpenSource::GithubApi
|
6
|
-
# def self.token
|
7
|
-
# 'PASTE_TOKEN_HERE_AS_STRING'
|
8
|
-
# end
|
9
|
-
|
10
|
-
# def self.agent
|
11
|
-
# 'PASTE_GITHUB_USERNAME_HERE_AS_STRING'
|
12
|
-
# end
|
13
|
-
# end")}
|
14
|
-
|
15
5
|
require_relative "secrets.rb"
|
16
6
|
require_relative "cli"
|
17
7
|
|
18
|
-
require 'json'
|
19
8
|
require 'httparty'
|
20
9
|
# require 'pry' #just for development
|
@@ -1,77 +1,49 @@
|
|
1
1
|
class BeginningOpenSource::GithubApi
|
2
2
|
|
3
|
-
#i am passing around variables. might be better off using class variables.
|
4
|
-
@@array_of_issues = []
|
5
|
-
|
6
3
|
def self.get_issues(input_string) #still very long. refactor
|
7
|
-
|
8
|
-
|
9
|
-
puts "Total Issue count matching #{input_string}:".blue + " #{response["total_count"]}".red
|
4
|
+
response = self.get_json("https://api.github.com/search/issues?q=label:\"#{input_string}\"+language:ruby+state:open&sort=created&order=desc")
|
10
5
|
|
11
|
-
|
6
|
+
puts "Total Issue count matching #{input_string}:".blue + " #{response["total_count"]}".red
|
12
7
|
|
13
|
-
|
14
|
-
|
15
|
-
hash_of_issue = {}
|
8
|
+
response["items"].each_with_index.map do |issue, index|
|
9
|
+
hash_of_issue = {}
|
16
10
|
|
17
|
-
|
11
|
+
issue_url_array = issue["html_url"].split("/")
|
18
12
|
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
13
|
+
hash_of_issue[:repo_name] = issue_url_array[4]
|
14
|
+
hash_of_issue[:title] = issue["title"]
|
15
|
+
hash_of_issue[:labels] = (issue["labels"].map {|issue| issue["name"]})
|
16
|
+
hash_of_issue[:body] = issue["body"]
|
17
|
+
hash_of_issue[:html_url] = issue["html_url"]
|
18
|
+
hash_of_issue[:created_at] = issue["created_at"]
|
19
|
+
hash_of_issue[:repo_url] = "https://github.com/#{issue_url_array[3]}/#{issue_url_array[4]}"
|
20
|
+
|
21
|
+
repo_json = self.get_json("https://api.github.com/repos/#{issue_url_array[3]}/#{issue_url_array[4]}")
|
28
22
|
|
29
|
-
|
30
|
-
|
31
|
-
end
|
32
|
-
loaded_repo_count += 1
|
33
|
-
|
34
|
-
self.get_repository(issue_url_array[3], issue_url_array[4], hash_of_issue)
|
23
|
+
hash_of_issue[:repo_description] = repo_json["description"]
|
24
|
+
hash_of_issue[:stars] = repo_json["stargazers_count"]
|
35
25
|
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
end #end of method
|
26
|
+
if index > 10
|
27
|
+
puts "loading #{index + 1}/30"
|
28
|
+
end
|
29
|
+
hash_of_issue
|
30
|
+
end
|
31
|
+
end
|
43
32
|
|
44
|
-
|
45
|
-
|
46
|
-
|
33
|
+
def self.get_json(url)
|
34
|
+
unless self.token?
|
35
|
+
HTTParty.get(url)
|
47
36
|
else
|
48
|
-
|
37
|
+
HTTParty.get(
|
38
|
+
url,
|
49
39
|
:headers => {
|
50
|
-
|
51
|
-
|
52
|
-
|
40
|
+
"Authorization" => "token #{self.token}",
|
41
|
+
"User-Agent" => self.agent
|
42
|
+
})
|
53
43
|
end
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
def self.get_repository(user, repository, hash)
|
58
|
-
if self.token == 'PASTE_TOKEN_HERE_AS_STRING'
|
59
|
-
repo_json = HTTParty.get("https://api.github.com/repos/#{user}/#{repository}")
|
60
|
-
else
|
61
|
-
repo_json = HTTParty.get(
|
62
|
-
"https://api.github.com/repos/#{user}/#{repository}",
|
63
|
-
:headers => {
|
64
|
-
"Authorization" => "token #{self.token}",
|
65
|
-
"User-Agent" => self.agent
|
66
|
-
})
|
67
|
-
end
|
68
|
-
repo_parsed = JSON.parse(repo_json.body)
|
69
|
-
hash[:repo_description] = repo_parsed["description"]
|
70
|
-
hash[:stars] = repo_parsed["stargazers_count"]
|
71
|
-
hash
|
72
|
-
end
|
73
|
-
|
74
|
-
end #end of class
|
44
|
+
end
|
45
|
+
|
46
|
+
end
|
75
47
|
|
76
48
|
class String
|
77
49
|
#colorization
|
@@ -94,4 +66,8 @@ class String
|
|
94
66
|
def red
|
95
67
|
colorize(31)
|
96
68
|
end
|
97
|
-
end
|
69
|
+
end
|
70
|
+
#use class variables to not pass them between methods?
|
71
|
+
|
72
|
+
#there are pagination options.
|
73
|
+
# right now it is only giving me 30 per page. can go up to 100
|
data/lib/cli.rb
CHANGED
@@ -26,46 +26,39 @@ class BeginningOpenSource::CLI
|
|
26
26
|
unless input == 'exit'
|
27
27
|
get_and_print(input)
|
28
28
|
end
|
29
|
-
# list_issues #do i want to return all issues or just the last searched ones. i'm thinking last searched
|
30
|
-
#possibly could store the other in memory to retrieve again if i want
|
31
29
|
end
|
32
30
|
end
|
33
31
|
|
34
|
-
def goodbye
|
35
|
-
puts "Happy learning!"
|
36
|
-
end
|
37
|
-
|
38
32
|
def get_and_print(input_string)
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
puts "Labels: #{issue.labels}"
|
51
|
-
puts "Issue Url: #{issue.html_url}"
|
52
|
-
puts "Repository Url: #{issue.repo_url}"
|
53
|
-
length.times {print "*"}
|
54
|
-
end
|
55
|
-
else
|
56
|
-
BeginningOpenSource::Issues.starred.each do |issue|
|
57
|
-
length = "Repository Url: #{issue.repo_url}".length
|
58
|
-
puts " "
|
59
|
-
puts "Issue Title: #{issue.title}".blue
|
60
|
-
puts "Repository Name: #{issue.repo_name}"
|
61
|
-
puts "Repository Description: #{issue.repo_description}"
|
62
|
-
puts "Stars: #{issue.stars}"
|
63
|
-
puts "Labels: #{issue.labels}"
|
64
|
-
puts "Issue Url: #{issue.html_url}"
|
65
|
-
puts "Repository Url: #{issue.repo_url}"
|
66
|
-
length.times {print "*"}
|
33
|
+
issues_array = BeginningOpenSource::GithubApi.get_issues(input_string)
|
34
|
+
|
35
|
+
BeginningOpenSource::Issues.create_from_collection(issues_array)
|
36
|
+
if BeginningOpenSource::Issues.starred.empty?
|
37
|
+
BeginningOpenSource::Issues.all.each do |issue|
|
38
|
+
print_issues(issue)
|
39
|
+
end
|
40
|
+
else
|
41
|
+
BeginningOpenSource::Issues.starred.each do |issue|
|
42
|
+
print_issues(issue)
|
43
|
+
end
|
67
44
|
end
|
68
45
|
end
|
69
|
-
|
46
|
+
|
47
|
+
def print_issues(issue)
|
48
|
+
length = "Repository Url: #{issue.repo_url}".length
|
49
|
+
puts " "
|
50
|
+
puts "Issue Title: #{issue.title}".blue
|
51
|
+
puts "Repository Name: #{issue.repo_name}"
|
52
|
+
puts "Repository Description: #{issue.repo_description}"
|
53
|
+
puts "Stars: #{issue.stars}"
|
54
|
+
puts "Labels: #{issue.labels}"
|
55
|
+
puts "Issue Url: #{issue.html_url}"
|
56
|
+
puts "Repository Url: #{issue.repo_url}"
|
57
|
+
length.times {print "*"}
|
58
|
+
end
|
59
|
+
|
60
|
+
def goodbye
|
61
|
+
puts "Happy learning!"
|
62
|
+
end
|
70
63
|
|
71
64
|
end
|
data/lib/secrets.rb
CHANGED
@@ -1,9 +1,17 @@
|
|
1
|
-
class BeginningOpenSource::GithubApi
|
1
|
+
class BeginningOpenSource::GithubApi #should probably change to a module or just ask user for input
|
2
2
|
def self.token
|
3
3
|
'PASTE_TOKEN_HERE_AS_STRING'
|
4
4
|
end
|
5
5
|
|
6
6
|
def self.agent
|
7
|
-
'
|
7
|
+
'c1505'
|
8
|
+
end
|
9
|
+
|
10
|
+
def self.token?
|
11
|
+
if self.token == 'PASTE_TOKEN_HERE_AS_STRING'
|
12
|
+
false
|
13
|
+
else
|
14
|
+
true
|
15
|
+
end
|
8
16
|
end
|
9
17
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: beginning_open_source
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Corey Morris
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-01-
|
11
|
+
date: 2016-01-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -127,9 +127,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
127
127
|
version: '0'
|
128
128
|
requirements: []
|
129
129
|
rubyforge_project:
|
130
|
-
rubygems_version: 2.4.
|
130
|
+
rubygems_version: 2.4.6
|
131
131
|
signing_key:
|
132
132
|
specification_version: 4
|
133
133
|
summary: A tool to find beginner friendly open source issues to work on.
|
134
134
|
test_files: []
|
135
|
-
has_rdoc:
|