tins 1.4.2 → 1.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/VERSION +1 -1
- data/lib/tins/string_version.rb +40 -45
- data/lib/tins/version.rb +1 -1
- data/tests/string_version_test.rb +11 -0
- data/tins.gemspec +3 -3
- metadata +12 -12
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 922f4bd8f753505287a7f7180a4c680e635e5272
|
4
|
+
data.tar.gz: fd47770711502cf30a048adffe9755ba3cdde5b9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 997a5a11dd2cfe3cf1dba2bf4289e2bcf05e41a8ec25457d565adbae825e37951ce40a261c853666a5651aaed9ef54805a3c9407b4535590f51c786e6e7b33d7
|
7
|
+
data.tar.gz: b3ee39e829eee26476169af8d0bde24230566d2094e3a4071297131cc62cc7fba58738c144d31433d4baeeb3c5f7296e5520df75d715195cd1a8773f2676e91e
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.
|
1
|
+
1.5.0
|
data/lib/tins/string_version.rb
CHANGED
@@ -1,70 +1,73 @@
|
|
1
1
|
module Tins
|
2
2
|
module StringVersion
|
3
|
+
LEVELS = %i[ major minor build revision ].each_with_index.to_h.freeze
|
4
|
+
|
5
|
+
SYMBOLS = LEVELS.invert.freeze
|
6
|
+
|
3
7
|
class Version
|
4
8
|
include Comparable
|
5
9
|
|
6
10
|
def initialize(string)
|
7
|
-
string =~ /\A
|
11
|
+
string =~ /\A\d+(\.\d+)*\z/ or
|
12
|
+
raise ArgumentError, "#{string.inspect} isn't a version number"
|
8
13
|
@version = string.frozen? ? string.dup : string
|
9
14
|
end
|
10
15
|
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
def major=(number)
|
16
|
-
self[0] = number
|
17
|
-
end
|
18
|
-
|
19
|
-
def minor
|
20
|
-
self[1]
|
21
|
-
end
|
22
|
-
|
23
|
-
def minor=(number)
|
24
|
-
self[1] = number
|
25
|
-
end
|
26
|
-
|
27
|
-
def build
|
28
|
-
self[2]
|
29
|
-
end
|
16
|
+
LEVELS.each do |symbol, level|
|
17
|
+
define_method(symbol) do
|
18
|
+
self[level]
|
19
|
+
end
|
30
20
|
|
31
|
-
|
32
|
-
|
21
|
+
define_method("#{symbol}=") do |new_level|
|
22
|
+
self[level] = new_level
|
23
|
+
end
|
33
24
|
end
|
34
25
|
|
35
|
-
def
|
36
|
-
|
26
|
+
def bump(level = array.size - 1)
|
27
|
+
level = level_of(level)
|
28
|
+
self[level] += 1
|
29
|
+
for l in level.succ..3
|
30
|
+
self[l] &&= 0
|
31
|
+
end
|
32
|
+
self
|
37
33
|
end
|
38
34
|
|
39
|
-
def
|
40
|
-
|
35
|
+
def level_of(specifier)
|
36
|
+
if specifier.respond_to?(:to_sym)
|
37
|
+
LEVELS.fetch(specifier)
|
38
|
+
else
|
39
|
+
specifier
|
40
|
+
end
|
41
41
|
end
|
42
42
|
|
43
|
-
def [](
|
44
|
-
array[
|
43
|
+
def [](level)
|
44
|
+
array[level_of(level)]
|
45
45
|
end
|
46
46
|
|
47
|
-
def []=(
|
47
|
+
def []=(level, value)
|
48
|
+
level = level_of(level)
|
48
49
|
value = value.to_i
|
49
|
-
value >= 0 or raise ArgumentError,
|
50
|
+
value >= 0 or raise ArgumentError,
|
51
|
+
"version numbers can't contain negative numbers like #{value}"
|
50
52
|
a = array
|
51
|
-
|
52
|
-
a
|
53
|
-
|
54
|
-
@version.replace a * '.'
|
53
|
+
a[level] = value
|
54
|
+
a.map!(&:to_i)
|
55
|
+
@version.replace a * ?.
|
55
56
|
end
|
56
57
|
|
57
58
|
def succ!
|
58
59
|
self[-1] += 1
|
60
|
+
self
|
59
61
|
end
|
60
62
|
|
61
63
|
def pred!
|
62
64
|
self[-1] -= 1
|
65
|
+
self
|
63
66
|
end
|
64
67
|
|
65
68
|
def <=>(other)
|
66
69
|
pairs = array.zip(other.array)
|
67
|
-
pairs.map! { |a, b| [ a.
|
70
|
+
pairs.map! { |a, b| [ a.to_i, b.to_i ] }
|
68
71
|
a, b = pairs.transpose
|
69
72
|
a <=> b
|
70
73
|
end
|
@@ -74,7 +77,7 @@ module Tins
|
|
74
77
|
end
|
75
78
|
|
76
79
|
def array
|
77
|
-
@version.split(
|
80
|
+
@version.split(?.).map(&:to_i)
|
78
81
|
end
|
79
82
|
|
80
83
|
alias to_a array
|
@@ -84,18 +87,10 @@ module Tins
|
|
84
87
|
end
|
85
88
|
|
86
89
|
alias inspect to_s
|
87
|
-
|
88
|
-
def version
|
89
|
-
self
|
90
|
-
end
|
91
90
|
end
|
92
91
|
|
93
92
|
def version
|
94
|
-
|
95
|
-
Version.new(self)
|
96
|
-
else
|
97
|
-
@version ||= Version.new(self)
|
98
|
-
end
|
93
|
+
Version.new(self)
|
99
94
|
end
|
100
95
|
end
|
101
96
|
end
|
data/lib/tins/version.rb
CHANGED
@@ -27,5 +27,16 @@ module Tins
|
|
27
27
|
s.version.minor = 1
|
28
28
|
assert_equal '2.1.0.2', s
|
29
29
|
end
|
30
|
+
|
31
|
+
def test_bump
|
32
|
+
s = '1.2.3'
|
33
|
+
assert_equal '2.0.0', s.version.bump(:major).to_s
|
34
|
+
s = '1.2.3'
|
35
|
+
assert_equal '1.3.0', s.version.bump(:minor).to_s
|
36
|
+
s = '1.2.3'
|
37
|
+
assert_equal '1.2.4', s.version.bump(:build).to_s
|
38
|
+
s = '1.2.3'
|
39
|
+
assert_equal '1.2.4', s.version.bump.to_s
|
40
|
+
end
|
30
41
|
end
|
31
42
|
end
|
data/tins.gemspec
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
# -*- encoding: utf-8 -*-
|
2
|
-
# stub: tins 1.
|
2
|
+
# stub: tins 1.5.0 ruby lib
|
3
3
|
|
4
4
|
Gem::Specification.new do |s|
|
5
5
|
s.name = "tins"
|
6
|
-
s.version = "1.
|
6
|
+
s.version = "1.5.0"
|
7
7
|
|
8
8
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
9
9
|
s.require_paths = ["lib"]
|
10
10
|
s.authors = ["Florian Frank"]
|
11
|
-
s.date = "2015-04-
|
11
|
+
s.date = "2015-04-24"
|
12
12
|
s.description = "All the stuff that isn't good/big enough for a real library."
|
13
13
|
s.email = "flori@ping.de"
|
14
14
|
s.extra_rdoc_files = ["README.md", "lib/dslkit.rb", "lib/dslkit/polite.rb", "lib/dslkit/rude.rb", "lib/spruz.rb", "lib/tins.rb", "lib/tins/alias.rb", "lib/tins/annotate.rb", "lib/tins/ask_and_send.rb", "lib/tins/attempt.rb", "lib/tins/bijection.rb", "lib/tins/case_predicate.rb", "lib/tins/concern.rb", "lib/tins/count_by.rb", "lib/tins/date_dummy.rb", "lib/tins/date_time_dummy.rb", "lib/tins/deep_const_get.rb", "lib/tins/deep_dup.rb", "lib/tins/dslkit.rb", "lib/tins/extract_last_argument_options.rb", "lib/tins/file_binary.rb", "lib/tins/find.rb", "lib/tins/generator.rb", "lib/tins/go.rb", "lib/tins/hash_symbolize_keys_recursive.rb", "lib/tins/hash_union.rb", "lib/tins/if_predicate.rb", "lib/tins/implement.rb", "lib/tins/limited.rb", "lib/tins/lines_file.rb", "lib/tins/memoize.rb", "lib/tins/method_description.rb", "lib/tins/minimize.rb", "lib/tins/module_group.rb", "lib/tins/named_set.rb", "lib/tins/null.rb", "lib/tins/once.rb", "lib/tins/p.rb", "lib/tins/partial_application.rb", "lib/tins/proc_compose.rb", "lib/tins/proc_prelude.rb", "lib/tins/range_plus.rb", "lib/tins/require_maybe.rb", "lib/tins/responding.rb", "lib/tins/rotate.rb", "lib/tins/secure_write.rb", "lib/tins/sexy_singleton.rb", "lib/tins/shuffle.rb", "lib/tins/string_byte_order_mark.rb", "lib/tins/string_camelize.rb", "lib/tins/string_underscore.rb", "lib/tins/string_version.rb", "lib/tins/subhash.rb", "lib/tins/terminal.rb", "lib/tins/thread_local.rb", "lib/tins/time_dummy.rb", "lib/tins/to.rb", "lib/tins/to_proc.rb", "lib/tins/token.rb", "lib/tins/uniq_by.rb", "lib/tins/version.rb", "lib/tins/write.rb", "lib/tins/xt.rb", "lib/tins/xt/annotate.rb", "lib/tins/xt/ask_and_send.rb", "lib/tins/xt/attempt.rb", "lib/tins/xt/blank.rb", "lib/tins/xt/case_predicate.rb", "lib/tins/xt/concern.rb", "lib/tins/xt/count_by.rb", "lib/tins/xt/date_dummy.rb", "lib/tins/xt/date_time_dummy.rb", "lib/tins/xt/deep_const_get.rb", "lib/tins/xt/deep_dup.rb", "lib/tins/xt/dslkit.rb", "lib/tins/xt/extract_last_argument_options.rb", "lib/tins/xt/file_binary.rb", "lib/tins/xt/full.rb", "lib/tins/xt/hash_symbolize_keys_recursive.rb", "lib/tins/xt/hash_union.rb", "lib/tins/xt/if_predicate.rb", "lib/tins/xt/implement.rb", "lib/tins/xt/irb.rb", "lib/tins/xt/method_description.rb", "lib/tins/xt/named.rb", "lib/tins/xt/null.rb", "lib/tins/xt/p.rb", "lib/tins/xt/partial_application.rb", "lib/tins/xt/proc_compose.rb", "lib/tins/xt/proc_prelude.rb", "lib/tins/xt/range_plus.rb", "lib/tins/xt/require_maybe.rb", "lib/tins/xt/responding.rb", "lib/tins/xt/rotate.rb", "lib/tins/xt/secure_write.rb", "lib/tins/xt/sexy_singleton.rb", "lib/tins/xt/shuffle.rb", "lib/tins/xt/string.rb", "lib/tins/xt/string_byte_order_mark.rb", "lib/tins/xt/string_camelize.rb", "lib/tins/xt/string_underscore.rb", "lib/tins/xt/string_version.rb", "lib/tins/xt/subhash.rb", "lib/tins/xt/symbol_to_proc.rb", "lib/tins/xt/time_dummy.rb", "lib/tins/xt/time_freezer.rb", "lib/tins/xt/to.rb", "lib/tins/xt/uniq_by.rb", "lib/tins/xt/write.rb"]
|
metadata
CHANGED
@@ -1,41 +1,41 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: tins
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.5.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Florian Frank
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-04-
|
11
|
+
date: 2015-04-24 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
19
|
version: 1.0.0
|
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
26
|
version: 1.0.0
|
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: '2.5'
|
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: '2.5'
|
41
41
|
description: All the stuff that isn't good/big enough for a real library.
|
@@ -153,8 +153,8 @@ extra_rdoc_files:
|
|
153
153
|
- lib/tins/xt/uniq_by.rb
|
154
154
|
- lib/tins/xt/write.rb
|
155
155
|
files:
|
156
|
-
- .gitignore
|
157
|
-
- .travis.yml
|
156
|
+
- ".gitignore"
|
157
|
+
- ".travis.yml"
|
158
158
|
- COPYING
|
159
159
|
- Gemfile
|
160
160
|
- README.md
|
@@ -358,20 +358,20 @@ licenses:
|
|
358
358
|
metadata: {}
|
359
359
|
post_install_message:
|
360
360
|
rdoc_options:
|
361
|
-
- --title
|
361
|
+
- "--title"
|
362
362
|
- Tins - Useful stuff.
|
363
|
-
- --main
|
363
|
+
- "--main"
|
364
364
|
- README.md
|
365
365
|
require_paths:
|
366
366
|
- lib
|
367
367
|
required_ruby_version: !ruby/object:Gem::Requirement
|
368
368
|
requirements:
|
369
|
-
- -
|
369
|
+
- - ">="
|
370
370
|
- !ruby/object:Gem::Version
|
371
371
|
version: '0'
|
372
372
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
373
373
|
requirements:
|
374
|
-
- -
|
374
|
+
- - ">="
|
375
375
|
- !ruby/object:Gem::Version
|
376
376
|
version: '0'
|
377
377
|
requirements: []
|