ddr-aux-client 1.0.0.pre.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: b61f7264be61118ea520153359725d26fcca9fde
4
+ data.tar.gz: 50e9500f36c7df7b237369d67cac26e8117cf741
5
+ SHA512:
6
+ metadata.gz: 0a4b97d343559d22563ac2de3c1262a3f6f8803c6a5d6acad9a6b9705ee2633db37ed5b3fb5977f58efc242d7295683b8fa1c0acf1484c741fd3ec27cafec108
7
+ data.tar.gz: c9470a0dc51fb64753dd3ca7649dddc0b610f26f72487a21fa1b381971142c22a1420d4a34dd9153594cfd8073d12c9da10ba920dd69fb76c7be3da015ea837d
data/.gitignore ADDED
@@ -0,0 +1,9 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --format documentation
2
+ --color
data/.travis.yml ADDED
@@ -0,0 +1,4 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.2.1
4
+ before_install: gem install bundler -v 1.10.2
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in ddr-aux-client.gemspec
4
+ gemspec
data/README.md ADDED
@@ -0,0 +1,36 @@
1
+ # Ddr::Aux::Client
2
+
3
+ Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/ddr/aux/client`. To experiment with that code, run `bin/console` for an interactive prompt.
4
+
5
+ TODO: Delete this and the text above, and describe your gem
6
+
7
+ ## Installation
8
+
9
+ Add this line to your application's Gemfile:
10
+
11
+ ```ruby
12
+ gem 'ddr-aux-client'
13
+ ```
14
+
15
+ And then execute:
16
+
17
+ $ bundle
18
+
19
+ Or install it yourself as:
20
+
21
+ $ gem install ddr-aux-client
22
+
23
+ ## Usage
24
+
25
+ TODO: Write usage instructions here
26
+
27
+ ## Development
28
+
29
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake rspec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
30
+
31
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
32
+
33
+ ## Contributing
34
+
35
+ Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/ddr-aux-client.
36
+
data/Rakefile ADDED
@@ -0,0 +1,6 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task :default => :spec
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "ddr/aux/client"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start
data/bin/setup ADDED
@@ -0,0 +1,7 @@
1
+ #!/bin/bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+
5
+ bundle install
6
+
7
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,23 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'ddr_aux/client/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "ddr-aux-client"
8
+ spec.version = DdrAux::Client::VERSION
9
+ spec.authors = ["David Chandek-Stark"]
10
+ spec.email = ["dchandekstark@gmail.com"]
11
+
12
+ spec.summary = "Client library for ddr-aux web services."
13
+ spec.homepage = "https://github.com/duke-libraries/ddr-aux-client"
14
+
15
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
16
+ spec.bindir = "exe"
17
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
18
+ spec.require_paths = ["lib"]
19
+
20
+ spec.add_development_dependency "bundler", "~> 1.10"
21
+ spec.add_development_dependency "rake", "~> 10.0"
22
+ spec.add_development_dependency "rspec"
23
+ end
@@ -0,0 +1,16 @@
1
+ require "ddr_aux/client/version"
2
+ require "ddr_aux/client/connection"
3
+ require "ddr_aux/client/api"
4
+
5
+ module DdrAux
6
+ module Client
7
+ extend Api
8
+
9
+ class << self
10
+ attr_accessor :api_url
11
+ end
12
+
13
+ self.api_url = ENV["DDR_AUX_API_URL"]
14
+
15
+ end
16
+ end
@@ -0,0 +1,15 @@
1
+ module DdrAux::Client
2
+ module Api
3
+
4
+ def license(id)
5
+ require_relative "license"
6
+ License.call(id)
7
+ end
8
+
9
+ def licenses(params=nil)
10
+ require_relative "licenses"
11
+ Licenses.call(params)
12
+ end
13
+
14
+ end
15
+ end
@@ -0,0 +1,38 @@
1
+ require 'net/http'
2
+ require 'json'
3
+
4
+ module DdrAux::Client
5
+ class Connection < SimpleDelegator
6
+
7
+ def self.call(*args)
8
+ new.get_response(*args)
9
+ end
10
+
11
+ def initialize
12
+ conn = Net::HTTP.new(uri.host, uri.port)
13
+ if uri.scheme == "https"
14
+ conn.use_ssl = true
15
+ conn.verify_mode = OpenSSL::SSL::VERIFY_NONE
16
+ end
17
+ super conn
18
+ end
19
+
20
+ def get_response(relative_path)
21
+ path = uri.path + relative_path
22
+ res = get(path, request_headers)
23
+ res.value # raises exception if not 2XX response code
24
+ JSON.parse(res.body)
25
+ end
26
+
27
+ private
28
+
29
+ def uri
30
+ URI(DdrAux::Client.api_url)
31
+ end
32
+
33
+ def request_headers
34
+ {"Accept"=>"application/json"}
35
+ end
36
+
37
+ end
38
+ end
@@ -0,0 +1,9 @@
1
+ module DdrAux::Client
2
+ class License
3
+
4
+ def self.call(id)
5
+ Connection.call("/licenses/#{id}")
6
+ end
7
+
8
+ end
9
+ end
@@ -0,0 +1,13 @@
1
+ module DdrAux::Client
2
+ class Licenses
3
+
4
+ def self.call(params=nil)
5
+ path = "/licenses"
6
+ if params
7
+ path << "?" + URI.encode_www_form(params)
8
+ end
9
+ Connection.call(path)
10
+ end
11
+
12
+ end
13
+ end
@@ -0,0 +1,5 @@
1
+ module DdrAux
2
+ module Client
3
+ VERSION = "1.0.0.pre.1"
4
+ end
5
+ end
metadata ADDED
@@ -0,0 +1,100 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: ddr-aux-client
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0.pre.1
5
+ platform: ruby
6
+ authors:
7
+ - David Chandek-Stark
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2015-09-09 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.10'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.10'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '10.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '10.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rspec
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ description:
56
+ email:
57
+ - dchandekstark@gmail.com
58
+ executables: []
59
+ extensions: []
60
+ extra_rdoc_files: []
61
+ files:
62
+ - ".gitignore"
63
+ - ".rspec"
64
+ - ".travis.yml"
65
+ - Gemfile
66
+ - README.md
67
+ - Rakefile
68
+ - bin/console
69
+ - bin/setup
70
+ - ddr-aux-client.gemspec
71
+ - lib/ddr_aux/client.rb
72
+ - lib/ddr_aux/client/api.rb
73
+ - lib/ddr_aux/client/connection.rb
74
+ - lib/ddr_aux/client/license.rb
75
+ - lib/ddr_aux/client/licenses.rb
76
+ - lib/ddr_aux/client/version.rb
77
+ homepage: https://github.com/duke-libraries/ddr-aux-client
78
+ licenses: []
79
+ metadata: {}
80
+ post_install_message:
81
+ rdoc_options: []
82
+ require_paths:
83
+ - lib
84
+ required_ruby_version: !ruby/object:Gem::Requirement
85
+ requirements:
86
+ - - ">="
87
+ - !ruby/object:Gem::Version
88
+ version: '0'
89
+ required_rubygems_version: !ruby/object:Gem::Requirement
90
+ requirements:
91
+ - - ">"
92
+ - !ruby/object:Gem::Version
93
+ version: 1.3.1
94
+ requirements: []
95
+ rubyforge_project:
96
+ rubygems_version: 2.4.6
97
+ signing_key:
98
+ specification_version: 4
99
+ summary: Client library for ddr-aux web services.
100
+ test_files: []