release-metrics 1.0.1 → 1.1.0

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
  SHA256:
3
- metadata.gz: cc7bbb525a16b6d01fd47a86015e1dccb7f2f6b376f39a930d47b0b4b923f50c
4
- data.tar.gz: ff10ce19da2fa0b649e0b93eef9b32bf8db8bc09b5444e7ac68ca9029e021eab
3
+ metadata.gz: 10cee685e7c6fea0197ebec0f887bb13195ec7f0da6f33fa89158d1cc3a5e39c
4
+ data.tar.gz: fe061d3b372f4c78fda6909dc8d637eab12062c3aabf25e98f4f6bea8b2aa279
5
5
  SHA512:
6
- metadata.gz: a91b4f7fd598ae7423f1ce2c5e26af65e316e3a2ae053bfefd0eb5e27cbaed1e03b3b99aadd0d480525738f12e78cb2d6979b0949a03f231a17941ef917908e9
7
- data.tar.gz: a8515ce56816b4fb48daf69e2523c3407e187b093d73ae8f8e608ce736a90c35ee6c711a33df6c382e13a20b00749fa37e44c74002a8608f26c87a72a46c91d4
6
+ metadata.gz: 25457cc1516b43880cb0ff6957d5788cd84ccb51177f5aeec4a39ad85aa20c799b1c1734553b90fb869a498bd3ac982fb62c9f09ce6bddff9447ba729bd2cd1b
7
+ data.tar.gz: 4e76b4160cc6980c8115bae1bdae010881c3d1a5dc434a3c6c53844d70e4b35953bc493b4de3f6fd53518ff458d440a1933aa43f9e036128fbc0e8bcfdd162e6
@@ -0,0 +1,54 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'docopt'
4
+ load File.expand_path(File.join(__dir__, '..', 'lib', 'metrics.rb'))
5
+
6
+ # Parse options
7
+ DOC =<<DOCOPT
8
+ Count releases in a given year (2012 - present).
9
+
10
+ Usage:
11
+ #{__FILE__} in-year YEAR
12
+ #{__FILE__} per-day-in-year YEAR
13
+ #{__FILE__} per-week-in-year YEAR
14
+ #{__FILE__} of-pe-in-year YEAR
15
+ #{__FILE__} of-foss-in-year YEAR
16
+ #{__FILE__} by-project-in-year YEAR --project PROJECT
17
+ DOCOPT
18
+
19
+ begin
20
+ options = Docopt::docopt(DOC)
21
+ rescue Docopt::Exit => e
22
+ puts "ERROR: Option parsing failed."
23
+ puts e.message
24
+ exit 1
25
+ end
26
+
27
+ # Do the thing
28
+ year = options['YEAR']
29
+
30
+ if options['in-year']
31
+ count = Metrics.releases_in_year(year)
32
+ puts "There have been #{count} total releases in #{year}"
33
+ end
34
+ if options['per-day-in-year']
35
+ count = Metrics.releases_per_day_in_year(year)
36
+ puts "There have been #{count} releases per day in #{year}"
37
+ end
38
+ if options['per-week-in-year']
39
+ count = Metrics.releases_per_week_in_year(year)
40
+ puts "There have been #{count} releases per week in #{year}"
41
+ end
42
+ if options['of-pe-in-year']
43
+ count = Metrics.pe_releases_in_year(year)
44
+ puts "There have been #{count} PE releases in #{year}"
45
+ end
46
+ if options['of-foss-in-year']
47
+ count = Metrics.foss_releases_in_year(year)
48
+ puts "There have been #{count} FOSS releases in #{year}"
49
+ end
50
+ if options['by-project-in-year']
51
+ project = options['PROJECT']
52
+ count = Metrics.releases_of_project_in_year(year, project)
53
+ puts "There have been #{count} releases of #{project} in #{year}"
54
+ end
@@ -0,0 +1,48 @@
1
+ require 'csv'
2
+
3
+ module Metrics
4
+ module_function
5
+
6
+ DATA_FILE = 'releases.csv'
7
+
8
+ def release_data
9
+ return CSV.read(DATA_FILE)
10
+ end
11
+
12
+ def release_year(release_array)
13
+ date_string = release_array.first
14
+ return date_string.split('/').last
15
+ end
16
+
17
+ def data_in_year(year)
18
+ return release_data.select { |release_array| release_year(release_array) == year }
19
+ end
20
+
21
+ def releases_in_year(year)
22
+ return data_in_year(year).count
23
+ end
24
+
25
+ def releases_per_day_in_year(year)
26
+ # use a decimal so that division includes the decimal
27
+ days_in_year = 365.0
28
+ days_in_year = 366.0 if Date.new(year.to_i).leap?
29
+ return releases_in_year(year) / days_in_year
30
+ end
31
+
32
+ def releases_per_week_in_year(year)
33
+ return releases_per_day_in_year(year) * 7
34
+ end
35
+
36
+ def releases_of_project_in_year(year, project)
37
+ project_releases = data_in_year(year).select { |release_array| release_array.include? project }
38
+ return project_releases.count
39
+ end
40
+
41
+ def pe_releases_in_year(year)
42
+ return releases_of_project_in_year(year, 'Puppet Enterprise')
43
+ end
44
+
45
+ def foss_releases_in_year(year)
46
+ return releases_in_year(year) - pe_releases_in_year(year)
47
+ end
48
+ end
@@ -2,7 +2,7 @@ require 'time'
2
2
 
3
3
  Gem::Specification.new do |gem|
4
4
  gem.name = 'release-metrics'
5
- gem.version = '1.0.1'
5
+ gem.version = '1.1.0'
6
6
  gem.date = Date.today.to_s
7
7
  gem.summary = "Puppet, Inc. Release Metrics"
8
8
  gem.authors = ["Puppet, Inc."]
@@ -11,6 +11,7 @@ Gem::Specification.new do |gem|
11
11
  gem.license = 'Apache-2.0'
12
12
 
13
13
  gem.files = %x(git ls-files -z).split("\0")
14
+ gem.require_path = 'lib'
14
15
  gem.bindir = 'bin'
15
16
  gem.executables = gem.files.grep(%r{^#{gem.bindir}}) { |f| File.basename(f) }
16
17
 
@@ -1,4 +1,10 @@
1
1
  Date,Project,Version,Final?,Notes
2
+ 11/14/2019,Puppet Enterprise,2019.2.1,y,
3
+ 11/8/2019,puppet-bolt,1.37.0,y,
4
+ 11/7/2019,puppet-bolt,1.36.0,y,
5
+ 11/6/2019,Puppet Enterprise,2019.1.3,y,
6
+ 11/6/2019,Puppet Enterprise,2018.1.11,y,
7
+ 11/6/2019,Puppet Enterprise,2019.2.0,y,
2
8
  11/1/2019,pdk,1.14.1.0,y,
3
9
  10/25/2019,puppet-bolt,1.35.0,y,
4
10
  10/23/2019,puppetdb,6.7.2,y,
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: release-metrics
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.1
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Puppet, Inc.
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-11-05 00:00:00.000000000 Z
11
+ date: 2019-11-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: docopt
@@ -42,6 +42,7 @@ description:
42
42
  email: release@puppet.com
43
43
  executables:
44
44
  - add-release
45
+ - releases
45
46
  extensions: []
46
47
  extra_rdoc_files: []
47
48
  files:
@@ -51,6 +52,8 @@ files:
51
52
  - LICENSE
52
53
  - README.md
53
54
  - bin/add-release
55
+ - bin/releases
56
+ - lib/metrics.rb
54
57
  - release-metrics.gemspec
55
58
  - releases.csv
56
59
  homepage: https://github.com/puppetlabs/release-metrics