scrum_yo 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml ADDED
@@ -0,0 +1,15 @@
1
+ ---
2
+ !binary "U0hBMQ==":
3
+ metadata.gz: !binary |-
4
+ OTQ0MDM2ZDJmNTYyOTU4NjY0YjgwYmM2ODJiZWE5MWIzY2U4MWNjMg==
5
+ data.tar.gz: !binary |-
6
+ YWMzZWEzOGI3M2JiNGRiNWY5Yjc3NzBiZTQ1MTY2NjYyMjMxZTk2ZQ==
7
+ SHA512:
8
+ metadata.gz: !binary |-
9
+ NzNhZTViMmVlYzMxYmRlNDkxODgyNTNjNDU2YzAwMjhiMmM0OGE2N2NmYTYz
10
+ NzA2YTIxYTRjNGU4Njk3MGZlZWJjM2ZjZWM2OTE0NDI3MGEyNmEzNjUyZGQy
11
+ OGI5MDg5YzliYjZkYmM1YzE1NzIxYTc5MWJhNzg5NzhmYTMyZDA=
12
+ data.tar.gz: !binary |-
13
+ ZWYwMDdhZTk3YTgyYTMyMDAxZjk4OGQ4ZmVkZmM3MmNkMDRkZWFjZDM1ZGZi
14
+ ODYzOTU2MDVkYzc4MTM4ZmYzYjk0ZWNiMDIxOGI3YjEyZjA3ZGVjMzdlNTRh
15
+ YWUxNGUyYTVmMmQ1ZTA2ZTUzMGVmODdmYjViYzZmMTA4MGE3NDU=
data/.gitignore ADDED
@@ -0,0 +1,17 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --color
2
+ --format documentation
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in standup_time.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2014 Mike Coutermarsh
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,29 @@
1
+ # ScrumYo
2
+
3
+ TODO: Write a gem description
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ gem 'scrum_yo'
10
+
11
+ And then execute:
12
+
13
+ $ bundle
14
+
15
+ Or install it yourself as:
16
+
17
+ $ gem install scrum_yo
18
+
19
+ ## Usage
20
+
21
+ TODO: Write usage instructions here
22
+
23
+ ## Contributing
24
+
25
+ 1. Fork it ( http://github.com/mscoutermarsh/scrum_yo/fork )
26
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
27
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
28
+ 4. Push to the branch (`git push origin my-new-feature`)
29
+ 5. Create new Pull Request
data/Rakefile ADDED
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
data/bin/scrumyo ADDED
@@ -0,0 +1,5 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'scrum_yo'
4
+
5
+ ScrumYo::CLI.start(*ARGV)
data/lib/rainbow.rb ADDED
@@ -0,0 +1,33 @@
1
+ # Allows us to print rainbow text to console
2
+ class Rainbow
3
+ PI_3 = Math::PI / 3
4
+
5
+ def initialize
6
+ # colors calculation stolen from Minitest's Pride Plugin
7
+ # https://github.com/seattlerb/minitest
8
+ @colors = (0...(6 * 7)).map do |n|
9
+ n *= 1.0 / 6
10
+ r = (3 * Math.sin(n) + 3).to_i
11
+ g = (3 * Math.sin(n + 2 * PI_3) + 3).to_i
12
+ b = (3 * Math.sin(n + 4 * PI_3) + 3).to_i
13
+
14
+ 36 * r + 6 * g + b + 16
15
+ end
16
+ @color_index = 0
17
+ end
18
+
19
+ def rainbow
20
+ @color_index == (@colors.size - 1) ? @color_index = 0 : @color_index += 1
21
+ @colors[@color_index]
22
+ end
23
+
24
+ def colorize(string)
25
+ rainbow_string = ''
26
+ string.each_char do |char|
27
+ rainbow_string << "\e[38;5;#{rainbow}m#{char}\e[0m"
28
+ end
29
+
30
+ rainbow_string
31
+ end
32
+
33
+ end
@@ -0,0 +1,41 @@
1
+ module ScrumYo
2
+ class Activity
3
+ attr_reader :github_activity, :user
4
+
5
+ def initialize
6
+ @user = ScrumYo::User.new
7
+ @github = @user.github_client
8
+ @github_activity = load_activities
9
+ end
10
+
11
+ private
12
+
13
+ def load_activities(page = 1)
14
+ activities = @github.user_events(@user.username, page: page)
15
+
16
+ if older_than_one_day(activities.last)
17
+ return filter_activity(activities)
18
+ else
19
+ # recursion alert! get events from next page
20
+ activities.push(*load_activities(page + 1))
21
+ end
22
+ end
23
+
24
+ def older_than_one_day(event)
25
+ (DateTime.now.in_time_zone('UTC') - event.created_at) / 1.hour > 24
26
+ end
27
+
28
+ def filter_activity(events)
29
+ events.select! { |e| %w{PushEvent PullRequestEvent}.include? e.type }
30
+
31
+ events.each do |event|
32
+ if event.payload.commits
33
+ event.payload.commits.select! { |commit| @user.emails.include? commit.author.email }
34
+ end
35
+ end
36
+
37
+ events
38
+ end
39
+
40
+ end
41
+ end
@@ -0,0 +1,59 @@
1
+ module ScrumYo
2
+ class Output
3
+ def initialize
4
+ @activity = ScrumYo::Activity.new
5
+ @activities = @activity.github_activity
6
+ end
7
+
8
+ def print
9
+ @activities.reverse.each do |event|
10
+ print_day(event)
11
+ case event.type
12
+ when 'PushEvent'
13
+ print_push(event)
14
+ when 'PullRequestEvent'
15
+ print_pull_request(event)
16
+ end
17
+ end
18
+ end
19
+
20
+ private
21
+
22
+ def print_day(event)
23
+ day = "#{event.created_at.strftime('%a, %b %e')}"
24
+
25
+ puts day.green unless @current_day == day
26
+ @current_day = day
27
+ end
28
+
29
+ def print_push(event)
30
+ commits = event.payload.commits
31
+ return if commits.size == 0
32
+
33
+ event_time = format_time(event.created_at)
34
+
35
+ puts "#{event_time}: Pushed to: #{event.repo.name}".indent(2).red
36
+ puts "Commit #{'message'.pluralize(commits.size)}:".indent(4).yellow
37
+
38
+ print_commits(commits)
39
+ end
40
+
41
+ def print_commits(commits)
42
+ commits.each do |commit|
43
+ puts "#{commit.message}\n\n".indent(4)
44
+ end
45
+ end
46
+
47
+ def print_pull_request(event)
48
+ event_time = format_time(event.created_at)
49
+
50
+ puts "#{event_time}: #{event.payload.action} Pull Request on #{event.repo.name}".indent(2).red
51
+ puts "#{event.payload.pull_request.title}\n".indent(4).yellow
52
+ end
53
+
54
+ def format_time(time)
55
+ time = time.in_time_zone(@activity.user.time_zone)
56
+ time.strftime('%l:%M %p')
57
+ end
58
+ end
59
+ end
@@ -0,0 +1,17 @@
1
+ module ScrumYo
2
+ class User
3
+ attr_reader :github_client, :username, :emails
4
+
5
+ def initialize
6
+ # Uses credentials in .netrc to authenticate
7
+ @github_client = Octokit::Client.new(netrc: true)
8
+ @username = @github_client.login
9
+ @emails = @github_client.emails
10
+ end
11
+
12
+ def time_zone
13
+ Time.zone = DateTime.now.utc_offset / 60 / 60
14
+ Time.zone.name
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,3 @@
1
+ module ScrumYo
2
+ VERSION = "0.0.1"
3
+ end
data/lib/scrum_yo.rb ADDED
@@ -0,0 +1,19 @@
1
+ require 'octokit'
2
+ require 'colorize'
3
+ require 'active_support/inflector'
4
+ require 'active_support/time'
5
+ require 'active_support/time_with_zone'
6
+ require 'scrum_yo/activity'
7
+ require 'scrum_yo/output'
8
+ require 'scrum_yo/user'
9
+ require 'string_hacks'
10
+
11
+ module ScrumYo
12
+ class CLI
13
+ def self.start(*args)
14
+ puts "Happy #{DateTime.current.strftime('%A')}!\n"
15
+ puts "Grabbing your recent GitHub Activity...\n".rainbow
16
+ ScrumYo::Output.new.print
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,19 @@
1
+ # Methods to make printing prettier
2
+ String.class_eval do
3
+ require 'rainbow'
4
+
5
+ def indent(count, char = ' ')
6
+ gsub(/([^\n]*)(\n|$)/) do |match|
7
+ last_iteration = ($1 == '' && $2 == '')
8
+ line = ''
9
+ line << (char * count) unless last_iteration
10
+ line << $1
11
+ line << $2
12
+ line
13
+ end
14
+ end
15
+
16
+ def rainbow
17
+ Rainbow.new.colorize(self)
18
+ end
19
+ end
data/scrum_yo.gemspec ADDED
@@ -0,0 +1,31 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'scrum_yo/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "scrum_yo"
8
+ spec.version = ScrumYo::VERSION
9
+ spec.authors = ["Mike Coutermarsh"]
10
+ spec.email = ["coutermarsh.mike@gmail.com"]
11
+ spec.summary = %q{Be awesome at your daily stand up with a summary of all your recent GitHub Activity.}
12
+ spec.description = %q{ScrumYo! G}
13
+ spec.homepage = ""
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files -z`.split("\x0")
17
+ spec.executables = ['scrumyo']
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.add_dependency 'octokit', '~> 2.0'
22
+ spec.add_dependency 'netrc', '~> 0.7.7'
23
+ spec.add_dependency 'activesupport', '~> 4.1.0'
24
+ spec.add_dependency 'colorize'
25
+
26
+ spec.add_development_dependency "bundler", "~> 1.5"
27
+ spec.add_development_dependency "pry"
28
+ spec.add_development_dependency "pry-debugger"
29
+ spec.add_development_dependency "rspec"
30
+ spec.add_development_dependency "rake"
31
+ end
@@ -0,0 +1,12 @@
1
+ require 'bundler/setup'
2
+ Bundler.setup
3
+
4
+ require 'standup_time'
5
+
6
+ RSpec.configure do |config|
7
+ config.treat_symbols_as_metadata_keys_with_true_values = true
8
+ config.run_all_when_everything_filtered = true
9
+ config.filter_run :focus
10
+
11
+ config.order = 'random'
12
+ end
metadata ADDED
@@ -0,0 +1,189 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: scrum_yo
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Mike Coutermarsh
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-04-26 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: octokit
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ~>
18
+ - !ruby/object:Gem::Version
19
+ version: '2.0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ~>
25
+ - !ruby/object:Gem::Version
26
+ version: '2.0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: netrc
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ~>
32
+ - !ruby/object:Gem::Version
33
+ version: 0.7.7
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ~>
39
+ - !ruby/object:Gem::Version
40
+ version: 0.7.7
41
+ - !ruby/object:Gem::Dependency
42
+ name: activesupport
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ~>
46
+ - !ruby/object:Gem::Version
47
+ version: 4.1.0
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ~>
53
+ - !ruby/object:Gem::Version
54
+ version: 4.1.0
55
+ - !ruby/object:Gem::Dependency
56
+ name: colorize
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ! '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ! '>='
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: bundler
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ~>
74
+ - !ruby/object:Gem::Version
75
+ version: '1.5'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ~>
81
+ - !ruby/object:Gem::Version
82
+ version: '1.5'
83
+ - !ruby/object:Gem::Dependency
84
+ name: pry
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ! '>='
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ! '>='
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
97
+ - !ruby/object:Gem::Dependency
98
+ name: pry-debugger
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - ! '>='
102
+ - !ruby/object:Gem::Version
103
+ version: '0'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - ! '>='
109
+ - !ruby/object:Gem::Version
110
+ version: '0'
111
+ - !ruby/object:Gem::Dependency
112
+ name: rspec
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - ! '>='
116
+ - !ruby/object:Gem::Version
117
+ version: '0'
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - ! '>='
123
+ - !ruby/object:Gem::Version
124
+ version: '0'
125
+ - !ruby/object:Gem::Dependency
126
+ name: rake
127
+ requirement: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - ! '>='
130
+ - !ruby/object:Gem::Version
131
+ version: '0'
132
+ type: :development
133
+ prerelease: false
134
+ version_requirements: !ruby/object:Gem::Requirement
135
+ requirements:
136
+ - - ! '>='
137
+ - !ruby/object:Gem::Version
138
+ version: '0'
139
+ description: ScrumYo! G
140
+ email:
141
+ - coutermarsh.mike@gmail.com
142
+ executables:
143
+ - scrumyo
144
+ extensions: []
145
+ extra_rdoc_files: []
146
+ files:
147
+ - .gitignore
148
+ - .rspec
149
+ - Gemfile
150
+ - LICENSE.txt
151
+ - README.md
152
+ - Rakefile
153
+ - bin/scrumyo
154
+ - lib/rainbow.rb
155
+ - lib/scrum_yo.rb
156
+ - lib/scrum_yo/activity.rb
157
+ - lib/scrum_yo/output.rb
158
+ - lib/scrum_yo/user.rb
159
+ - lib/scrum_yo/version.rb
160
+ - lib/string_hacks.rb
161
+ - scrum_yo.gemspec
162
+ - spec/spec_helper.rb
163
+ homepage: ''
164
+ licenses:
165
+ - MIT
166
+ metadata: {}
167
+ post_install_message:
168
+ rdoc_options: []
169
+ require_paths:
170
+ - lib
171
+ required_ruby_version: !ruby/object:Gem::Requirement
172
+ requirements:
173
+ - - ! '>='
174
+ - !ruby/object:Gem::Version
175
+ version: '0'
176
+ required_rubygems_version: !ruby/object:Gem::Requirement
177
+ requirements:
178
+ - - ! '>='
179
+ - !ruby/object:Gem::Version
180
+ version: '0'
181
+ requirements: []
182
+ rubyforge_project:
183
+ rubygems_version: 2.1.11
184
+ signing_key:
185
+ specification_version: 4
186
+ summary: Be awesome at your daily stand up with a summary of all your recent GitHub
187
+ Activity.
188
+ test_files:
189
+ - spec/spec_helper.rb