hrk 1.0.3 → 1.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: 53e910ea77cfbd6307926ba296eba33f3a6b8e43
4
- data.tar.gz: 73d1df2e9827bc0eaa1417e3c7f966d3a72b5aff
3
+ metadata.gz: c0e96c9119e9ab6760b61ed413b194342492abe0
4
+ data.tar.gz: d724167d86311058927c2f23071ecabbd660f773
5
5
  SHA512:
6
- metadata.gz: b812509b8e4a20cbc67fc93646a01fc014dab686582baad96d6867ad15303595641d7afe0103298362baeffe3d0030dd0990adadbeaf78a57b6fdbb1fa592953
7
- data.tar.gz: 293229e3d9b9db5f192e82308bb18a299ddd0176bdb79469a092575cd260abd9bbbfdaf8ce64056fe76e0507839c92f30a3c44e974d340affd6d3c3b31daa15f
6
+ metadata.gz: 8e31139f91797f411a26d4e1c845841d2610bccd1cb89cba0313ea4c2ce44b75072fb4de90f86bdeb5de9721d877a220573dcfa8579ba4fe32ed95d00a142a42
7
+ data.tar.gz: e275e2ec264e95371275d171cea050ba64c5f0ef1357437f6d835f621e84a950052396b48b78249cfa4ffc26bc4ba067583255716aaf650627edf010e7955c7b
@@ -7,10 +7,10 @@ module Hrk
7
7
 
8
8
  def call *args
9
9
  if args.include? '--hrk-testing'
10
- @callee.call *(args - ['--hrk-testing'])
10
+ @callee.call(*(args - ['--hrk-testing']))
11
11
  else
12
12
  begin
13
- @callee.call *args
13
+ @callee.call(*args)
14
14
  rescue
15
15
  puts "Error: #{$!.message}"
16
16
  false
@@ -16,6 +16,7 @@ module Hrk
16
16
  def display
17
17
  puts <<-eos
18
18
  Usage:
19
+ hrk
19
20
  hrk command [(-r remote | -a appname)] [options]...
20
21
  hrk [h | help | -h | --help]
21
22
 
@@ -28,6 +29,9 @@ The command is whatever you would give heroku, except (obviously) for the
28
29
  Note that whatever argument and/or options the command is composed of should not
29
30
  be tampered with and passed as is to the heroku toolbelt command.
30
31
 
32
+ You can pass no option to hrk to have it return current memorized remote (the
33
+ command will fail when no remote have been defined).
34
+
31
35
  Options:
32
36
  -h --help Display this screen.
33
37
  -r remote Sets the remote for this command and the following.
@@ -0,0 +1,23 @@
1
+ module Hrk
2
+ module Execute
3
+ class RemoteDisplay
4
+ def initialize fallback
5
+ @env = Hrk::Env.new
6
+ @fallback = fallback
7
+ end
8
+
9
+ def call *args
10
+ if args.empty?
11
+ if @env.remote?
12
+ puts @env.remote.join ' '
13
+ true
14
+ else
15
+ false
16
+ end
17
+ else
18
+ @fallback.call(*args)
19
+ end
20
+ end
21
+ end
22
+ end
23
+ end
data/lib/hrk/execute.rb CHANGED
@@ -4,13 +4,14 @@ module Hrk
4
4
  autoload :Help, 'hrk/execute/help'
5
5
  autoload :ErrorTrap, 'hrk/execute/error_trap'
6
6
  autoload :HerokuDetector, 'hrk/execute/heroku_detector'
7
+ autoload :RemoteDisplay, 'hrk/execute/remote_display'
7
8
 
8
9
  def self.call *args
9
10
  executer.call(*args)
10
11
  end
11
12
 
12
13
  def self.executer
13
- ErrorTrap.new HerokuDetector.new Help.new Command.new
14
+ ErrorTrap.new HerokuDetector.new RemoteDisplay.new Help.new Command.new
14
15
  end
15
16
  end
16
17
  end
data/lib/hrk/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Hrk
2
- VERSION = '1.0.3'
2
+ VERSION = '1.0.4'
3
3
  end
