tins 1.13.0 → 1.13.2

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: 8a9620431b6efcf35a63e4d4efa1af60bae0ddd0
4
- data.tar.gz: 9bfd320a7851d2a6e31e25adcb357b6ad8d3da06
3
+ metadata.gz: 99efac73ec5ece0d983985586964602629bde647
4
+ data.tar.gz: 1d2f05d18a9181c07da367fc4cb30dec6ab9ca56
5
5
  SHA512:
6
- metadata.gz: 4a70669d7118f915c3b63e38715d8ed8b0359bed1574c567a1c3636b65032c8746417b8e952381bbe9a39fe70262f7fdf545fc38ee17fd78016389c118cc6fd7
7
- data.tar.gz: 9ce24f3accd87c98adabca6b14d845ffaffc8a57e790efebc7e4607df81e0a08844fba84988e567a2371fce6c55dcdef97da161a783bacb368b8de34031e63f6
6
+ metadata.gz: 711eaed745f7bfc3a7d4f4d5cc38c4c0af503dd291b8b3e8c9dab7a5e5d5db9cf0539dfb0a6e14c4cf87bea81913c6e2c3ac5aa4643d6d9a2d3b08705d67bc7c
7
+ data.tar.gz: 887888d7d3489d0fc2529f65958d73c2837fcd75a2a361180aeeeb70d676dc4a0a2df3e961e9fb6aa0b1ea8d228dbb2ba4a0252a5c254e55d2b728490f5b2adb
@@ -3,13 +3,9 @@ rvm:
3
3
  - 2.1
4
4
  - 2.2
5
5
  - 2.3.3
6
+ - 2.4.0
6
7
  - ruby-head
7
- - rbx-head
8
8
  matrix:
9
9
  allow_failures:
10
10
  - rvm: ruby-head
11
- - rvm: rbx-head
12
11
  sudo: false
13
- addons:
14
- code_climate:
15
- repo_token: 62d082406430ccf662c2e401976b613c0091e26fcfb546f92b1f2b391951cf50
data/Gemfile CHANGED
@@ -5,8 +5,6 @@ source 'https://rubygems.org'
5
5
  gemspec
6
6
 
7
7
  group :development, :test do
8
- gem 'simplecov'
9
- gem 'term-ansicolor'
10
- gem "codeclimate-test-reporter", require: nil
11
8
  gem 'byebug', platform: :mri
9
+ gem 'term-ansicolor'
12
10
  end
data/Rakefile CHANGED
@@ -19,4 +19,5 @@ GemHadar do
19
19
 
20
20
  required_ruby_version '>= 2.0'
21
21
  development_dependency 'test-unit', '~>3.1'
22
+ development_dependency 'simplecov'
22
23
  end
data/TODO CHANGED
@@ -0,0 +1,3 @@
1
+ # TODO
2
+
3
+ - Add Tins::Duration.parse(string) method.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.13.0
1
+ 1.13.2
@@ -1,6 +1,9 @@
1
1
  module Tins
2
2
  class Duration
3
+ include Comparable
4
+
3
5
  def initialize(seconds)
6
+ @original_seconds = seconds
4
7
  @days, @hours, @minutes, @seconds, @fractional_seconds =
5
8
  [ 86_400, 3600, 60, 1, 0 ].inject([ [], seconds ]) {|(r, s), d|
6
9
  if d > 0
@@ -13,6 +16,14 @@ module Tins
13
16
  }
14
17
  end
15
18
 
19
+ def to_f
20
+ @original_seconds.to_f
21
+ end
22
+
23
+ def <=>(other)
24
+ to_f <=> other.to_f
25
+ end
26
+
16
27
  def days?
17
28
  @days > 0
18
29
  end
@@ -37,11 +37,16 @@ module Tins::Unit
37
37
  prefixes = prefixes(prefix)
38
38
  first_prefix = prefixes.first or
39
39
  raise ArgumentError, 'a non-empty array of prefixes is required'
40
- prefix = prefixes[
41
- (first_prefix.fraction ? -1 : 1) * Math.log(value) / Math.log(first_prefix.step)
42
- ]
43
- result = format.sub('%U', "#{prefix.name}#{unit}")
44
- result %= (value / prefix.multiplier.to_f)
40
+ if value.zero?
41
+ result = format.sub('%U', unit)
42
+ result %= value
43
+ else
44
+ prefix = prefixes[
45
+ (first_prefix.fraction ? -1 : 1) * Math.log(value) / Math.log(first_prefix.step)
46
+ ]
47
+ result = format.sub('%U', "#{prefix.name}#{unit}")
48
+ result %= (value / prefix.multiplier.to_f)
49
+ end
45
50
  end
