rcicindela 0.2.0 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. data/README.rdoc +1 -1
  2. data/lib/rcicindela.rb +15 -4
  3. metadata +2 -2
data/README.rdoc CHANGED
@@ -13,7 +13,7 @@ See Also: http://code.google.com/p/cicindela2/
13
13
 
14
14
  Initialization:
15
15
 
16
- cicindela = RCicindela.new('http://localhost/cicindela')
16
+ cicindela = RCicindela.new('localhost', :port => 30000, :timeout => 3)
17
17
 
18
18
  Accumulating data:
19
19
 
data/lib/rcicindela.rb CHANGED
@@ -1,7 +1,15 @@
1
1
  require 'net/http'
2
2
 
3
3
  class RCicindela
4
- VERSION = '0.2.0'
4
+ VERSION = '0.3.0'
5
+
6
+ class APIError < StandardError
7
+ attr_reader :response
8
+ def initialize(response, message = '')
9
+ super(message)
10
+ @response = response
11
+ end
12
+ end
5
13
 
6
14
  attr_reader :host, :port, :base_path, :timeout, :default_params
7
15
 
@@ -45,11 +53,14 @@ class RCicindela
45
53
  end
46
54
 
47
55
  def get(path)
48
- result = nil
49
56
  Net::HTTP.start(host, port) do |http|
50
57
  http.open_timeout = http.read_timeout = timeout
51
- result = http.get(path).body
58
+ response = http.get(path)
59
+ if response.code =~ /^2/
60
+ response.body
61
+ else
62
+ raise APIError.new(response)
63
+ end
52
64
  end
53
- result
54
65
  end
55
66
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rcicindela
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - jugyo
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-05-21 00:00:00 +09:00
12
+ date: 2009-05-27 00:00:00 +09:00
13
13
  default_executable:
14
14
  dependencies: []
15
15