swd 0.0.7 → 0.0.8

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore CHANGED
@@ -14,7 +14,7 @@ tmtags
14
14
  *.swp
15
15
 
16
16
  ## PROJECT::GENERAL
17
- coverage
17
+ coverage*
18
18
  rdoc
19
19
  pkg
20
20
 
data/.travis.yml CHANGED
@@ -2,5 +2,4 @@ rvm:
2
2
  - 1.8.7
3
3
  - 1.9.2
4
4
  - 1.9.3
5
- - jruby
6
- - ree
5
+ - jruby
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- swd (0.0.4)
4
+ swd (0.0.7)
5
5
  activesupport (>= 3)
6
6
  attr_required (>= 0.0.3)
7
7
  httpclient (>= 2.2.1)
@@ -11,37 +11,44 @@ PATH
11
11
  GEM
12
12
  remote: http://rubygems.org/
13
13
  specs:
14
- activesupport (3.1.0)
14
+ activesupport (3.2.1)
15
+ i18n (~> 0.6)
15
16
  multi_json (~> 1.0)
16
17
  addressable (2.2.6)
17
18
  attr_required (0.0.3)
18
- crack (0.1.8)
19
+ configatron (2.9.0)
20
+ yamler (>= 0.1.0)
21
+ cover_me (1.2.0)
22
+ configatron
23
+ hashie
24
+ crack (0.3.1)
19
25
  diff-lcs (1.1.3)
20
- httpclient (2.2.1)
26
+ hashie (1.2.0)
27
+ httpclient (2.2.4)
21
28
  i18n (0.6.0)
22
- json (1.5.4)
23
- multi_json (1.0.3)
24
- rake (0.9.2)
25
- rcov (0.9.10)
26
- rspec (2.6.0)
27
- rspec-core (~> 2.6.0)
28
- rspec-expectations (~> 2.6.0)
29
- rspec-mocks (~> 2.6.0)
30
- rspec-core (2.6.4)
31
- rspec-expectations (2.6.0)
29
+ json (1.6.5)
30
+ multi_json (1.0.4)
31
+ rake (0.9.2.2)
32
+ rspec (2.8.0)
33
+ rspec-core (~> 2.8.0)
34
+ rspec-expectations (~> 2.8.0)
35
+ rspec-mocks (~> 2.8.0)
36
+ rspec-core (2.8.0)
37
+ rspec-expectations (2.8.0)
32
38
  diff-lcs (~> 1.1.2)
33
- rspec-mocks (2.6.0)
34
- webmock (1.7.5)
35
- addressable (> 2.2.5, ~> 2.2)
39
+ rspec-mocks (2.8.0)
40
+ webmock (1.7.10)
41
+ addressable (~> 2.2, > 2.2.5)
36
42
  crack (>= 0.1.7)
43
+ yamler (0.1.0)
37
44
 
38
45
  PLATFORMS
39
46
  ruby
40
47
 
41
48
  DEPENDENCIES
49
+ cover_me (>= 1.2.0)
42
50
  jruby-openssl (>= 0.7)
43
51
  rake (>= 0.8)
44
- rcov (>= 0.9)
45
52
  rspec (>= 2)
46
53
  swd!
47
54
  webmock (>= 1.6.2)
data/Rakefile CHANGED
@@ -1,11 +1,19 @@
1
- require 'bundler/gem_tasks'
1
+ require 'bundler'
2
+ Bundler::GemHelper.install_tasks
2
3
 
3
4
  require 'rspec/core/rake_task'
4
5
  RSpec::Core::RakeTask.new(:spec)
5
6
 