46
51
 
47
52
  class UnitParser < StringScanner
@@ -1,6 +1,6 @@
1
1
  module Tins
2
2
  # Tins version
3
- VERSION = '1.13.0'
3
+ VERSION = '1.13.2'
4
4
  VERSION_ARRAY = VERSION.split('.').map(&:to_i) # :nodoc:
5
5
  VERSION_MAJOR = VERSION_ARRAY[0] # :nodoc:
6
6
  VERSION_MINOR = VERSION_ARRAY[1] # :nodoc:
@@ -57,6 +57,12 @@ module Tins
57
57
  s += 0.1
58
58
  assert_true Tins::Duration.new(s).fractional_seconds?
59
59
  end
60
+
61
+ def test_comparison
62
+ t1 = Tins::Duration.new(666.23456)
63
+ t2 = Tins::Duration.new(666.12345)
64
+ assert_operator t1, :>, t2
65
+ end
60
66
  end
61
67
  end
62
68
 
@@ -4,13 +4,15 @@ require 'tins/xt/expose'
4
4
  module Tins
5
5
  class ExposeTest < Test::Unit::TestCase
6
6
  class A
7
- private def priv
7
+ def priv
8
8
  :priv
9
9
  end
10
+ private :priv
10
11
 
11
- protected def prot(x)
12
+ def prot(x)
12
13
  :prot
13
14
  end
15
+ protected :prot
14
16
  end
15
17
 
16
18
  def setup
@@ -4,10 +4,6 @@ if ENV['START_SIMPLECOV'].to_i == 1
4
4
  add_filter "#{File.basename(File.dirname(__FILE__))}/"
5
5
  end
6
6
  end
7
- if ENV['CODECLIMATE_REPO_TOKEN']
8
- require "codeclimate-test-reporter"
9
- CodeClimate::TestReporter.start
10
- end
11
7
  begin
12
8
  require 'byebug'
13
9
  rescue LoadError
@@ -19,6 +19,10 @@ module Tins
19
19
  assert_equal nil, prefixes(:nix)
20
20
  end
21
21
 
22
+ def test_0_format
23
+ assert_equal '0 b', format(0, format: '%d %U')
24
+ end
25
+
22
26
  def test_format_multipliers
23
27
  assert_equal '23 Kb',
24
28
  format(23 * 1024, format: '%d %U')
@@ -1,14 +1,14 @@
1
1
  # -*- encoding: utf-8 -*-
2
- # stub: tins 1.13.0 ruby lib
2
+ # stub: tins 1.13.2 ruby lib
3
3
 
4
4
  Gem::Specification.new do |s|
5
5
  s.name = "tins".freeze
6
- s.version = "1.13.0"
6
+ s.version = "1.13.2"
7
7
 
8
8
  s.required_rubygems_version = Gem::Requirement.new(">= 0".freeze) if s.respond_to? :required_rubygems_version=
9
9
  s.require_paths = ["lib".freeze]
10
10
  s.authors = ["Florian Frank".freeze]
11
- s.date = "2016-11-23"
11
+ s.date = "2017-02-03"
12
12
  s.description = "All the stuff that isn't good/big enough for a real library.".freeze
13
13
  s.email = "flori@ping.de".freeze
