biola_web_services 1.1.1 → 1.1.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: cf10953201e6608c1689dbe7b197120f925ff0a5
4
+ data.tar.gz: 4b2d8c20aad3a185c64a1d305cecc27988bd6f3a
5
+ SHA512:
6
+ metadata.gz: 323072ad7b71a9b83a72d2d5b262ef54b3249842f0d8254bab2d59350dc3eb486f0c545863dcdf41bb440e2259d454b54fa2ef96ce105c417974c7b169308e15
7
+ data.tar.gz: d0206098558c367f660bddc0a64d8a71a51d386dc36466dc7ae2e8e4a88b22dbf040cefebb766087c16401caa6e95850da431118ac87d90f69af40478c312882
@@ -1,25 +1,26 @@
1
1
  module BiolaWebServices
2
2
  class Service
3
3
  require 'json'
4
-
4
+
5
5
  @service_name = nil
6
-
6
+
7
7
  def initialize(service_name)
8
8
  @service_name = service_name
9
9
  end
10
-
11
- def send(method_name, args)
10
+
11
+ def send_request(method_name, args)
12
12
  request = Net::HTTP::Post.new request_path(method_name)
13
13
  request.set_form_data args
14
14
 
15
- response = BiolaWebServices.connection.start{|conn| conn.request(request)}
15
+ conn = BiolaWebServices.connection
16
+ response = conn.start { |conn| conn.request(request) }
16
17
  begin
17
18
  JSON.parse response.body
18
19
  rescue JSON::ParserError
19
20
  response.body # not all responses are JSON
20
21
  end
21
22
  end
22
-
23
+
23
24
  def method_missing(m, *args)
24
25
  method_name = ruby_to_ws_method_name(m)
25
26
  modifier = m.to_s[-1, 1]
@@ -27,19 +28,19 @@ module BiolaWebServices
27
28
 
28
29
  case modifier
29
30
  when '?' # return true or false
30
- response = send(method_name, args)
31
+ response = send_request(method_name, args)
31
32
  %w(true t yes y 1).include?(response.to_s.downcase.strip)
32
33
  when '!' # raise errors
33
- send(method_name, args)
34
+ send_request(method_name, args)
34
35
  else # return nil on error
35
36
  begin
36
- send(method_name, args)
37
+ send_request(method_name, args)
37
38
  rescue
38
39
  nil
39
40
  end
40
41
  end
41
42
  end
42
-
43
+
43
44
  private
44
45
  def request_path(method_name)
45
46
  @uri ||= URI.parse(BiolaWebServices.config.url)
@@ -1,3 +1,3 @@
1
1
  module BiolaWebServices
2
- VERSION = '1.1.1'
2
+ VERSION = '1.1.2'
3
3
  end
@@ -12,24 +12,22 @@ module BiolaWebServices
12
12
  end
13
13
 
14
14
  public
15
-
16
- def self.connection
17
- return @connection unless @connection.nil?
18
15
 
19
- cert = OpenSSL::X509::Certificate.new(File.read(self.config.cert_path))
16
+ def self.connection
17
+ cert = OpenSSL::X509::Certificate.new(File.read(self.config.cert_path))
20
18
  key = OpenSSL::PKey::RSA.new(File.read(self.config.key_path), self.config.key_password)
21
19
  uri = URI.parse(self.config.url)
22
20
 
23
- @connection = Net::HTTP.new(uri.host, uri.port)
21
+ conn = Net::HTTP.new(uri.host, uri.port)
24
22
  if uri.scheme == 'https'
25
- @connection.use_ssl = true
26
- @connection.cert = cert
27
- @connection.key = key
28
- @connection.verify_mode = self.config.verify_ssl ? OpenSSL::SSL::VERIFY_PEER : OpenSSL::SSL::VERIFY_NONE
29
- @connection.ssl_version = self.config.ssl_version unless self.config.ssl_version.nil?
23
+ conn.use_ssl = true
24
+ conn.cert = cert
25
+ conn.key = key
26
+ conn.verify_mode = self.config.verify_ssl ? OpenSSL::SSL::VERIFY_PEER : OpenSSL::SSL::VERIFY_NONE
27
+ conn.ssl_version = self.config.ssl_version unless self.config.ssl_version.nil?
30
28
  end
31
29
 
32
- @connection
30
+ conn
33
31
  end
34
32
 
35
33
  def self.[](service_name)
metadata CHANGED
@@ -1,15 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: biola_web_services
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.1
5
- prerelease:
4
+ version: 1.1.2
6
5
  platform: ruby
7
6
  authors:
8
7
  - Adam Crownoble
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2012-05-07 00:00:00.000000000 Z
11
+ date: 2014-12-12 00:00:00.000000000 Z
13
12
  dependencies: []
14
13
  description: Simple Ruby wrapper for Biola Web Services REST calls
15
14
  email: adam.crownoble@biola.edu
@@ -18,31 +17,30 @@ extensions: []
18
17
  extra_rdoc_files: []
19
18
  files:
20
19
  - lib/biola_web_services.rb
21
- - lib/biola_web_services/version.rb
22
- - lib/biola_web_services/service.rb
23
20
  - lib/biola_web_services/configuration.rb
21
+ - lib/biola_web_services/service.rb
22
+ - lib/biola_web_services/version.rb
24
23
  homepage: http://biola.edu/it
25
24
  licenses: []
25
+ metadata: {}
26
26
  post_install_message:
27
27
  rdoc_options: []
28
28
  require_paths:
29
29
  - lib
30
30
  required_ruby_version: !ruby/object:Gem::Requirement
31
- none: false
32
31
  requirements:
33
- - - ! '>='
32
+ - - ">="
34
33
  - !ruby/object:Gem::Version
35
34
  version: '0'
36
35
  required_rubygems_version: !ruby/object:Gem::Requirement
37
- none: false
38
36
  requirements:
39
- - - ! '>='
37
+ - - ">="
40
38
  - !ruby/object:Gem::Version
41
39
  version: '0'
42
40
  requirements: []
43
41
  rubyforge_project:
44
- rubygems_version: 1.8.16
42
+ rubygems_version: 2.2.2
45
43
  signing_key:
46
- specification_version: 3
44
+ specification_version: 4
47
45
  summary: Biola Web Services helper methods
48
46
  test_files: []