6
- RSpec::Core::RakeTask.new(:rcov) do |spec|
7
- spec.rcov = true
8
- spec.rcov_opts = ['-Ilib -Ispec --exclude spec,gems']
7
+ if RUBY_VERSION >= '1.9'
8
+ require 'cover_me'
9
+ CoverMe.config do |c|
10
+ c.file_pattern = /(#{CoverMe.config.project.root}\/lib\/.+\.rb)/i
11
+ end
12
+ else
13
+ RSpec::Core::RakeTask.new(:rcov) do |spec|
14
+ spec.rcov = true
15
+ spec.rcov_opts = ['-Ilib -Ispec --exclude spec,gems']
16
+ end
9
17
  end
10
18
 
11
19
  task :default => :spec
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.7
1
+ 0.0.8
data/lib/swd.rb CHANGED
@@ -42,6 +42,18 @@ module SWD
42
42
  self.debugging = original
43
43
  end
44
44
  self.debugging = false
45
+
46
+ def self.http_client
47
+ _http_client_ = HTTPClient.new(
48
+ :agent_name => "SWD (#{VERSION})"
49
+ )
50
+ _http_client_.request_filter << Debugger::RequestFilter.new if SWD.debugging?
51
+ http_config.try(:call, _http_client_)
52
+ _http_client_
53
+ end
54
+ def self.http_config(&block)
55
+ @@http_config ||= block
56
+ end
45
57
  end
46
58
 
47
59
  require 'swd/cache'
data/lib/swd/resource.rb CHANGED
@@ -22,7 +22,7 @@ module SWD
22
22
  def discover!(cache_options = {})
23
23
  SWD.cache.fetch(cache_key, cache_options) do
24
24
  handle_response do
25
- http_client.get_content endpoint.to_s
25
+ SWD.http_client.get_content endpoint.to_s
26
26
  end
27
27
  end
28
28
  end
@@ -38,14 +38,6 @@ module SWD
38
38
 
39
39
  private
40
40
 
41
- def http_client
42
- _http_client_ = HTTPClient.new(
43
- :agent_name => "SWD (#{VERSION})"
44
- )
45
- _http_client_.request_filter << Debugger::RequestFilter.new if SWD.debugging?
46
- _http_client_
47
- end
48
-
49
41
  def handle_response
50
42
  res = JSON.parse(yield).with_indifferent_access
51
43
  if redirect = res[:SWD_service_redirect]
data/spec/spec_helper.rb CHANGED
@@ -1,3 +1,10 @@
1
+ if RUBY_VERSION >= '1.9'
2
+ require 'cover_me'
3
+ at_exit do
4
+ CoverMe.complete!
5
+ end
6
+ end
7
+
1
8
  require 'rspec'
2
9
  require 'swd'
3
10
 
@@ -70,41 +70,41 @@ describe SWD::Resource do
70
70
  end
71
71
 
72
72
  describe 'error handling' do
73
- let(:http_client) { resource.send(:http_client) }
74
73
  before do
75
74
  module SWD
76
- class Resource
77
- def http_client
78
- @http_client ||= HTTPClient.new
75
+ class << self
76
+ def http_client_with_cached
77
+ @http_client ||= http_client_without_cached
79
78
  end
79
+ alias_method_chain :http_client, :cached
80
80
  end
81
81
  end
82
82
  end
83
83
 
84
84
  context 'when invalid SSL cert' do
85
85
  it do
86
- http_client.should_receive(:get_content).and_raise(OpenSSL::SSL::SSLError)
86
+ SWD.http_client.should_receive(:get_content).and_raise(OpenSSL::SSL::SSLError)
87
87
  expect { res = resource.discover! }.should raise_error SWD::Exception
88
88
  end
89
89
  end
90
90
 
91
91
  context 'when invalid JSON' do
92
92
  it do
93
- http_client.should_receive(:get_content).and_raise(JSON::ParserError)
93
+ SWD.http_client.should_receive(:get_content).and_raise(JSON::ParserError)
94
94
  expect { res = resource.discover! }.should raise_error SWD::Exception
95
95
  end
96
96
  end
97
97
 
98
98
  context 'when SocketError' do
99
99
  it do
100
- http_client.should_receive(:get_content).and_raise(SocketError)
100
+ SWD.http_client.should_receive(:get_content).and_raise(SocketError)
101
101
  expect { res = resource.discover! }.should raise_error SWD::Exception
102
102
  end
103
103
  end
104
104
 
105
105
  context 'when BadResponseError without response' do
106
106
  it do
107
- http_client.should_receive(:get_content).and_raise(HTTPClient::BadResponseError.new(''))
107
+ SWD.http_client.should_receive(:get_content).and_raise(HTTPClient::BadResponseError.new(''))
108
108
  expect { res = resource.discover! }.should raise_error SWD::Exception
109
109
  end
110
110
  end
data/spec/swd_spec.rb CHANGED
@@ -43,4 +43,17 @@ describe SWD do
43
43
  SWD.debugging?.should be_true
44
44
  end
45
45
  end
46
+
47
+ describe '.http_client' do
48
+ context 'with http_config' do
49
+ before do
50
+ SWD.http_config do |config|
51
+ config.ssl_config.verify_mode = OpenSSL::SSL::VERIFY_NONE
52
+ end
53
+ end
54
+ it 'should configure http_client' do
55
+ SWD.http_client.ssl_config.verify_mode.should == OpenSSL::SSL::VERIFY_NONE
56
+ end
57
+ end
58
+ end
46
59
  end
data/swd.gemspec CHANGED
@@ -16,7 +16,11 @@ Gem::Specification.new do |s|
16
16
  s.add_runtime_dependency "i18n"
17
17
  s.add_runtime_dependency "attr_required", ">= 0.0.3"
18
18
  s.add_development_dependency "rake", ">= 0.8"
19
- s.add_development_dependency "rcov", ">= 0.9"
19
+ if RUBY_VERSION >= '1.9'
20
+ s.add_development_dependency "cover_me", ">= 1.2.0"
21
+ else
22
+ s.add_development_dependency "rcov", ">= 0.9"
23
+ end
20
24
  s.add_development_dependency "rspec", ">= 2"
21
25
  s.add_development_dependency "webmock", ">= 1.6.2"
22
26
  end
metadata CHANGED
@@ -1,126 +1,122 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: swd
3
- version: !ruby/object:Gem::Version
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.8
4
5
  prerelease:
5
- version: 0.0.7
6
6
  platform: ruby
7
- authors:
7
+ authors:
8
8
  - nov matake
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
-
13
- date: 2011-09-13 00:00:00 Z
14
- dependencies:
15
- - !ruby/object:Gem::Dependency
12
+ date: 2012-02-06 00:00:00.000000000Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
16
15
  name: json
17
- prerelease: false
18
- requirement: &id001 !ruby/object:Gem::Requirement
16
+ requirement: &70323199319380 !ruby/object:Gem::Requirement
19
17
  none: false
20
- requirements:
21
- - - ">="
22
- - !ruby/object:Gem::Version
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
23
21
  version: 1.4.3
24
22
  type: :runtime
25
- version_requirements: *id001
26
- - !ruby/object:Gem::Dependency
27
- name: httpclient
28
23
  prerelease: false
29
- requirement: &id002 !ruby/object:Gem::Requirement
24
+ version_requirements: *70323199319380
25
+ - !ruby/object:Gem::Dependency
26
+ name: httpclient
27
+ requirement: &70323199619160 !ruby/object:Gem::Requirement
30
28
  none: false
31
- requirements:
32
- - - ">="
33
- - !ruby/object:Gem::Version
29
+ requirements:
30
+ - - ! '>='
31
+ - !ruby/object:Gem::Version
34
32
  version: 2.2.1
35
33
  type: :runtime
36
- version_requirements: *id002
37
- - !ruby/object:Gem::Dependency
38
- name: activesupport
39
34
  prerelease: false
40
- requirement: &id003 !ruby/object:Gem::Requirement
35
+ version_requirements: *70323199619160
36
+ - !ruby/object:Gem::Dependency
37
+ name: activesupport
38
+ requirement: &70323199704860 !ruby/object:Gem::Requirement
41
39
  none: false
42
- requirements:
43
- - - ">="
44
- - !ruby/object:Gem::Version
45
- version: "3"
40
+ requirements:
41
+ - - ! '>='
42
+ - !ruby/object:Gem::Version
43
+ version: '3'
46
44
  type: :runtime
47
- version_requirements: *id003
48
- - !ruby/object:Gem::Dependency
49
- name: i18n
50
45
  prerelease: false
51
- requirement: &id004 !ruby/object:Gem::Requirement
46
+ version_requirements: *70323199704860
47
+ - !ruby/object:Gem::Dependency
48
+ name: i18n
49
+ requirement: &70323199818480 !ruby/object:Gem::Requirement
52
50
  none: false
53
- requirements:
54
- - - ">="
55
- - !ruby/object:Gem::Version
56
- version: "0"
51
+ requirements:
52
+ - - ! '>='
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
57
55
  type: :runtime
58
- version_requirements: *id004
59
- - !ruby/object:Gem::Dependency
60
- name: attr_required
61
56
  prerelease: false
62
- requirement: &id005 !ruby/object:Gem::Requirement
57
+ version_requirements: *70323199818480
58
+ - !ruby/object:Gem::Dependency
59
+ name: attr_required
60
+ requirement: &70323202583220 !ruby/object:Gem::Requirement
63
61
  none: false
64
- requirements:
65
- - - ">="
66
- - !ruby/object:Gem::Version
62
+ requirements:
63
+ - - ! '>='
64
+ - !ruby/object:Gem::Version
67
65
  version: 0.0.3
68
66
  type: :runtime
69
- version_requirements: *id005
70
- - !ruby/object:Gem::Dependency
71
- name: rake
72
67
  prerelease: false
73
- requirement: &id006 !ruby/object:Gem::Requirement
68
+ version_requirements: *70323202583220
69
+ - !ruby/object:Gem::Dependency
70
+ name: rake
71
+ requirement: &70323203381700 !ruby/object:Gem::Requirement
74
72
  none: false
75
- requirements:
76
- - - ">="
77
- - !ruby/object:Gem::Version
78
- version: "0.8"
73
+ requirements:
74
+ - - ! '>='
75
+ - !ruby/object:Gem::Version
76
+ version: '0.8'
79
77
  type: :development
80
- version_requirements: *id006
81
- - !ruby/object:Gem::Dependency
82
- name: rcov
83
78
  prerelease: false
84
- requirement: &id007 !ruby/object:Gem::Requirement
79
+ version_requirements: *70323203381700
80
+ - !ruby/object:Gem::Dependency
81
+ name: cover_me
82
+ requirement: &70323203676500 !ruby/object:Gem::Requirement
85
83
  none: false
86
- requirements:
87
- - - ">="
88
- - !ruby/object:Gem::Version
89
- version: "0.9"
84
+ requirements:
85
+ - - ! '>='
86
+ - !ruby/object:Gem::Version
87
+ version: 1.2.0
90
88
  type: :development
91
- version_requirements: *id007
92
- - !ruby/object:Gem::Dependency
93
- name: rspec
94
89
  prerelease: false
95
- requirement: &id008 !ruby/object:Gem::Requirement
90
+ version_requirements: *70323203676500
91
+ - !ruby/object:Gem::Dependency
92
+ name: rspec
93
+ requirement: &70323203882660 !ruby/object:Gem::Requirement
96
94
  none: false
97
- requirements:
98
- - - ">="
99
- - !ruby/object:Gem::Version
100
- version: "2"
95
+ requirements:
96
+ - - ! '>='
97
+ - !ruby/object:Gem::Version
98
+ version: '2'
101
99
  type: :development
102
- version_requirements: *id008
103
- - !ruby/object:Gem::Dependency
104
- name: webmock
105
100
  prerelease: false
106
- requirement: &id009 !ruby/object:Gem::Requirement
101
+ version_requirements: *70323203882660
102
+ - !ruby/object:Gem::Dependency
103
+ name: webmock
104
+ requirement: &70323204209540 !ruby/object:Gem::Requirement
107
105
  none: false
108
- requirements:
109
- - - ">="
110
- - !ruby/object:Gem::Version
106
+ requirements:
107
+ - - ! '>='
108
+ - !ruby/object:Gem::Version
111
109
  version: 1.6.2
112
110
  type: :development
113
- version_requirements: *id009
111
+ prerelease: false
112
+ version_requirements: *70323204209540
114
113
  description: SWD (Simple Web Discovery) Client Library
115
- email:
114
+ email:
116
115
  - nov@matake.jp
117
116
  executables: []
118
-
119
117
  extensions: []
120
-
121
118
  extra_rdoc_files: []
122
-
123
- files:
119
+ files:
124
120
  - .gitignore
125
121
  - .rspec
126
122
  - .travis.yml
@@ -150,32 +146,29 @@ files:
150
146
  - swd.gemspec
151
147
  homepage: https://github.com/nov/swd
152
148
  licenses: []
153
-
154
149
  post_install_message:
155
150
  rdoc_options: []
156
-
157
- require_paths:
151
+ require_paths:
158
152
  - lib
159
- required_ruby_version: !ruby/object:Gem::Requirement
153
+ required_ruby_version: !ruby/object:Gem::Requirement
160
154
  none: false
161
- requirements:
162
- - - ">="
163
- - !ruby/object:Gem::Version
164
- version: "0"
165
- required_rubygems_version: !ruby/object:Gem::Requirement
155
+ requirements:
156
+ - - ! '>='
157
+ - !ruby/object:Gem::Version
158
+ version: '0'
159
+ required_rubygems_version: !ruby/object:Gem::Requirement
166
160
  none: false
167
- requirements:
168
- - - ">="
169
- - !ruby/object:Gem::Version
170
- version: "0"
161
+ requirements:
162
+ - - ! '>='
163
+ - !ruby/object:Gem::Version
164
+ version: '0'
171
165
  requirements: []
172
-
173
166
  rubyforge_project:
174
- rubygems_version: 1.8.10
167
+ rubygems_version: 1.8.12
175
168
  signing_key:
176
169
  specification_version: 3
177
170
  summary: SWD (Simple Web Discovery) Client Library
178
- test_files:
171
+ test_files:
179
172
  - spec/helpers/webmock_helper.rb
180
173
  - spec/mock_json/blank.json
181
174
  - spec/mock_json/redirect.json