githop 0.0.2 → 0.0.3

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: cce817eab2856355be8ca1fec8e9b5db45ab0472
4
- data.tar.gz: bf81a00589813d04a982ba93add251c4421ecced
3
+ metadata.gz: 1b0602a3d04493f7bc0a6cb6edce8ff53a1ac355
4
+ data.tar.gz: 2c4be77cbf81bd11e80072d95591b515ee0e8b8e
5
5
  SHA512:
6
- metadata.gz: 42d7e03227877153edda6ecd2f75fe96ea3d3d889f5d688ad49cf471159f1b92d9e9c9238dd271a536ce5ea2bed63f7b57a775cf7a76cd3b9de5c420ad46238b
7
- data.tar.gz: 1ded110397de5827cb63f8015e9d9ff559c64aa1e8706e3697d13fcec2cf81dcac39f57edfaaf9c3088b8775b16aea52e4c7a7a8c4909a1e520d9168855c808f
6
+ metadata.gz: 2790df340ee9faaa793bb2a0312b4e04e029a6b7d5353215e3bb96644e698b6aba797b153f3e7eeba74f191b709acc2c644ae60b1a50d994d45b3955743e97f4
7
+ data.tar.gz: 97c8ea236ec5a08c06ea47c1b840a3cfb6ce594e9e2c34fdb31ba99452b0b7ff58d45eab2443c62bb561a3e849a42a5334afa4645e13e252b83c299f06bf5951
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- githop (0.0.1)
4
+ githop (0.0.3)
5
5
  activesupport
6
6
  bigquery
7
7
 
data/README.md CHANGED
@@ -25,6 +25,9 @@ At 2014-05-24 10:15:34, jpsim watched the repo shahruz/Sketch-Toolbox
25
25
  At 2014-05-24 10:18:35, jpsim watched the repo heardrwt/RHObjectiveBeagle
26
26
  ```
27
27
 
28
+ For the real lazy, it is also available on the web: <https://githop-yolo.herokuapp.com/orta>, specify
29
+ the desired GitHub user as path.
30
+
28
31
  ## Installation
29
32
 
30
33
  Use
data/bin/githop CHANGED
@@ -9,21 +9,4 @@ end
9
9
 
10
10
  require 'githop'
11
11
 
12
- config = YAML.load(File.read("#{ENV['HOME']}/.githop.yml"))
13
- other_user = ARGV.first
14
-
15
- result = GitHop.hop(config, other_user)
16
-
17
- if result['rows'].nil?
18
- $stderr.puts "GitHub Archive query for #{other_user || config['github_user']} had no results."
19
- $stderr.puts result.inspect
20
- exit(1)
21
- end
22
-
23
- result = GitHop.pretty_print(result, other_user)
24
-
25
- if result.count == 0
26
- puts "No events found, but #{other_user || 'you'} surely had an awesome day nevertheless :)"
27
- else
28
- puts result
29
- end
12
+ GitHop::Command.run(ARGV.first)
@@ -0,0 +1,24 @@
1
+ require 'active_support/time'
2
+
3
+ module GitHop
4
+ class Command
5
+ def self.run(other_user, date = 1.year.ago)
6
+ config = YAML.load(File.read("#{ENV['HOME']}/.githop.yml"))
7
+ result = GitHop.hop(config, other_user, date)
8
+
9
+ if result['rows'].nil?
10
+ $stderr.puts "GitHub Archive query for #{other_user || config['github_user']} had no results."
11
+ $stderr.puts result.inspect
12
+ exit(1)
13
+ end
14
+
15
+ result = GitHop.pretty_print(result, other_user)
16
+
17
+ if result.count == 0
18
+ puts "No events found, but #{other_user || 'you'} surely had an awesome day nevertheless :)"
19
+ else
20
+ puts result
21
+ end
22
+ end
23
+ end
24
+ end
@@ -1,3 +1,3 @@
1
1
  module GitHop
2
- VERSION = '0.0.2'
2
+ VERSION = '0.0.3'
3
3
  end
data/lib/githop.rb CHANGED
@@ -1,3 +1,4 @@
1
+ require 'githop/command'
1
2
  require 'githop/version'
2
3
 
3
4
  require 'active_support/time'
@@ -8,8 +9,7 @@ require 'yaml'
8
9
  module GitHop
9
10
  private
10
11
 
11
- def self.build_query_2014(gh_user)
12
- end_date = 1.year.ago
12
+ def self.build_query_2014(gh_user, end_date)
13
13
  month = end_date.strftime('%Y%m')
14
14
  end_date = end_date.strftime('%Y-%m-%d')
15
15
 
@@ -24,8 +24,7 @@ END
24
24
  query
25
25
  end
26
26
 
27
- def self.build_query_2015(gh_user)
28
- end_date = 1.year.ago
27
+ def self.build_query_2015(gh_user, end_date)
29
28
  start_date = (end_date - 1.day).strftime('%Y-%m-%d')
30
29
  end_date = end_date.strftime('%Y-%m-%d')
31
30
 
@@ -50,9 +49,9 @@ END
50
49
  opts
51
50
  end
52
51
 
53
- def self.hop(config, user = nil)
52
+ def self.hop(config, user = nil, date = 1.year.ago)
54
53
  bq = BigQuery::Client.new(client_options(config))
55
- query = build_query_2014(user || config['github_user'])
54
+ query = build_query_2014(user || config['github_user'], date)
56
55
  result = bq.query(query)
57
56
 
58
57
  # File.open('bigquery-sample.marshal', 'w') { |to_file| Marshal.dump(result, to_file) }
@@ -65,6 +64,7 @@ END
65
64
  def self.labels
66
65
  {
67
66
  'CreateEvent' => 'created the',
67
+ 'DeleteEvent' => 'deleted the',
68
68
  'ForkEvent' => 'forked the repo',
69
69
  'IssueCommentEvent' => 'commented an issue on',
70
70
  'IssuesEvent' => 'created an issue on',
@@ -93,6 +93,10 @@ END
93
93
  action += " #{ref} on" if ref_type != 'repository'
94
94
  end
95
95
 
96
+ if type == 'DeleteEvent'
97
+ action += " #{ref_type} #{ref} on"
98
+ end
99
+
96
100
  if type == 'PushEvent'
97
101
  next if pushed_repos.include?(target)
98
102
  pushed_repos << target
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: githop
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Boris Bügling
@@ -84,6 +84,7 @@ files:
84
84
  - bin/githop
85
85
  - githop.gemspec
86
86
  - lib/githop.rb
87
+ - lib/githop/command.rb
87
88
  - lib/githop/version.rb
88
89
  homepage: https://github.com/neonichu/githop
89
90
  licenses: