lasertag 0.1.0 → 0.2.1

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,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 51b7eeed39ca350bcfc31c4317d26487c92aa5f8
4
- data.tar.gz: 374809d974706664733f4aa1ccddf134d13e98a2
3
+ metadata.gz: 3cba8453f70d25300d93b0ed7bd38091d6eb58d0
4
+ data.tar.gz: 31b59dc849797a5060b2e5fab8204db60c38f286
5
5
  SHA512:
6
- metadata.gz: a7f43099a0d4994a428d172ccc1ef4cf41b3156536fccc74f0def1efa3a45fe2f0f49a310ca5ae1db7d5127c3c931895a6149a8790b3445a2144fb8b35c9a331
7
- data.tar.gz: c39837724e2bd5d8d26cb9997ea20631e613a563780b59d194b13fccd87aa218a73ef76e6f8d132d86af5a34773463a56e0825428b94e421feb8ad6a3f4b4275
6
+ metadata.gz: 9a746042144bb40e3ff59c5ee40a5445ac21a9556e37d7894b244220c674f2e7069ebe83af25c971a0d02cf7cbaf59164395d7ffb4b6b6c0556a642624133908
7
+ data.tar.gz: 1ea63e8dc865466aa6ee5d1db68a8e7667ddc0d46a4e2668ec6caa48bd164223ebf9ab0a61632dfc3b01bb8f9491b1260050e3cb47b7e5976f73bf6c8d31bff1
data/README.md CHANGED
@@ -1,38 +1,20 @@
1
1
  # Lasertag
2
2
 