14
14
  s.extra_rdoc_files = ["README.md".freeze, "lib/dslkit.rb".freeze, "lib/dslkit/polite.rb".freeze, "lib/dslkit/rude.rb".freeze, "lib/spruz.rb".freeze, "lib/tins.rb".freeze, "lib/tins/alias.rb".freeze, "lib/tins/annotate.rb".freeze, "lib/tins/ask_and_send.rb".freeze, "lib/tins/attempt.rb".freeze, "lib/tins/bijection.rb".freeze, "lib/tins/case_predicate.rb".freeze, "lib/tins/complete.rb".freeze, "lib/tins/concern.rb".freeze, "lib/tins/count_by.rb".freeze, "lib/tins/date_dummy.rb".freeze, "lib/tins/date_time_dummy.rb".freeze, "lib/tins/deep_const_get.rb".freeze, "lib/tins/deep_dup.rb".freeze, "lib/tins/dslkit.rb".freeze, "lib/tins/duration.rb".freeze, "lib/tins/expose.rb".freeze, "lib/tins/extract_last_argument_options.rb".freeze, "lib/tins/file_binary.rb".freeze, "lib/tins/find.rb".freeze, "lib/tins/generator.rb".freeze, "lib/tins/go.rb".freeze, "lib/tins/hash_symbolize_keys_recursive.rb".freeze, "lib/tins/hash_union.rb".freeze, "lib/tins/if_predicate.rb".freeze, "lib/tins/implement.rb".freeze, "lib/tins/limited.rb".freeze, "lib/tins/lines_file.rb".freeze, "lib/tins/memoize.rb".freeze, "lib/tins/method_description.rb".freeze, "lib/tins/minimize.rb".freeze, "lib/tins/module_group.rb".freeze, "lib/tins/named_set.rb".freeze, "lib/tins/null.rb".freeze, "lib/tins/once.rb".freeze, "lib/tins/p.rb".freeze, "lib/tins/partial_application.rb".freeze, "lib/tins/proc_compose.rb".freeze, "lib/tins/proc_prelude.rb".freeze, "lib/tins/range_plus.rb".freeze, "lib/tins/require_maybe.rb".freeze, "lib/tins/responding.rb".freeze, "lib/tins/secure_write.rb".freeze, "lib/tins/sexy_singleton.rb".freeze, "lib/tins/string_byte_order_mark.rb".freeze, "lib/tins/string_camelize.rb".freeze, "lib/tins/string_underscore.rb".freeze, "lib/tins/string_version.rb".freeze, "lib/tins/subhash.rb".freeze, "lib/tins/terminal.rb".freeze, "lib/tins/thread_local.rb".freeze, "lib/tins/time_dummy.rb".freeze, "lib/tins/to.rb".freeze, "lib/tins/to_proc.rb".freeze, "lib/tins/token.rb".freeze, "lib/tins/uniq_by.rb".freeze, "lib/tins/unit.rb".freeze, "lib/tins/version.rb".freeze, "lib/tins/write.rb".freeze, "lib/tins/xt.rb".freeze, "lib/tins/xt/annotate.rb".freeze, "lib/tins/xt/ask_and_send.rb".freeze, "lib/tins/xt/attempt.rb".freeze, "lib/tins/xt/blank.rb".freeze, "lib/tins/xt/case_predicate.rb".freeze, "lib/tins/xt/complete.rb".freeze, "lib/tins/xt/concern.rb".freeze, "lib/tins/xt/count_by.rb".freeze, "lib/tins/xt/date_dummy.rb".freeze, "lib/tins/xt/date_time_dummy.rb".freeze, "lib/tins/xt/deep_const_get.rb".freeze, "lib/tins/xt/deep_dup.rb".freeze, "lib/tins/xt/dslkit.rb".freeze, "lib/tins/xt/expose.rb".freeze, "lib/tins/xt/extract_last_argument_options.rb".freeze, "lib/tins/xt/file_binary.rb".freeze, "lib/tins/xt/full.rb".freeze, "lib/tins/xt/hash_symbolize_keys_recursive.rb".freeze, "lib/tins/xt/hash_union.rb".freeze, "lib/tins/xt/if_predicate.rb".freeze, "lib/tins/xt/implement.rb".freeze, "lib/tins/xt/irb.rb".freeze, "lib/tins/xt/method_description.rb".freeze, "lib/tins/xt/named.rb".freeze, "lib/tins/xt/null.rb".freeze, "lib/tins/xt/p.rb".freeze, "lib/tins/xt/partial_application.rb".freeze, "lib/tins/xt/proc_compose.rb".freeze, "lib/tins/xt/proc_prelude.rb".freeze, "lib/tins/xt/range_plus.rb".freeze, "lib/tins/xt/require_maybe.rb".freeze, "lib/tins/xt/responding.rb".freeze, "lib/tins/xt/secure_write.rb".freeze, "lib/tins/xt/sexy_singleton.rb".freeze, "lib/tins/xt/string.rb".freeze, "lib/tins/xt/string_byte_order_mark.rb".freeze, "lib/tins/xt/string_camelize.rb".freeze, "lib/tins/xt/string_underscore.rb".freeze, "lib/tins/xt/string_version.rb".freeze, "lib/tins/xt/subhash.rb".freeze, "lib/tins/xt/time_dummy.rb".freeze, "lib/tins/xt/time_freezer.rb".freeze, "lib/tins/xt/to.rb".freeze, "lib/tins/xt/uniq_by.rb".freeze, "lib/tins/xt/write.rb".freeze]
@@ -17,7 +17,7 @@ Gem::Specification.new do |s|
17
17
  s.licenses = ["MIT".freeze]
18
18
  s.rdoc_options = ["--title".freeze, "Tins - Useful stuff.".freeze, "--main".freeze, "README.md".freeze]
19
19
  s.required_ruby_version = Gem::Requirement.new(">= 2.0".freeze)
