ghuls 1.4.3 → 1.5.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (4) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +6 -0
  3. data/lib/ghuls/cli.rb +78 -20
  4. metadata +20 -6
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 13c6d080b29670af384549e29e366764ca27987c
4
- data.tar.gz: 99b6cbd49810cb647992fe14ca5c053b29180359
3
+ metadata.gz: 0682abc8e68f58c6c51e8ea6c1871330d028be16
4
+ data.tar.gz: f1bcc058c722548b5a76e976a340e472538ffbdd
5
5
  SHA512:
6
- metadata.gz: 2c4b7a69199edccd29db9e957bafbd934131da9ad8f1135ad72ca84e9380fb2f5e48c122d107e0e738d9b57560e23069d4e7692845e522a3f416b667546ce590
7
- data.tar.gz: c72f1c3c7e565f75b98e23a1699c77a3f09a022600c399de9ec4e9843f3abbaf200bab43331bd7c8dd13b45578a1f30e3dc2af41eea745346f6be60cc916ec92
6
+ metadata.gz: ff779511554ce94bc88ef840afa9b4635ab6f931bc15d1241a305680ac7e28b1ab14053a8ae4540909ce1a21f9de07780d20b3ef0ed717b0e26b81e2f144a8ca
7
+ data.tar.gz: b0600c9d57a8c9e529d80de360fe246b1c10e15eea8371d8d4442100886f1955b20760bbd681e6204b0511a1b01246e1b389a8054aba76bae1b09fbb27717b59
data/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # Changelog
2
2
  ## Version 1