3
- Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/lasertag`. To experiment with that code, run `bin/console` for an interactive prompt.
3
+ Match your CVS tags with the android versions in laser speed!
4
4
 
5
- TODO: Delete this and the text above, and describe your gem
6
-
7
- ## Installation
8
-
9
- Add this line to your application's Gemfile:
10
-
11
- ```ruby
12
- gem 'lasertag'
13
- ```
14
-
15
- And then execute:
16
-
17
- $ bundle
18
-
19
- Or install it yourself as:
20
-
21
- $ gem install lasertag
22
5
 
23
6
  ## Usage
24
7
 
25
- TODO: Write usage instructions here
8
+ $ lasertag -m app
26
9
 
27
- ## Development
10
+ If you want to specify a flavour:
28
11
 
29
- After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
12
+ $ lasertag --module app --flavour prod
30
13
 
31
- 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).
32
14
 
33
- ## Contributing
15
+ ## Installation
34
16
 
35
- Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/lasertag. 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.
17
+ $ gem install lasertag
36
18
 
37
19
 
38
20
  ## License
data/bin/lasertag CHANGED
@@ -1,14 +1,5 @@
1
1
  #!/usr/bin/env ruby
2
+ require 'bundler/setup'
3
+ require 'lasertag'
2
4
 
3
- require "bundler/setup"
4
- require "lasertag"
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
5
+ Lasertag::MainApp.new(ARGV).call
data/lasertag.gemspec CHANGED
@@ -3,14 +3,19 @@ lib = File.expand_path('../lib', __FILE__)
3
3
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
4
  require 'lasertag/version'
5
5
 
6
+ #rake build # Build lasertag-0.0.1.gem into the pkg directory
7
+ #rake install # Build and install lasertag-0.0.1.gem into system gems
8
+ #rake release # Create tag v0.0.1 and build and push lasertag-0.0.1.gem t...
9
+ #rake spec # Run RSpec code examples
10
+
6
11
  Gem::Specification.new do |spec|
7
12
  spec.name = "lasertag"
8
13
  spec.version = Lasertag::VERSION
9
14
  spec.authors = ["cesarferreira"]
10
15
  spec.email = ["cesar.manuel.ferreira@gmail.com"]
11
16
 
12
- spec.summary = %q{Tag your android version in you CVS with ease.}
13
- spec.description = %q{Tag your android version in you CVS with ease.}
17
+ spec.summary = %q{Match your CVS tags with the android versions in laser speed!}
18
+ spec.description = %q{Match your CVS tags with the android versions in laser speed!}
14
19
  spec.homepage = "https://github.com/cesarferreira/lasertag"
15
20
  spec.license = "MIT"
16
21
 
@@ -19,7 +24,15 @@ Gem::Specification.new do |spec|
19
24
  spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
20
25
  spec.require_paths = ["lib"]
21
26
 
22
- spec.add_development_dependency "bundler", "~> 1.10"
23
- spec.add_development_dependency "rake", "~> 10.0"
24
- spec.add_development_dependency "rspec"
27
+ spec.required_ruby_version = '>= 2.0.0'
28
+
29
+ spec.add_development_dependency 'rake', '~> 10.0'
30
+ spec.add_development_dependency 'pry-byebug', '~> 3.2'
31
+ spec.add_development_dependency 'rspec'
32
+
33
+ spec.add_dependency 'bundler', '~> 1.7'
34
+ spec.add_dependency 'colorize', '~> 0.7'
35
+ spec.add_dependency 'oga', '~> 1.3.1'
36
+ spec.add_dependency 'hirb'
37
+
25
38
  end
data/lib/lasertag.rb CHANGED
@@ -1,5 +1,223 @@
1
- require "lasertag/version"
1
+ require 'optparse'
2
+ require 'colorize'
3
+ require 'hirb'
4
+ require 'oga'
5
+ require 'lasertag/version'
6
+ require 'pry'
2
7
 
3
8
  module Lasertag
4
- # Your code goes here...
9
+ class MainApp
10
+ def initialize(arguments)
11
+
12
+ # defaults
13
+ @app_path = Dir.pwd
14
+ @app_module = nil
15
+ @app_flavour = nil
16
+
17
+ @require_analyses = true
18
+
19
+ # Parse Options
20
+ arguments.push "-h" if arguments.length == 0
21
+ create_options_parser(arguments)
22
+
23
+ manage_opts
24
+
25
+ end
26
+
27
+ def create_options_parser(args)
28
+
29
+ args.options do |opts|
30
+ opts.banner = "Usage: lasertag [OPTIONS]"
31
+ opts.separator ''
32
+ opts.separator "Options"
33
+
34
+ opts.on('-p PATH', '--path PATH', 'Custom path to android project') do |app_path|
35
+ @app_path = app_path if @app_path != '.'
36
+ end
37
+
38
+ opts.on('-f', '--flavour FLAVOUR', 'Specifies the flavour (e.g. dev, qa, prod)') do |app_flavour|
39
+ @app_flavour = app_flavour
40
+ end
41
+
42
+ opts.on('-m', '--module MODULE', 'Specifies the app module') do |app_module|
43
+ @app_module = app_module
44
+ end
45
+
46
+ opts.on('-h', '--help', 'Displays help') do
47
+ @require_analyses = false
48
+ puts opts.help
49
+ exit
50
+ end
51
+ opts.on('-v', '--version', 'Displays version') do
52
+ @require_analyses = false
53
+ puts Lasertag::VERSION
54
+ exit
55
+ end
56
+ opts.parse!
57
+
58
+ end
59
+ end
60
+
61
+ ##
62
+ ## Manage options
63
+ ##
64
+ def manage_opts
65
+
66
+ if @require_analyses
67
+ # instatiate android project
68
+ # android_project = AndroidProject.new(@app_path)
69
+
70
+ # # is a valid android project?
71
+ # unless android_project.is_valid
72
+ # puts "#{@app_path.red} is not a valid android project"
73
+ # exit
74
+ # end
75
+ end
76
+
77
+ if @clear_flag
78
+ android_project.clear_app_data
79
+ end
80
+
81
+ unless @app_module
82
+ puts "Please give me an app module name".yellow
83
+ exit 1
84
+ end
85
+
86
+ handle_it_all
87
+
88
+ end
89
+
90
+ def handle_it_all
91
+
92
+ Dir.chdir @app_path
93
+
94
+ ### Assemble
95
+ system assemble_command
96
+
97
+ ### Get project properties
98
+ @hash = project_properties @app_module
99
+
100
+ puts "\n"
101
+
102
+ ### Find app info
103
+ app_info = get_app_info
104
+
105
+ puts "For package #{app_info[:package].green}"
106
+
107
+ ### dont let uncommited stuffgit commit
108
+
109
+
110
+ ### git tag -a "versionNumber" -m "versionName"
111
+
112
+ version = "v#{app_info[:versionName]}"
113
+ tag = "git tag -a #{version} -m 'versionCode: #{app_info[:versionCode]}'"
114
+
115
+ puts "Trying to tag #{version}...".yellow
116
+
117
+ puts "Tagged #{version}\n".green
118
+
119
+
120
+ ### git push --tags
121
+ end
122
+
123
+ def android_home_is_defined
124
+ sdk = `echo $ANDROID_HOME`.gsub("\n",'')
125
+ !sdk.empty?
126
+ end
127
+
128
+ def call
129
+ unless android_home_is_defined
130
+ puts "\nWARNING: your #{'$ANDROID_HOME'.yellow} is not defined\n"
131
+ puts "\nhint: in your #{'~/.bashrc'.yellow} add:\n #{"export ANDROID_HOME=\"/Users/cesarferreira/Library/Android/sdk/\"".yellow}"
132
+ puts "\nNow type #{'source ~/.bashrc'.yellow}\n\n"
133
+ exit 1
134
+ end
135
+ end
136
+
137
+ def settings_gradle_file(path = @base_path)
138
+ File.join(path, 'settings.gradle')
139
+ end
140
+
141
+ def is_valid(settings_path = @settings_gradle_path)
142
+ File.exist?(settings_path)
143
+ end
144
+
145
+ ##############
146
+
147
+
148
+ def convert_values_to_hash (str)
149
+ hash = Hash.new
150
+
151
+ str.split(/\r?\n|\r/).each { |line|
152
+ next unless line.include? ':'
153
+ indexOf = line.index(':')
154
+ next unless indexOf > 0
155
+
156
+ key = line[0..indexOf-1].strip
157
+ value = line[indexOf+1..line.length].strip
158
+
159
+ hash[key] = value
160
+ }
161
+
162
+ hash
163
+ end
164
+
165
+ def project_properties(project=nil)
166
+
167
+ project = "#{project}:" if project
168
+
169
+ result = %x[gradle #{project}properties]
170
+ hash = convert_values_to_hash result
171
+ #puts Hirb::Helpers::AutoTable.render(hash)
172
+ hash
173
+ end
174
+
175
+
176
+ def get_app_info
177
+ path = get_path_to_merged_manifest
178
+ handle = File.open(path)
179
+
180
+ parser = Oga.parse_xml(handle)
181
+
182
+ # package="com.cesarferreira.testout"
183
+ # versionCode="10000"
184
+ # versionName="1.0.0"
185
+ package = parser.xpath("//manifest").attr('package').last.value
186
+ versionCode = parser.xpath("//manifest").attr('android:versionCode').last.value
187
+ versionName = parser.xpath("//manifest").attr('android:versionName').last.value
188
+
189
+ {
190
+ package: package,
191
+ versionCode: versionCode,
192
+ versionName: versionName,
193
+ }
194
+ end
195
+
196
+ def get_path_to_merged_manifest
197
+ build_dir = @hash['buildDir']
198
+
199
+ flavor = @app_flavour ? "/#{@app_flavour}/" : "/"
200
+
201
+ path = "#{build_dir}/intermediates/manifests/full"
202
+ path = "#{path}#{flavor}release/"
203
+
204
+ full_path = File.join(path, 'AndroidManifest.xml')
205
+
206
+ exists = File.exist?(full_path)
207
+
208
+ unless exists
209
+ puts "#{full_path.red} could not be found"
210
+ puts "Try specifying a Flavor".yellow
211
+ exit 1
212
+ end
213
+
214
+
215
+ full_path
216
+ end
217
+
218
+ def assemble_command
219
+ "gradle assemble#{(@app_flavour or "").capitalize}Release"
220
+ end
221
+
222
+ end
5
223
  end
@@ -1,3 +1,3 @@
1
1
  module Lasertag
2
- VERSION = "0.1.0"
2
+ VERSION = "0.2.1"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lasertag
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - cesarferreira
@@ -11,33 +11,33 @@ cert_chain: []
11
11
  date: 2015-12-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
- name: bundler
14
+ name: rake
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '1.10'
19
+ version: '10.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
- version: '1.10'
26
+ version: '10.0'
27
27
  - !ruby/object:Gem::Dependency
28
- name: rake
28
+ name: pry-byebug
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: '10.0'
33
+ version: '3.2'
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
- version: '10.0'
40
+ version: '3.2'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: rspec
43
43
  requirement: !ruby/object:Gem::Requirement
@@ -52,7 +52,63 @@ dependencies:
52
52
  - - ">="
53
53
  - !ruby/object:Gem::Version
54
54
  version: '0'
55
- description: Tag your android version in you CVS with ease.
55
+ - !ruby/object:Gem::Dependency
56
+ name: bundler
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '1.7'
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '1.7'
69
+ - !ruby/object:Gem::Dependency
70
+ name: colorize
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '0.7'
76
+ type: :runtime
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '0.7'
83
+ - !ruby/object:Gem::Dependency
84
+ name: oga
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: 1.3.1
90
+ type: :runtime
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - "~>"
95
+ - !ruby/object:Gem::Version
96
+ version: 1.3.1
97
+ - !ruby/object:Gem::Dependency
98
+ name: hirb
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - ">="
102
+ - !ruby/object:Gem::Version
103
+ version: '0'
104
+ type: :runtime
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - ">="
109
+ - !ruby/object:Gem::Version
110
+ version: '0'
111
+ description: Match your CVS tags with the android versions in laser speed!
56
112
  email:
57
113
  - cesar.manuel.ferreira@gmail.com
58
114
  executables:
@@ -81,7 +137,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
81
137
  requirements:
82
138
  - - ">="
83
139
  - !ruby/object:Gem::Version
84
- version: '0'
140
+ version: 2.0.0
85
141
  required_rubygems_version: !ruby/object:Gem::Requirement
86
142
  requirements:
87
143
  - - ">="
@@ -92,6 +148,6 @@ rubyforge_project:
92
148
  rubygems_version: 2.4.8
93
149
  signing_key:
94
150
  specification_version: 4
95
- summary: Tag your android version in you CVS with ease.
151
+ summary: Match your CVS tags with the android versions in laser speed!
96
152
  test_files: []
97
153
  has_rdoc: