cykl 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: b07a376904547e0e04bf745b064ce931ac1eacb9
4
- data.tar.gz: e6b664cc00679e72968b9a7a43df3228241cc1b5
3
+ metadata.gz: 8c99ae9d7e779ef2a320a87ffcb3e1aef9de0d05
4
+ data.tar.gz: 3334785aeb7e86a06eb94d9518737a8e3b0ac41e
5
5
  SHA512:
6
- metadata.gz: 1c3c7513e8aea904661cd346fbb3d13eddb272c81207997fc5c88ded21c929fc958cd922985e0ed7534752bc5c76e85c85921e0bf4028ea4d574fb48396ec29b
7
- data.tar.gz: 021223d73ca7ea9362d38d498d8e105bed6b2c7ce382bee2b42b13bae7983a13eca6f9a8e2bee7cc7cd568e9048e2eecf4d87f4d630e7850441d25613b33f5b0
6
+ metadata.gz: 4a3c1f622558e13bdcda749654c902de8e7e7ea369d7659835f44ab21dcbec021f2c586df31ed1418044316195d54f337f2d26faf6f8a6780b3f87cfbf4366b6
7
+ data.tar.gz: e63c0fd8a3a8213a0904c58e507f6378a9b5588bb447eeb519662375f6c03a2ca5b1ee10dd3490faef5f22d2fa996722dd771e71a1a8ee3363e6382e88bc42de
data/README.md CHANGED
@@ -15,7 +15,7 @@ board (if the board is connected to Github)
15
15
  Add this line to your application's Gemfile:
16
16
 
17
17
  ```ruby
18
- gem 'cykl', '~> 0.1.3'
18
+ gem 'cykl', '~> 0.1.4'
19
19
  ```
20
20
 
21
21
  And then execute:
@@ -30,12 +30,19 @@ Or install it yourself as:
30
30
 
31
31
  First, be sure to have your Github login details in a `.netrc` in your root directory
32
32
 
33
- - Just call `cykl` with no arguments to return up to the last 100
34
- closed issues assigned to you
33
+ - Just call `cykl` with no arguments to return at least the
34
+ last 50 closed issues assigned to you
35
35
 
36
- - Or `cykl 'owner/repo'` to return up to the last 100 closed issues
37
- from a specific repository
36
+ - Or `cykl 'owner/repo'` to return at least the last 50
37
+ closed issues from a specific repository
38
38
 
39
+ #### Options
40
+
41
+ `--label`
42
+
43
+ - You can provide a label to scope your return to issues only
44
+ containing the given label, like so: `--label '<your repo label>'`.
45
+ You can also pass `-l`
39
46
 
40
47
  ## Contributing
41
48
 
data/bin/cykl CHANGED
@@ -2,4 +2,4 @@
2
2
 
3
3
  require 'cykl'
4
4
 
5
- Cykl.time(ARGV.first)
5
+ Cykl::Initializer.start(ARGV)
@@ -9,13 +9,8 @@ Gem::Specification.new do |spec|
9
9
  spec.authors = ['Brandon Burton']
10
10
  spec.email = ['brandon.anthony.burton@gmail.com']
11
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
- }
12
+ spec.description = "Track the cycle-time of your repo's issues"
13
+ spec.summary = spec.description
19
14
  spec.homepage = 'https://github.com/Baron-burton/cykl'
20
15
  spec.license = 'MIT'
21
16
 
@@ -27,6 +22,7 @@ Gem::Specification.new do |spec|
27
22
 
28
23
  spec.add_dependency 'netrc', '~> 0.11'
29
24
  spec.add_dependency 'octokit', '~> 4.7'
25
+ spec.add_dependency 'thor', '~> 0.19.1'
30
26
 
31
27
  spec.add_development_dependency 'bundler', '~> 1.15'
32
28
  spec.add_development_dependency 'byebug', '~> 9.0'
@@ -1,51 +1,3 @@
1
1
  require 'cykl/issues'
