capkin 0.0.3 → 0.0.5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: fc56cefd98005237ace17ecf0a32843a5432ccac
4
- data.tar.gz: eed3f69ea3d85eee6bfe0cbfd6482958cd27b9ef
3
+ metadata.gz: c3f1e5b9f964f0ec5930d4d0e56bff97e3246046
4
+ data.tar.gz: e47ecad436d9f7cc7db493012e6a1582ae6fd937
5
5
  SHA512:
6
- metadata.gz: 92a532caf240bf94331d4a3f7808afefcbba52d39e12e051ed1bed45c8817411d509d802c3960adbeeeea5e5756eaee83579f13c62837981529c01909bf5e753
7
- data.tar.gz: c543b5bd893d665b0054eb77a6749070443706e1b61847f8b28551b76e341767c34cb0d6631d5c28cbd4f8ff2a6c758d60d86ada67c5aff6a07de321ff2a749f
6
+ metadata.gz: 4d435acdc8eeb8cb52656d94c19c5d9b9f07934aff31fdfe2eb804089be34f56001a85ac3fa5c2456ee7dfab8a5f0ef7733c379c53d15edc8dfca7f17a0ef7dc
7
+ data.tar.gz: b68473a84285b8b9dfb25f83e002454408efc6475d4edaad0a420472a8b0c461abb13889256f32fb6c3b0c34cdc48688e344faf642e06cb6bc2732f036673436
data/README.md CHANGED
@@ -18,8 +18,12 @@ Capkin
18
18
 
19
19
  ## Use
20
20
 
21
- To upload a new `.apk`:
21
+ To upload a **new** `.apk`:
22
22
 
23
+ **TODO**
24
+
25
+
26
+ To upload a **new version** `.apk`:
23
27
 
24
28
 
25
29
  capkin production
@@ -24,6 +24,7 @@ Gem::Specification.new do |s|
24
24
 
25
25
  s.add_dependency 'thor'
26
26
  s.add_dependency 'paint'
27
+ s.add_dependency 'ruby_apk'
27
28
  s.add_dependency 'google-api-client', '0.9.pre3'
28
29
  s.add_dependency 'googleauth'
29
30
  end
@@ -2,6 +2,7 @@ require 'pry'
2
2
  require 'yaml'
3
3
  require 'paint'
4
4
  require 'fileutils'
5
+ require 'ruby_apk'
5
6
 
6
7
  require 'googleauth'
7
8
  require 'google/apis/androidpublisher_v2'
@@ -16,14 +16,22 @@ module Capkin
16
16
 
17
17
  def read_file
18
18
  @config = YAML.load_file('Capkin')
19
- msg = "✓ Config file OK! '#{@config['app']}' [#{@config['name']}]"
19
+ msg = "✓ Config file OK! '#{@config['app']}'"
20
20
  puts Paint[msg, :green]
21
21
  end
22
22
 
23
23
  def work!(params)
24
24
  check_capkin_file
25
25
  read_file
26
- Capkin::Robot.new(@config, params).upload_apk!
26
+
27
+ robot = Capkin::Robot.new(@config, params)
28
+ case params.join
29
+ when 'list' then robot.list
30
+ when 'info' then robot.info
31
+ else
32
+ puts Paint["Publishing new APK: ./#{source} ➔ '#{@stage}'", :blue]
33
+ robot.upload_apk!
34
+ end
27
35
  end
28
36
  end
29
37
  end
@@ -22,19 +22,18 @@ module Capkin
22
22
 
23
23
  def initialize(config, stage = nil)
24
24
  @app = config['app']
25
- @pkg = config['name']
26
25
  @source ||= File.join(config['build'], "#{@app}.apk")
27
26
  stage = stage.join if stage.respond_to?(:join)
28
27
  @stage = stage.strip.empty? ? STAGE : stage.strip
29
28
 
29
+ @pkg = namespace
30
30
  init_google
31
- puts Paint["Publishing new APK: ./#{source} ➔ '#{@stage}'", :blue]
32
31
  end
33
32
 
34
33
  def init_google
35
34
  # Get authorization!
36
35
  @auth = Google::Auth.get_application_default(SCOPE)
37
- # create a publisher object
36
+ # Create a publisher object
38
37
  @pub = Google::Apis::AndroidpublisherV2::AndroidPublisherService.new
39
38
  @pub.authorization = @auth
40
39
  end
@@ -48,12 +47,54 @@ module Capkin
48
47
  @track ||= pub.get_track(pkg, edit.id, stage)
49
48
  end
50
49
 
50
+ def subject # the apk
51
+ @current_apk ||= Android::Apk.new(source)
52
+ end
53
+
54
+ def app_name
55
+ subject.manifest.label
56
+ end
57
+
58
+ def namespace
59
+ subject.manifest.package_name
60
+ end
61
+
62
+ def current_version
63
+ subject.manifest.version_code
64
+ end
65
+
66
+ def apk_date
67
+ subject.time.strftime('%Y-%m-%d')
68
+ end
69
+
70
+ #
71
+ #
72
+ # pub.list_listings -> Info about the app
73
+ # def all_listings ??
74
+
75
+ #
76
+ # pub.list_apks -> Lists with idcode and sha1
77
+ def list
78
+ puts "➔ Listing all APK! Current #{current_version} - #{apk_date}"
79
+ pub.list_apks(pkg, edit.id).apks.each do |a|
80
+ color = current_version == a.version_code ? :green : :black
81
+ puts Paint["#{a.version_code} ➔ #{a.binary.sha1}", color]
82
+ end
83
+ end
84
+
85
+ def info
86
+ a = pub.get_listing(pkg, edit.id, 'pt-BR')
87
+ puts "\n#{a.title} - #{a.short_description}"
88
+ puts '---'
89
+ puts a.full_description
90
+ puts
91
+ end
92
+
51
93
  # Uploads the APK
52
94
  def upload_apk!
53
95
  @apk = pub.upload_apk(pkg, edit.id, upload_source: source)
54
- puts Paint["✓ APK uploaded! ##{apk.version_code}", :green]
55
96
  track!
56
- puts Paint["✓ All done! ##{apk.inspect}", :green]
97
+ puts Paint["✓ APK uploaded! ##{apk.version_code}", :green]
57
98
  rescue Google::Apis::ClientError => e
58
99
  if e.to_s =~ /apkUpgradeVersionConflict/
59
100
  puts Paint['✓ Version already exists on play store!', :yellow]
@@ -66,7 +107,6 @@ module Capkin
66
107
  # Update the alpha track to point to this APK
67
108
  # You need to use a track object to change this
68
109
  def track!
69
- puts Paint["Pushing APK ➔ '#{track.track}'", :blue]
70
110
  track.update!(version_codes: [apk.version_code])
71
111
 
72
112
  # Save the modified track object
@@ -1,3 +1,4 @@
1
+ # Capkin version
1
2
  module Capkin
2
- VERSION = '0.0.3'
3
+ VERSION = '0.0.5'
3
4
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: capkin
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Marcos Piccinini
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2015-09-19 00:00:00.000000000 Z
12
+ date: 2015-09-22 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: thor
@@ -39,6 +39,20 @@ dependencies:
39
39
  - - ">="
40
40
  - !ruby/object:Gem::Version
41
41
  version: '0'
42
+ - !ruby/object:Gem::Dependency
43
+ name: ruby_apk
44
+ requirement: !ruby/object:Gem::Requirement
45
+ requirements:
46
+ - - ">="
47
+ - !ruby/object:Gem::Version
48
+ version: '0'
49
+ type: :runtime
50
+ prerelease: false
51
+ version_requirements: !ruby/object:Gem::Requirement
52
+ requirements:
53
+ - - ">="
54
+ - !ruby/object:Gem::Version
55
+ version: '0'
42
56
  - !ruby/object:Gem::Dependency
43
57
  name: google-api-client
44
58
  requirement: !ruby/object:Gem::Requirement