collectiveaccess 0.1.0 → 0.2.0

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: 41b9a4d1c86b0c70ec8907524656fadf8cb6de1d
4
- data.tar.gz: 6fd0d95fab36a585d7b7be37b0a892fa228651db
3
+ metadata.gz: 2c1de3393ad65a3d0c4f62fe76950d9ff8f4a688
4
+ data.tar.gz: 8931df984446dbb7c24061f30b8b9ebf6a5b6320
5
5
  SHA512:
6
- metadata.gz: 9f20ca9eaa6ac8bdf1ecc5001609147eba4af61f3bed0d7d92447dabf45772b460ac61a04a8921dd4e9d98e0367ba4296221f152994e46a941a21a11a825fb63
7
- data.tar.gz: c62aed278aea70da93fb904d3c9cbfc3f728a057ace3795d10599ef3df3a814f2471b1952f97e607bd711acf49895d27c75d7c8e6f7b2affc170a85547fea8c4
6
+ metadata.gz: e150ea9236089dbb62b7c9e4ea4c468731f7baa224c46e58bd61d6ba690ac3938c8a3b57bdb207764d145e5385f891541e1f6413b6786bf8dea620760debe604
7
+ data.tar.gz: 30d9a89cf8936efdd266efce87a7f87bfce57943e2990da417e5747fc382ef802f881f38e8d1b3544fee5ab9b609b5555acfe38d67772e49aa09336b5837d199
data/README.rdoc CHANGED
@@ -4,6 +4,9 @@ This gem is a simple plain Ruby wrapper for the {CollectiveAccess}[http://www.co
4
4
  Web {Service API}[docs.collectiveaccess.org/wiki/Web_Service_API]. Before you start fiddling with
5
5
  the gem, make sure you're familiar with the API.
6
6
 
7
+ Note that this library requires CollectiveAccess Providence v1.5 or later! It might work with v1.4
8
+ but we don't test it against the old stable code.
9
+
7
10
  == Setup
8
11
 
9
12
  Through RubyGems:
@@ -12,7 +15,7 @@ Through RubyGems:
12
15
 
13
16
  In a Gemfile:
14
17
 
15
- gem 'collectiveaccess', '~> 0.1.0'
18
+ gem 'collectiveaccess', '~> 0.2.0'
16
19
 
17
20
  == Usage
18
21
 
@@ -95,6 +98,16 @@ All of them assume that you have required the 'collectiveaccess' gem and also th
95
98
  }
96
99
  puts "#{r}"
97
100
 