2
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
- puts_and_flush "Pulling in your issues, please wait..."
11
- issues = Issues.new.list_issues(repo)
12
- @cycle_time = average_cycle_time(issues)
13
-
14
- puts_and_flush(cycle_time_message)
15
- rescue Octokit::NotFound
16
- puts_and_flush('Sorry, Github couldn\'t find anything')
17
- end
18
-
19
- private
20
-
21
- def cycle_time_message
22
- "Your average cycle time is #{cycle_time}" +
23
- (cycle_time == 1.00 ? 'day' : 'days')
24
- end
25
-
26
- def average_cycle_time(issues)
27
- lifetimes = []
28
-
29
- issues.each do |issue|
30
- lifetimes << ((issue.closed_at - issue.created_at) / seconds_in_a_day)
31
- end
32
-
33
- calculate_average(lifetimes)
34
- end
35
-
36
- def calculate_average(data)
37
- total = data.inject(:+)
38
-
39
- (total / data.count).round(2)
40
- end
41
-
42
- def seconds_in_a_day
43
- (24 * 60 * 60)
44
- end
45
-
46
- def puts_and_flush(msg)
47
- puts msg
48
- STDOUT.flush
49
- end
50
- end
51
- end
3
+ require 'cykl/initializer'
@@ -0,0 +1,75 @@
1
+ require 'thor'
2
+
3
+ module Cykl
4
+ class Initializer < Thor
5
+ attr_reader :cycle_time
6
+ private :cycle_time
7
+
8
+
9
+ desc 'time REPO', 'returns the average cycle time for your repo'
10
+ method_option(
11
+ :label,
12
+ type: :string,
13
+ aliases: '-l',
14
+ lazy_default: '',
15
+ desc: 'search for repositories with a given label'
16
+ )
17
+
18
+ def time(repo = nil)
19
+ initializer_message(repo, options)
20
+ list_of_issues(repo, options)
21
+
22
+ puts_and_flush(cycle_time_message)
23
+ rescue Octokit::NotFound
24
+ puts_and_flush('Sorry, Github couldn\'t find anything')
25
+ end
26
+
27
+ private
28
+
29
+ def list_of_issues(repo, options)
30
+ issues = Issues.new.list_issues(repo, options)
31
+ @cycle_time = average_cycle_time(issues)
32
+ end
33
+
34
+ def cycle_time_message
35
+ "\nYour average cycle time is #{cycle_time}" +
36
+ (cycle_time == 1.00 ? 'day' : 'days')
37
+ end
38
+
39
+ def average_cycle_time(issues)
40
+ lifetimes = []
41
+
42
+ issues.each do |issue|
43
+ lifetimes << ((issue.closed_at - issue.created_at) / seconds_in_a_day)
44
+ end
45
+
46
+ calculate_average(lifetimes)
47
+ end
48
+
49
+ def calculate_average(data)
50
+ total = data.inject(:+)
51
+
52
+ (total / data.count).round(2)
53
+ end
54
+
55
+ def seconds_in_a_day
56
+ (24 * 60 * 60)
57
+ end
58
+
59
+ def initializer_message(repo, options)
60
+ if options.any? && !options[:label].empty?
61
+ puts_and_flush(
62
+ "Attempting to pull in your #{options[:label]} issues \n" +
63
+ "from #{repo}, please wait..."
64
+ )
65
+ else
66
+ puts_and_flush("Pulling in your issues from #{repo}, please wait...")
67
+ end
68
+ end
69
+
70
+ def puts_and_flush(msg)
71
+ puts msg
72
+ STDOUT.flush
73
+ end
74
+ end
75
+ end
@@ -12,24 +12,25 @@ module Cykl
12
12
  )
13
13
  end
14
14
 
15
- def list_issues(repo = nil)
15
+ def list_issues(repo = nil, options)
16
16
  pr_free_issues = []
17
17
  counter = 1
18
18
 
19
19
  while pr_free_issues.count < 50
20
- issues = get_issues(repo, counter)
20
+ issues = get_issues(repo, counter, options)
21
21
  issues.select { |issue| pr_free_issues << issue if issue.pull_request == nil }
22
22
  counter += 1
23
23
  end
24
24
  pr_free_issues
25
25
  end
26
26
 
27
- def get_issues(repo = nil, pages)
27
+ def get_issues(repo = nil, page, options)
28
28
  client.issues(
29
29
  repo,
30
30
  state: 'closed',
31
31
  per_page: 100,
32
- page: pages
32
+ page: page,
33
+ labels: options[:label]
33
34
  )
34
35
  end
35
36
  end
@@ -1,3 +1,3 @@
1
1
  module Cykl
2
- VERSION = "0.1.3"
2
+ VERSION = "0.1.4"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cykl
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
  - Brandon Burton
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-07-28 00:00:00.000000000 Z
11
+ date: 2017-08-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: netrc
@@ -38,6 +38,20 @@ dependencies:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
40
  version: '4.7'
41
+ - !ruby/object:Gem::Dependency
42
+ name: thor
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: 0.19.1
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: 0.19.1
41
55
  - !ruby/object:Gem::Dependency
42
56
  name: bundler
43
57
  requirement: !ruby/object:Gem::Requirement
@@ -94,11 +108,7 @@ dependencies:
94
108
  - - "~>"
95
109
  - !ruby/object:Gem::Version
96
110
  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 "
111
+ description: Track the cycle-time of your repo's issues
102
112
  email:
103
113
  - brandon.anthony.burton@gmail.com
104
114
  executables:
@@ -116,6 +126,7 @@ files:
116
126
  - bin/setup
117
127
  - cykl.gemspec
118
128
  - lib/cykl.rb
129
+ - lib/cykl/initializer.rb
119
130
  - lib/cykl/issues.rb
120
131
  - lib/cykl/version.rb
121
132
  homepage: https://github.com/Baron-burton/cykl
@@ -141,5 +152,5 @@ rubyforge_project:
141
152
  rubygems_version: 2.4.5.1
142
153
  signing_key:
143
154
  specification_version: 4
144
- summary: View the cycle-time of your Github issues
155
+ summary: Track the cycle-time of your repo's issues
145
156
  test_files: []