@@ -0,0 +1,47 @@
1
+ require 'spec_helper'
2
+
3
+ RSpec.describe Hrk::Execute::RemoteDisplay do
4
+ describe '#call' do
5
+ let(:fallback) { double }
6
+ let(:fallback_result) { [true, false].sample }
7
+ let(:remote) { [%w(-a -r).sample, "demo#{rand(1..9)}"] }
8
+ let(:there_be_a_remote) { [true, false].sample }
9
+
10
+ subject(:remote_display) { Hrk::Execute::RemoteDisplay.new(fallback) }
11
+
12
+ before { allow_any_instance_of(Hrk::Env).to receive(:remote?).and_return(there_be_a_remote) }
13
+ before { allow_any_instance_of(Hrk::Env).to receive(:remote).and_return(remote) }
14
+ before { allow(fallback).to receive(:call).and_return(fallback_result) }
15
+ before { allow(remote_display).to receive(:puts) }
16
+
17
+ subject!(:result) { remote_display.call(*args) }
18
+
19
+ context 'there are no arguments' do
20
+ let(:args) { [] }
21
+
22
+ context 'but there is a remote' do
23
+ let(:there_be_a_remote) { true }
24
+
25
+ it { expect(result).to eq true }
26
+ it { expect(remote_display).to have_received(:puts).with(remote.join(' ')) }
27
+ it { expect(fallback).not_to have_received(:call) }
28
+ end
29
+
30
+ context 'and no remote' do
31
+ let(:there_be_a_remote) { false }
32
+
33
+ it { expect(result).to eq false }
34
+ it { expect(remote_display).not_to have_received(:puts) }
35
+ it { expect(fallback).not_to have_received(:call) }
36
+ end
37
+ end
38
+
39
+ context 'there are arguments' do
40
+ let(:args) { %W(what#{rand(1..9)} --will we --do -to -- the drunken --whaler?) }
41
+
42
+ it { expect(result).to eq fallback_result }
43
+ it { expect(remote_display).not_to have_received(:puts) }
44
+ it { expect(fallback).to have_received(:call).with(*args) }
45
+ end
46
+ end
47
+ end
@@ -20,12 +20,15 @@ RSpec.describe Hrk::Execute do
20
20
  describe '.executer' do
21
21
  let(:error_trap) { double(Hrk::Execute::ErrorTrap) }
22
22
  let(:heroku_detector) { double(Hrk::Execute::HerokuDetector) }
23
+ let(:remote_display) { double(Hrk::Execute::RemoteDisplay) }
23
24
  let(:help) { double(Hrk::Execute::Help) }
24
25
  let(:command) { double(Hrk::Execute::Command) }
25
- before { allow(Hrk::Execute::ErrorTrap).to receive(:new).with(heroku_detector).and_return(error_trap) }
26
- before { allow(Hrk::Execute::HerokuDetector).to receive(:new).with(help).and_return(heroku_detector) }
27
- before { allow(Hrk::Execute::Help).to receive(:new).with(command).and_return(help) }
26
+
28
27
  before { allow(Hrk::Execute::Command).to receive(:new).and_return(command) }
28
+ before { allow(Hrk::Execute::Help).to receive(:new).with(command).and_return(help) }
29
+ before { allow(Hrk::Execute::RemoteDisplay).to receive(:new).with(help).and_return(remote_display) }
30
+ before { allow(Hrk::Execute::HerokuDetector).to receive(:new).with(remote_display).and_return(heroku_detector) }
31
+ before { allow(Hrk::Execute::ErrorTrap).to receive(:new).with(heroku_detector).and_return(error_trap) }
29
32
 
30
33
  it { expect(Hrk::Execute.executer).to eq error_trap }
31
34
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hrk
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.3
4
+ version: 1.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Michel Belleville
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-01-16 00:00:00.000000000 Z
11
+ date: 2015-01-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rspec
@@ -169,6 +169,7 @@ files:
169
169
  - lib/hrk/execute/error_trap.rb
170
170
  - lib/hrk/execute/help.rb
171
171
  - lib/hrk/execute/heroku_detector.rb
172
+ - lib/hrk/execute/remote_display.rb
172
173
  - lib/hrk/heroku.rb
173
174
  - lib/hrk/version.rb
174
175
  - spec/hrk/env_spec.rb
@@ -176,6 +177,7 @@ files:
176
177
  - spec/hrk/execute/error_trap_spec.rb
177
178
  - spec/hrk/execute/help_spec.rb
178
179
  - spec/hrk/execute/heroku_detector_spec.rb
180
+ - spec/hrk/execute/remote_display_spec.rb
179
181
  - spec/hrk/execute_spec.rb
180
182
  - spec/hrk/heroku_spec.rb
181
183
  - spec/spec_helper.rb