cykl 0.1.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,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 23651edd6a80f1af217e4da233d37aeb0e2e2e0c
4
+ data.tar.gz: fe91e3fc6c20b799c98cd1f9ec9f7e9f73e318cb
5
+ SHA512:
6
+ metadata.gz: d7a860b9285f9ad1a975ba20a554a9940d79693e1d89bb78730c11bc1a4a2b7d76da5282588693aee9f088e34b67a388dc81d25c1fdc20626cd14ced81dda93c
7
+ data.tar.gz: fe426792fbc14404c7d38f2ede2eeae77a37d714b39923e5a07210210ff1392dc76e17a226ce985ede87b4917071955ab6a5ae0c82706543f98f99132cd46506
data/.gitignore ADDED
@@ -0,0 +1,12 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
10
+
11
+ # rspec failure tracking
12
+ .rspec_status
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --format documentation
2
+ --color
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source "https://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in cykl.gemspec
4
+ gemspec
data/README.md ADDED
@@ -0,0 +1,47 @@
1
+ # Cykl
2
+
3
+ View the cycle-time of your Github issues
4
+
5
+ Cykl uses the Github API via Octokit to pull information on the last 100 closed
6
+ issues in your repo. Currently, you can track the average lifetime of those issues.
7
+
8
+ ### Upcoming
9
+
10
+ - How long issues have spent in a particular column on your project
11
+ board (if the board is connected to Github)
12
+
13
+ ## Installation
14
+
15
+ Add this line to your application's Gemfile:
16
+
17
+ ```ruby
18
+ gem 'cykl', '0.1.0'
19
+ ```
20
+
21
+ And then execute:
22
+
23
+ $ bundle
24
+
25
+ Or install it yourself as:
26
+
27
+ $ gem install cykl
28
+
29
+ ## Usage
30
+
31
+ First, be sure to have your Github login details in a `.netrc` in your root directory
32
+
33
+ - Just call `cykl` with no arguments to return up to the last 100
34
+ closed issues assigned to you
35
+
36
+ - Or `cykl 'owner/repo'` to return up to the last 100 closed issues
37
+ from a specific repository
38
+
39
+
40
+ ## Contributing
41
+
42
+ Bug reports and pull requests are welcome on GitHub at https://github.com/Baron-burton/cykl. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
43
+
44
+ ## License
45
+
46
+ The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
47
+
data/Rakefile ADDED
@@ -0,0 +1,6 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task :default => :spec
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "cykl"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start(__FILE__)
data/bin/cykl ADDED
@@ -0,0 +1,5 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'cykl'
4
+
5
+ Cykl.time(ARGV.first)
data/bin/setup ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
data/cykl.gemspec ADDED
@@ -0,0 +1,35 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'cykl/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = 'cykl'
8
+ spec.version = Cykl::VERSION
9
+ spec.authors = ['Brandon Burton']
10
+ spec.email = ['brandon.anthony.burton@gmail.com']
11
+
12
+ spec.summary = %q{View the cycle-time of your Github issues}
13
+ spec.description = %q{
14
+ Cykl uses the Github API to pull information on the last 100 issues in your repo.
15
+ Currently you can track the average lifetime of your issues, and soon you'll be
16
+ able to see how long they've spent in a particular column on your project board
17
+ (if the board is connected to Github).
18
+ }
19
+ spec.homepage = 'https://github.com/Baron-burton/cykl'
20
+ spec.license = 'MIT'
21
+
22
+ spec.files = `git ls-files -z`.split("\x0").reject do |f|
23
+ f.match(%r{^(test|spec|features)/})
24
+ end
25
+ spec.executables << 'cykl'
26
+ spec.require_paths = ['lib']
27
+
28
+ spec.add_dependency 'netrc', '~> 0.11'
29
+ spec.add_dependency 'octokit', '~> 4.7'
30
+
31
+ spec.add_development_dependency 'bundler', '~> 1.15'
32
+ spec.add_development_dependency 'byebug', '~> 9.0'
33
+ spec.add_development_dependency 'rake', '~> 10.0'
34
+ spec.add_development_dependency 'rspec', '~> 3.0'
35
+ end
@@ -0,0 +1,23 @@
1
+ require 'octokit'
2
+
3
+ module Cykl
4
+ class Issues
5
+
6
+ attr_reader :client
7
+ private :client
8
+
9
+ def initialize
10
+ @client = Octokit::Client.new(
11
+ netrc: true
12
+ )
13
+ end
14
+
15
+ def list_issues(repo = nil)
16
+ client.issues(
17
+ repo,
18
+ state: 'closed',
19
+ per_page: 100
20
+ )
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,3 @@
1
+ module Cykl
2
+ VERSION = "0.1.1"
3
+ end
data/lib/cykl.rb ADDED
@@ -0,0 +1,50 @@
1
+ require 'cykl/issues'
2
+ require 'cykl/version'
3
+
4
+ module Cykl
5
+ class << self
6
+ attr_reader :cycle_time
7
+ private :cycle_time
8
+
9
+ def time(repo = nil)
10
+ issues = Issues.new.list_issues(repo)
11
+ @cycle_time = average_cycle_time(issues)
12
+
13
+ print_and_flush(cycle_time_message)
14
+ rescue Octokit::NotFound
15
+ print_and_flush('Sorry, Github couldn\'t find anything')
16
+ end
17
+
18
+ private
19
+
20
+ def cycle_time_message
21
+ "Your average cycle time is #{cycle_time}" +
22
+ (cycle_time == 1.00 ? 'day' : 'days')
23
+ end
24
+
25
+ def average_cycle_time(issues)
26
+ lifetimes = []
27
+
28
+ issues.each do |issue|
29
+ lifetimes << ((issue.closed_at - issue.created_at) / seconds_in_a_day)
30
+ end
31
+
32
+ calculate_average(lifetimes)
33
+ end
34
+
35
+ def calculate_average(data)
36
+ total = data.inject(:+)
37
+
38
+ (total / data.count).round(2)
39
+ end
40
+
41
+ def seconds_in_a_day
42
+ (24 * 60 * 60)
43
+ end
44
+
45
+ def print_and_flush(msg)
46
+ print msg
47
+ STDOUT.flush
48
+ end
49
+ end
50
+ end
metadata ADDED
@@ -0,0 +1,145 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: cykl
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.1
5
+ platform: ruby
6
+ authors:
7
+ - Brandon Burton
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2017-07-16 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: netrc
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '0.11'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '0.11'
27
+ - !ruby/object:Gem::Dependency
28
+ name: octokit
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '4.7'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '4.7'
41
+ - !ruby/object:Gem::Dependency
42
+ name: bundler
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '1.15'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '1.15'
55
+ - !ruby/object:Gem::Dependency
56
+ name: byebug
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '9.0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '9.0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: rake
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '10.0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '10.0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: rspec
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: '3.0'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - "~>"
95
+ - !ruby/object:Gem::Version
96
+ version: '3.0'
97
+ description: "\n Cykl uses the Github API to pull information
98
+ on the last 100 issues in your repo.\n Currently you can
99
+ track the average lifetime of your issues, and soon you'll be\n able
100
+ to see how long they've spent in a particular column on your project board\n (if
101
+ the board is connected to Github).\n "
102
+ email:
103
+ - brandon.anthony.burton@gmail.com
104
+ executables:
105
+ - cykl
106
+ extensions: []
107
+ extra_rdoc_files: []
108
+ files:
109
+ - ".gitignore"
110
+ - ".rspec"
111
+ - Gemfile
112
+ - README.md
113
+ - Rakefile
114
+ - bin/console
115
+ - bin/cykl
116
+ - bin/setup
117
+ - cykl.gemspec
118
+ - lib/cykl.rb
119
+ - lib/cykl/issues.rb
120
+ - lib/cykl/version.rb
121
+ homepage: https://github.com/Baron-burton/cykl
122
+ licenses:
123
+ - MIT
124
+ metadata: {}
125
+ post_install_message:
126
+ rdoc_options: []
127
+ require_paths:
128
+ - lib
129
+ required_ruby_version: !ruby/object:Gem::Requirement
130
+ requirements:
131
+ - - ">="
132
+ - !ruby/object:Gem::Version
133
+ version: '0'
134
+ required_rubygems_version: !ruby/object:Gem::Requirement
135
+ requirements:
136
+ - - ">="
137
+ - !ruby/object:Gem::Version
138
+ version: '0'
139
+ requirements: []
140
+ rubyforge_project:
141
+ rubygems_version: 2.6.8
142
+ signing_key:
143
+ specification_version: 4
144
+ summary: View the cycle-time of your Github issues
145
+ test_files: []