20
- s.rubygems_version = "2.6.8".freeze
20
+ s.rubygems_version = "2.6.7".freeze
21
21
  s.summary = "Useful stuff.".freeze
22
22
  s.test_files = ["tests/annotate_test.rb".freeze, "tests/ask_and_send_test.rb".freeze, "tests/attempt_test.rb".freeze, "tests/bijection_test.rb".freeze, "tests/blank_full_test.rb".freeze, "tests/case_predicate_test.rb".freeze, "tests/concern_test.rb".freeze, "tests/count_by_test.rb".freeze, "tests/date_dummy_test.rb".freeze, "tests/date_time_dummy_test.rb".freeze, "tests/deep_const_get_test.rb".freeze, "tests/deep_dup_test.rb".freeze, "tests/delegate_test.rb".freeze, "tests/dslkit_test.rb".freeze, "tests/duaration_test.rb".freeze, "tests/dynamic_scope_test.rb".freeze, "tests/expose_test.rb".freeze, "tests/extract_last_argument_options_test.rb".freeze, "tests/file_binary_test.rb".freeze, "tests/find_test.rb".freeze, "tests/from_module_test.rb".freeze, "tests/generator_test.rb".freeze, "tests/go_test.rb".freeze, "tests/hash_symbolize_keys_recursive_test.rb".freeze, "tests/hash_union_test.rb".freeze, "tests/if_predicate_test.rb".freeze, "tests/implement_test.rb".freeze, "tests/limited_test.rb".freeze, "tests/lines_file_test.rb".freeze, "tests/memoize_test.rb".freeze, "tests/method_description_test.rb".freeze, "tests/minimize_test.rb".freeze, "tests/module_group_test.rb".freeze, "tests/named_set_test.rb".freeze, "tests/named_test.rb".freeze, "tests/null_test.rb".freeze, "tests/p_test.rb".freeze, "tests/partial_application_test.rb".freeze, "tests/proc_compose_test.rb".freeze, "tests/proc_prelude_test.rb".freeze, "tests/range_plus_test.rb".freeze, "tests/require_maybe_test.rb".freeze, "tests/responding_test.rb".freeze, "tests/rotate_test.rb".freeze, "tests/scope_test.rb".freeze, "tests/secure_write_test.rb".freeze, "tests/sexy_singleton_test.rb".freeze, "tests/string_byte_order_mark_test.rb".freeze, "tests/string_camelize_test.rb".freeze, "tests/string_underscore_test.rb".freeze, "tests/string_version_test.rb".freeze, "tests/subhash_test.rb".freeze, "tests/test_helper.rb".freeze, "tests/time_dummy_test.rb".freeze, "tests/time_freezer_test.rb".freeze, "tests/to_test.rb".freeze, "tests/token_test.rb".freeze, "tests/uniq_by_test.rb".freeze, "tests/unit_test.rb".freeze, "tests/annotate_test.rb".freeze, "tests/ask_and_send_test.rb".freeze, "tests/attempt_test.rb".freeze, "tests/bijection_test.rb".freeze, "tests/blank_full_test.rb".freeze, "tests/case_predicate_test.rb".freeze, "tests/concern_test.rb".freeze, "tests/count_by_test.rb".freeze, "tests/date_dummy_test.rb".freeze, "tests/date_time_dummy_test.rb".freeze, "tests/deep_const_get_test.rb".freeze, "tests/deep_dup_test.rb".freeze, "tests/delegate_test.rb".freeze, "tests/dslkit_test.rb".freeze, "tests/duaration_test.rb".freeze, "tests/dynamic_scope_test.rb".freeze, "tests/expose_test.rb".freeze, "tests/extract_last_argument_options_test.rb".freeze, "tests/file_binary_test.rb".freeze, "tests/find_test.rb".freeze, "tests/from_module_test.rb".freeze, "tests/generator_test.rb".freeze, "tests/go_test.rb".freeze, "tests/hash_symbolize_keys_recursive_test.rb".freeze, "tests/hash_union_test.rb".freeze, "tests/if_predicate_test.rb".freeze, "tests/implement_test.rb".freeze, "tests/limited_test.rb".freeze, "tests/lines_file_test.rb".freeze, "tests/memoize_test.rb".freeze, "tests/method_description_test.rb".freeze, "tests/minimize_test.rb".freeze, "tests/module_group_test.rb".freeze, "tests/named_set_test.rb".freeze, "tests/named_test.rb".freeze, "tests/null_test.rb".freeze, "tests/p_test.rb".freeze, "tests/partial_application_test.rb".freeze, "tests/proc_compose_test.rb".freeze, "tests/proc_prelude_test.rb".freeze, "tests/range_plus_test.rb".freeze, "tests/require_maybe_test.rb".freeze, "tests/responding_test.rb".freeze, "tests/rotate_test.rb".freeze, "tests/scope_test.rb".freeze, "tests/secure_write_test.rb".freeze, "tests/sexy_singleton_test.rb".freeze, "tests/string_byte_order_mark_test.rb".freeze, "tests/string_camelize_test.rb".freeze, "tests/string_underscore_test.rb".freeze, "tests/string_version_test.rb".freeze, "tests/subhash_test.rb".freeze, "tests/time_dummy_test.rb".freeze, "tests/time_freezer_test.rb".freeze, "tests/to_test.rb".freeze, "tests/token_test.rb".freeze, "tests/uniq_by_test.rb".freeze, "tests/unit_test.rb".freeze]
