play_time 0.1.0 → 0.1.1

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: e23c57d7102a28cbe8b3554651891b0a5b6bff67
4
- data.tar.gz: 813f6b865d38e05b6998991d307c8fa8c973a0e6
3
+ metadata.gz: fc7b8bd352e9255fdce7a7db0f06a82291d01073
4
+ data.tar.gz: 456df0cc83b507c0b67f0cbc9c478e5a416e91fd
5
5
  SHA512:
6
- metadata.gz: 90cd9ec3380d972328fef4105a8729b57fd39aabc9c71269ecac47ed51938b3b18daba3b30adb24545a9fe5d7679dd633999f17ad8fcb848962aa2ac0325d7df
7
- data.tar.gz: 841c881c775d74055937b3e3be0d96ce9dc68a883dae45440023ea01f51d9664a67297c5c383a23db913ab8df5af08383d83db93278a2346e8fb7ff696f825ac
6
+ metadata.gz: 90a06320ca651e9f5c3cec695d9d919106243b1bc0c64f97e115374d6285068551427f05c07fb84e87383f17b65342fbcd04ee156cf6b788b3bd6166a97a039d
7
+ data.tar.gz: aade25ec7ac0e023f9007a314336eccd7462f44e2bcc502c2c631532bf38bb9eab80ae279ae13420008b09887e03bb3866f01546d9092b3d358824047156e3ee
data/.travis.yml ADDED
@@ -0,0 +1,20 @@
1
+ script: "bundle exec rake spec"
2
+
3
+ rvm:
4
+ - 2.0.0
5
+ - 2.1
6
+ - 2.2.0-preview1
7
+ - ruby-head
8
+ - jruby
9
+ - rbx
10
+
11
+ env:
12
+ - PLAY_TIME_CONFIG_PATH=spec/support/config/default.yml
13
+
14
+ matrix:
15
+ allow_failures:
16
+ - rvm: 2.2.0-preview1
17
+ - rvm: ruby-head
18
+ - rvm: jruby
19
+ - rvm: rbx
20
+ fast_finish: true
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
- # PlayTime
1
+ # PlayTime [![Build Status](https://travis-ci.org/is-devteam/play_time.svg?branch=master)](https://travis-ci.org/is-devteam/play_time)
2
2
 
3
- TODO: Write a gem description
3
+ PlayTime simplifies deploying apps to the Google Play Store.
4
4
 
5
5
  ## Installation
6
6
 
@@ -18,11 +18,81 @@ Or install it yourself as:
18
18
 
19
19
  $ gem install play_time
20
20
 
21
+ Then add the following line to your Rakefile. If you don't have a Rakefile, just create it.
22
+
23
+ require 'line_change/tasks'
24
+
25
+ Then run the rake task to create a config file.
26
+
27
+ $ rake play_time:install
28
+ # Generating a new config file: config/play_time.yml
29
+
21
30
  ## Usage
22
31
 
23
- TODO: Write usage instructions here
32
+ ### Getting access to your Play account
33
+
34
+ First you will need a Google Play developer account. After this is setup you will need to create a Google developer project <https://console.developers.google.com>. This is the project that PlayTime will be using to access your Google Play developer account. Once your project is created you will need to enable the Google Play Android Developer API. And then also create a new client id as a service account. This will create and download a P12 key for you and present you with the P12 passphrase, (these will be needed below).
35
+
36
+ **NOTE** You should probably change this passphrase, see <http://wiki.bsdserver.nl/doku.php?id=misc:ssl:sslchangepwonpkcs12cert>.
37
+
38
+ ### Fill out all of the config fields.
39
+
40
+ ```yml
41
+ package_name: # package name for your google play app
42
+ secret_path: # fill path to secret.p12
43
+ secret_passphrase: # passphrase for secert.p12
44
+ apk_path: # path to apk file
45
+ client_name: # This can be anything (as far as we can tell)
46
+ client_version: # This can be anything as well
47
+ issuer: # emaill address generated by your service account (<somestuff>@developer.gserviceaccount.com)
48
+ ```
49
+
50
+ **NOTE:** The apk_path can be a regular expression and PlayTime::Apk.load will find the most recent file using **mtime**. `mtime` is not always the most recent file and can change depending how your disk is mounted. Make sure that this is what you want. If not you can hard code your path each time you are uploading.
51
+
52
+ Check out your new rake commands:
53
+
54
+ $ rake -T
55
+ rake play_time:promote:alpha[version_code] # Promote apk version code to alpha
56
+ rake play_time:promote:beta[version_code] # Promote apk version code to beta
57
+ rake play_time:promote:production[version_code] # Promote apk version code to production
58
+ rake play_time:promote:rollout[version_code] # Promote apk version code to rollout
59
+ rake play_time:upload:alpha # Uploads apk to alpha
60
+ rake play_time:upload:beta # Uploads apk to beta
61
+ rake play_time:upload:production # Uploads apk to production
62
+ rake play_time:upload:rollout # Uploads apk to rollout
63
+
64
+ ### Upload
65
+
66
+ The upload namespace will attempt to upload the latest apk specified at the apk path to the track that you specify.
67
+
68
+ ### Promote
69
+
70
+ Promote will remove the version code from its existing track and then add that version code to the new track.
71
+
72
+ **Note** if the version code does not exist on a current track, it will raise an error.
73
+
74
+ ## Using without rake
75
+
76
+ ```ruby
77
+ require 'play_time'
78
+
79
+ PlayTime.install
80
+
81
+ # modify the config file
82
+
83
+ PlayTime::Track::TRACKS
84
+ > ['alpha', 'beta', 'rollout', 'production']
85
+
86
+ track = PlayTime::Track::ALPHA
87
+ PlayTime.upload(track)
88
+
89
+ PlayTime.promote(PlayTime::Track::BETA, <version_code>)
90
+ ```
91
+
92
+ ## TODO
24
93
 
25
94
  * add promotion syntax like `rake play_time:promote['alpha', 'beta']`
95
+ * Add more precise steps for linking your Google Play account and Google Developer accounts.
26
96
 
27
97
  ## Contributing
28
98
 
data/lib/play_time/apk.rb CHANGED
@@ -2,18 +2,33 @@ require 'google/api_client'
2
2
 
3
3
  module PlayTime
4
4
  class Apk
5
+ class FileNotFound < StandardError; end
6
+
5
7
  MIME_TYPE = 'application/vnd.android.package-archive'.freeze
6
8
 
7
9
  class << self
8
10
  def load
9
- Google::APIClient::UploadIO.new(path, MIME_TYPE)
11
+ Google::APIClient::UploadIO.new(most_recent_modified_file_path, MIME_TYPE)
10
12
  end
11
13
 
12
14
  private
13
15
 
14
- def path
16
+ def file_path
15
17
  PlayTime.configuration.apk_path
16
18
  end
19
+
20
+ def most_recent_modified_file_path
21
+ @most_recent_modified_file_path ||=
22
+ begin
23
+ file = Dir[file_path].map{|file_path| File.open(file_path) }.sort_by(&:mtime).last
24
+
25
+ if file
26
+ file.path
27
+ else
28
+ raise FileNotFound, "No such file or directory: #{file_path}"
29
+ end
30
+ end
31
+ end
17
32
  end
18
33
  end
19
34
  end
@@ -1,3 +1,3 @@
1
1
  module PlayTime
2
- VERSION = "0.1.0"
2
+ VERSION = "0.1.1"
3
3
  end
data/spec/lib/apk_spec.rb CHANGED
@@ -1,11 +1,16 @@
1
1
  describe PlayTime::Apk do
2
2
  describe '#load' do
3
- let(:path) { 'path/to/apk' }
3
+ let(:path) { 'path/to/*apk' }
4
+ let(:old_file) { instance_double(File, mtime: Time.now - 10, path: 'should not get here') }
5
+ let(:file) { instance_double(File, mtime: Time.now, path: 'newest/file') }
4
6
 
5
7
  subject { PlayTime::Apk.load }
6
8
 
7
9
  before do
8
10
  allow(PlayTime.configuration).to receive(:apk_path).and_return(path)
11
+ allow(File).to receive(:open).with(file.path).and_return(file)
12
+ allow(File).to receive(:open).with(old_file.path).and_return(old_file)
13
+ allow(Dir).to receive(:[]).and_return([file.path, old_file.path])
9
14
  end
10
15
 
11
16
  it 'returns a Google::APIClient::UploadIO with the path and MIME_TYPE' do
@@ -13,7 +18,29 @@ describe PlayTime::Apk do
13
18
 
14
19
  subject
15
20
 
16
- expect(Google::APIClient::UploadIO).to have_received(:new).with(path, PlayTime::Apk::MIME_TYPE)
21
+ expect(Google::APIClient::UploadIO).to have_received(:new).with('newest/file', PlayTime::Apk::MIME_TYPE)
22
+ end
23
+
24
+ it "searches the directory for the path" do
25
+ subject
26
+
27
+ expect(Dir).to have_received(:[]).with path
28
+ end
29
+
30
+ context 'when file not found' do
31
+ before do
32
+ allow(Dir).to receive(:[]).and_return([])
33
+ end
34
+
35
+ it 'raises an error' do
36
+ expect {
37
+ subject
38
+ }.to raise_error(PlayTime::Apk::FileNotFound, "No such file or directory: #{path}")
39
+ end
40
+ end
41
+
42
+ after do
43
+ PlayTime::Apk.instance_variable_set(:@most_recent_modified_file_path, nil)
17
44
  end
18
45
  end
19
46
  end
@@ -6,7 +6,9 @@ describe 'play_time tasks' do
6
6
  it 'uploads an apk to production' do
7
7
  allow(PlayTime).to receive(:upload)
8
8
 
9
- Rake::Task["play_time:upload:#{track}"].invoke
9
+ without_output do
10
+ Rake::Task["play_time:upload:#{track}"].invoke
11
+ end
10
12
 
11
13
  expect(PlayTime).to have_received(:upload).with(track)
12
14
  end
@@ -51,7 +53,9 @@ describe 'play_time tasks' do
51
53
 
52
54
  context "when config file doesn't exist" do
53
55
  it 'generates an exmaple config file' do
54
- Rake::Task['play_time:install'].invoke
56
+ without_output do
57
+ Rake::Task['play_time:install'].invoke
58
+ end
55
59
 
56
60
  expect(File).to exist(config_file)
57
61
  expect(open(File.expand_path("lib/play_time/templates/play_time.yml")).read). to eq(open(config_file).read)
@@ -60,16 +64,20 @@ describe 'play_time tasks' do
60
64
 
61
65
  context "when config file already exists" do
62
66
  before do
63
- Rake::Task['play_time:install'].invoke
64
- Rake::Task['play_time:install'].reenable
67
+ without_output do
68
+ Rake::Task['play_time:install'].invoke
69
+ Rake::Task['play_time:install'].reenable
70
+ end
65
71
  end
66
72
 
67
73
  it "doesn't do anything" do
68
74
  sleep(0.5)
69
75
 
70
- expect do
71
- Rake::Task['play_time:install'].invoke
72
- end.not_to change { File.open(PlayTime.config_path).mtime }
76
+ expect {
77
+ without_output do
78
+ Rake::Task['play_time:install'].invoke
79
+ end
80
+ }.not_to change { File.open(PlayTime.config_path).mtime }
73
81
  end
74
82
  end
75
83
  end
@@ -63,7 +63,8 @@ describe PlayTime, if: PlayTime.config_path.end_with?('default.yml') do
63
63
  end
64
64
 
65
65
  it 'creates the config' do
66
- subject
66
+ without_output { subject }
67
+
67
68
  expect(PlayTime::Configuration).to have_received(:create_config).with('config', PlayTime.config_path)
68
69
  end
69
70
  end
data/spec/spec_helper.rb CHANGED
@@ -18,7 +18,14 @@ require 'did_you_mean'
18
18
  # users commonly want.
19
19
  #
20
20
  # See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
21
+
22
+ # require any files in spec/support/
23
+ Dir["#{__dir__}/support/**/*.rb"].each { |f| require f }
24
+
21
25
  RSpec.configure do |config|
26
+ # supress stdout
27
+ config.include StdoutHelper
28
+
22
29
  # rspec-expectations config goes here. You can use an alternate
23
30
  # assertion/expectation library such as wrong or the stdlib/minitest
24
31
  # assertions if you prefer.
@@ -0,0 +1,8 @@
1
+ module StdoutHelper
2
+ def without_output
3
+ org, $stdout = $stdout, double(:stdout, write: nil)
4
+ yield
5
+ ensure
6
+ $stdout = org
7
+ end
8
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: play_time
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - IS Dev team
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-10-28 00:00:00.000000000 Z
11
+ date: 2014-10-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: google-api-client
@@ -76,6 +76,7 @@ files:
76
76
  - ".gitignore"
77
77
  - ".rspec"
78
78
  - ".ruby-version"
79
+ - ".travis.yml"
79
80
  - Gemfile
80
81
  - LICENSE.txt
81
82
  - README.md
@@ -103,6 +104,7 @@ files:
103
104
  - spec/play_time_spec.rb
104
105
  - spec/spec_helper.rb
105
106
  - spec/support/config/default.yml
107
+ - spec/support/helpers/stdout_helper.rb
106
108
  homepage: https://github.com/is-devteam/play_time
107
109
  licenses:
108
110
  - MIT
@@ -139,3 +141,4 @@ test_files:
139
141
  - spec/play_time_spec.rb
140
142
  - spec/spec_helper.rb
141
143
  - spec/support/config/default.yml
144
+ - spec/support/helpers/stdout_helper.rb