timewizard 0.3.5 → 0.3.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- YWY1NDgxOTA5OWNkZTY1MTY3NDhlNGQzOTVlZGYyMmJjN2FmYWFiZg==
4
+ ZGUzNTAyNGY0MTU3ZDc3NjdiNDJkOWVjMWQ5NjZhMjA3NTNjOWRiYg==
5
5
  data.tar.gz: !binary |-
6
- YzQ2ZmI1YWEzZWIzYzc2ZTVkYzViM2E4OGM5NTc5NGRmNTVhMzNmOA==
6
+ MWQ4NmM2ZTZiNTQ3NWM4YWZlN2YzNTdkNTFjNTBhMjNmYzMwMmE4Mw==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- NDZhYTE3NGE5YzZhOTRmMTkwYmY5YTVlZWUzNmM5N2UyOTM3MjJhNTFkYzcy
10
- MzAwZGJhYjI2Y2YzNjBhODU3YTRhMjIwZmI0NGZiNjEyOWI2N2Y1ZWQzNzdl
11
- NjU4ZmUwMjQwYTJmYjZlNzMxNjFiYzEyMjVlOTVjMzJkNzBlYmI=
9
+ ODFkYjM1MDQ1MWUyZjNiZTkzMjgxYzFhMjkxZjMzNWYxNWM0YTJhYzgyYTc4
10
+ Y2RlYWVjMTYwNDJhMmZjNGYwMDk2MGQzMGM4MWNhOTVjZTBhZGMyNzhiYjg4
11
+ ZjUwYzM5MWY4MjE4MGJiZmI5YWViOGZmYmNmZjFkOGU1OWZiNDA=
12
12
  data.tar.gz: !binary |-
13
- YjVjMjUwMTVlZGFmNDU0MzRhYTI4NjEzYzVkODg2Y2E3NTFiNTIxMTI3ZDFm
14
- ZWIyNTFjODYzYjg3MDk1YTU5OGJhYTAzOWQ4ODZlZTU4MjdjMjM3NTM0NDc2
15
- MjNjMGNlMGFhZTVhMjIwMmI3YmU5ZDBhZmRiZDExYWIzZjM1OGM=
13
+ YzFkZTE2NDRkYjI0MzUxOTc5NTJmZTIwMTJkZGI2Zjk3OWQyM2Y4MDBmNTBi
14
+ ZWUyOWQ2NzBiZWFkMjljMzZiOTQyZmI0ZTgzYzQ5ZjdiNWFkNzg4NzQwYjBj
15
+ YjM0NDJmYjU3ODdlMTYyN2MyN2UxNDNkYWM5MWQyYjg5YTZjMjQ=
@@ -3,5 +3,5 @@
3
3
  module Timewizard
4
4
  # Version of this gem.
5
5
  # @return [String] current version
6
- VERSION = "0.3.5"
6
+ VERSION = "0.3.7"
7
7
  end
@@ -1,3 +1,4 @@
1
+ require 'nokogiri'
1
2
  require 'timewizard/versioner'
2
3
 
3
4
  module Timewizard
@@ -23,16 +24,19 @@ module Timewizard
23
24
  private
24
25
 
25
26
  SPACE_REGEX = /\s+/
27
+ NAMESPACE = 'android'
28
+ VERSION_CODE = 'versionCode'
29
+ VERSION_NAME = 'versionName'
26
30
 
27
31
  def read_file
28
32
  if @file.nil?
29
33
  raise 'file is nil and cannot be read'
30
34
  end
31
35
 
32
- @file_contents = ''
36
+ @file_contents = Nokogiri.XML('')
33
37
 
34
38
  if File.exist?(@file)
35
- @file_contents = File.open(@file, 'r+') { |f| f.read }
39
+ @file_contents = File.open(@file, 'r+') { |f| Nokogiri.XML(f) }
36
40
  end
37
41
 
38
42
  @file_contents
@@ -45,20 +49,21 @@ module Timewizard
45
49
  if @file_contents.nil?
46
50
  raise 'file_contents is null and cannot be written'
47
51
  end
48
- File.open(@file, 'w') { |file| file.write(@file_contents) }
52
+ File.open(@file, 'w') { |f| @file_contents.write_xml_to(f) }
49
53
  end
50
54
 
51
55
  def find_build_and_version_numbers
52
56
  if @file_contents.nil?
53
57
  read_file
54
58
  end
55
- matched = @file_contents.match "android:versionCode=\"(.*)\""
56
59
 
57
- first_match = matched[0]
58
- split_match = first_match.partition(SPACE_REGEX)
60
+ manifest = @file_contents.at_xpath('//manifest')
61
+
62
+ manifest_attr_vc = manifest[NAMESPACE + ':' + VERSION_CODE]
63
+ manifest_attr_vn = manifest[NAMESPACE + ':' + VERSION_NAME]
59
64
 
60
- build_num = Timewizard::Utils::Wizardry.only_version split_match[0]
61
- version_num = Timewizard::Utils::Wizardry.only_version split_match[2]
65
+ build_num = Timewizard::Utils::Wizardry.only_version manifest_attr_vc
66
+ version_num = Timewizard::Utils::Wizardry.only_version manifest_attr_vn
62
67
 
63
68
  parsed_build_num = Versionomy.parse(build_num, Versionomy::Format.get('rubygems'))
64
69
  parsed_version_num = Versionomy.parse(version_num, Versionomy::Format.get('rubygems'))
@@ -81,7 +86,9 @@ module Timewizard
81
86
  if @new_build_number.nil?
82
87
  read_build_numbers
83
88
  end
84
- @file_contents.gsub!(@old_build_number.to_s, @new_build_number.to_s)
89
+ manifest = @file_contents.at_xpath('//manifest')
90
+
91
+ manifest[NAMESPACE + ':' + VERSION_CODE] = @new_build_number.to_s
85
92
  end
86
93
 
87
94
  def change_version_numbers
@@ -91,7 +98,9 @@ module Timewizard
91
98
  if @new_version_number.nil?
92
99
  read_version_numbers
93
100
  end
94
- @file_contents.gsub!(@old_version_number.to_s, @new_version_number.to_s)
101
+ manifest = @file_contents.at_xpath('//manifest')
102
+
103
+ manifest[NAMESPACE + ':' + VERSION_NAME] = @new_version_number.to_s
95
104
  end
96
105
 
97
106
  end
@@ -44,6 +44,7 @@ module Timewizard
44
44
  if @file_contents.nil?
45
45
  raise 'file_contents is nil and cannot be written'
46
46
  end
47
+ @file_contents.formatted = true
47
48
  @file_contents.save(@file)
48
49
  end
49
50
 
@@ -99,4 +100,4 @@ module Timewizard
99
100
 
100
101
  end
101
102
  end
102
- end
103
+ end
@@ -1,3 +1,4 @@
1
+ require 'nokogiri'
1
2
  require 'timewizard/versioner'
2
3
 
3
4
  module Timewizard
@@ -29,10 +30,10 @@ module Timewizard
29
30
  raise 'file is nil and cannot be read'
30
31
  end
31
32
 
32
- @file_contents = ''
33
+ @file_contents = Nokogiri.XML('')
33
34
 
34
35
  if File.exist?(@file)
35
- @file_contents = File.open(@file, 'r+') { |f| f.read }
36
+ @file_contents = File.open(@file, 'r+') { |f| Nokogiri.XML(f) }
36
37
  end
37
38
 
38
39
  @file_contents
@@ -45,27 +46,30 @@ module Timewizard
45
46
  if @file_contents.nil?
46
47
  raise 'file_contents is null and cannot be written'
47
48
  end
48
- File.open(@file, 'w') { |file| file.write(@file_contents) }
49
+ File.open(@file, 'w') { |f| @file_contents.write_xml_to(f) }
49
50
  end
50
51
 
51
52
  def find_build_and_version_numbers
52
53
  if @file_contents.nil?
53
54
  read_file
54
55
  end
55
- matched = @file_contents.match "version=\"(.*)\">"
56
56
 
57
- first_match = matched[0]
58
- split_match = first_match.partition(SPACE_REGEX)
57
+ iphone = @file_contents.at_css('application iphone')
58
+ android = @file_contents.at_css('application android')
59
+
60
+ iphone_version_num = iphone['version']
61
+ android_version_num = android['version']
59
62
 
60
- build_num = Timewizard::Utils::Wizardry.only_version split_match[0]
63
+ parsed_iphone_num = Versionomy.parse(iphone_version_num, Versionomy::Format.get('rubygems'))
64
+ parsed_android_num = Versionomy.parse(android_version_num, Versionomy::Format.get('rubygems'))
61
65
 
62
- parsed_build_num = Versionomy.parse(build_num, Versionomy::Format.get('rubygems'))
66
+ parsed_version_num = parsed_android_num > parsed_iphone_num ? parsed_android_num : parsed_iphone_num
63
67
 
64
- @bumped_build_number = parsed_build_num.bump(parsed_build_num.parts.length - 1)
68
+ @bumped_version_number = parsed_version_num.bump(parsed_version_num.parts.length - 1)
65
69
 
66
- obn = parsed_build_num.unparse
67
- ovn = parsed_build_num.unparse
68
- nbn = parsed_build_num.bump(parsed_build_num.parts.length - 1).unparse
70
+ obn = parsed_version_num.unparse
71
+ ovn = parsed_version_num.unparse
72
+ nbn = parsed_version_num.bump(parsed_version_num.parts.length - 1).unparse
69
73
  nvn = ovn
70
74
 
71
75
  [obn, ovn, nbn, nvn]
@@ -78,7 +82,8 @@ module Timewizard
78
82
  if @new_build_number.nil?
79
83
  read_build_numbers
80
84
  end
81
- @file_contents.gsub!(@old_build_number.to_s, @new_build_number.to_s)
85
+ # don't actually want to do anything for build numbers for worklight
86
+ nil
82
87
  end
83
88
 
84
89
  def change_version_numbers
@@ -88,7 +93,11 @@ module Timewizard
88
93
  if @new_version_number.nil?
89
94
  read_version_numbers
90
95
  end
91
- @file_contents.gsub!(@old_version_number.to_s, @new_version_number.to_s)
96
+ iphone = @file_contents.at_css('application iphone')
97
+ android = @file_contents.at_css('application android')
98
+
99
+ iphone['version'] = @new_version_number.to_s
100
+ android['version'] = @new_version_number.to_s
92
101
  end
93
102
 
94
103
  end
@@ -1,3 +1,5 @@
1
1
  <?xml version="1.0" encoding="UTF-8"?>
2
2
 
3
- <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="timewizard" android:versionCode="200" android:versionName="0.0.1" />
3
+ <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="timewizard" android:versionCode="200"
4
+ android:versionName="0.0.1">
5
+ </manifest>
@@ -23,8 +23,9 @@ Gem::Specification.new do |gem|
23
23
  gem.test_files = glob['{spec/{**/}*_spec.rb']
24
24
  gem.extra_rdoc_files = glob['*.{txt,rdoc}']
25
25
 
26
- gem.add_dependency 'versionomy', '~> 0.4'
27
26
  gem.add_dependency 'CFPropertyList', '~> 2.3'
27
+ gem.add_dependency 'nokogiri', '~> 1.6.6'
28
+ gem.add_dependency 'versionomy', '~> 0.4'
28
29
 
29
30
  gem.add_development_dependency 'bundler', '~> 1.10'
30
31
  gem.add_development_dependency 'rake', '~> 10.0'
metadata CHANGED
@@ -1,43 +1,57 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: timewizard
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.5
4
+ version: 0.3.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Richard Harrah
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2015-10-19 00:00:00.000000000 Z
11
+ date: 2015-10-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
- name: versionomy
14
+ name: CFPropertyList
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
17
  - - ~>
18
18
  - !ruby/object:Gem::Version
19
- version: '0.4'
19
+ version: '2.3'
20
20
  type: :runtime
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: '0.4'
26
+ version: '2.3'
27
27
  - !ruby/object:Gem::Dependency
28
- name: CFPropertyList
28
+ name: nokogiri
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
31
  - - ~>
32
32
  - !ruby/object:Gem::Version
33
- version: '2.3'
33
+ version: 1.6.6
34
34
  type: :runtime
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: '2.3'
40
+ version: 1.6.6
41
+ - !ruby/object:Gem::Dependency
42
+ name: versionomy
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ~>
46
+ - !ruby/object:Gem::Version
47
+ version: '0.4'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ~>
53
+ - !ruby/object:Gem::Version
54
+ version: '0.4'
41
55
  - !ruby/object:Gem::Dependency
42
56
  name: bundler
43
57
  requirement: !ruby/object:Gem::Requirement