heroku-shortcuts 0.0.3 → 0.0.4

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: 3a352ec9d15744aa78c7701195cfc0d07ac55996
4
- data.tar.gz: 7838af08c998c66c569eb13c1d58026c43a6555e
3
+ metadata.gz: 10b8e5e542416a3f0eb017852af47b2a08346317
4
+ data.tar.gz: eed1d122317a2a5471d01878ab4925e047c2d9da
5
5
  SHA512:
6
- metadata.gz: a6745933055cfe0e91fc8523a34f85a5565a8066d84a7af99c9192aa5222d4c2ab72b864e963cdad40c01caf9ffad52a4608175f7207834446579f34e227848e
7
- data.tar.gz: ec5eab58a98d85cffec6a731f98506a9488871b15731aa2cc3f0ee87393bec292d2c1f7d9871af231dd3b973cf76f18eb13cbfb884e74f98620d774e81a3942d
6
+ metadata.gz: 0c729dc44cfc3b959b4d5e5462440ad1d12a6fa18313a41946e97c3c0a36b663037f6655ba3ffc8ebf95d41e25fdef64c03dc10ef8f9441a48e5aaffcbf3f63d
7
+ data.tar.gz: 722cc6748649b0940f588d0a7fdf46e1e81f64b0807949252a2f2fd1e41ccb00ede8c94156893eba1efad69b7e03399d184e1a78d8d5b15d409bd42663a4561f
data/bin/h CHANGED
@@ -7,7 +7,7 @@ if File.exists?(path)
7
7
  else
8
8
  puts '~/.heroku-apps.json must be configured for your environments before '\
9
9
  'using `h`'
10
- exit -1
10
+ exit(-1)
11
11
  end
12
12
 
13
13
  action_key = ARGV.shift
@@ -77,12 +77,9 @@ end
77
77
 
78
78
  # Selects a follower
79
79
  def follower_database(env)
80
- dbs = %x[heroku pg:info --app #{env}]
81
- .split("\n")
82
- .grep(/=== HEROKU_POSTGRESQL/)
83
-
84
- follower = dbs.detect { |db| db !~ /DATABASE_URL/ }
85
- return follower.delete('=') if follower
80
+ db_blocks = %x[heroku pg:info --app #{env}].split('=== ')
81
+ follower = db_blocks.find { |db| db.include?('Following') && !db.include?('DATABASE_URL') }
82
+ follower.nil? ? nil : follower.split("\n").first
86
83
  end
87
84
 
88
85
  if not action_key or action_key =~ /help/i
@@ -131,4 +128,4 @@ command_array = ["heroku", real_action, *action_args, app]
131
128
 
132
129
  command = command_array * ' '
133
130
  puts "Executing '#{command}'..."
134
- output = system(command)
131
+ exec(command)
@@ -0,0 +1,25 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ # Usage: ./generate_config [organization]
4
+ #
5
+ # Fetches all available Heroku apps, optionally for a particular organization,
6
+ # and generates JSON you can put in ~/.heroku-apps.json.
7
+ #
8
+ # It naively takes the first letter of every segment of your app name, eg:
9
+ # apps-are-cool -> aac
10
+ # It does nothing to notice collisions.
11
+
12
+ require 'json'
13
+
14
+ org = ARGV[0]
15
+
16
+ args = "--org #{org}" if org
17
+ apps = `heroku apps #{args}`.split("\n")
18
+
19
+ names = apps
20
+ .map {|app| app.split(' ').first}
21
+ .select{ |app| app && app !~ /^=/ && !app.empty? }
22
+ shortcuts = names.map {|app| app.split('-').map {|word| word[0]}.join}
23
+ config = Hash[shortcuts.zip(names)]
24
+
25
+ puts JSON.pretty_generate(config)
@@ -11,7 +11,7 @@ AUTHORS = [
11
11
 
12
12
  Gem::Specification.new do |spec|
13
13
  spec.name = "heroku-shortcuts"
14
- spec.version = "0.0.3"
14
+ spec.version = "0.0.4"
15
15
  spec.authors = AUTHORS.map(&:first)
16
16
  spec.email = AUTHORS.map(&:last)
17
17
  spec.description = %q{Shortcuts for the Heroku CLI}
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: heroku-shortcuts
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Rick Dillon
@@ -11,7 +11,7 @@ authors:
11
11
  autorequire:
12
12
  bindir: bin
13
13
  cert_chain: []
14
- date: 2015-07-20 00:00:00.000000000 Z
14
+ date: 2017-05-04 00:00:00.000000000 Z
15
15
  dependencies: []
16
16
  description: Shortcuts for the Heroku CLI
17
17
  email:
@@ -27,6 +27,7 @@ files:
27
27
  - MIT-LICENSE.txt
28
28
  - README.md
29
29
  - bin/h
30
+ - generate_config
30
31
  - heroku-shortcuts.gemspec
31
32
  homepage: https://github.com/apartmentlist/h
32
33
  licenses:
@@ -48,9 +49,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
48
49
  version: '0'
49
50
  requirements: []
50
51
  rubyforge_project:
51
- rubygems_version: 2.4.6
52
+ rubygems_version: 2.6.10
52
53
  signing_key:
53
54
  specification_version: 4
54
55
  summary: Shortcuts for the Heroku CLI
55
56
  test_files: []
56
- has_rdoc: false