duration-formatter 1.1.1 → 1.2.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
  SHA1:
3
- metadata.gz: 6c15a7267c925c45ad91c80e956db0d5fc57ee2a
4
- data.tar.gz: d0a69ecac8179b8c1e0cd79931413ba69ae7f2c9
3
+ metadata.gz: d7e09efaf9e97304ec46ee26493ab16e2f7d6c55
4
+ data.tar.gz: 1b4d5d142340debdb646d1b135db0b66ebcb14b9
5
5
  SHA512:
6
- metadata.gz: afd682c2028e8f80d1986035eaa364d59a2fcfc6581ab04aaaf8ed25c681e6e2fa68d8d90835ad8249b502ab3a4c825ad803e370b662dfafeedfef8924d84197
7
- data.tar.gz: fef1f3c1efa3825d34d15462cc317405779972356873e66ac9ee30b97a51d96702f56f7330610b5c95f9500e6abc8e61e643e27c8f4a72a043aca00205e909a8
6
+ metadata.gz: 36c3a9b63bf0fba1aa0f01a85b3131d71ac189a60eae37eb1e9b45dd3d647199f8a4ae104b192c01bff11f05fe3066fb705ed484e3a4fbe3cc07aa429540d12f
7
+ data.tar.gz: c1ee518358905e5e5b25d6131b5e197e7b88543c3f3f84d1139cfd682fc98d5e61f13494fac8834a3ee1a0e7f76307360f8afbee6c43fb73f0884eede8a9da0a
data/.gitignore CHANGED
@@ -1,2 +1,5 @@
1
+ .ruby-version
1
2
  coverage
2
- tmp
3
+ tmp
4
+ Gemfile.lock
5
+
data/.travis.yml CHANGED
@@ -1,10 +1,8 @@
1
1
  language: ruby
2
2
 
3
3
  rvm:
4
- - 1.9.3
5
- - 2.0
6
- - 2.1
7
- - 2.2.1
4
+ - 2.2.5
5
+ - 2.3.1
8
6
 
9
7
  addons:
10
8
  code_climate:
data/README.md CHANGED
@@ -2,17 +2,22 @@
2
2
 
3
3
  A simple gem to parse minutes into a readable format using [ruby-duration](https://github.com/peleteiro/ruby-duration).
4
4
 
5
- [![Gem Version](https://badge.fury.io/rb/duration-formatter.svg)](http://badge.fury.io/rb/duration-formatter) [![Code Climate](https://codeclimate.com/github/richardvenneman/duration-formatter/badges/gpa.svg)](https://codeclimate.com/github/richardvenneman/duration-formatter) [![Dependency Status](https://gemnasium.com/richardvenneman/duration-formatter.svg)](https://gemnasium.com/richardvenneman/duration-formatter) [![Test Coverage](https://codeclimate.com/github/richardvenneman/duration-formatter/badges/coverage.svg)](https://codeclimate.com/github/richardvenneman/duration-formatter/coverage) [![Build Status](http://img.shields.io/travis/richardvenneman/duration-formatter.svg)](https://travis-ci.org/richardvenneman/duration-formatter)
5
+ [![Gem](https://img.shields.io/gem/v/duration-formatter.svg?style=flat-square)](http://rubygems.org/gems/duration-formatter)
6
+ [![Build Status](https://img.shields.io/travis/richardvenneman/duration-formatter/master.svg?style=flat-square)](https://travis-ci.org/richardvenneman/duration-formatter)
7
+ [![Code Climate](https://img.shields.io/codeclimate/github/richardvenneman/duration-formatter.svg?style=flat-square)](https://codeclimate.com/github/richardvenneman/duration-formatter)
8
+ [![Test Coverage](https://img.shields.io/codeclimate/coverage/github/richardvenneman/duration-formatter.svg?style=flat-square)](https://codeclimate.com/github/richardvenneman/duration-formatter/coverage)
6
9
 
7
10
  ## Installation
8
11
 
12
+ This library is tested with the following Rubies: 2.2.5, 2.3.1.
13
+
9
14
  Add it to your Gemfile with:
10
15
 
11
16
  ```ruby
12
17
  gem 'duration-formatter'
13
18
  ```
14
19
 
15
- Run the `bundle install` in your terminal command to install it.
20
+ Run the `bundle install` command in your terminal to install it.
16
21
 
17
22
  ## Usage
18
23
 
@@ -41,19 +46,6 @@ FormattedDuration.new(1440, :hours).format # => 24 hours
41
46
  FormattedDuration.new(80, :minutes).format # => 80 minutes
42
47
  ```
43
48
 
44
- ## TODO
45
-
46
- This gem is a work-in-progress. Planned features:
47
-
48
- 1. Seconds support
49
- 2. Support “half” units, e.g. 90 minutes becomes 1½ hours
50
-
51
- ## Contributing
52
-
53
- Everyone is encouraged to help improve this project. Here are a few ways you can help:
49
+ ## License
54
50
 
55
- - Report bugs
56
- - Fix bugs and submit pull requests
57
- - Write, clarify, or fix documentation
58
- - Suggest or add new features
59
- - Write missing tests
51
+ This library is released under the [MIT License](http://www.opensource.org/licenses/MIT).
@@ -3,7 +3,8 @@ require './lib/duration_formatter/version'
3
3
  Gem::Specification.new do |s|
4
4
  s.name = 'duration-formatter'
5
5
  s.version = DurationFormatter::VERSION
6
- s.authors = ["Richard Venneman"]
6
+ s.license = 'MIT'
7
+ s.authors = ['Richard Venneman']
7
8
  s.email = 'richardvenneman@me.com'
8
9
  s.homepage =
9
10
  'https://github.com/richardvenneman/duration-formatter'
@@ -11,15 +12,13 @@ Gem::Specification.new do |s|
11
12
  s.description = 'A simple gem to parse minutes into a readable format using
12
13
  ruby-duration.'
13
14
 
14
- s.license = 'MIT'
15
-
16
15
  s.files = `git ls-files`.split("\n")
17
16
  s.test_files = Dir['test/**/*']
18
17
 
19
18
  s.add_dependency 'ruby-duration', '~> 3.2'
20
19
 
21
- s.add_development_dependency 'rake', '~> 10.4'
22
- s.add_development_dependency 'guard', '~> 2.12'
20
+ s.add_development_dependency 'rake', '~> 11.1'
21
+ s.add_development_dependency 'guard', '~> 2.13'
23
22
  s.add_development_dependency 'guard-minitest', '~> 2.4'
24
23
  s.add_development_dependency 'simplecov', '~> 0.9'
25
24
  s.add_development_dependency 'codeclimate-test-reporter', '~> 0.4'
@@ -1,3 +1,3 @@
1
1
  module DurationFormatter
2
- VERSION = '1.1.1'
2
+ VERSION = '1.2.0'
3
3
  end
@@ -1,10 +1,10 @@
1
1
  require 'ruby-duration'
2
2
 
3
3
  class FormattedDuration
4
- CONSTRAINTS = [:minutes, :hours, :days, :weeks]
5
- FORMATS = { weeks: '%w %~w', days: '%tdu', hours: '%thu', minutes: '%tmu' }
6
- BARE_FORMATS = { days: '%d %~d', hours: '%h %~h', minutes: '%m %~m' }
7
- BARE = { days: 7, hours: 24, minutes: 60 }
4
+ CONSTRAINTS = [:minutes, :hours, :days, :weeks].freeze
5
+ FORMATS = { weeks: '%w %~w', days: '%tdu', hours: '%thu', minutes: '%tmu' }.freeze
6
+ BARE_FORMATS = { days: '%d %~d', hours: '%h %~h', minutes: '%m %~m' }.freeze
7
+ BARE = { days: 7, hours: 24, minutes: 60 }.freeze
8
8
 
9
9
  def initialize(minutes, constraint = :weeks)
10
10
  @constraint = CONSTRAINTS.index(constraint)
@@ -16,7 +16,7 @@ class FormattedDuration
16
16
  end
17
17
 
18
18
  def format
19
- append(:weeks, @weeks, '%w %~w') if @weeks > 0 && @constraint > 2
19
+ append(:weeks, @weeks, '%w %~w') if @weeks.positive? && @constraint > 2
20
20
  add(:days, @days, 2)
21
21
  add(:hours, @hours, 1)
22
22
  add(:minutes, @minutes, 0)
@@ -34,9 +34,9 @@ class FormattedDuration
34
34
  def add(unit, value, constraint)
35
35
  bare = value % BARE[unit]
36
36
 
37
- if value > 0 && @constraint == constraint
37
+ if value.positive? && @constraint == constraint
38
38
  append(unit, value, FORMATS[unit])
39
- elsif bare > 0 && @constraint > constraint - 1
39
+ elsif bare.positive? && @constraint > constraint - 1
40
40
  append(unit, bare, BARE_FORMATS[unit])
41
41
  end
42
42
  end
@@ -6,7 +6,7 @@ class FormattedDurationTest < Minitest::Test
6
6
 
7
7
  def test_weeks_only_duration
8
8
  text = '1 week'
9
- output = FormattedDuration.new(10080).format
9
+ output = FormattedDuration.new(100_80).format
10
10
 
11
11
  assert_equal text, output
12
12
  end
@@ -36,7 +36,7 @@ class FormattedDurationTest < Minitest::Test
36
36
 
37
37
  def test_weeks_and_days_duration
38
38
  text = '1 week, 4 days'
39
- output = FormattedDuration.new(15840).format
39
+ output = FormattedDuration.new(158_40).format
40
40
 
41
41
  assert_equal text, output
42
42
  end
@@ -59,7 +59,7 @@ class FormattedDurationTest < Minitest::Test
59
59
 
60
60
  def test_days_constraint
61
61
  text = '8 days'
62
- output = FormattedDuration.new(11520, :days).format
62
+ output = FormattedDuration.new(115_20, :days).format
63
63
 
64
64
  assert_equal text, output
65
65
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: duration-formatter
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.1
4
+ version: 1.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Richard Venneman
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-07-09 00:00:00.000000000 Z
11
+ date: 2016-10-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: ruby-duration
@@ -30,28 +30,28 @@ dependencies:
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: '10.4'
33
+ version: '11.1'
34
34
  type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: '10.4'
40
+ version: '11.1'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: guard
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
45
  - - "~>"
46
46
  - !ruby/object:Gem::Version
47
- version: '2.12'
47
+ version: '2.13'
48
48
  type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
52
  - - "~>"
53
53
  - !ruby/object:Gem::Version
54
- version: '2.12'
54
+ version: '2.13'
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: guard-minitest
57
57
  requirement: !ruby/object:Gem::Requirement
@@ -105,7 +105,6 @@ files:
105
105
  - ".gitignore"
106
106
  - ".travis.yml"
107
107
  - Gemfile
108
- - Gemfile.lock
109
108
  - Guardfile
110
109
  - README.md
111
110
  - Rakefile
@@ -135,7 +134,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
135
134
  version: '0'
136
135
  requirements: []
137
136
  rubyforge_project:
138
- rubygems_version: 2.4.8
137
+ rubygems_version: 2.5.1
139
138
  signing_key:
140
139
  specification_version: 4
141
140
  summary: Formatter for ruby-duration
data/Gemfile.lock DELETED
@@ -1,84 +0,0 @@
1
- PATH
2
- remote: .
3
- specs:
4
- duration-formatter (1.1.1)
5
- ruby-duration (~> 3.2)
6
-
7
- GEM
8
- remote: https://rubygems.org/
9
- specs:
10
- activesupport (4.2.3)
11
- i18n (~> 0.7)
12
- json (~> 1.7, >= 1.7.7)
13
- minitest (~> 5.1)
14
- thread_safe (~> 0.3, >= 0.3.4)
15
- tzinfo (~> 1.1)
16
- codeclimate-test-reporter (0.4.7)
17
- simplecov (>= 0.7.1, < 1.0.0)
18
- coderay (1.1.0)
19
- docile (1.1.5)
20
- ffi (1.9.10)
21
- formatador (0.2.5)
22
- guard (2.12.7)
23
- formatador (>= 0.2.4)
24
- listen (>= 2.7, <= 4.0)
25
- lumberjack (~> 1.0)
26
- nenv (~> 0.1)
27
- notiffany (~> 0.0)
28
- pry (>= 0.9.12)
29
- shellany (~> 0.0)
30
- thor (>= 0.18.1)
31
- guard-compat (1.2.1)
32
- guard-minitest (2.4.4)
33
- guard-compat (~> 1.2)
34
- minitest (>= 3.0)
35
- i18n (0.7.0)
36
- iso8601 (0.8.6)
37
- json (1.8.3)
38
- listen (3.0.1)
39
- rb-fsevent (>= 0.9.3)
40
- rb-inotify (>= 0.9)
41
- lumberjack (1.0.9)
42
- method_source (0.8.2)
43
- minitest (5.7.0)
44
- nenv (0.2.0)
45
- notiffany (0.0.6)
46
- nenv (~> 0.1)
47
- shellany (~> 0.0)
48
- pry (0.10.1)
49
- coderay (~> 1.1.0)
50
- method_source (~> 0.8.1)
51
- slop (~> 3.4)
52
- rake (10.4.2)
53
- rb-fsevent (0.9.5)
54
- rb-inotify (0.9.5)
55
- ffi (>= 0.5.0)
56
- ruby-duration (3.2.1)
57
- activesupport (>= 3.0.0)
58
- i18n
59
- iso8601
60
- shellany (0.0.1)
61
- simplecov (0.10.0)
62
- docile (~> 1.1.0)
63
- json (~> 1.8)
64
- simplecov-html (~> 0.10.0)
65
- simplecov-html (0.10.0)
66
- slop (3.6.0)
67
- thor (0.19.1)
68
- thread_safe (0.3.5)
69
- tzinfo (1.2.2)
70
- thread_safe (~> 0.1)
71
-
72
- PLATFORMS
73
- ruby
74
-
75
- DEPENDENCIES
76
- codeclimate-test-reporter (~> 0.4)
77
- duration-formatter!
78
- guard (~> 2.12)
79
- guard-minitest (~> 2.4)
80
- rake (~> 10.4)
81
- simplecov (~> 0.9)
82
-
83
- BUNDLED WITH
84
- 1.10.5