handle-system 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: 76c65ae14325b6d728f70dcebf771e1fb751cf79
4
- data.tar.gz: 21672e3d8709029e49c46f5e45b8d384acd08ca5
3
+ metadata.gz: 549796c65d94011546d191cd875f4f5acf6c66ba
4
+ data.tar.gz: 8bb4e27b7fca6429d6f0c2eb918ac286dc1f3950
5
5
  SHA512:
6
- metadata.gz: b70973c2a12ce56edb3ccc497c6a96d3ea8636f7b6fc10e44c0a08a2b57a46c4830526b50f735faba62ae64273e99211fd1432ad1aa58182764e78b5d9a61a5f
7
- data.tar.gz: cf546a453841f775eaae19b5ee5b8cac2cf3dc39fe139b344526f4a55a3750da4d82270c32e6a65a9987f270f6ad38dfdbe6082b88b0d1646ae445d3d3b69f41
6
+ metadata.gz: 3e471e7c08e283574a2439c6e13307841e555632a4dd2021154848a58118b6c39d72b0f7248ac7ebce1d44b37f26bc9f4f9980ec9270e0ab99dd83674c229a7d
7
+ data.tar.gz: 9bcbf9c24969da9722e580eb883a1f90d7b67961867c108e355c66de0a541fa4de149d44b23f76e3bf0c0f3d994cf0692467ea27d561cc951460e729936a06f2
data/README.md CHANGED
@@ -58,4 +58,5 @@ record = conn.resolve_handle('handle.prefix/new.handle')
58
58
 
59
59
  ## History
60
60
 
61
+ - v0.1.1 - Fix error handling (h/t [jcoyne](https://github.com/jcoyne))
61
62
  - v0.1.0 - First stable release
@@ -106,7 +106,7 @@ module Handle
106
106
 
107
107
  def resolve_handle(handle, types=[], indexes=[], auth=true)
108
108
  cmd = File.join(Handle::HOME, 'bin', 'hdl-qresolver')
109
- response = `#{cmd} #{handle} 2>/dev/null`.strip
109
+ response = `#{cmd} #{handle} 2>&1`.strip
110
110
  if response =~ /^Got Response:/
111
111
  response = response.lines.select { |line| line =~ /^\s*index=/ }.join("")
112
112
  result = Handle::Record.from_data(response)
@@ -114,7 +114,7 @@ module Handle
114
114
  result.handle = handle
115
115
  result
116
116
  else
117
- (code, message) = response.lines.to_a.last.scan(/Error\(([0-9]+)\): (.+)$/).flatten
117
+ (code, message) = response.scan(/Error\(([0-9]+)\): (.+)$/).last
118
118
  exception_klass = case code.to_i
119
119
  when 100 then Handle::NotFound
120
120
  else Handle::HandleError
@@ -1,3 +1,3 @@
1
1
  module Handle
2
- VERSION = "0.1.0"
2
+ VERSION = "0.1.1"
3
3
  end
@@ -45,30 +45,41 @@ on_cruby do
45
45
  let(:server) { double(Handle::Java::Native::HSAdapter) }
46
46
  subject { Handle::Command::Connection.new('0.NA/FAKE.ADMIN', 300, 'privkey', 'keypass') }
47
47
 
48
- it "#resolve_handle" do
49
- expect(subject).to receive(:`) { |command|
50
- expect(command).to match(/hdl-qresolver #{fake_handle}/)
51
- "Got Response:\n#{record.to_s}"
52
- }
53
- expect(subject.resolve_handle(fake_handle)).to eq(record)
54
- end
48
+ describe "#resolve_handle" do
49
+ it "is successful" do
50
+ expect(subject).to receive(:`) { |command|
51
+ expect(command).to match(/hdl-qresolver #{fake_handle}/)
52
+ "Got Response:\n#{record.to_s}"
53
+ }
54
+ expect(subject.resolve_handle(fake_handle)).to eq(record)
55
+ end
55
56
 
56
- it "#resolve_handle (not found)" do
57
- expect(subject).to receive(:`) { |command|
58
- expect(command).to match(/hdl-qresolver #{bad_handle}/)
59
- "Got Error:\nError(100): HANDLE NOT FOUND"
60
- }
61
- expect { subject.resolve_handle(bad_handle) }.to raise_error(Handle::NotFound)
62
- end
57
+ it "handles not found" do
58
+ expect(subject).to receive(:`) { |command|
59
+ expect(command).to match(/hdl-qresolver #{bad_handle}/)
60
+ "Got Error:\nError(100): HANDLE NOT FOUND"
61
+ }
62
+ expect { subject.resolve_handle(bad_handle) }.to raise_error(Handle::NotFound)
63
+ end
63
64
 
64
- it "#resolve_handle (other error)" do
65
- expect(subject).to receive(:`) { |command|
66
- expect(command).to match(/hdl-qresolver #{bad_handle}/)
67
- "Got Error:\nError(3): SERVER TOO BUSY"
68
- }
69
- expect { subject.resolve_handle(bad_handle) }.to raise_error(Handle::HandleError)
65
+ it "handles other error" do
66
+ expect(subject).to receive(:`) { |command|
67
+ expect(command).to match(/hdl-qresolver #{bad_handle}/)
68
+ "Got Error:\nError(3): SERVER TOO BUSY"
69
+ }
70
+ expect { subject.resolve_handle(bad_handle) }.to raise_error(Handle::HandleError)
71
+ end
72
+
73
+ it "handles error on stderr (Bad prefix)" do
74
+ expect(subject).to receive(:`) { |command|
75
+ expect(command).to match(/hdl-qresolver #{bad_handle}/)
76
+ "received HDL-UDP response: Error(100): HANDLE NOT FOUND\n\nError: HandleException (SERVICE_NOT_FOUND) Unable to find service for prefix 0.NA/10427.TEXX; prefix resolution response: Error(100): HANDLE NOT FOUND\nHandleException (SERVICE_NOT_FOUND) Unable to find service for prefix 0.NA/10427.TEXX; prefix resolution response: Error(100): HANDLE NOT FOUND\nat net.handle.hdllib.HandleResolver.tryAuthGlobalServiceLookupAndThrowExceptionOnFailure(HandleResolver.java:804)"
77
+ }
78
+ expect { subject.resolve_handle(bad_handle) }.to raise_error(Handle::HandleError)
79
+ end
70
80
  end
71
81
 
82
+
72
83
  it "#create_record" do
73
84
  new_record = subject.create_record(new_handle)
74
85
  expect(new_record.connection).to eq(subject)
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: handle-system
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
  - Michael Klein
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-06-09 00:00:00.000000000 Z
11
+ date: 2015-06-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -123,7 +123,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
123
123
  version: '0'
124
124
  requirements: []
125
125
  rubyforge_project:
126
- rubygems_version: 2.2.2
126
+ rubygems_version: 2.4.8
127
127
  signing_key:
128
128
  specification_version: 4
129
129
  summary: Ruby classes for interfacing with Handle System servers