deis-interactive 0.0.9 → 0.1.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
2
  SHA1:
3
- metadata.gz: 9f70b8ea8d4d5f8476499bc38b7fed8069b172fa
4
- data.tar.gz: 2443ac3c1a94e21b9e9c37c7322298fc8ce3ea1a
3
+ metadata.gz: 3491032ff87b2b4079cfca8ba55079cd3f68e61d
4
+ data.tar.gz: a1aecddd69397bdeb6f47156ddb827b42c8bed80
5
5
  SHA512:
6
- metadata.gz: a899fba6f5a44be98252f4ea108e26010a69f3cfedddf0ba86e6426e8dd685d8cb0b5a366ace3085db3f17d658c38cea20ec5895e20aeed662644f8a479034d8
7
- data.tar.gz: 22206cd17ca9cc1b9132bae8ba5b540ca0c6e7bc02000c1e70e462623ab6dcb58d0811f075c492d4264b28fa8a3869b219ea684e34f42c335708a66fb2fe93ab
6
+ metadata.gz: 65c14a3a90a6ba415650e8daf095eb1d27d33deee6a1e17ce44dc31b087054188e3ee296c3448217ac752eb1f41fde5f587368d70c081f62448dfade60588cbe
7
+ data.tar.gz: b62290b45d5d26fe2a7891605083da8b9f31c8d5f791da2ccd3ac0c9ac3454acf076bfda847b1c4c83a7c9584dcb81b9e8e41e294b31a9bd817f7c3f6cfef150
data/.gitignore CHANGED
@@ -19,3 +19,4 @@ vendor/
19
19
  .idea/
20
20
  binstubs/
21
21
  .byebug_history
22
+ .DS_Store
@@ -4,7 +4,7 @@ require "thor"
4
4
 
5
5
  class DeisRails < Thor
6
6
  desc "console -a APP", "run console on an app"
7
- method_option :app, aliases: ["a"], type: :string, required: true, desc: "Name of the app"
7
+ method_option :app, aliases: ["a"], type: :string, desc: "Name of the app"
8
8
  def console
9
9
  require_relative "../lib/deis-interactive/rails/console"
10
10
  app = options[:app]
@@ -12,7 +12,7 @@ class DeisRails < Thor
12
12
  end
13
13
 
14
14
  desc "exec -a APP COMMAND PARAMS", "run any command on an app"
15
- method_option :app, aliases: ["a"], type: :string, required: true, desc: "Name of the app"
15
+ method_option :app, aliases: ["a"], type: :string, desc: "Name of the app"
16
16
  def exec(command, *params)
17
17
  require_relative "../lib/deis-interactive/rails/exec"
18
18
  app = options[:app]
@@ -20,7 +20,7 @@ class DeisRails < Thor
20
20
  end
21
21
 
22
22
  desc "logs [-n COUNT] [-f] -a APP [-d PROCESS]", "logs on an app"
23
- method_option :app, aliases: ["a"], type: :string, required: true, desc: "Name of the app"
23
+ method_option :app, aliases: ["a"], type: :string, desc: "Name of the app"
24
24
  method_option :process, aliases: ["p"], type: :string, required: false, desc: "Processes to be logged on"
25
25
  method_option :follow, aliases: ["f"], type: :boolean, required: false, desc: "Tail the log"
26
26
  method_option :count, aliases: ["n"], type: :numeric, required: false, desc: "Number of lines"
@@ -21,4 +21,5 @@ Gem::Specification.new do |spec|
21
21
  spec.add_development_dependency "bundler", "~> 1.3"
22
22
  spec.add_development_dependency "thor"
23
23
  spec.add_development_dependency "concurrent-ruby"
24
+ spec.add_development_dependency "rspec"
24
25
  end
@@ -4,8 +4,12 @@ module DeisInteractive
4
4
  attr_reader :app, :process
5
5
 
6
6
  def initialize(app, process)
7
- @app = app
7
+ @app = app || inferred_app
8
8
  @process = process
9
+ if @app.nil?
10
+ puts "App name can't be inferred. Please pass the app name with -a APP"
11
+ exit 1
12
+ end
9
13
  end
10
14
 
11
15
  def processes_pattern
@@ -23,6 +27,28 @@ module DeisInteractive
23
27
  end
24
28
  )
25
29
  end
30
+
31
+ def git_remote_response
32
+ `git remote -v`
33
+ end
34
+
35
+ def deis_remote
36
+ remotes = git_remote_response.split("\n")
37
+ remotes.each do |remote|
38
+ name, url, type = remote.split(" ")
39
+ if name == "deis"
40
+ return url
41
+ end
42
+ end
43
+
44
+ nil
45
+ end
46
+
47
+ def inferred_app
48
+ url = deis_remote
49
+ return nil if url.nil?
50
+ url.split("/").last.gsub(".git", "")
51
+ end
26
52
  end
27
53
  end
28
54
  end
@@ -1,3 +1,3 @@
1
1
  module DeisInteractive
2
- VERSION = "0.0.9"
2
+ VERSION = "0.1.0"
3
3
  end
@@ -0,0 +1,36 @@
1
+ require 'spec_helper'
2
+ require 'deis-interactive/rails/base'
3
+
4
+ describe DeisInteractive::Rails::Base do
5
+ let(:base) { DeisInteractive::Rails::Base.new(nil, nil) }
6
+
7
+ describe "#inferred_app" do
8
+ before do
9
+ allow(base).to receive(:git_remote_response).and_return remotes
10
+ end
11
+
12
+ context "there is deis repo" do
13
+ let(:remotes) { "deis\tssh://git@my.domain.com:2222/my-app.git (fetch)" }
14
+
15
+ it "returns the name" do
16
+ expect(base.inferred_app).to eq "my-app"
17
+ end
18
+ end
19
+
20
+ context "there is no git repo" do
21
+ let(:remotes) { "fatal: Not a git repository (or any of the parent directories): .git" }
22
+
23
+ it "returns nil" do
24
+ expect(base.inferred_app).to be_nil
25
+ end
26
+ end
27
+
28
+ context "there is no deis repo" do
29
+ let(:remotes) { "origin\tssh://git@my.domain.com:2222/my-app.git (fetch)" }
30
+
31
+ it "returns nil" do
32
+ expect(base.inferred_app).to be_nil
33
+ end
34
+ end
35
+ end
36
+ end
@@ -0,0 +1,19 @@
1
+ require 'rubygems'
2
+ require 'bundler/setup'
3
+
4
+ # Requires supporting ruby files with custom matchers and macros, etc,
5
+ # in spec/support/ and its subdirectories.
6
+ Dir[File.expand_path("./spec/support/**/*.rb")].each { |f| require f }
7
+
8
+ # See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
9
+ RSpec.configure do |config|
10
+ config.treat_symbols_as_metadata_keys_with_true_values = true
11
+ config.run_all_when_everything_filtered = true
12
+ config.filter_run :focus
13
+
14
+ # Run specs in random order to surface order dependencies. If you find an
15
+ # order dependency and want to debug it, you can fix the order by providing
16
+ # the seed, which is printed after each run.
17
+ # --seed 1234
18
+ config.order = 'random'
19
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: deis-interactive
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.9
4
+ version: 0.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Phuong Nguyen
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-02-04 00:00:00.000000000 Z
11
+ date: 2018-02-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -52,6 +52,20 @@ dependencies:
52
52
  - - ">="
53
53
  - !ruby/object:Gem::Version
54
54
  version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rspec
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
55
69
  description: Wrapper for kubectl to quickly launch console to a deis app
56
70
  email:
57
71
  - phuongnd08@gmail.com
@@ -71,6 +85,8 @@ files:
71
85
  - lib/deis-interactive/rails/exec.rb
72
86
  - lib/deis-interactive/rails/logs.rb
73
87
  - lib/deis-interactive/version.rb
88
+ - spec/lib/rails/deis-interactive/base_spec.rb
89
+ - spec/spec_helper.rb
74
90
  homepage: https://github.com/phuongnd08/deis-interactive
75
91
  licenses:
76
92
  - MIT
@@ -95,4 +111,6 @@ rubygems_version: 2.4.5.3
95
111
  signing_key:
96
112
  specification_version: 4
97
113
  summary: Wrapper for kubectl to quickly launch console to a deis app
98
- test_files: []
114
+ test_files:
115
+ - spec/lib/rails/deis-interactive/base_spec.rb
116
+ - spec/spec_helper.rb