101
+ === "Simple" API
102
+
103
+ In v1.6 of CollectiveAccess there's a new service interface called
104
+ {Simple API}[http://docs.collectiveaccess.org/wiki/SimpleAPI]. Gem versions v0.2.x and later support querying
105
+ this API using the `simple` class method. Below is an example for the endpoint 'testDetail'. Note that you have
106
+ to define the endpoint first in your CollectiveAccess services configuration for this to work. For more info
107
+ take a look at the {documentation}[http://docs.collectiveaccess.org/wiki/SimpleAPI]:
108
+
109
+ r = CollectiveAccess.simple hostname: 'providence.dev', endpoint: 'testDetail', get_params: { id: 1 }
110
+
98
111
  == Contributing to collectiveaccess
99
112
 
100
113
  * Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet.
data/Rakefile CHANGED
@@ -16,7 +16,7 @@ Jeweler::Tasks.new do |gem|
16
16
  # gem is a Gem::Specification... see http://guides.rubygems.org/specification-reference/ for more options
17
17
  gem.name = 'collectiveaccess'
18
18
  gem.homepage = 'http://github.com/CollectiveAccessProject/collectiveaccess'
19
- gem.license = 'MIT'
19
+ gem.license = 'GPL3'
20
20
  gem.summary = 'Ruby wrapper for CollectiveAccess Web Service API'
21
21
  gem.description = 'This gem is a simple plain Ruby wrapper for the CollectiveAccess Web Service API. For more info see https://github.com/CollectiveAccessProject/collectiveaccess'
22
22
  gem.email = 'info@collectiveaccess.org'
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.0
1
+ 0.2.0
@@ -2,16 +2,16 @@
2
2
  # DO NOT EDIT THIS FILE DIRECTLY
3
3
  # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
4
4
  # -*- encoding: utf-8 -*-
5
- # stub: collectiveaccess 0.1.0 ruby lib
5
+ # stub: collectiveaccess 0.2.0 ruby lib
6
6
 
7
7
  Gem::Specification.new do |s|
8
8
  s.name = "collectiveaccess"
9
- s.version = "0.1.0"
9
+ s.version = "0.2.0"
10
10
 
11
11
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
12
12
  s.require_paths = ["lib"]
13
13
  s.authors = ["CollectiveAccess", "Stefan"]
14
- s.date = "2015-07-22"
14
+ s.date = "2015-08-14"
15
15
  s.description = "This gem is a simple plain Ruby wrapper for the CollectiveAccess Web Service API. For more info see https://github.com/CollectiveAccessProject/collectiveaccess"
16
16
  s.email = "info@collectiveaccess.org"
17
17
  s.extra_rdoc_files = [
@@ -31,7 +31,7 @@ Gem::Specification.new do |s|
31
31
  "test/test_collectiveaccess.rb"
32
32
  ]
33
33
  s.homepage = "http://github.com/CollectiveAccessProject/collectiveaccess"
34
- s.licenses = ["MIT"]
34
+ s.licenses = ["GPL3"]
35
35
  s.required_ruby_version = Gem::Requirement.new(">= 1.9.3")
36
36
  s.rubygems_version = "2.4.6"
37
37
  s.summary = "Ruby wrapper for CollectiveAccess Web Service API"
@@ -58,6 +58,24 @@ class CollectiveAccess
58
58
  custom_request :delete, request_opts
59
59
  end
60
60
 
61
+ def self.simple(request_opts = {})
62
+ opts = parse_options request_opts
63
+ uri = build_simple_uri opts
64
+
65
+ resp = HTTParty.public_send :get, uri
66
+
67
+ # if 401 (access denied), try to re-authenticate
68
+ if resp.code == 401
69
+ delete_stored_auth_token # nuke old token
70
+ authenticate opts
71
+ # have to re-build the URI to include the new auth token
72
+ new_uri = build_simple_uri opts
73
+ # try again
74
+ resp = HTTParty.public_send :get, new_uri
75
+ end
76
+ resp.parsed_response
77
+ end
78
+
61
79
  # Core request method. Tries to send the request with the given parameters. If it encounters a 401
62
80
  # it'll try to re-authenticate with the Web Service API and retries the same request. Returns a
63
81
  # parsed Hash containing the JSON response from the API or false if something went wrong.
@@ -89,6 +107,16 @@ class CollectiveAccess
89
107
  url
90
108
  end
91
109
 
110
+ def self.build_simple_uri(opts)
111
+ # URI available params: scheme, userinfo, host, port, registry, path, opaque, query and fragment
112
+ url = URI::HTTP.build({ :scheme => opts[:protocol],
113
+ :host => opts[:hostname],
114
+ :path => opts[:url_root]+opts[:script_name]+'/simple/'+opts[:endpoint],
115
+ :query => URI.encode_www_form(opts[:get_params].merge(authToken: stored_auth_token)) })
116
+ url.path.gsub! %r{/+}, '/'
117
+ url
118
+ end
119
+
92
120
  def self.pstore
93
121
  PStore.new(Dir.tmpdir + File::PATH_SEPARATOR + 'collectiveaccess_gem_token.pstore')
94
122
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: collectiveaccess
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - CollectiveAccess
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2015-07-22 00:00:00.000000000 Z
12
+ date: 2015-08-14 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: httparty
@@ -116,7 +116,7 @@ files:
116
116
  - test/test_collectiveaccess.rb
117
117
  homepage: http://github.com/CollectiveAccessProject/collectiveaccess
118
118
  licenses:
119
- - MIT
119
+ - GPL3
120
120
  metadata: {}
121
121
  post_install_message:
122
122
  rdoc_options: []