ddr-aux-client 1.0.0 → 1.1.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: 2872f276c6ed831c58553af66cdc534e882c257e
4
- data.tar.gz: 6af9ef5da2d45a7d15a89a761ab0b5070dc2c681
3
+ metadata.gz: 8f9c3cc6c1e5f15ab0e067460e227071a3493f11
4
+ data.tar.gz: ecf92af2bfd5010f4bd33295c661996f3732f7a7
5
5
  SHA512:
6
- metadata.gz: 9f269fa57b9bdc9c3e6d4597ae7b64d72a7df710d1c3759cf0992d60e90d784cb8394b85a2358a47327ba210c2fc3b090199beae7449e71a115a70d0305b7472
7
- data.tar.gz: 70e341b64462a5588794aa9b8159e73df0ff132364974c6c1653908299e0b1a23e0c47c1011404bd895ddbc12750453d2d8e8203247a6f517098d1e732ad189a
6
+ metadata.gz: f8fb113dd55fbb8fa53471e6fa006dc57424e9700e08319a5a6aaa8ab3377bcc126545d33014df45c349c946f6ea1209b07c1651339105ae1c0ec8c974eff036
7
+ data.tar.gz: b1d6a84bffb0d269b82ba086aac61e1d33deecd0b0e3c38d366d6077cf067175703ed2d6dbf4518959a2735c7e7997702426f4eb602bad2e5f1db84f421bf3fb
@@ -1,28 +1,44 @@
1
+ require "uri"
2
+ require_relative "api/model"
3
+ require_relative "api/license"
4
+ require_relative "api/admin_set"
5
+
1
6
  module DdrAux::Client
2
7
  module Api
3
8
 
4
- def license(arg)
5
- if arg.respond_to?(:to_h)
6
- find_license(**(arg.to_h))
7
- else
8
- get_license(arg)
9
+ MODELS = {
10
+ license: License,
11
+ admin_set: AdminSet,
12
+ }.freeze
13
+
14
+ MODELS.each do |key, klass|
15
+ # get_license(id) => License.get(id)
16
+ define_method "get_#{key}" do |id|
17
+ klass.get(id)
9
18
  end
10
- end
11
19
 
12
- def get_license(id)
13
- require_relative "api/get_license"
14
- GetLicense.call(id)
15
- end
20
+ # get_licenses => License.list
21
+ # licenses => License.list
22
+ define_method "get_#{key}s" do
23
+ klass.list
24
+ end
25
+ alias_method "#{key}s", "get_#{key}s"
16
26
 
17
- def get_licenses
18
- require_relative "api/get_licenses"
19
- GetLicenses.call
20
- end
21
- alias_method :licenses, :get_licenses
27
+ # find_license(**args) => License.find(**args)
28
+ define_method "find_#{key}" do |args|
29
+ klass.find **args
30
+ end
22
31
 
23
- def find_license(**args)
24
- require_relative "api/find_license"
25
- FindLicense.call(**args)
32
+ # license(arg)
33
+ # => find_license(**(arg.to_h))
34
+ # => get_license(arg)
35
+ define_method key do |arg|
36
+ if arg.respond_to?(:to_h)
37
+ send "find_#{key}", **(arg.to_h)
38
+ else
39
+ send "get_#{key}", arg
40
+ end
41
+ end
26
42
  end
27
43
 
28
44
  end
@@ -0,0 +1,9 @@
1
+ module DdrAux::Client
2
+ module Api
3
+ class AdminSet < Model
4
+
5
+ self.path = "/admin_sets"
6
+
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,9 @@
1
+ module DdrAux::Client
2
+ module Api
3
+ class License < Model
4
+
5
+ self.path = "/licenses"
6
+
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,26 @@
1
+ require "uri"
2
+
3
+ module DdrAux::Client
4
+ module Api
5
+ class Model
6
+
7
+ class << self
8
+ attr_accessor :path
9
+
10
+ def get(id)
11
+ Connection.call [path, id].join("/")
12
+ end
13
+
14
+ def list
15
+ Connection.call path
16
+ end
17
+ alias_method :all, :list
18
+
19
+ def find(**args)
20
+ Connection.call "#{path}/find?%s" % URI.encode_www_form(args)
21
+ end
22
+ end
23
+
24
+ end
25
+ end
26
+ end
@@ -1,5 +1,5 @@
1
1
  module DdrAux
2
2
  module Client
3
- VERSION = "1.0.0"
3
+ VERSION = "1.1.0"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ddr-aux-client
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - David Chandek-Stark
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2015-09-11 00:00:00.000000000 Z
11
+ date: 2015-09-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -85,9 +85,9 @@ files:
85
85
  - ddr-aux-client.gemspec
86
86
  - lib/ddr_aux/client.rb
87
87
  - lib/ddr_aux/client/api.rb
88
- - lib/ddr_aux/client/api/find_license.rb
89
- - lib/ddr_aux/client/api/get_license.rb
90
- - lib/ddr_aux/client/api/get_licenses.rb
88
+ - lib/ddr_aux/client/api/admin_set.rb
89
+ - lib/ddr_aux/client/api/license.rb
90
+ - lib/ddr_aux/client/api/model.rb
91
91
  - lib/ddr_aux/client/connection.rb
92
92
  - lib/ddr_aux/client/version.rb
93
93
  homepage: https://github.com/duke-libraries/ddr-aux-client
@@ -1,10 +0,0 @@
1
- module DdrAux::Client
2
- class FindLicense
3
-
4
- def self.call(**args)
5
- path = "/licenses/find?" + URI.encode_www_form(args)
6
- Connection.call(path)
7
- end
8
-
9
- end
10
- end
@@ -1,9 +0,0 @@
1
- module DdrAux::Client
2
- class GetLicense
3
-
4
- def self.call(id)
5
- Connection.call("/licenses/#{id}")
6
- end
7
-
8
- end
9
- end
@@ -1,9 +0,0 @@
1
- module DdrAux::Client
2
- class GetLicenses
3
-
4
- def self.call
5
- Connection.call("/licenses")
6
- end
7
-
8
- end
9
- end