timewizard 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 49ca4592aa591aae335114bf2df2b28073e91608
4
+ data.tar.gz: ed0c7a5bfab56be821de2e70b4cfb63e7e171366
5
+ SHA512:
6
+ metadata.gz: 15743e80ca951afe3260974047cd4207ea719603b47d15250de232fd8e3dd33966288f88707965cdc8d89bce01f63f40d8be92965d613b9719eb72667a504ce4
7
+ data.tar.gz: 7f1b989fcf51df5ba1bc9e384bc2f684eeceb641856d4cc9f3809b23788bf42f710cbae3ab0ea52e3993eac6da66fdd6e5dc39288081934741e3017d1e10760c
data/.gitignore ADDED
@@ -0,0 +1,97 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
10
+
11
+ ### Ruby template
12
+ *.gem
13
+ *.rbc
14
+ /.config
15
+ /coverage/
16
+ /InstalledFiles
17
+ /pkg/
18
+ /spec/reports/
19
+ /test/tmp/
20
+ /test/version_tmp/
21
+ /tmp/
22
+
23
+ ## Specific to RubyMotion:
24
+ .dat*
25
+ .repl_history
26
+ build/
27
+
28
+ ## Documentation cache and generated files:
29
+ /.yardoc/
30
+ /_yardoc/
31
+ /doc/
32
+ /rdoc/
33
+
34
+ ## Environment normalisation:
35
+ /.bundle/
36
+ /vendor/bundle
37
+ /lib/bundler/man/
38
+
39
+ # for a library or gem, you might want to ignore these files since the code is
40
+ # intended to run in multiple environments; otherwise, check them in:
41
+ # Gemfile.lock
42
+ # .ruby-version
43
+ # .ruby-gemset
44
+
45
+ # unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
46
+ .rvmrc
47
+
48
+
49
+ ### JetBrains template
50
+ # Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion
51
+
52
+ *.iml
53
+
54
+ ## Directory-based project format:
55
+ .idea/
56
+ # if you remove the above rule, at least ignore the following:
57
+
58
+ # User-specific stuff:
59
+ # .idea/workspace.xml
60
+ # .idea/tasks.xml
61
+ # .idea/dictionaries
62
+
63
+ # Sensitive or high-churn files:
64
+ # .idea/dataSources.ids
65
+ # .idea/dataSources.xml
66
+ # .idea/sqlDataSources.xml
67
+ # .idea/dynamic.xml
68
+ # .idea/uiDesigner.xml
69
+
70
+ # Gradle:
71
+ # .idea/gradle.xml
72
+ # .idea/libraries
73
+
74
+ # Mongo Explorer plugin:
75
+ # .idea/mongoSettings.xml
76
+
77
+ ## File-based project format:
78
+ *.ipr
79
+ *.iws
80
+
81
+ ## Plugin-specific files:
82
+
83
+ # IntelliJ
84
+ /out/
85
+
86
+ # mpeltonen/sbt-idea plugin
87
+ .idea_modules/
88
+
89
+ # JIRA plugin
90
+ atlassian-ide-plugin.xml
91
+
92
+ # Crashlytics plugin (for Android Studio and IntelliJ)
93
+ com_crashlytics_export_strings.xml
94
+ crashlytics.properties
95
+ crashlytics-build.properties
96
+
97
+
data/.idea/.name ADDED
@@ -0,0 +1 @@
1
+ timewizard
data/.travis.yml ADDED
@@ -0,0 +1,7 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.0.0
4
+ before_install: gem install bundler -v 1.10.6
5
+ addons:
6
+ code_climate:
7
+ repo_token: 3dadb0fa3dce6a25c5f684b84239182e45fabf0d45c64511f621863e4c89b3fb
@@ -0,0 +1,13 @@
1
+ # Contributor Code of Conduct
2
+
3
+ As contributors and maintainers of this project, we pledge to respect all people who contribute through reporting issues, posting feature requests, updating documentation, submitting pull requests or patches, and other activities.
4
+
5
+ We are committed to making participation in this project a harassment-free experience for everyone, regardless of level of experience, gender, gender identity and expression, sexual orientation, disability, personal appearance, body size, race, ethnicity, age, or religion.
6
+
7
+ Examples of unacceptable behavior by participants include the use of sexual language or imagery, derogatory comments or personal attacks, trolling, public or private harassment, insults, or other unprofessional conduct.
8
+
9
+ Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct. Project maintainers who do not follow the Code of Conduct may be removed from the project team.
10
+
11
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by opening an issue or contacting one or more of the project maintainers.
12
+
13
+ This Code of Conduct is adapted from the [Contributor Covenant](http://contributor-covenant.org), version 1.0.0, available at [http://contributor-covenant.org/version/1/0/0/](http://contributor-covenant.org/version/1/0/0/)
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in timewizard.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2015 Richard Harrah
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,42 @@
1
+ # Timewizard
2
+
3
+ [![Code Climate](https://codeclimate.com/github/Nunnery/timewizard/badges/gpa.svg)](https://codeclimate.com/github/Nunnery/timewizard)
4
+ [![Test Coverage](https://codeclimate.com/github/Nunnery/timewizard/badges/coverage.svg)](https://codeclimate.com/github/Nunnery/timewizard/coverage)
5
+ [![Build Status](https://travis-ci.org/Nunnery/timewizard.svg?branch=master)](https://travis-ci.org/Nunnery/timewizard)
6
+ [![Dependency Status](https://gemnasium.com/Nunnery/timewizard.svg)](https://gemnasium.com/Nunnery/timewizard)
7
+
8
+ ## Installation
9
+
10
+ Add this line to your application's Gemfile:
11
+
12
+ ```ruby
13
+ gem 'timewizard'
14
+ ```
15
+
16
+ And then execute:
17
+
18
+ $ bundle
19
+
20
+ Or install it yourself as:
21
+
22
+ $ gem install timewizard
23
+
24
+ ## Usage
25
+
26
+ TODO: Write usage instructions here
27
+
28
+ ## Development
29
+
30
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake false` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
31
+
32
+ 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).
33
+
34
+ ## Contributing
35
+
36
+ Bug reports and pull requests are welcome on GitHub at https://github.com/Nunnery/timewizard. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](contributor-covenant.org) code of conduct.
37
+
38
+
39
+ ## License
40
+
41
+ The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
42
+
data/Rakefile ADDED
@@ -0,0 +1,10 @@
1
+ require "bundler/gem_tasks"
2
+ require "rake/testtask"
3
+
4
+ Rake::TestTask.new do |t|
5
+ t.libs << "lib"
6
+ t.libs << "test"
7
+ t.pattern = "test/**/*_test.rb"
8
+ end
9
+
10
+ task :default => :test
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "timewizard"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start
data/bin/setup ADDED
@@ -0,0 +1,7 @@
1
+ #!/bin/bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+
5
+ bundle install
6
+
7
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,3 @@
1
+ module Timewizard
2
+ VERSION = "0.1.0"
3
+ end
@@ -0,0 +1,83 @@
1
+ module Timewizard
2
+ module Versioner
3
+ class AndroidVersioner
4
+ attr_accessor :dir
5
+ attr_reader :manifest
6
+ attr_reader :old_version
7
+ attr_accessor :new_version
8
+
9
+ def initialize(dir)
10
+ @dir = dir
11
+ @manifest = nil
12
+ @last_version = 0
13
+ end
14
+
15
+ def update(change_to = -1)
16
+ write_manifest(change_manifest(open_manifest, change_to))
17
+ end
18
+
19
+ def find_manifest()
20
+ # check if the directory exists
21
+ unless Dir.exist?(@dir)
22
+ raise "directory passed in does not exist"
23
+ end
24
+ temp_file = nil
25
+ # check if the directory contains an AndroidManifest.xml
26
+ Dir.foreach(@dir.to_s) { |x|
27
+ if x == "AndroidManifest.xml"
28
+ temp_file = x
29
+ end }
30
+ if temp_file.nil?
31
+ raise "there is no AndroidManifest.xml in the given directory"
32
+ end
33
+
34
+ @manifest = File.expand_path(temp_file, @dir)
35
+ end
36
+
37
+ def open_manifest()
38
+ if @manifest.nil?
39
+ find_manifest
40
+ end
41
+
42
+ file_str = ''
43
+
44
+ if File.exist?(@manifest)
45
+ file_str = File.open(@manifest, 'r+') { |file| file.read }
46
+ end
47
+
48
+ file_str
49
+ end
50
+
51
+ def find_version_code(container)
52
+ parts = container.match("android:versionCode=\"(.*)\"")
53
+ version_code = parts[1]
54
+
55
+ @old_version = (version_code.to_i)
56
+ @new_version = (version_code.to_i + 1)
57
+
58
+ parts
59
+ end
60
+
61
+ def change_version_code(parts, change_to = -1)
62
+ if change_to >= 0
63
+ parts[0].gsub(parts[1], @changeTo.to_s)
64
+ else
65
+ parts[0].gsub(parts[1], @new_version.to_s)
66
+ end
67
+ end
68
+
69
+ def change_manifest(container, change_to = -1)
70
+ version_codes = find_version_code(container)
71
+ changed_codes = change_version_code(version_codes, change_to)
72
+ container = container.gsub(version_codes[0], changed_codes)
73
+ end
74
+
75
+ def write_manifest(container)
76
+ if @manifest.nil?
77
+ find_manifest
78
+ end
79
+ File.open(@manifest, 'w') { |file| file.write(container) }
80
+ end
81
+ end
82
+ end
83
+ end
@@ -0,0 +1,5 @@
1
+ module Timewizard
2
+ module Versioner
3
+ autoload :Android, 'timewizard/versioner/android'
4
+ end
5
+ end
data/lib/timewizard.rb ADDED
@@ -0,0 +1,5 @@
1
+ require "timewizard/version"
2
+
3
+ module Timewizard
4
+ # Your code goes here...
5
+ end
@@ -0,0 +1,25 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'timewizard/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "timewizard"
8
+ spec.version = Timewizard::VERSION
9
+ spec.authors = ["Richard Harrah"]
10
+ spec.email = ["topplethenunnery@gmail.com"]
11
+
12
+ spec.summary = %q{A gem for incrementing and decrementing iOS and Android app versions.}
13
+ spec.homepage = "https://github.com/Nunnery/timewizard"
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
17
+ spec.bindir = "exe"
18
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.add_development_dependency "bundler", "~> 1.10"
22
+ spec.add_development_dependency "rake", "~> 10.0"
23
+ spec.add_development_dependency "codeclimate-test-reporter"
24
+ spec.add_development_dependency "minitest"
25
+ end
metadata ADDED
@@ -0,0 +1,115 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: timewizard
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Richard Harrah
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2015-08-13 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ~>
18
+ - !ruby/object:Gem::Version
19
+ version: '1.10'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ~>
25
+ - !ruby/object:Gem::Version
26
+ version: '1.10'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ~>
32
+ - !ruby/object:Gem::Version
33
+ version: '10.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ~>
39
+ - !ruby/object:Gem::Version
40
+ version: '10.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: codeclimate-test-reporter
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'
55
+ - !ruby/object:Gem::Dependency
56
+ name: minitest
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - '>='
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ description:
70
+ email:
71
+ - topplethenunnery@gmail.com
72
+ executables: []
73
+ extensions: []
74
+ extra_rdoc_files: []
75
+ files:
76
+ - .gitignore
77
+ - .idea/.name
78
+ - .travis.yml
79
+ - CODE_OF_CONDUCT.md
80
+ - Gemfile
81
+ - LICENSE.txt
82
+ - README.md
83
+ - Rakefile
84
+ - bin/console
85
+ - bin/setup
86
+ - lib/timewizard.rb
87
+ - lib/timewizard/version.rb
88
+ - lib/timewizard/versioner.rb
89
+ - lib/timewizard/versioner/android.rb
90
+ - timewizard.gemspec
91
+ homepage: https://github.com/Nunnery/timewizard
92
+ licenses:
93
+ - MIT
94
+ metadata: {}
95
+ post_install_message:
96
+ rdoc_options: []
97
+ require_paths:
98
+ - lib
99
+ required_ruby_version: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - '>='
102
+ - !ruby/object:Gem::Version
103
+ version: '0'
104
+ required_rubygems_version: !ruby/object:Gem::Requirement
105
+ requirements:
106
+ - - '>='
107
+ - !ruby/object:Gem::Version
108
+ version: '0'
109
+ requirements: []
110
+ rubyforge_project:
111
+ rubygems_version: 2.4.8
112
+ signing_key:
113
+ specification_version: 4
114
+ summary: A gem for incrementing and decrementing iOS and Android app versions.
115
+ test_files: []