timewizard 0.2.4.pre.alpha.pre.41 → 0.3.0.pre.alpha.pre.47
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +8 -8
- data/.document +3 -0
- data/.gitignore +2 -0
- data/.rspec +2 -0
- data/.travis.yml +8 -8
- data/.yardopts +1 -0
- data/LICENSE.txt +0 -2
- data/README.md +6 -8
- data/README.rdoc +29 -0
- data/Rakefile +72 -7
- data/gemspec.yml +20 -0
- data/lib/timewizard/utils/wizardry.rb +23 -4
- data/lib/timewizard/version.rb +21 -1
- data/lib/timewizard/versioner/android.rb +101 -91
- data/lib/timewizard/versioner/apple.rb +102 -84
- data/lib/timewizard/versioner.rb +52 -0
- data/lib/timewizard.rb +21 -5
- data/spec/spec_helper.rb +33 -0
- data/spec/timewizard_spec.rb +5 -0
- data/spec/utils/wizardry_spec.rb +27 -0
- data/spec/versioner_spec.rb +107 -0
- data/timewizard.gemspec +60 -28
- metadata +74 -24
- data/bin/console +0 -14
- data/bin/setup +0 -7
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
NjY1MTBlMzA5OTdiZjg3Y2RjNTVhNDYwM2Q3NmQ2YmE4MTlkNDVmYg==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
OTc3ZmI0ZGVjNDMyODM4NDM0ZTVlOWJjNWEyNTc3NGY3NjJhMDUzOA==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
OWY2ZGU1YzNkODMyNzc3ZTExYzVlNjEzZTI2OGVlYTY2MDc1OTI0YTQ0YzY0
|
10
|
+
MjE3ZmNhZDg5NzRlOTYwZDIwOGUxM2RkZjRjM2I5YWNjNDYwYjhlMjVkM2Q0
|
11
|
+
N2IzNzE1OTZjN2U3ZGM3YzU5NDQzNTgwMzhhYWJmNGY5ZWQwMmI=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
OGUyNDkyMTQ0M2Y3MjFmODk2NWE2NTJjNGJiZTY5ZGI5ZDBhNzExYjQ4NWU3
|
14
|
+
Mjg3MTBjNmFmYjMwMTVmODFlNjcyN2ViYjE5Y2ZlMDk1Y2U3MDIxMDhlMWYw
|
15
|
+
N2E5ODhkNzljMmY4YmEyZDkxNzlhMDI2YzQ5ODZhYzIxYmRkNzM=
|
data/.document
ADDED
data/.gitignore
CHANGED
data/.rspec
ADDED
data/.travis.yml
CHANGED
@@ -1,18 +1,18 @@
|
|
1
|
-
language:
|
1
|
+
language: ruby
|
2
|
+
os: osx
|
2
3
|
osx_image: xcode6.4
|
4
|
+
rvm:
|
5
|
+
- 2.0.0
|
6
|
+
- 2.1.3
|
3
7
|
before_install:
|
4
|
-
- rvm get stable --auto-dotfiles
|
5
|
-
- rvm install 1.9.3
|
6
|
-
- rvm install 2.1.3
|
7
|
-
- rvm use 2.1.3
|
8
8
|
- gem install bundler -v 1.10.6
|
9
9
|
- rm -rf /usr/local/Cellar /usr/local/.git && brew cleanup
|
10
10
|
- ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
|
11
11
|
- brew update
|
12
12
|
- brew tap gemnasium/gemnasium
|
13
13
|
install:
|
14
|
+
- brew install icu4c openssl libyaml gemnasium-toolbelt
|
14
15
|
- bundle install --jobs=3 --retry=3
|
15
|
-
- brew install openssl libyaml gemnasium-toolbelt
|
16
16
|
script: bundle exec rake
|
17
17
|
after_script: gemnasium autoupdate
|
18
18
|
branches:
|
@@ -27,18 +27,18 @@ deploy:
|
|
27
27
|
api_key:
|
28
28
|
secure: "iUqr4kxkxh5jioaDBjdf2Peu543U8dpaP9bAbkLQ5Lc26hYck8VfqTHzVAveLYsaipsgO7vwTTAKizbAj3eZqnASmb9v+A+Ejgrj6XPnPLpXzRAZsAqx5Qf+zCgiA5gRkI7g653HF160nXje08NpWeXKRpyYZj+oxIEUeGr31SHlffHvMBOVchB9UWl1dfiS2mYLdrFCpBlCgvppO0+Mr3OI8JLfLe3bpA3uES/poFyKFBUbYJZF1p1Hmr1lmIM3vaU6W4rzYWjFzfTxs/LgM6GlhQOgohhsvwD6T+cDNunXGze3V4EzwVtIe5VrzepLaH7DXLaO0PKgv+calXseDeAGTz5nE5eFh+GqKEtYl/FeBz+35m1cDIFYUF7p1uPGM+R+sQmPnUFlu6tFXLrwfDkS/Rorjtl0p922DpZqJnGWDJW1YLFt/OGR5zZ0SY01n/1EkCLyd4K6xVyGU/ErUGgmjmljQyjXd4G/FxFm+ULtCYyS0W0o63wX5EHEU0ftO24H1rM8Vb2ajKRZbF9zy7QnMscnDJRnOsgWUq0IbXecQVxK25wegwA31r/k1ImtKPfeKs92LoQkFZgsi3lh4qJGx2vdqQHnJaQkcZ5ZFuPR4u1tFWnmoFRjNB8eCdiHHrKNLm/zFB6m//C+ebeTpuUf+CoYV1SeWzEBnsiK74c="
|
29
29
|
gem: timewizard
|
30
|
-
edge: true
|
31
30
|
on:
|
32
31
|
branch: master
|
33
32
|
repo: Nunnery/timewizard
|
33
|
+
ruby: '2.1.3'
|
34
34
|
- provider: rubygems
|
35
35
|
api_key:
|
36
36
|
secure: "iUqr4kxkxh5jioaDBjdf2Peu543U8dpaP9bAbkLQ5Lc26hYck8VfqTHzVAveLYsaipsgO7vwTTAKizbAj3eZqnASmb9v+A+Ejgrj6XPnPLpXzRAZsAqx5Qf+zCgiA5gRkI7g653HF160nXje08NpWeXKRpyYZj+oxIEUeGr31SHlffHvMBOVchB9UWl1dfiS2mYLdrFCpBlCgvppO0+Mr3OI8JLfLe3bpA3uES/poFyKFBUbYJZF1p1Hmr1lmIM3vaU6W4rzYWjFzfTxs/LgM6GlhQOgohhsvwD6T+cDNunXGze3V4EzwVtIe5VrzepLaH7DXLaO0PKgv+calXseDeAGTz5nE5eFh+GqKEtYl/FeBz+35m1cDIFYUF7p1uPGM+R+sQmPnUFlu6tFXLrwfDkS/Rorjtl0p922DpZqJnGWDJW1YLFt/OGR5zZ0SY01n/1EkCLyd4K6xVyGU/ErUGgmjmljQyjXd4G/FxFm+ULtCYyS0W0o63wX5EHEU0ftO24H1rM8Vb2ajKRZbF9zy7QnMscnDJRnOsgWUq0IbXecQVxK25wegwA31r/k1ImtKPfeKs92LoQkFZgsi3lh4qJGx2vdqQHnJaQkcZ5ZFuPR4u1tFWnmoFRjNB8eCdiHHrKNLm/zFB6m//C+ebeTpuUf+CoYV1SeWzEBnsiK74c="
|
37
37
|
gem: timewizard
|
38
|
-
edge: true
|
39
38
|
on:
|
40
39
|
branch: development
|
41
40
|
repo: Nunnery/timewizard
|
41
|
+
ruby: '2.1.3'
|
42
42
|
env:
|
43
43
|
global:
|
44
44
|
GEMNASIUM_TESTSUITE: bundle exec rake
|
data/.yardopts
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
--markup rdoc --title "timewizard Documentation" --protected
|
data/LICENSE.txt
CHANGED
data/README.md
CHANGED
@@ -1,10 +1,10 @@
|
|
1
1
|
# Timewizard
|
2
2
|
|
3
|
-
[![Code Climate](https://
|
4
|
-
[![Test Coverage](https://
|
5
|
-
[![Build Status](https://
|
6
|
-
[![Dependency Status](https://
|
7
|
-
[![Gem Version](https://
|
3
|
+
[![Code Climate](https://img.shields.io/codeclimate/github/Nunnery/timewizard.svg?style=flat-square)](https://codeclimate.com/github/Nunnery/timewizard)
|
4
|
+
[![Test Coverage](https://img.shields.io/codeclimate/coverage/github/Nunnery/timewizard.svg?style=flat-square)](https://codeclimate.com/github/Nunnery/timewizard/coverage)
|
5
|
+
[![Build Status](https://img.shields.io/travis/Nunnery/timewizard.svg?style=flat-square)](https://travis-ci.org/Nunnery/timewizard)
|
6
|
+
[![Dependency Status](https://img.shields.io/gemnasium/Nunnery/timewizard.svg?style=flat-square)](https://gemnasium.com/Nunnery/timewizard)
|
7
|
+
[![Gem Version](https://img.shields.io/gem/v/timewizard.svg?style=flat-square)](https://rubygems.org/gems/timewizard)
|
8
8
|
|
9
9
|
## Installation
|
10
10
|
|
@@ -28,9 +28,7 @@ TODO: Write usage instructions here
|
|
28
28
|
|
29
29
|
## Development
|
30
30
|
|
31
|
-
|
32
|
-
|
33
|
-
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
31
|
+
TODO: Write development instructions here
|
34
32
|
|
35
33
|
## Contributing
|
36
34
|
|
data/README.rdoc
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
= timewizard
|
2
|
+
|
3
|
+
[![Code Climate](https://img.shields.io/codeclimate/github/Nunnery/timewizard.svg?style=flat-square)](https://codeclimate.com/github/Nunnery/timewizard)
|
4
|
+
[![Test Coverage](https://img.shields.io/codeclimate/coverage/github/Nunnery/timewizard.svg?style=flat-square)](https://codeclimate.com/github/Nunnery/timewizard/coverage)
|
5
|
+
[![Build Status](https://img.shields.io/travis/Nunnery/timewizard.svg?style=flat-square)](https://travis-ci.org/Nunnery/timewizard)
|
6
|
+
[![Dependency Status](https://img.shields.io/gemnasium/Nunnery/timewizard.svg?style=flat-square)](https://gemnasium.com/Nunnery/timewizard)
|
7
|
+
[![Gem Version](https://img.shields.io/gem/v/timewizard.svg?style=flat-square)](https://rubygems.org/gems/timewizard)
|
8
|
+
|
9
|
+
== Description
|
10
|
+
|
11
|
+
TODO: Description
|
12
|
+
|
13
|
+
== Features
|
14
|
+
|
15
|
+
== Examples
|
16
|
+
|
17
|
+
require 'timewizard'
|
18
|
+
|
19
|
+
== Requirements
|
20
|
+
|
21
|
+
== Install
|
22
|
+
|
23
|
+
$ gem install timewizard
|
24
|
+
|
25
|
+
== Copyright
|
26
|
+
|
27
|
+
Copyright (c) 2015 Richard Harrah
|
28
|
+
|
29
|
+
See LICENSE.txt for details.
|
data/Rakefile
CHANGED
@@ -1,10 +1,75 @@
|
|
1
|
-
|
2
|
-
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require 'rubygems'
|
4
|
+
|
5
|
+
begin
|
6
|
+
require 'bundler'
|
7
|
+
rescue LoadError => e
|
8
|
+
warn e.message
|
9
|
+
warn "Run `gem install bundler` to install Bundler."
|
10
|
+
exit -1
|
11
|
+
end
|
12
|
+
|
13
|
+
begin
|
14
|
+
Bundler.setup(:development)
|
15
|
+
rescue Bundler::BundlerError => e
|
16
|
+
warn e.message
|
17
|
+
warn "Run `bundle install` to install missing gems."
|
18
|
+
exit e.status_code
|
19
|
+
end
|
3
20
|
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
21
|
+
require 'rake'
|
22
|
+
|
23
|
+
desc "Removes the tmp and pkg directories"
|
24
|
+
task :clean do
|
25
|
+
pwd = Dir.pwd.to_s
|
26
|
+
FileUtils.rm_rf Dir["#{pwd}/tmp"]
|
27
|
+
FileUtils.rm_rf Dir["#{pwd}/pkg"]
|
28
|
+
end
|
29
|
+
|
30
|
+
desc "Copies resource files to the tmp directory (for testing purposes)"
|
31
|
+
task :prepare do
|
32
|
+
pwd = Dir.pwd.to_s
|
33
|
+
FileUtils.cp_r("#{pwd}/resources/.", "#{pwd}/tmp")
|
8
34
|
end
|
9
35
|
|
10
|
-
|
36
|
+
require 'rspec/core/rake_task'
|
37
|
+
RSpec::Core::RakeTask.new
|
38
|
+
|
39
|
+
|
40
|
+
Rake::Task[:spec].enhance [:clean, :prepare]
|
41
|
+
|
42
|
+
task :test => :spec
|
43
|
+
task :default => :spec
|
44
|
+
|
45
|
+
require 'yard'
|
46
|
+
YARD::Rake::YardocTask.new
|
47
|
+
task :doc => :yard
|
48
|
+
|
49
|
+
desc "Adds copyright headers to source/spec files."
|
50
|
+
task :headers do
|
51
|
+
require 'copyright_header'
|
52
|
+
|
53
|
+
args = {
|
54
|
+
:license => 'MIT',
|
55
|
+
:copyright_software => 'timewizard',
|
56
|
+
:copyright_software_description => 'A Ruby library for manipulating iOS and Android version numbers.',
|
57
|
+
:copyright_holders => ['Richard Harrah <topplethenunnery@gmail.com>'],
|
58
|
+
:copyright_years => ['2015'],
|
59
|
+
:add_path => 'lib/:spec/',
|
60
|
+
:output_dir => '.'
|
61
|
+
}
|
62
|
+
|
63
|
+
command_line = CopyrightHeader::CommandLine.new args
|
64
|
+
command_line.execute
|
65
|
+
end
|
66
|
+
|
67
|
+
task :abide do
|
68
|
+
require 'abide'
|
69
|
+
|
70
|
+
Bundler.clean_exec 'lebascii'
|
71
|
+
end
|
72
|
+
|
73
|
+
require "bundler/gem_tasks"
|
74
|
+
|
75
|
+
Rake::Task[:build].enhance [:clean]
|
data/gemspec.yml
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
name: timewizard
|
2
|
+
summary: "A Ruby library for parsing and changing iOS and Android version numbers."
|
3
|
+
description: "Uses the RubyGems style of versioning in order to ease updates."
|
4
|
+
license: MIT
|
5
|
+
authors: Richard Harrah
|
6
|
+
email: topplethenunnery@gmail.com
|
7
|
+
homepage: https://github.com/Nunnery/timewizard
|
8
|
+
|
9
|
+
development_dependencies:
|
10
|
+
bundler: ~> 1.10
|
11
|
+
rake: ~> 10.0
|
12
|
+
rspec: ~> 3.3
|
13
|
+
yard: ~> 0.8.7.6
|
14
|
+
codeclimate-test-reporter: ~> 0.4
|
15
|
+
abide: ~> 0.0.3
|
16
|
+
copyright-header: ~> 1.0
|
17
|
+
|
18
|
+
dependencies:
|
19
|
+
versionomy: ~> 0.4
|
20
|
+
xcodeproj: ~> 0.26
|
@@ -1,14 +1,33 @@
|
|
1
|
+
#
|
2
|
+
# Copyright (C) 2015 Richard Harrah <topplethenunnery@gmail.com>
|
3
|
+
#
|
4
|
+
# Permission is hereby granted, free of charge, to any person obtaining a copy of
|
5
|
+
# this software and associated documentation files (the "Software"), to deal in
|
6
|
+
# the Software without restriction, including without limitation the rights to
|
7
|
+
# use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
8
|
+
# the Software, and to permit persons to whom the Software is furnished to do so,
|
9
|
+
# subject to the following conditions:
|
10
|
+
#
|
11
|
+
# The above copyright notice and this permission notice shall be included in all
|
12
|
+
# copies or substantial portions of the Software.
|
13
|
+
#
|
14
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
15
|
+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
16
|
+
# FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
17
|
+
# COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
18
|
+
# IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
19
|
+
# CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
20
|
+
#
|
1
21
|
module Timewizard
|
2
22
|
module Utils
|
3
23
|
module Wizardry
|
4
24
|
|
5
25
|
VERSION_REGEX = /((\d+\.)?(\d+\.)?(\*|\d+))(?:-([0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*))?(?:\+([0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*))?$/
|
6
26
|
|
7
|
-
def self.to_i(stringy)
|
8
|
-
stringy.gsub(/\D/, '').to_i || 0
|
9
|
-
end
|
10
|
-
|
11
27
|
def self.only_version(stringy)
|
28
|
+
if stringy.nil?
|
29
|
+
raise "stringy cannot be null"
|
30
|
+
end
|
12
31
|
VERSION_REGEX.match(stringy).to_s
|
13
32
|
end
|
14
33
|
|
data/lib/timewizard/version.rb
CHANGED
@@ -1,3 +1,23 @@
|
|
1
|
+
#
|
2
|
+
# Copyright (C) 2015 Richard Harrah <topplethenunnery@gmail.com>
|
3
|
+
#
|
4
|
+
# Permission is hereby granted, free of charge, to any person obtaining a copy of
|
5
|
+
# this software and associated documentation files (the "Software"), to deal in
|
6
|
+
# the Software without restriction, including without limitation the rights to
|
7
|
+
# use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
8
|
+
# the Software, and to permit persons to whom the Software is furnished to do so,
|
9
|
+
# subject to the following conditions:
|
10
|
+
#
|
11
|
+
# The above copyright notice and this permission notice shall be included in all
|
12
|
+
# copies or substantial portions of the Software.
|
13
|
+
#
|
14
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
15
|
+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
16
|
+
# FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
17
|
+
# COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
18
|
+
# IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
19
|
+
# CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
20
|
+
#
|
1
21
|
module Timewizard
|
2
|
-
VERSION = "0.
|
22
|
+
VERSION = "0.3.0"
|
3
23
|
end
|
@@ -1,127 +1,137 @@
|
|
1
|
+
#
|
2
|
+
# Copyright (C) 2015 Richard Harrah <topplethenunnery@gmail.com>
|
3
|
+
#
|
4
|
+
# Permission is hereby granted, free of charge, to any person obtaining a copy of
|
5
|
+
# this software and associated documentation files (the "Software"), to deal in
|
6
|
+
# the Software without restriction, including without limitation the rights to
|
7
|
+
# use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
8
|
+
# the Software, and to permit persons to whom the Software is furnished to do so,
|
9
|
+
# subject to the following conditions:
|
10
|
+
#
|
11
|
+
# The above copyright notice and this permission notice shall be included in all
|
12
|
+
# copies or substantial portions of the Software.
|
13
|
+
#
|
14
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
15
|
+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
16
|
+
# FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
17
|
+
# COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
18
|
+
# IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
19
|
+
# CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
20
|
+
#
|
21
|
+
require 'timewizard/versioner'
|
1
22
|
require 'timewizard/utils/wizardry'
|
2
23
|
|
3
24
|
module Timewizard
|
4
25
|
module Versioner
|
5
|
-
class Android
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
@manifest = nil
|
26
|
+
class Android < Timewizard::Versioner::Base
|
27
|
+
|
28
|
+
#
|
29
|
+
# Public functions (inherited from parent)
|
30
|
+
#
|
31
|
+
public
|
32
|
+
|
33
|
+
def read_build_numbers
|
34
|
+
read_file
|
35
|
+
find_build_numbers
|
16
36
|
end
|
17
37
|
|
18
|
-
def
|
19
|
-
|
38
|
+
def read_version_numbers
|
39
|
+
read_file
|
40
|
+
find_version_numbers
|
20
41
|
end
|
21
42
|
|
22
|
-
def
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
Dir.foreach(@dir.to_s) { |x|
|
31
|
-
if x == "AndroidManifest.xml"
|
32
|
-
temp_file = x
|
33
|
-
end }
|
34
|
-
if temp_file.nil?
|
35
|
-
raise "there is no AndroidManifest.xml in the given directory"
|
36
|
-
end
|
37
|
-
@manifest = File.expand_path(temp_file, @dir)
|
38
|
-
else
|
39
|
-
unless File.exist?(@dir)
|
40
|
-
raise "file passed in does not exist"
|
41
|
-
end
|
42
|
-
unless @dir == "AndroidManifest.xml"
|
43
|
-
raise "file must be an AndroidManifest.xml"
|
44
|
-
end
|
45
|
-
temp_file = File.absolute_path(@dir)
|
46
|
-
@manifest = temp_file
|
47
|
-
end
|
43
|
+
def write_build_numbers
|
44
|
+
change_build_number
|
45
|
+
write_file
|
46
|
+
end
|
47
|
+
|
48
|
+
def write_version_numbers
|
49
|
+
change_version_number
|
50
|
+
write_file
|
48
51
|
end
|
49
52
|
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
+
#
|
54
|
+
# Private functions (implementation specific)
|
55
|
+
#
|
56
|
+
private
|
57
|
+
|
58
|
+
def read_file
|
59
|
+
if @file.nil?
|
60
|
+
raise 'file is nil and cannot be read'
|
53
61
|
end
|
54
62
|
|
55
|
-
|
63
|
+
@file_contents = ''
|
56
64
|
|
57
|
-
if File.exist?(@
|
58
|
-
|
65
|
+
if File.exist?(@file)
|
66
|
+
@file_contents = File.open(@file, 'r+') { |f| f.read }
|
59
67
|
end
|
60
68
|
|
61
|
-
|
69
|
+
@file_contents
|
70
|
+
end
|
71
|
+
|
72
|
+
def write_file
|
73
|
+
if @file.nil?
|
74
|
+
raise 'file is nil and cannot be written'
|
75
|
+
end
|
76
|
+
if @file_contents.nil?
|
77
|
+
raise 'file_contents is null and cannot be written'
|
78
|
+
end
|
79
|
+
File.open(@file, 'w') { |file| file.write(@file_contents) }
|
62
80
|
end
|
63
81
|
|
64
|
-
def
|
65
|
-
|
66
|
-
|
82
|
+
def find_build_numbers
|
83
|
+
find_build_and_version_numbers
|
84
|
+
[@old_build_number, @new_build_number]
|
67
85
|
end
|
68
86
|
|
69
|
-
def
|
70
|
-
|
71
|
-
|
87
|
+
def find_version_numbers
|
88
|
+
find_build_and_version_numbers
|
89
|
+
[@old_version_number, @new_version_number]
|
72
90
|
end
|
73
91
|
|
74
|
-
def
|
75
|
-
|
92
|
+
def find_build_and_version_numbers
|
93
|
+
if @file_contents.nil?
|
94
|
+
read_file
|
95
|
+
end
|
96
|
+
matched = @file_contents.match "android:versionCode=\"(.*)\""
|
76
97
|
|
77
|
-
|
78
|
-
|
98
|
+
first_match = matched[0]
|
99
|
+
split_match = first_match.partition /\s+/
|
79
100
|
|
80
|
-
|
81
|
-
|
101
|
+
build_num = Timewizard::Utils::Wizardry.only_version split_match[0]
|
102
|
+
version_num = Timewizard::Utils::Wizardry.only_version split_match[2]
|
82
103
|
|
83
|
-
|
84
|
-
|
104
|
+
parsed_build_num = Versionomy.parse(build_num, Versionomy::Format.get('rubygems'))
|
105
|
+
parsed_version_num = Versionomy.parse(version_num, Versionomy::Format.get('rubygems'))
|
85
106
|
|
86
|
-
|
87
|
-
|
107
|
+
@old_build_number = parsed_build_num.unparse
|
108
|
+
@old_version_number = parsed_version_num.unparse
|
88
109
|
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
if change_to.to_s == '-1'
|
93
|
-
text = text.gsub(version, @new_version_code.to_s)
|
94
|
-
else
|
95
|
-
@new_version_code = change_to.to_i
|
96
|
-
text = text.gsub(version, @new_version_code.to_s)
|
97
|
-
end
|
110
|
+
@new_build_number = parsed_build_num.bump(parsed_build_num.parts.length - 1).unparse
|
111
|
+
@new_version_number = @old_version_number
|
112
|
+
self
|
98
113
|
end
|
99
114
|
|
100
|
-
def
|
101
|
-
|
102
|
-
|
103
|
-
if change_to.to_s == '-1'
|
104
|
-
text = text.gsub(version, @new_version_name.to_s)
|
105
|
-
else
|
106
|
-
@new_version_name = Timewizard::Utils::Wizardry.only_version change_to
|
107
|
-
text = text.gsub(version, @new_version_name.to_s)
|
115
|
+
def change_build_number
|
116
|
+
if @file_contents.nil?
|
117
|
+
read_file
|
108
118
|
end
|
119
|
+
if @new_build_number.nil?
|
120
|
+
read_build_numbers
|
121
|
+
end
|
122
|
+
@file_contents.gsub!(@old_build_number.to_s, @new_build_number.to_s)
|
109
123
|
end
|
110
124
|
|
111
|
-
def
|
112
|
-
|
113
|
-
|
114
|
-
version_name = find_version_name(container)
|
115
|
-
changed_name = change_version_name(version_name, version_name_change)
|
116
|
-
container = container.gsub(version_code, changed_code).gsub(version_name, changed_name)
|
117
|
-
end
|
118
|
-
|
119
|
-
def write_manifest(container)
|
120
|
-
if @manifest.nil?
|
121
|
-
find_manifest
|
125
|
+
def change_version_number
|
126
|
+
if @file_contents.nil?
|
127
|
+
read_file
|
122
128
|
end
|
123
|
-
|
129
|
+
if @new_version_number.nil?
|
130
|
+
read_version_numbers
|
131
|
+
end
|
132
|
+
@file_contents.gsub!(@old_version_number.to_s, @new_version_number.to_s)
|
124
133
|
end
|
134
|
+
|
125
135
|
end
|
126
136
|
end
|
127
137
|
end
|