3
+ ### Version 1.5.0
4
+ * Data about issues, pulls, forks, stargazers, watchers, followers, following, and repository category totals is now available (#2).
5
+ * Now uses GHULS::Lib 2.2.0 and StringUtility 2.6.0, which provide a lot of performance improvements.
6
+ * array_utility is now a dependency because get_next will be removed from GHUS::Lib in its next version.
7
+ * Data for combined organization and personal repository languages is now available.
8
+
3
9
  ### Version 1.4.3
4
10
  * Update to use ghuls-lib 1.2.1.
5
11
  * Provides slightly more information.
data/lib/ghuls/cli.rb CHANGED
@@ -3,19 +3,21 @@ require 'base64'
3
3
  require 'rainbow'
4
4
  require 'progress_bar'
5
5
  require 'ghuls/lib'
6
+ require 'array_utility'
6
7
 
7
8
  module GHULS
8
9
  class CLI
10
+ using ArrayUtility
9
11
  # Parses the arguments (typically ARGV) into a usable hash.
10
12
  # @param args [Array] The arguments to parse.
11
13
  def parse_options(args)
12
14
  args.each do |arg|
13
15
  case arg
14
16
  when '-h', '--help' then @opts[:help] = true
15
- when '-un', '--user' then @opts[:user] = GHULS::Lib.get_next(arg, args)
16
- when '-pw', '--pass' then @opts[:pass] = GHULS::Lib.get_next(arg, args)
17
- when '-t', '--token' then @opts[:token] = GHULS::Lib.get_next(arg, args)
18
- when '-g', '--get' then @opts[:get] = GHULS::Lib.get_next(arg, args)
17
+ when '-un', '--user' then @opts[:user] = args.next(arg)
18
+ when '-pw', '--pass' then @opts[:pass] = args.next(arg)
19
+ when '-t', '--token' then @opts[:token] = args.next(arg)
20
+ when '-g', '--get' then @opts[:get] = args.next(arg)
19
21
  when '-d', '--debug' then @opts[:debug] = true
20
22
  when '-r', '--random' then @opts[:get] = nil
21
23
  end
@@ -88,6 +90,67 @@ module GHULS
88
90
  exit
89
91
  end
90
92
 
93
+ # Gets and outputs language data for the user and their organizations.
94
+ # @param username [String] The username of the user.
95
+ def language_data(username)
96
+ user_langs = GHULS::Lib.get_user_langs(@opts[:get], @gh)
97
+ increment
98
+ org_langs = GHULS::Lib.get_org_langs(@opts[:get], @gh)
99
+ increment
100
+ if !user_langs.empty?
101
+ puts "Getting language data for #{username}..."
102
+ user_percents = GHULS::Lib.get_language_percentages(user_langs)
103
+ output(user_percents)
104
+ else
105
+ puts 'Could not find any personal data to analyze.'
106
+ end
107
+ if !org_langs.empty?
108
+ puts 'Getting language data for their organizations...'
109
+ org_percents = GHULS::Lib.get_language_percentages(org_langs)
110
+ output(org_percents)
111
+ else
112
+ puts 'Could not find any organization data to analyze.'
113
+ end
114
+
115
+ return if org_langs.empty? && user_langs.empty?
116
+
117
+ user_langs.update(org_langs) { |_, v1, v2| v1 + v2 }
118
+ puts 'Getting combined language data...'
119
+ output(GHULS::Lib.get_language_percentages(user_langs))
120
+ end
121
+
122
+ def fork_data(repos)
123
+ repos[:public].each do |r|
124
+ next if repos[:forks].include? r
125
+ fsw = GHULS::Lib.get_forks_stars_watchers(r, @gh)
126
+ puts "#{r}: #{fsw[:forks]} forks, #{fsw[:stars]} stars, and " \
127
+ "#{fsw[:watchers]} watchers"
128
+ end
129
+ end
130
+
131
+ def follower_data(username)
132
+ follows = GHULS::Lib.get_followers_following(@opts[:get], @gh)
133
+ followers = Rainbow("#{follows[:followers]} followers").green
134
+ following = Rainbow("following #{follows[:following]}").color('#FFA500')
135
+ puts "#{username} has #{followers} and is #{following} people"
136
+ end
137
+
138
+ def issue_data(repos)
139
+ puts 'Getting issue and pull request data...'
140
+ repos[:public].each do |r|
141
+ next if repos[:forks].include? r
142
+ things = GHULS::Lib.get_issues_pulls(r, @gh)
143
+ open_issues = Rainbow("#{things[:issues][:open]} open").green
144
+ closed_issues = Rainbow("#{things[:issues][:closed]} closed").red
145
+ open_pulls = Rainbow("#{things[:pulls][:open]} open").green
146
+ closed_pulls = Rainbow("#{things[:pulls][:closed]} closed").red
147
+ merged_pulls = Rainbow("#{things[:pulls][:merged]} merged").magenta
148
+ puts "Issue data for #{r}: #{open_issues} and #{closed_issues}"
149
+ puts "Pull data for #{r}: #{open_pulls}, #{merged_pulls}, " \
150
+ "and #{closed_pulls}"
151
+ end
152
+ end
153
+
91
154
  # Simply runs the program.
92
155
  def run
93
156
  puts @usage if failed?
@@ -102,22 +165,17 @@ module GHULS
102
165
  puts "We could not find any user named #{@opts[:get]}."
103
166
  puts 'If you believe this is an error, please report it as a bug.'
104
167
  else
105
- user_percents = GHULS::Lib.analyze_user(@opts[:get], @gh)
106
- increment
107
- org_percents = GHULS::Lib.analyze_orgs(@opts[:get], @gh)
108
- increment
109
- if !user_percents.nil?
110
- puts "Getting language data for #{user[:username]}..."
111
- output(user_percents)
112
- else
113
- puts 'Could not find any personal data to analyze.'
114
- end
115
- if !org_percents.nil?
116
- puts 'Getting language data for their organizations...'
117
- output(org_percents)
118
- else
119
- puts 'Could not find any organizaztion data to analyze.'
120
- end
168
+ @repos = GHULS::Lib.get_user_repos(@opts[:get], @gh)
169
+ @org_repos = GHULS::Lib.get_org_repos(@opts[:get], @gh)
170
+ language_data(user[:username])
171
+ puts 'Getting forks, stars, and watchers of user repositories...'
172
+ fork_data(@repos)
173
+ puts 'Getting forks, stars, and watchers of ' \
174
+ 'organization repositories...'
175
+ fork_data(@org_repos)
176
+ follower_data(user[:username])
177
+ issue_data(@repos)
178
+ issue_data(@org_repos)
121
179
  end
122
180
  exit
123
181
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ghuls
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.4.3
4
+ version: 1.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Eli Foster
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-11-07 00:00:00.000000000 Z
11
+ date: 2015-11-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: octokit
@@ -44,28 +44,28 @@ dependencies:
44
44
  requirements:
45
45
  - - ">="
46
46
  - !ruby/object:Gem::Version
47
- version: 2.5.0
47
+ version: 2.6.0
48
48
  type: :runtime
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
52
  - - ">="
53
53
  - !ruby/object:Gem::Version
54
- version: 2.5.0
54
+ version: 2.6.0
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: ghuls-lib
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
59
  - - ">="
60
60
  - !ruby/object:Gem::Version
61
- version: 1.1.3
61
+ version: 2.2.0
62
62
  type: :runtime
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
66
  - - ">="
67
67
  - !ruby/object:Gem::Version
68
- version: 1.1.3
68
+ version: 2.2.0
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: progress_bar
71
71
  requirement: !ruby/object:Gem::Requirement
@@ -80,6 +80,20 @@ dependencies:
80
80
  - - ">="
81
81
  - !ruby/object:Gem::Version
82
82
  version: 1.0.5
83
+ - !ruby/object:Gem::Dependency
84
+ name: array_utility
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: 1.0.0
90
+ type: :runtime
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: 1.0.0
83
97
  description: Getting GitHub repository language data by user! It also has a web alternative
84
98
  at http://ghuls.herokuapp.com
85
99
  email: elifosterwy@gmail.com