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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 27729e255dc1dc15058bd33396eaf0fc99ad6e34
4
- data.tar.gz: 523bc7c50cbb2f479f8cda6eadf89f440c23bc19
3
+ metadata.gz: 9080dd808b86a35b70ae58dfa5eeefee91d897ba
4
+ data.tar.gz: decb69565e105679ebdded0767aee804b2c8c689
5
5
  SHA512:
6
- metadata.gz: 9756b162e82f93e9f93cdd181d20ed28d6f3395ade3073ce81f0d5011b935d45c91ff35d9d4b7f70847b0234fe1f849515fbc4f8b6817635823da296e7cb2390
7
- data.tar.gz: 98e17cd0b5c98189d367957461c9b762fe54c3bb9c039ce8858278f68223402b90d37e357b0c8e8adff97f357cb018b3ade6a3b83aae70e245b0e4673a86fc6f
6
+ metadata.gz: c25e77c425fc2e2009967923211d90498c5eecf45df518716a86710d609ea815ef4d569f173c7999984a2aee7b4fc4cd8aecd435be8cfafb3a2d6fbda31240bd
7
+ data.tar.gz: 585c9e7db35e0404e0e1b92a6de598910310fbb2be4a48c6824e16568b070163c1ad63f8a146296cfd7219c426ee921dadc805cc3f35666a5f99a5175f2263f0
data/.gitignore CHANGED
@@ -9,3 +9,4 @@
9
9
  /tmp/
10
10
  /lib/this_will_be_secrets_file.rb
11
11
  notes.md
12
+ notes
data/README.md CHANGED
@@ -24,6 +24,8 @@ https://guides.github.com/activities/contributing-to-open-source/
24
24
 
25
25
  https://www.quora.com/How-can-I-contribute-to-open-source-software
26
26
 
27
+ https://changelog.com/nightly/
28
+
27
29
 
28
30
  ## Installation
29
31
 
@@ -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
- response = self.search_issues(input_string)
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
- search_results = JSON.parse(response.body)["items"]
6
+ puts "Total Issue count matching #{input_string}:".blue + " #{response["total_count"]}".red
12
7
 
13
- loaded_repo_count = 1
14
- search_results.each do |issue|
15
- hash_of_issue = {}
8
+ response["items"].each_with_index.map do |issue, index|
9
+ hash_of_issue = {}
16
10
 
17
- issue_url_array = issue["html_url"].split("/")
11
+ issue_url_array = issue["html_url"].split("/")
18
12
 
19
- hash_of_issue[:repo_name] = issue_url_array[4]
20
- repo_string = "https://api.github.com/repos/#{issue_url_array[3]}/#{issue_url_array[4]}"
21
-
22
- hash_of_issue[:title] = issue["title"]
23
- hash_of_issue[:labels] = (issue["labels"].map {|issue| issue["name"]})
24
- hash_of_issue[:body] = issue["body"]
25
- hash_of_issue[:html_url] = issue["html_url"]
26
- hash_of_issue[:created_at] = issue["created_at"]
27
- hash_of_issue[:repo_url] = repo_string
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
- if loaded_repo_count > 10
30
- puts "loading #{loaded_repo_count}/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
- @@array_of_issues << hash_of_issue
37
-
38
- end #end of each statement
39
- @@array_of_issues
40
- #there are pagination options.
41
- # right now it is only giving me 30 per page. can go up to 100
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
- def self.search_issues(input_string)
45
- if self.token == 'PASTE_TOKEN_HERE_AS_STRING' #doing this twice, but with a different url. if i take in the url or have it set as a variable, i might be able to combine these
46
- response = HTTParty.get("https://api.github.com/search/issues?q=label:\"#{input_string}\"+language:ruby+state:open&sort=created&order=desc")
33
+ def self.get_json(url)
34
+ unless self.token?
35
+ HTTParty.get(url)
47
36
  else
48
- response = HTTParty.get("https://api.github.com/search/issues?q=label:\"#{input_string}\"+language:ruby+state:open&sort=created&order=desc",
37
+ HTTParty.get(
38
+ url,
49
39
  :headers => {
50
- "Authorization" => "token #{self.token}",
51
- "User-Agent" => self.agent
52
- })
40
+ "Authorization" => "token #{self.token}",
41
+ "User-Agent" => self.agent
42
+ })
53
43
  end
54
- response
55
- end
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
@@ -1,3 +1,3 @@
1
1
  module BeginningOpenSource
2
- VERSION = "0.1.3"
2
+ VERSION = "0.1.4"
3
3
  end
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
- issues_array = BeginningOpenSource::GithubApi.get_issues(input_string)
40
-
41
- BeginningOpenSource::Issues.create_from_collection(issues_array)
42
- if BeginningOpenSource::Issues.starred.empty?
43
- BeginningOpenSource::Issues.all.each do |issue|
44
- length = "Repository Url: #{issue.repo_url}".length
45
- puts " "
46
- puts "Issue Title: #{issue.title}".blue
47
- puts "Repository Name: #{issue.repo_name}"
48
- puts "Repository Description: #{issue.repo_description}"
49
- puts "Stars: #{issue.stars}"
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
- end
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
- 'PASTE_GITHUB_USERNAME_HERE_AS_STRING'
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.3
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-17 00:00:00.000000000 Z
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.8
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: