heroku_cli 0.1.2 → 0.2.0

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
- SHA1:
3
- metadata.gz: 6478a119a07ee608a0a8f98d2dcff91934351c4f
4
- data.tar.gz: fc4f72070758af5f4a4e7bd33ae897b07f2ff79e
2
+ SHA256:
3
+ metadata.gz: 2c99382408a106949c0637e1b3cb3d3d04ddc69e39d7135ce782362947047988
4
+ data.tar.gz: 52beb449e3e84438fdecb1a2e483bcf51108fe243e49e8c574c25c2a21e8fd51
5
5
  SHA512:
6
- metadata.gz: b847dc310a70fa29076edf867f2564823c6c967b04401e190b20f5b1b2d501085eb243cccd84b216472f35bd502c6371694eb22c8701aa83370f6f02ad10d3ed
7
- data.tar.gz: 21e3b53a26d763264b238439871275ea163bc0307d5234a81a1afa940abcf0afd07c688bf7d0c70fd71070fe284c4f6b09c1e97a2f939535b4a90a427f3e3228
6
+ metadata.gz: f86d962640cf56d89f574c12cf41f7bfbf7fbe582402e9568df052c62fdf6e07937e4dd59ca3c327f43f30d55fb37f57f16f6628a55194f809f5b35f7c2ce3d9
7
+ data.tar.gz: 7cbec9b0cdc21b9ab4fb23091a2d4519a14990267d16eae50168899556a557c8152093e385252984d6c8631877c5f12b62c44bd589da2996f004254e8e844db4
@@ -0,0 +1,20 @@
1
+ name: Ruby
2
+
3
+ on: [push]
4
+
5
+ jobs:
6
+ build:
7
+
8
+ runs-on: ubuntu-latest
9
+
10
+ steps:
11
+ - uses: actions/checkout@v2
12
+ - name: Set up Ruby 2.6
13
+ uses: actions/setup-ruby@v1
14
+ with:
15
+ ruby-version: 2.6.x
16
+ - name: Build and test with Rake
17
+ run: |
18
+ gem install bundler
19
+ bundle install --jobs 4 --retry 3
20
+ bundle exec rake
data/.ruby-version ADDED
@@ -0,0 +1 @@
1
+ 2.6.6
data/README.md CHANGED
@@ -1,3 +1,5 @@
1
+ ![Ruby](https://github.com/Flightlogger/heroku_cli/workflows/Ruby/badge.svg)
2
+
1
3
  # HerokuCLI
2
4
 
3
5
  This gem will wrap the Heroku CLI so it may be used in ruby code
@@ -31,7 +33,7 @@ staging = HerokuCLI.application('staging')
31
33
  staging.pg.create_follower(production_db)
32
34
  staging.pg.wait
33
35
  new_db = staging.pg.followers.first
34
- staging.promote(new_db)
36
+ staging.pg.promote(new_db, wait: true)
35
37
  ```
36
38
 
37
39
  ## Development
data/heroku_cli.gemspec CHANGED
@@ -10,7 +10,7 @@ Gem::Specification.new do |spec|
10
10
  spec.email = ["rasmus.bergholdt@gmail.com"]
11
11
 
12
12
  spec.summary = %q{A tiny wrapper for Heroku CLI}
13
- spec.description = %q{Wrap the Heroku CLI to make it more accessable from your ruby script}
13
+ spec.description = %q{Wrap the Heroku CLI to make it more accessible from your ruby script}
14
14
  spec.homepage = "https://github.com/Flightlogger/heroku_cli"
15
15
  spec.license = "MIT"
16
16
 
@@ -21,7 +21,7 @@ Gem::Specification.new do |spec|
21
21
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
22
22
  spec.require_paths = ["lib"]
23
23
 
24
- spec.add_development_dependency "bundler", "~> 1.15"
25
- spec.add_development_dependency "rake", "~> 10.0"
24
+ spec.add_development_dependency "bundler", "~> 2.0"
25
+ spec.add_development_dependency "rake", "~> 13.0"
26
26
  spec.add_development_dependency "rspec", "~> 3.0"
27
27
  end
@@ -6,8 +6,6 @@ module HerokuCLI
6
6
  @application = application.is_a?(String) ? Application.new(application) : application
7
7
  end
8
8
 
9
- protected
10
-
11
9
  def heroku(cmd)
12
10
  %x{ heroku #{cmd} -a #{application.name} }
13
11
  end
data/lib/heroku_cli/pg.rb CHANGED
@@ -10,11 +10,15 @@ module HerokuCLI
10
10
  next if stdout.nil? || stdout.length.zero?
11
11
  stdout = stdout.split("\n")
12
12
  stdout[0] = "===#{stdout[0]}"
13
- Database.new(stdout)
13
+ Database.new(stdout, self)
14
14
  end
15
15
  end
16
16
  end
17
17
 
18
+ def reload
19
+ @info = nil
20
+ end
21
+
18
22
  # create a follower database
19
23
  def create_follower(database, options = {})
20
24
  plan = options.delete(:plan) || database.plan
@@ -22,15 +26,18 @@ module HerokuCLI
22
26
  end
23
27
 
24
28
  # Remove the following of a database and put DB into write mode
25
- def un_follow(database)
29
+ def un_follow(database, wait: false)
26
30
  raise "Not a following database #{database.name}" unless database.follower?
31
+
27
32
  heroku "pg:unfollow #{database.url_name} -c #{application.name}"
33
+ wait_for_follow_fork_transformation(database) if wait
28
34
  end
29
35
 
30
36
  # sets DATABASE as your DATABASE_URL
31
- def promote(database)
37
+ def promote(database, wait: false)
32
38
  raise "Database already main #{database.name}" if database.main?
33
- un_follow(database) if database.follower?
39
+
40
+ un_follow(database, wait: wait) if database.follower?
34
41
  heroku "pg:promote #{database.resource_name}"
35
42
  end
36
43
 
@@ -58,5 +65,14 @@ module HerokuCLI
58
65
  def wait
59
66
  heroku 'pg:wait'
60
67
  end
68
+
69
+ def wait_for_follow_fork_transformation(database)
70
+ while database.follower? do
71
+ puts "...wait 10 seconds for DB to change from follower to fork"
72
+ sleep 10
73
+ database.reload
74
+ puts database
75
+ end
76
+ end
61
77
  end
62
78
  end
@@ -2,17 +2,16 @@ module HerokuCLI
2
2
  class PG < Base
3
3
  class Database
4
4
  attr_reader :url_names, :info
5
+ attr_reader :pg
5
6
 
6
- def initialize(info)
7
- @url_names = info.shift
8
- @url_names = @url_names.sub('=== ','').split(',').map(&:strip)
9
- @info = {}
10
- info.each do |line|
11
- k = line.split(':')[0].strip
12
- v = line.split(':')[1..-1].join(':').strip
13
- next if k.nil? || v.nil?
14
- @info[k] = v
15
- end
7
+ def initialize(info, pg = nil)
8
+ @pg = pg
9
+ parse_info(info)
10
+
11
+ end
12
+
13
+ def reload
14
+ parse_info(pg.heroku("pg:info #{url_name}")) if pg.present?
16
15
  end
17
16
 
18
17
  def url_name
@@ -55,11 +54,11 @@ module HerokuCLI
55
54
  end
56
55
 
57
56
  def forks
58
- info['Forks'].split(',').map(&:strip)
57
+ info['Forks']&.split(',')&.map(&:strip)
59
58
  end
60
59
 
61
60
  def forked_from
62
- info['Forked From'].split(',').map(&:strip)
61
+ info['Forked From']&.split(',')&.map(&:strip)
63
62
  end
64
63
 
65
64
  def following
@@ -71,7 +70,7 @@ module HerokuCLI
71
70
  end
72
71
 
73
72
  def fork?
74
- info.key?('Forks')
73
+ !(main? || follower?) && forked_from&.any?
75
74
  end
76
75
 
77
76
  def follower?
@@ -93,6 +92,19 @@ module HerokuCLI
93
92
  def resource_name
94
93
  info['Add-on']
95
94
  end
95
+
96
+ def parse_info(info)
97
+ info = info.split("\n") if info.is_a?(String)
98
+ @url_names = info.shift
99
+ @url_names = @url_names.sub('=== ','').split(',').map(&:strip)
100
+ @info = {}
101
+ info.each do |line|
102
+ k = line.split(':')[0].strip
103
+ v = line.split(':')[1..-1].join(':').strip
104
+ next if k.nil? || v.nil?
105
+ @info[k] = v
106
+ end
107
+ end
96
108
  end
97
109
  end
98
110
  end
@@ -1,3 +1,3 @@
1
1
  module HerokuCLI
2
- VERSION = "0.1.2"
2
+ VERSION = "0.2.0"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: heroku_cli
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Rasmus Bergholdt
8
- autorequire:
8
+ autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2018-05-17 00:00:00.000000000 Z
11
+ date: 2021-07-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -16,28 +16,28 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '1.15'
19
+ version: '2.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.15'
26
+ version: '2.0'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: rake
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: '10.0'
33
+ version: '13.0'
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: '13.0'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: rspec
43
43
  requirement: !ruby/object:Gem::Requirement
@@ -52,15 +52,17 @@ dependencies:
52
52
  - - "~>"
53
53
  - !ruby/object:Gem::Version
54
54
  version: '3.0'
55
- description: Wrap the Heroku CLI to make it more accessable from your ruby script
55
+ description: Wrap the Heroku CLI to make it more accessible from your ruby script
56
56
  email:
57
57
  - rasmus.bergholdt@gmail.com
58
58
  executables: []
59
59
  extensions: []
60
60
  extra_rdoc_files: []
61
61
  files:
62
+ - ".github/workflows/ruby.yml"
62
63
  - ".gitignore"
63
64
  - ".rspec"
65
+ - ".ruby-version"
64
66
  - ".travis.yml"
65
67
  - CODE_OF_CONDUCT.md
66
68
  - Gemfile
@@ -82,7 +84,7 @@ homepage: https://github.com/Flightlogger/heroku_cli
82
84
  licenses:
83
85
  - MIT
84
86
  metadata: {}
85
- post_install_message:
87
+ post_install_message:
86
88
  rdoc_options: []
87
89
  require_paths:
88
90
  - lib
@@ -97,10 +99,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
97
99
  - !ruby/object:Gem::Version
98
100
  version: '0'
99
101
  requirements: []
100
- rubyforge_project:
101
- rubygems_version: 2.6.12
102
- signing_key:
102
+ rubygems_version: 3.0.3
103
+ signing_key:
103
104
  specification_version: 4
104
105
  summary: A tiny wrapper for Heroku CLI
105
106
  test_files: []
106
- has_rdoc: