pmp 0.2.2 → 0.2.3

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 967b6fcc653a652190480ecf5adb50f25fdee49b
4
- data.tar.gz: 7e41ed111ce829ad2b876f3dacc619fde4112250
3
+ metadata.gz: ccd9974d908a4e63fce21f4e629dba99d8ffb964
4
+ data.tar.gz: da91fd91c23b1c07091ded1f7f60d504c552e2a7
5
5
  SHA512:
6
- metadata.gz: 864ccef40568b132f5da9da1def8c99a6d681348ddf213d4c5361d646c73a5f2609062b1a87a0457c75aeecd6756aef5fda926721c31b37caebfa8f98d0cab64
7
- data.tar.gz: f3139d704838d3480da9003478458b3df76278eef5b08ff9a753514b41ad9d63dc1700d165e9c714b966e2619613d8ad95c7511514ed201605ad28e68c049d46
6
+ metadata.gz: e57d28e41caf69a6d76732d59d8c0f05e5e0c0c1f61551fa5df046b4c945301e988dab00724ebc868b9ff144374dc01f3d86eb1919695103ca6216bfa1b96e54
7
+ data.tar.gz: 39a229cd3c8f8f7d2fca39e3b9f7a3fc880a8d286c307af0b7b403ed389544c310e9063cd6ab898ee151ee4b76715204b95254bb11a6cdcdfc35667e1bd98bea
data/.gitignore CHANGED
@@ -15,3 +15,4 @@ spec/reports
15
15
  test/tmp
16
16
  test/version_tmp
17
17
  tmp
18
+ *.DS_Store
data/README.md CHANGED
@@ -1,13 +1,16 @@
1
- # PMP gem
1
+ # PMP (Public Media Platform)
2
2
 
3
3
  [![Build Status](https://travis-ci.org/PRX/pmp.png)](https://travis-ci.org/PRX/pmp)
4
4
  [![Coverage Status](https://coveralls.io/repos/PRX/pmp/badge.png)](https://coveralls.io/r/PRX/pmp)
5
+ [![Dependency Status](https://gemnasium.com/PRX/pmp.png)](https://gemnasium.com/PRX/pmp)
6
+ [![Gem Version](https://badge.fury.io/rb/pmp.png)](http://badge.fury.io/rb/pmp)
5
7
 
6
- Gem to make it easier to use the PMP API, which is a hypermedia API using the collection.doc+json format.
8
+ Gem to make it easier to use the PMP (Public Media Platform) API, which is a hypermedia API using the collection.doc+json format.
9
+
10
+ You can learn more about the PMP here:
7
11
 
8
12
  https://github.com/publicmediaplatform/pmpdocs/wiki
9
13
 
10
- Very big hat tip to the hyperresource gem: https://github.com/gamache/hyperresource
11
14
 
12
15
 
13
16
  ## Installation
@@ -26,11 +29,14 @@ Or install it yourself as:
26
29
 
27
30
  ## Usage
28
31
 
29
- You can go through the `PMP::Client` as a convenience or start with a `PMP::CollectionDocument`
32
+ You should usually go through the `PMP::Client` as a convenience or start with a `PMP::CollectionDocument`.
33
+
34
+ Below is a basic guide, you can also [see the examples for more info](example/).
35
+
30
36
 
31
37
  ```ruby
32
38
 
33
- # so you need a few things, like the endpoint, default is "https://api.pmp.io"
39
+ # so you need a few things, like the endpoint, but default is "https://api.pmp.io"
34
40
  endpoint = "https://api-sandbox.pmp.io"
35
41
 
36
42
  # and you need credentials, the gem doesn't help you create these (yet)
@@ -67,17 +73,21 @@ puts root.guid
67
73
  puts root.links.keys.sort
68
74
  > ["creator", "edit", "navigation", "query"]
69
75
 
76
+ # don't feel like getting root first? Methods on the client get passed on to root
77
+ puts pmp.links.keys.sort
78
+ > ["creator", "edit", "navigation", "query"]
79
+
70
80
  # want to get the creator link?
71
- puts root.links["creator"]
81
+ puts pmp.links["creator"]
72
82
  > #<PMP::Link href="https://api-sandbox.pmp.io/docs/af676335-21df-4486-ab43-e88c1b48f026">
73
83
 
74
84
  # get the same thing as a method
75
- puts root.creator
85
+ puts pmp.creator
76
86
  > #<PMP::Link href="https://api-sandbox.pmp.io/docs/af676335-21df-4486-ab43-e88c1b48f026">
77
87
 
78
88
  # like the root doc itself, this is lazy loaded
79
89
  # but ask for an attribute on there, and you'll get the doc loaded up
80
- puts root.creator.guid
90
+ puts pmp.creator.guid
81
91
 
82
92
  #### http get request to link href occurs, loads info about the creator
83
93
  > 'af676335-21df-4486-ab43-e88c1b48f026'
@@ -89,7 +99,6 @@ puts root.creator.guid
89
99
  Once you have a doc, you can save or delete it like so:
90
100
 
91
101
  ```ruby
92
-
93
102
  # create a new blank doc, will generatr a guid automatically if not present
94
103
  doc = PMP::CollectionDocument.new()
95
104
  doc.title = "this is an example, ok?"
@@ -119,9 +128,11 @@ doc.save
119
128
 
120
129
  # never mind, delete it
121
130
  doc.delete
131
+ ```
122
132
 
133
+ # Credits
123
134
 
124
- ```
135
+ Very big hat tip to the hyperresource gem: https://github.com/gamache/hyperresource
125
136
 
126
137
  ## To Do
127
138
 
@@ -129,7 +140,6 @@ Think about integrating this lovely json schema parsing project: https://github.
129
140
 
130
141
  or this one: https://github.com/hoxworth/json-schema
131
142
 
132
-
133
143
  ## Contributing
134
144
 
135
145
  1. Fork it
@@ -1073,5 +1073,3 @@ retrieved: {
1073
1073
 
1074
1074
 
1075
1075
  Step 5 complete, all done!
1076
-
1077
- [12:06:55][andrew][~/dev/projects/pmp/pmp]>
@@ -126,6 +126,7 @@ module PMP
126
126
  if !oauth_token
127
127
  token = PMP::Token.new(current_options).get_token
128
128
  self.oauth_token = token.token
129
+ self.token_type = token.params['token_type']
129
130
  end
130
131
  end
131
132
 
@@ -13,6 +13,7 @@ module PMP
13
13
  :client_id,
14
14
  :client_secret,
15
15
  :oauth_token,
16
+ :token_type,
16
17
  :adapter,
17
18
  :endpoint,
18
19
  :user_agent,
@@ -31,6 +32,8 @@ module PMP
31
32
 
32
33
  # The value sent in the http header for 'User-Agent' if none is set
33
34
  DEFAULT_USER_AGENT = "PMP Ruby Gem #{PMP::VERSION}".freeze
35
+
36
+ DEFAULT_TOKEN_TYPE = 'Bearer'
34
37
 
35
38
  # debug is defaulted to the ENV['DEBUG'], see below
36
39
 
@@ -76,6 +79,7 @@ module PMP
76
79
  self.adapter = DEFAULT_ADAPTER
77
80
  self.endpoint = DEFAULT_ENDPOINT
78
81
  self.user_agent = DEFAULT_USER_AGENT
82
+ self.token_type = DEFAULT_TOKEN_TYPE
79
83
  self.debug = ENV['DEBUG']
80
84
  self
81
85
  end
@@ -14,6 +14,7 @@ module PMP
14
14
  :adapter,
15
15
  :ssl,
16
16
  :oauth_token,
17
+ :token_type,
17
18
  :basic_auth,
18
19
  :user,
19
20
  :password,
@@ -27,7 +28,7 @@ module PMP
27
28
  if opts[:basic_auth] && opts[:user] && opts[:password]
28
29
  faraday.request :basic_auth, opts[:user], opts[:password]
29
30
  elsif opts[:oauth_token]
30
- faraday.request :authorization, 'Bearer', opts[:oauth_token]
31
+ faraday.request :authorization, opts[:token_type], opts[:oauth_token]
31
32
  end
32
33
 
33
34
  faraday.request :multipart
data/lib/pmp/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # -*- encoding: utf-8 -*-
2
2
 
3
3
  module PMP
4
- VERSION = "0.2.2"
4
+ VERSION = "0.2.3"
5
5
  end
data/spec/token_spec.rb CHANGED
@@ -35,6 +35,7 @@ describe PMP::Token do
35
35
  token_api= PMP::Token.new(client_id: client_id, client_secret: client_secret, endpoint: endpoint)
36
36
  token = token_api.get_token
37
37
  token.token.must_equal access_token
38
+ token.params['token_type'].must_equal 'Bearer'
38
39
  end
39
40
 
40
41
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pmp
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.2
4
+ version: 0.2.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andrew Kuklewicz