23
23
 
@@ -25,14 +25,17 @@ Gem::Specification.new do |s|
25
25
  s.specification_version = 4
26
26
 
27
27
  if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
28
- s.add_development_dependency(%q<gem_hadar>.freeze, ["~> 1.7.1"])
28
+ s.add_development_dependency(%q<gem_hadar>.freeze, ["~> 1.9.1"])
29
29
  s.add_development_dependency(%q<test-unit>.freeze, ["~> 3.1"])
30
+ s.add_development_dependency(%q<simplecov>.freeze, [">= 0"])
30
31
  else
31
- s.add_dependency(%q<gem_hadar>.freeze, ["~> 1.7.1"])
32
+ s.add_dependency(%q<gem_hadar>.freeze, ["~> 1.9.1"])
32
33
  s.add_dependency(%q<test-unit>.freeze, ["~> 3.1"])
34
+ s.add_dependency(%q<simplecov>.freeze, [">= 0"])
33
35
  end
34
36
  else
35
- s.add_dependency(%q<gem_hadar>.freeze, ["~> 1.7.1"])
37
+ s.add_dependency(%q<gem_hadar>.freeze, ["~> 1.9.1"])
36
38
  s.add_dependency(%q<test-unit>.freeze, ["~> 3.1"])
39
+ s.add_dependency(%q<simplecov>.freeze, [">= 0"])
37
40
  end
38
41
  end
metadata CHANGED
@@ -1,43 +1,57 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tins
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.13.0
4
+ version: 1.13.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Florian Frank
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-11-23 00:00:00.000000000 Z
11
+ date: 2017-02-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: gem_hadar
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - "~>"
17
+ - - ~>
18
18
  - !ruby/object:Gem::Version
19
- version: 1.7.1
19
+ version: 1.9.1
20
20
  type: :development
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - "~>"
24
+ - - ~>
25
25
  - !ruby/object:Gem::Version
26
- version: 1.7.1
26
+ version: 1.9.1
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: test-unit
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - "~>"
31
+ - - ~>
32
32
  - !ruby/object:Gem::Version
33
33
  version: '3.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
40
  version: '3.1'
41
+ - !ruby/object:Gem::Dependency
42
+ name: simplecov
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - '>='
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - '>='
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
41
55
  description: All the stuff that isn't good/big enough for a real library.
42
56
  email: flori@ping.de
43
57
  executables: []
@@ -154,8 +168,8 @@ extra_rdoc_files:
154
168
  - lib/tins/xt/uniq_by.rb
155
169
  - lib/tins/xt/write.rb
156
170
  files:
157
- - ".gitignore"
158
- - ".travis.yml"
171
+ - .gitignore
172
+ - .travis.yml
159
173
  - COPYING
160
174
  - Gemfile
161
175
  - README.md
@@ -362,25 +376,25 @@ licenses:
362
376
  metadata: {}
363
377
  post_install_message:
364
378
  rdoc_options:
365
- - "--title"
379
+ - --title
366
380
  - Tins - Useful stuff.
367
- - "--main"
381
+ - --main
368
382
  - README.md
369
383
  require_paths:
370
384
  - lib
371
385
  required_ruby_version: !ruby/object:Gem::Requirement
372
386
  requirements:
373
- - - ">="
387
+ - - '>='
374
388
  - !ruby/object:Gem::Version
375
389
  version: '2.0'
376
390
  required_rubygems_version: !ruby/object:Gem::Requirement
377
391
  requirements:
378
- - - ">="
392
+ - - '>='
379
393
  - !ruby/object:Gem::Version
380
394
  version: '0'
381
395
  requirements: []
382
396
  rubyforge_project:
383
- rubygems_version: 2.6.8
397
+ rubygems_version: 2.6.7
384
398
  signing_key:
385
399
  specification_version: 4
386
400
  summary: Useful stuff.