timewizard 0.3.0.pre.alpha.pre.56 → 0.3.0.pre.alpha.pre.57
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +8 -8
- data/lib/timewizard/utils/wizardry.rb +1 -1
- data/lib/timewizard/versioner/android.rb +8 -16
- data/lib/timewizard/versioner/apple.rb +5 -15
- data/lib/timewizard/versioner.rb +15 -2
- data/spec/utils/wizardry_spec.rb +9 -0
- data/spec/versioner/android_spec.rb +161 -0
- metadata +2 -1
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
MDZlMzk4OTdkODc5OGI5YWYzOGZlYzk2NGE5MzZiYTAzMmI5Zjg2NQ==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
YjNlMDkxOWFjY2M0NjliYWUzMTdiMGE1YzY3MWQ5ZDNkYTZlMGI0OA==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
ZmMyMzY4MDc2NzcwODIyN2ZkMWZkZjhjNzY3ZWI5NzAxYmUxMzM0YWFmZDM0
|
10
|
+
ZWYwMWZiYWJhNDBlM2NjNmExMmI4ZDRhNjliMTA5MzNhMTBhNDJhNjkyNjYw
|
11
|
+
MzQ0ZTRiYTI5YzIzNmIyZTBiZDc1Y2Y0ZTU1YTVmMzUxZDQyZjI=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
MjZkNGExMzMzYzhmOTM0Y2ZlMWZlNmE5Mjk0NmE3OGZlYWVlYTExMWQ1ZDdk
|
14
|
+
NzFiYjUwZGY5MTVhMjQzMGEyMGM0MDkxZTFiZTk3YzY5YzEwMzI4YzM5MjMy
|
15
|
+
YTc3NmU2YzlkZTQxMTllZTVkMWFlOWNhYWFiNTFlN2Q2MWQ2YmY=
|
@@ -7,7 +7,7 @@ module Timewizard
|
|
7
7
|
# @since 0.2.4
|
8
8
|
module Wizardry
|
9
9
|
|
10
|
-
VERSION_REGEX = /((\d+\.)?(\d+\.)?(\*|\d+))(?:-([0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*))?(?:\+([0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*))
|
10
|
+
VERSION_REGEX = /((\d+\.)?(\d+\.)?(\*|\d+))(?:-([0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*))?(?:\+([0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*))?/
|
11
11
|
|
12
12
|
# Returns a substring of the passed-in value that matches {Timewizard::Utils::Wizardry::VERSION_REGEX the version regex}.
|
13
13
|
# @param [String] stringy string from which to extract version string
|
@@ -12,6 +12,8 @@ module Timewizard
|
|
12
12
|
#
|
13
13
|
private
|
14
14
|
|
15
|
+
SPACE_REGEX = /\s+/
|
16
|
+
|
15
17
|
def read_file
|
16
18
|
if @file.nil?
|
17
19
|
raise 'file is nil and cannot be read'
|
@@ -36,16 +38,6 @@ module Timewizard
|
|
36
38
|
File.open(@file, 'w') { |file| file.write(@file_contents) }
|
37
39
|
end
|
38
40
|
|
39
|
-
def find_build_numbers
|
40
|
-
find_build_and_version_numbers
|
41
|
-
[@old_build_number, @new_build_number]
|
42
|
-
end
|
43
|
-
|
44
|
-
def find_version_numbers
|
45
|
-
find_build_and_version_numbers
|
46
|
-
[@old_version_number, @new_version_number]
|
47
|
-
end
|
48
|
-
|
49
41
|
def find_build_and_version_numbers
|
50
42
|
if @file_contents.nil?
|
51
43
|
read_file
|
@@ -53,7 +45,7 @@ module Timewizard
|
|
53
45
|
matched = @file_contents.match "android:versionCode=\"(.*)\""
|
54
46
|
|
55
47
|
first_match = matched[0]
|
56
|
-
split_match = first_match.partition
|
48
|
+
split_match = first_match.partition(SPACE_REGEX)
|
57
49
|
|
58
50
|
build_num = Timewizard::Utils::Wizardry.only_version split_match[0]
|
59
51
|
version_num = Timewizard::Utils::Wizardry.only_version split_match[2]
|
@@ -61,12 +53,12 @@ module Timewizard
|
|
61
53
|
parsed_build_num = Versionomy.parse(build_num, Versionomy::Format.get('rubygems'))
|
62
54
|
parsed_version_num = Versionomy.parse(version_num, Versionomy::Format.get('rubygems'))
|
63
55
|
|
64
|
-
|
65
|
-
|
56
|
+
obn = parsed_build_num.unparse
|
57
|
+
ovn = parsed_version_num.unparse
|
58
|
+
nbn = parsed_build_num.bump(parsed_build_num.parts.length - 1).unparse
|
59
|
+
nvn = ovn
|
66
60
|
|
67
|
-
|
68
|
-
@new_version_number = @old_version_number
|
69
|
-
self
|
61
|
+
[obn, ovn, nbn, nvn]
|
70
62
|
end
|
71
63
|
|
72
64
|
def change_build_numbers
|
@@ -37,16 +37,6 @@ module Timewizard
|
|
37
37
|
Xcodeproj::PlistHelper.write(@file_contents, @file)
|
38
38
|
end
|
39
39
|
|
40
|
-
def find_build_numbers
|
41
|
-
find_build_and_version_numbers
|
42
|
-
[@old_build_number, @new_build_number]
|
43
|
-
end
|
44
|
-
|
45
|
-
def find_version_numbers
|
46
|
-
find_build_and_version_numbers
|
47
|
-
[@old_version_number, @new_version_number]
|
48
|
-
end
|
49
|
-
|
50
40
|
def find_build_and_version_numbers
|
51
41
|
if @file_contents.nil?
|
52
42
|
read_file
|
@@ -58,12 +48,12 @@ module Timewizard
|
|
58
48
|
parsed_build_num = Versionomy.parse(build_num, Versionomy::Format.get('rubygems'))
|
59
49
|
parsed_version_num = Versionomy.parse(version_num, Versionomy::Format.get('rubygems'))
|
60
50
|
|
61
|
-
|
62
|
-
|
51
|
+
obn = parsed_build_num.unparse
|
52
|
+
ovn = parsed_version_num.unparse
|
53
|
+
nbn = parsed_build_num.bump(parsed_build_num.parts.length - 1).unparse
|
54
|
+
nvn = ovn
|
63
55
|
|
64
|
-
|
65
|
-
@new_version_number = @old_version_number
|
66
|
-
self
|
56
|
+
[obn, ovn, nbn, nvn]
|
67
57
|
end
|
68
58
|
|
69
59
|
def change_build_numbers
|
data/lib/timewizard/versioner.rb
CHANGED
@@ -42,6 +42,10 @@ module Timewizard
|
|
42
42
|
raise "passed in file cannot be nil"
|
43
43
|
end
|
44
44
|
@file = path_to_file
|
45
|
+
@old_build_number = nil
|
46
|
+
@old_version_number = nil
|
47
|
+
@new_build_number = nil
|
48
|
+
@new_version_number = nil
|
45
49
|
end
|
46
50
|
|
47
51
|
# Reads the build numbers from {Timewizard::Versioner::Base.file}.
|
@@ -57,6 +61,7 @@ module Timewizard
|
|
57
61
|
def read_version_numbers
|
58
62
|
read_file
|
59
63
|
find_version_numbers
|
64
|
+
self
|
60
65
|
end
|
61
66
|
|
62
67
|
# Writes the build numbers to {Timewizard::Versioner::Base.file}.
|
@@ -64,6 +69,7 @@ module Timewizard
|
|
64
69
|
def write_build_numbers
|
65
70
|
change_build_numbers
|
66
71
|
write_file
|
72
|
+
self
|
67
73
|
end
|
68
74
|
|
69
75
|
# Writes the version numbers to {Timewizard::Versioner::Base.file}.
|
@@ -71,6 +77,7 @@ module Timewizard
|
|
71
77
|
def write_version_numbers
|
72
78
|
change_version_numbers
|
73
79
|
write_file
|
80
|
+
self
|
74
81
|
end
|
75
82
|
|
76
83
|
private
|
@@ -84,11 +91,17 @@ module Timewizard
|
|
84
91
|
end
|
85
92
|
|
86
93
|
def find_build_numbers
|
87
|
-
|
94
|
+
bn = find_build_and_version_numbers
|
95
|
+
@old_build_number = bn[0]
|
96
|
+
@new_build_number = bn[2]
|
97
|
+
[@old_build_number, @new_build_number]
|
88
98
|
end
|
89
99
|
|
90
100
|
def find_version_numbers
|
91
|
-
|
101
|
+
vn = find_build_and_version_numbers
|
102
|
+
@old_version_number = vn[1]
|
103
|
+
@new_version_number = vn[3]
|
104
|
+
[@old_version_number, @new_version_number]
|
92
105
|
end
|
93
106
|
|
94
107
|
def find_build_and_version_numbers
|
data/spec/utils/wizardry_spec.rb
CHANGED
@@ -23,5 +23,14 @@ RSpec.describe 'Timewizard::Utils::Wizardry' do
|
|
23
23
|
|
24
24
|
expect(actual).to eq(expected)
|
25
25
|
end
|
26
|
+
|
27
|
+
it 'should return a version number when version number is in the middle of the string' do
|
28
|
+
base = 'this, 0.0.1, is the version being test'
|
29
|
+
|
30
|
+
expected = '0.0.1'
|
31
|
+
actual = Timewizard::Utils::Wizardry.only_version base
|
32
|
+
|
33
|
+
expect(actual).to eq(expected)
|
34
|
+
end
|
26
35
|
end
|
27
36
|
end
|
@@ -0,0 +1,161 @@
|
|
1
|
+
require 'timewizard/versioner/android'
|
2
|
+
|
3
|
+
RSpec.describe 'Timewizard::Versioner::Android' do
|
4
|
+
|
5
|
+
context '.new' do
|
6
|
+
it 'should raise error if arg is nil' do
|
7
|
+
expect { Timewizard::Versioner::Android.new nil }.to raise_error("passed in file cannot be nil")
|
8
|
+
end
|
9
|
+
|
10
|
+
it 'should not raise error if arg is not nil' do
|
11
|
+
expect { Timewizard::Versioner::Android.new '' }.not_to raise_error
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
before(:example) do
|
16
|
+
@directory = Dir.pwd.to_s
|
17
|
+
@versioner = Timewizard::Versioner::Android.new "#{@directory}/tmp/android/AndroidManifest.xml"
|
18
|
+
end
|
19
|
+
|
20
|
+
context '#file' do
|
21
|
+
it 'should be an AndroidManifest.xml' do
|
22
|
+
expect(@versioner.file).to eq("#{@directory}/tmp/android/AndroidManifest.xml")
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
context '#old_build_number' do
|
27
|
+
it 'should be nil' do
|
28
|
+
expect(@versioner.old_build_number).to be_nil
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
context '#old_version_number' do
|
33
|
+
it 'should be nil' do
|
34
|
+
expect(@versioner.old_version_number).to be_nil
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
context '#new_build_number' do
|
39
|
+
it 'should be nil' do
|
40
|
+
expect(@versioner.new_build_number).to be_nil
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
context '#new_build_number=' do
|
45
|
+
it 'should change instance variable' do
|
46
|
+
@versioner.new_build_number = '1'
|
47
|
+
expect(@versioner.new_build_number).not_to be_nil
|
48
|
+
@versioner.new_build_number = nil
|
49
|
+
expect(@versioner.new_build_number).to be_nil
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
context '#new_version_number' do
|
54
|
+
it 'should be nil' do
|
55
|
+
expect(@versioner.new_version_number).to be_nil
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
context '#new_version_number=' do
|
60
|
+
it 'should change instance variable' do
|
61
|
+
@versioner.new_version_number = '1'
|
62
|
+
expect(@versioner.new_version_number).not_to be_nil
|
63
|
+
@versioner.new_version_number = nil
|
64
|
+
expect(@versioner.new_version_number).to be_nil
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
context '#read_build_numbers' do
|
69
|
+
it 'should not raise an error' do
|
70
|
+
expect { @versioner.read_build_numbers }.to_not raise_error
|
71
|
+
end
|
72
|
+
|
73
|
+
it 'should change instance variables' do
|
74
|
+
expect(@versioner.old_build_number).to be_nil
|
75
|
+
expect(@versioner.new_build_number).to be_nil
|
76
|
+
@versioner.read_build_numbers
|
77
|
+
expect(@versioner.old_build_number).to eq('200')
|
78
|
+
expect(@versioner.new_build_number).to eq('201')
|
79
|
+
end
|
80
|
+
end
|
81
|
+
|
82
|
+
context '#read_version_numbers' do
|
83
|
+
it 'should not raise an error' do
|
84
|
+
expect { @versioner.read_version_numbers }.to_not raise_error
|
85
|
+
end
|
86
|
+
|
87
|
+
it 'should change instance variables' do
|
88
|
+
expect(@versioner.old_version_number).to be_nil
|
89
|
+
expect(@versioner.new_version_number).to be_nil
|
90
|
+
@versioner.read_version_numbers
|
91
|
+
expect(@versioner.old_version_number).to eq('0.0.1')
|
92
|
+
expect(@versioner.new_version_number).to eq('0.0.1')
|
93
|
+
end
|
94
|
+
end
|
95
|
+
|
96
|
+
context '#write_build_numbers' do
|
97
|
+
before(:example) do
|
98
|
+
@versioner.read_build_numbers
|
99
|
+
end
|
100
|
+
|
101
|
+
after(:example) do
|
102
|
+
@versioner.new_build_number = '200'
|
103
|
+
@versioner.write_build_numbers
|
104
|
+
end
|
105
|
+
|
106
|
+
it 'should not raise an error' do
|
107
|
+
expect { @versioner.write_version_numbers }.to_not raise_error
|
108
|
+
end
|
109
|
+
|
110
|
+
it 'should not change instance variables' do
|
111
|
+
expect(@versioner.old_build_number).to eq('200')
|
112
|
+
expect(@versioner.new_build_number).to eq('201')
|
113
|
+
@versioner.write_build_numbers
|
114
|
+
expect(@versioner.old_build_number).to eq('200')
|
115
|
+
expect(@versioner.new_build_number).to eq('201')
|
116
|
+
end
|
117
|
+
|
118
|
+
it 'should change contents of parsed file' do
|
119
|
+
expect(@versioner.old_build_number).to eq('200')
|
120
|
+
expect(@versioner.new_build_number).to eq('201')
|
121
|
+
@versioner.write_build_numbers
|
122
|
+
@versioner.read_build_numbers
|
123
|
+
expect(@versioner.old_build_number).to eq('201')
|
124
|
+
expect(@versioner.new_build_number).to eq('202')
|
125
|
+
end
|
126
|
+
end
|
127
|
+
|
128
|
+
context '#write_version_numbers' do
|
129
|
+
before(:example) do
|
130
|
+
@versioner.read_version_numbers
|
131
|
+
end
|
132
|
+
|
133
|
+
after(:example) do
|
134
|
+
@versioner.new_version_number = '0.0.1'
|
135
|
+
@versioner.write_version_numbers
|
136
|
+
end
|
137
|
+
|
138
|
+
it 'should not raise an error' do
|
139
|
+
expect { @versioner.write_version_numbers }.to_not raise_error
|
140
|
+
end
|
141
|
+
|
142
|
+
it 'should not change instance variables' do
|
143
|
+
expect(@versioner.old_version_number).to eq('0.0.1')
|
144
|
+
expect(@versioner.new_version_number).to eq('0.0.1')
|
145
|
+
@versioner.write_version_numbers
|
146
|
+
expect(@versioner.old_version_number).to eq('0.0.1')
|
147
|
+
expect(@versioner.new_version_number).to eq('0.0.1')
|
148
|
+
end
|
149
|
+
|
150
|
+
it 'should change contents of parsed file' do
|
151
|
+
expect(@versioner.old_version_number).to eq('0.0.1')
|
152
|
+
expect(@versioner.new_version_number).to eq('0.0.1')
|
153
|
+
@versioner.new_version_number = '0.0.2'
|
154
|
+
@versioner.write_version_numbers
|
155
|
+
@versioner.read_version_numbers
|
156
|
+
expect(@versioner.old_version_number).to eq('0.0.2')
|
157
|
+
expect(@versioner.new_version_number).to eq('0.0.2')
|
158
|
+
end
|
159
|
+
end
|
160
|
+
|
161
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: timewizard
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.0.pre.alpha.pre.
|
4
|
+
version: 0.3.0.pre.alpha.pre.57
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Richard Harrah
|
@@ -170,6 +170,7 @@ files:
|
|
170
170
|
- spec/spec_helper.rb
|
171
171
|
- spec/timewizard_spec.rb
|
172
172
|
- spec/utils/wizardry_spec.rb
|
173
|
+
- spec/versioner/android_spec.rb
|
173
174
|
- spec/versioner_spec.rb
|
174
175
|
- timewizard.gemspec
|
175
176
|
homepage: https://github.com/Nunnery/timewizard
|