corespring 0.0.1 → 0.0.4
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 +4 -4
- data/.ruby-version +1 -1
- data/.travis.yml +1 -1
- data/Gemfile.lock +1 -2
- data/README.rdoc +4 -4
- data/lib/corespring-ruby.rb +12 -1
- data/lib/corespring/api_client.rb +47 -32
- data/lib/corespring/api_model.rb +14 -0
- data/lib/corespring/component.rb +5 -0
- data/lib/corespring/item.rb +14 -0
- data/lib/corespring/item_session.rb +19 -0
- data/lib/corespring/player_options.rb +21 -0
- data/lib/corespring/player_token.rb +27 -0
- data/lib/corespring/primary_subject.rb +5 -0
- data/lib/corespring/prior_use.rb +11 -0
- data/lib/corespring/score.rb +15 -0
- data/lib/corespring/standard.rb +6 -0
- data/lib/corespring/version.rb +2 -2
- data/spec/corespring/api_client_spec.rb +69 -26
- data/spec/corespring/api_model_spec.rb +26 -0
- data/spec/corespring/item_session_spec.rb +13 -0
- data/spec/corespring/item_spec.rb +19 -0
- data/spec/corespring/player_options_spec.rb +32 -0
- data/spec/corespring/player_token_spec.rb +15 -0
- data/spec/corespring/prior_use_spec.rb +12 -0
- data/spec/spec_helper.rb +2 -1
- metadata +25 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f998e7babda3ab2b518d928f87aafbbbc168270e
|
4
|
+
data.tar.gz: 1657d703cfb70443dd00ee42a0b884a2272407ec
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3b8323bcf25626b8fce99490d2927432d4a60a5dbcb7174ebf6e77ff9615110caebf663e8324ea1862d7b087fb051b528da573fa8495ebb0dc53bfe87a466646
|
7
|
+
data.tar.gz: 86a2e6fb661e460d8eb1427885f34246a29be49de0f235241e82d5699e5cb260501516f8e6664b4de80c34873628ca6508dcf3fe0c12a98f2fe7d55050b00bce
|
data/.ruby-version
CHANGED
@@ -1 +1 @@
|
|
1
|
-
2.0.0
|
1
|
+
2.0.0-p598
|
data/.travis.yml
CHANGED
@@ -1,2 +1,2 @@
|
|
1
1
|
language: ruby
|
2
|
-
script: rspec spec
|
2
|
+
script: "bundle exec rspec spec"
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
corespring (0.0.
|
4
|
+
corespring (0.0.2)
|
5
5
|
builder (>= 2.1.2)
|
6
6
|
httparty (>= 0.8)
|
7
7
|
|
@@ -29,7 +29,6 @@ GEM
|
|
29
29
|
rspec-mocks (2.99.3)
|
30
30
|
safe_yaml (1.0.4)
|
31
31
|
webmock (1.6.4)
|
32
|
-
addressable (~> 2.2, > 2.2.5)
|
33
32
|
addressable (~> 2.2, > 2.2.5)
|
34
33
|
crack (>= 0.1.7)
|
35
34
|
|
data/README.rdoc
CHANGED
@@ -1,12 +1,12 @@
|
|
1
1
|
== corespring-ruby
|
2
2
|
|
3
|
-
|
3
|
+
{<img src="https://travis-ci.org/corespring/corespring-ruby.svg" alt="Travis CI">}[https://travis-ci.org/corespring/corespring-ruby]
|
4
4
|
|
5
5
|
=== Installation
|
6
6
|
|
7
7
|
You can include the +corespring-ruby+ gem directly in your +Gemfile+:
|
8
8
|
|
9
|
-
gem 'corespring-ruby'
|
9
|
+
gem 'corespring', require: 'corespring-ruby'
|
10
10
|
|
11
11
|
See the 'Examples' section about specific API usage.
|
12
12
|
|
@@ -14,7 +14,7 @@ See the 'Examples' section about specific API usage.
|
|
14
14
|
|
15
15
|
A command line interface is availably if you install the Gem manually:
|
16
16
|
|
17
|
-
$ gem install corespring
|
17
|
+
$ gem install corespring
|
18
18
|
|
19
19
|
In conjunction with this, a +~/.corespring+ file can be used to store your credentials:
|
20
20
|
|
@@ -54,4 +54,4 @@ Create a new +CoreSpring::APIClient+ object with your +client_id+ and +secret+:
|
|
54
54
|
|
55
55
|
=== LICENSE
|
56
56
|
|
57
|
-
See the {LICENSE.txt}[link:LICENSE.txt] file for more information.
|
57
|
+
See the {LICENSE.txt}[link:LICENSE.txt] file for more information.
|
data/lib/corespring-ruby.rb
CHANGED
@@ -1,7 +1,18 @@
|
|
1
1
|
require 'httparty'
|
2
|
+
require 'corespring/api_model'
|
3
|
+
require 'corespring/primary_subject'
|
4
|
+
require 'corespring/prior_use'
|
5
|
+
require 'corespring/component'
|
6
|
+
require 'corespring/score'
|
7
|
+
require 'corespring/standard'
|
8
|
+
require 'corespring/item'
|
9
|
+
require 'corespring/item_session'
|
2
10
|
require 'corespring/api_client'
|
11
|
+
require 'corespring/player_options'
|
12
|
+
require 'corespring/player_token'
|
13
|
+
|
3
14
|
|
4
15
|
module CoreSpring
|
5
16
|
include HTTParty
|
6
17
|
self.base_uri 'https://platform.corespring.org'
|
7
|
-
end
|
18
|
+
end
|
@@ -1,46 +1,61 @@
|
|
1
1
|
module CoreSpring
|
2
|
-
class
|
2
|
+
class APIError < StandardError; end
|
3
3
|
|
4
|
+
class APIClient
|
4
5
|
def initialize(client_id, client_secret)
|
5
6
|
@client_id = client_id
|
6
7
|
@client_secret = client_secret
|
7
8
|
end
|
8
9
|
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
10
|
+
|
11
|
+
def get_item(item_id)
|
12
|
+
api_response(CoreSpring.get(api_url("/items/#{item_id}")), Item)
|
13
|
+
end
|
14
|
+
|
15
|
+
def get_item_session(session_id)
|
16
|
+
api_response(CoreSpring.get(api_url("/sessions/#{session_id}")), ItemSession)
|
17
|
+
end
|
18
|
+
|
19
|
+
def create_item_session(item_id)
|
20
|
+
api_response(CoreSpring.post(api_url("/items/#{item_id}/sessions")), ItemSession)
|
21
|
+
end
|
22
|
+
|
23
|
+
def reopen_item_session(session_id)
|
24
|
+
api_response(CoreSpring.put("/api/v2/sessions/#{session_id}/reopen?access_token=#{access_token}"))
|
25
|
+
end
|
26
|
+
|
27
|
+
def complete_item_session(session_id)
|
28
|
+
api_response(CoreSpring.put("/api/v2/sessions/#{session_id}/complete?access_token=#{access_token}"))
|
29
|
+
end
|
30
|
+
|
31
|
+
def get_score(session_id)
|
32
|
+
api_response(CoreSpring.get(api_url("/sessions/#{session_id}/score.json")), Score)
|
33
|
+
end
|
34
|
+
|
35
|
+
|
36
|
+
private
|
37
|
+
|
38
|
+
def api_url(subset)
|
39
|
+
"/api/v2#{subset}?access_token=#{access_token}"
|
40
|
+
end
|
41
|
+
|
42
|
+
def api_response(response, model=nil)
|
43
|
+
json = JSON.parse(response.body)
|
44
|
+
raise(APIError, json['message'] || json['error']) if response.code != 200
|
45
|
+
|
46
|
+
if model
|
47
|
+
model.new(json)
|
17
48
|
else
|
18
|
-
|
49
|
+
json
|
19
50
|
end
|
20
51
|
end
|
21
|
-
@token
|
22
|
-
end
|
23
52
|
|
24
|
-
|
25
|
-
|
26
|
-
digest = Digest::MD5.new
|
27
|
-
digest.update(raw_key)
|
28
|
-
digest.digest
|
53
|
+
def get_access_token
|
54
|
+
api_response(CoreSpring.post('/auth/access_token', body: {client_id: @client_id, client_secret: @client_secret}))['access_token']
|
29
55
|
end
|
30
56
|
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
key = digest_key(@client_secret)
|
35
|
-
aes.encrypt
|
36
|
-
aes.key = key
|
37
|
-
aes.iv = iv
|
38
|
-
cipher = aes.update(JSON.dump(options))
|
39
|
-
cipher << aes.final
|
40
|
-
|
41
|
-
encrypted_hexed = cipher.unpack('H*')[0]
|
42
|
-
"#{encrypted_hexed}--#{iv_hexed}"
|
43
|
-
end
|
44
|
-
|
57
|
+
def access_token
|
58
|
+
@access_token ||= get_access_token
|
59
|
+
end
|
45
60
|
end
|
46
|
-
end
|
61
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
module CoreSpring
|
2
|
+
class APIModel
|
3
|
+
def initialize(attrs={})
|
4
|
+
(attrs || {}).each do |key, value|
|
5
|
+
self.send("#{underscore(key)}=", value)
|
6
|
+
end
|
7
|
+
end
|
8
|
+
|
9
|
+
private
|
10
|
+
def underscore(string)
|
11
|
+
string.to_s.gsub(/([a-z])([A-Z])/, '\1_\2').downcase.to_sym
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
module CoreSpring
|
2
|
+
class Item < APIModel
|
3
|
+
attr_accessor :id, :author, :title, :primary_subject, :related_subject, :copyright_owner, :credentials, :grade_level,
|
4
|
+
:item_type, :standards, :key_skills, :blooms_taxonomy, :prior_use
|
5
|
+
|
6
|
+
def initialize(attrs={})
|
7
|
+
self.standards = (attrs.delete('standards') || []).map {|standard| Standard.new(standard)}
|
8
|
+
self.primary_subject = PrimarySubject.new(attrs.delete('primarySubject') || {})
|
9
|
+
self.prior_use = PriorUse.new(attrs.delete('priorUse') || {})
|
10
|
+
|
11
|
+
super
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
module CoreSpring
|
2
|
+
class ItemSession < APIModel
|
3
|
+
attr_accessor :id, :item_id, :completed, :components
|
4
|
+
|
5
|
+
def initialize(attrs={})
|
6
|
+
self.components = {}
|
7
|
+
(attrs.delete('components') || {}).each do |key, value|
|
8
|
+
self.components[underscore(key)] = Component.new(value)
|
9
|
+
end
|
10
|
+
|
11
|
+
super
|
12
|
+
end
|
13
|
+
|
14
|
+
|
15
|
+
def as_json
|
16
|
+
JSON.generate({completed: self.completed})
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
module CoreSpring
|
2
|
+
class PlayerOptions < Struct.new(:item_id, :session_id, :expires, :mode, :secure)
|
3
|
+
DEFAULTS = {
|
4
|
+
mode: 'view',
|
5
|
+
expires: 0,
|
6
|
+
secure: false,
|
7
|
+
session_id: '*',
|
8
|
+
item_id: nil,
|
9
|
+
}
|
10
|
+
|
11
|
+
def initialize(options={})
|
12
|
+
super
|
13
|
+
DEFAULTS.each {|k, v| self[k] = options[k] || v}
|
14
|
+
end
|
15
|
+
|
16
|
+
def player_json
|
17
|
+
self.item_id = '*' if !item_id && session_id == '*'
|
18
|
+
JSON.dump({mode: mode, itemId: item_id, sessionId: session_id, expires: expires, secure: secure}.reject {|k, v| v.nil?})
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
module CoreSpring
|
2
|
+
class PlayerToken < APIClient
|
3
|
+
def encrypt(player_options=PlayerOptions.new)
|
4
|
+
aes = OpenSSL::Cipher::Cipher.new("AES-128-CBC")
|
5
|
+
iv = aes.random_iv
|
6
|
+
iv_hexed = iv.unpack('H*')[0]
|
7
|
+
key = digest_key(@client_secret)
|
8
|
+
aes.encrypt
|
9
|
+
aes.key = key
|
10
|
+
aes.iv = iv
|
11
|
+
cipher = aes.update(player_options.player_json)
|
12
|
+
cipher << aes.final
|
13
|
+
|
14
|
+
encrypted_hexed = cipher.unpack('H*')[0]
|
15
|
+
"#{encrypted_hexed}--#{iv_hexed}"
|
16
|
+
end
|
17
|
+
|
18
|
+
|
19
|
+
private
|
20
|
+
|
21
|
+
def digest_key(raw_key)
|
22
|
+
digest = Digest::MD5.new
|
23
|
+
digest.update(raw_key)
|
24
|
+
digest.digest
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,11 @@
|
|
1
|
+
module CoreSpring
|
2
|
+
class PriorUse < APIModel
|
3
|
+
attr_accessor :contributor_name, :credentials, :grade_level, :source_url, :reviews_passed, :use,
|
4
|
+
:prior_use_other, :p_value, :primary_subject
|
5
|
+
|
6
|
+
def initialize(attrs={})
|
7
|
+
self.primary_subject = PrimarySubject.new(attrs.delete('primarySubject'))
|
8
|
+
super
|
9
|
+
end
|
10
|
+
end
|
11
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
module CoreSpring
|
2
|
+
class Score < APIModel
|
3
|
+
attr_accessor :max_points, :points, :percentage, :components
|
4
|
+
|
5
|
+
def initialize(attrs={})
|
6
|
+
# TODO this logic is duplicated in item_session
|
7
|
+
self.components = {}
|
8
|
+
(attrs.delete('components') || {}).each do |key, value|
|
9
|
+
self.components[underscore(key)] = Component.new(value)
|
10
|
+
end
|
11
|
+
|
12
|
+
super(attrs['summary'])
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
data/lib/corespring/version.rb
CHANGED
@@ -1,3 +1,3 @@
|
|
1
1
|
module CoreSpring
|
2
|
-
VERSION = "0.0.
|
3
|
-
end
|
2
|
+
VERSION = "0.0.4"
|
3
|
+
end
|
@@ -1,49 +1,92 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe 'CoreSpring::APIClient' do
|
4
|
-
|
5
4
|
let(:client_id) { SecureRandom.hex(13) }
|
6
5
|
let(:client_secret) { SecureRandom.hex(13) }
|
7
6
|
let(:client) { CoreSpring::APIClient.new(client_id, client_secret) }
|
8
7
|
|
9
|
-
|
8
|
+
let(:item_id) { SecureRandom.hex(13) }
|
9
|
+
let(:collection_id) { SecureRandom.hex(13) }
|
10
|
+
let(:session_id) { SecureRandom.hex(13) }
|
11
|
+
let(:access_token) { SecureRandom.hex(13) }
|
12
|
+
|
13
|
+
|
14
|
+
before(:each) do
|
15
|
+
stub_request(:post, "https://platform.corespring.org/auth/access_token").
|
16
|
+
with(:body => "client_id=#{client_id}&client_secret=#{client_secret}").
|
17
|
+
to_return(:status => 200, :body => "{\"access_token\": \"#{access_token}\"}", :headers => {})
|
18
|
+
end
|
19
|
+
|
20
|
+
|
21
|
+
|
22
|
+
describe "#get_item" do
|
23
|
+
before do
|
24
|
+
stub_request(:get, "https://platform.corespring.org/api/v2/items/#{item_id}?access_token=#{access_token}").
|
25
|
+
to_return(:status => 200, :body => "{}", :headers => {})
|
26
|
+
end
|
27
|
+
|
28
|
+
subject { client.get_item(item_id) }
|
29
|
+
|
30
|
+
it { is_expected.to be_a(CoreSpring::Item) }
|
31
|
+
end
|
32
|
+
|
33
|
+
|
34
|
+
describe "#get_item_session" do
|
35
|
+
before do
|
36
|
+
stub_request(:get, "https://platform.corespring.org/api/v2/sessions/#{session_id}?access_token=#{access_token}").
|
37
|
+
to_return(:status => 200, :body => "{}", :headers => {})
|
38
|
+
end
|
10
39
|
|
11
|
-
|
12
|
-
let(:token) { SecureRandom.hex(13) }
|
13
|
-
subject { client.get_token }
|
40
|
+
subject { client.get_item_session(session_id) }
|
14
41
|
|
15
|
-
|
16
|
-
|
17
|
-
.with(:body => "client_id=#{client_id}&client_secret=#{client_secret}")
|
18
|
-
.to_return(:status => 200, body: ({ access_token: token }.to_json))
|
19
|
-
}
|
42
|
+
it { is_expected.to be_a(CoreSpring::ItemSession) }
|
43
|
+
end
|
20
44
|
|
21
|
-
it { should == token }
|
22
45
|
|
46
|
+
describe "#create_item_session" do
|
47
|
+
before do
|
48
|
+
stub_request(:post, "https://platform.corespring.org/api/v2/items/#{item_id}/sessions?access_token=#{access_token}").
|
49
|
+
to_return(:status => 200, :body => "{}", :headers => {})
|
23
50
|
end
|
24
51
|
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
.with(:body => "client_id=#{client_id}&client_secret=#{client_secret}")
|
30
|
-
.to_return(:status => 403, body: ({"code" => 100, "message" => "Invalid credentials", "moreInfo" => ""}.to_json))
|
31
|
-
}
|
52
|
+
subject { client.create_item_session(item_id) }
|
53
|
+
|
54
|
+
it { is_expected.to be_a(CoreSpring::ItemSession) }
|
55
|
+
end
|
32
56
|
|
33
|
-
it 'raises an error' do
|
34
|
-
expect { subject }.to raise_error
|
35
|
-
end
|
36
57
|
|
58
|
+
describe "#reopen_item_session" do
|
59
|
+
before do
|
60
|
+
stub_request(:put, "https://platform.corespring.org/api/v2/sessions/#{session_id}/reopen?access_token=#{access_token}").
|
61
|
+
to_return(:status => 200, :body => "{}", :headers => {})
|
37
62
|
end
|
38
63
|
|
64
|
+
subject { client.reopen_item_session(session_id) }
|
65
|
+
|
66
|
+
it { is_expected.not_to be_nil }
|
39
67
|
end
|
40
68
|
|
41
|
-
describe 'encrypt' do
|
42
|
-
let(:options) { {} }
|
43
|
-
subject { client.encrypt(options) }
|
44
69
|
|
45
|
-
|
70
|
+
describe "#complete_item_session" do
|
71
|
+
before do
|
72
|
+
stub_request(:put, "https://platform.corespring.org/api/v2/sessions/#{session_id}/complete?access_token=#{access_token}").
|
73
|
+
to_return(:status => 200, :body => "{}", :headers => {})
|
74
|
+
end
|
46
75
|
|
76
|
+
subject { client.complete_item_session(session_id) }
|
77
|
+
|
78
|
+
it { is_expected.not_to be_nil }
|
47
79
|
end
|
48
80
|
|
49
|
-
|
81
|
+
|
82
|
+
describe "#get_score" do
|
83
|
+
before do
|
84
|
+
stub_request(:get, "https://platform.corespring.org/api/v2/sessions/#{session_id}/score.json?access_token=#{access_token}").
|
85
|
+
to_return(:status => 200, :body => "{}", :headers => {})
|
86
|
+
end
|
87
|
+
|
88
|
+
subject { client.get_score(session_id) }
|
89
|
+
|
90
|
+
it { is_expected.to be_a(CoreSpring::Score) }
|
91
|
+
end
|
92
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe 'CoreSpring::APIModel' do
|
4
|
+
class FooModel < CoreSpring::APIModel
|
5
|
+
attr_accessor :id, :not_camel_case
|
6
|
+
end
|
7
|
+
|
8
|
+
describe "#initialize" do
|
9
|
+
subject { FooModel.new(attrs) }
|
10
|
+
|
11
|
+
context "with correct attributes" do
|
12
|
+
let(:attrs) { {id: :abc123} }
|
13
|
+
specify { expect(subject.id).to eq(:abc123) }
|
14
|
+
end
|
15
|
+
|
16
|
+
context "with camelCase attributes" do
|
17
|
+
let(:attrs) { {notCamelCase: :value} }
|
18
|
+
specify { expect(subject.not_camel_case).to eq(:value) }
|
19
|
+
end
|
20
|
+
|
21
|
+
context "with incorrect attributes" do
|
22
|
+
let(:attrs) { {foo: :bar} }
|
23
|
+
specify { expect { subject }.to raise_error }
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe "CoreSpring::ItemSession" do
|
4
|
+
describe "#initialize" do
|
5
|
+
let(:attrs) { {'id' => 'asdf', 'itemId' => 'qwer', 'components' => {'foo' => {'answers' => ['choiceB']}}} }
|
6
|
+
|
7
|
+
subject { CoreSpring::ItemSession.new(attrs) }
|
8
|
+
|
9
|
+
specify { expect(subject.id).to eq('asdf') }
|
10
|
+
specify { expect(subject.components).to include(:foo) }
|
11
|
+
specify { expect(subject.components[:foo]).to be_a(CoreSpring::Component) }
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe "CoreSpring::Item" do
|
4
|
+
describe "#initialize" do
|
5
|
+
let(:attrs) do
|
6
|
+
{
|
7
|
+
'primarySubject' => {'id' => 'asdf'},
|
8
|
+
'standards' => [{'id' => 'asdf'}],
|
9
|
+
'priorUse' => {'contributorName' => 'Patrick', 'primarySubject' => {'id' => 'asdf'}}
|
10
|
+
}
|
11
|
+
end
|
12
|
+
|
13
|
+
subject { CoreSpring::Item.new(attrs)}
|
14
|
+
|
15
|
+
specify { subject.standards.each {|s| expect(s).to be_a(CoreSpring::Standard)} }
|
16
|
+
specify { expect(subject.primary_subject).to be_a(CoreSpring::PrimarySubject) }
|
17
|
+
specify { expect(subject.prior_use).to be_a(CoreSpring::PriorUse) }
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe "CoreSpring::PlayerOptions" do
|
4
|
+
let(:options) { {} }
|
5
|
+
let(:player_options) { CoreSpring::PlayerOptions.new(options) }
|
6
|
+
|
7
|
+
|
8
|
+
describe "defaults" do
|
9
|
+
specify { expect(player_options[:secure]).to be_falsey }
|
10
|
+
specify { expect(player_options[:expires]).to eq(0) }
|
11
|
+
specify { expect(player_options[:mode]).to eq('view') }
|
12
|
+
specify { expect(player_options[:item_id]).to be_nil }
|
13
|
+
specify { expect(player_options[:session_id]).to eq('*') }
|
14
|
+
end
|
15
|
+
|
16
|
+
|
17
|
+
describe "#player_json" do
|
18
|
+
subject { player_options.player_json }
|
19
|
+
|
20
|
+
it { is_expected.to match(/^\{.+\}$/) }
|
21
|
+
it { is_expected.to include('"sessionId":') }
|
22
|
+
it { is_expected.to include('"itemId":') }
|
23
|
+
|
24
|
+
|
25
|
+
context "with a session_id" do
|
26
|
+
let(:options) { {session_id: "ADF123"} }
|
27
|
+
|
28
|
+
it { is_expected.to include('"sessionId":') }
|
29
|
+
it { is_expected.not_to include('"itemId":') }
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe 'CoreSpring::PlayerToken' do
|
4
|
+
let(:client_id) { SecureRandom.hex(13) }
|
5
|
+
let(:client_secret) { SecureRandom.hex(13) }
|
6
|
+
let(:client) { CoreSpring::PlayerToken.new(client_id, client_secret) }
|
7
|
+
|
8
|
+
|
9
|
+
describe '#encrypt' do
|
10
|
+
let(:options) { CoreSpring::PlayerOptions.new }
|
11
|
+
subject { client.encrypt(options) }
|
12
|
+
|
13
|
+
it { should be_a(String) }
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe "CoreSpring::PriorUse" do
|
4
|
+
describe "#initialize" do
|
5
|
+
let(:attrs) { {'contributorName' => "Patrick", 'primarySubject' => {'id' => "asdf"}} }
|
6
|
+
|
7
|
+
subject { CoreSpring::PriorUse.new(attrs) }
|
8
|
+
|
9
|
+
specify { expect(subject.contributor_name).to eq("Patrick") }
|
10
|
+
specify { expect(subject.primary_subject).to be_a(CoreSpring::PrimarySubject) }
|
11
|
+
end
|
12
|
+
end
|
data/spec/spec_helper.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: corespring
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ben Burton
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-07-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: builder
|
@@ -102,8 +102,24 @@ files:
|
|
102
102
|
- corespring.gemspec
|
103
103
|
- lib/corespring-ruby.rb
|
104
104
|
- lib/corespring/api_client.rb
|
105
|
+
- lib/corespring/api_model.rb
|
106
|
+
- lib/corespring/component.rb
|
107
|
+
- lib/corespring/item.rb
|
108
|
+
- lib/corespring/item_session.rb
|
109
|
+
- lib/corespring/player_options.rb
|
110
|
+
- lib/corespring/player_token.rb
|
111
|
+
- lib/corespring/primary_subject.rb
|
112
|
+
- lib/corespring/prior_use.rb
|
113
|
+
- lib/corespring/score.rb
|
114
|
+
- lib/corespring/standard.rb
|
105
115
|
- lib/corespring/version.rb
|
106
116
|
- spec/corespring/api_client_spec.rb
|
117
|
+
- spec/corespring/api_model_spec.rb
|
118
|
+
- spec/corespring/item_session_spec.rb
|
119
|
+
- spec/corespring/item_spec.rb
|
120
|
+
- spec/corespring/player_options_spec.rb
|
121
|
+
- spec/corespring/player_token_spec.rb
|
122
|
+
- spec/corespring/prior_use_spec.rb
|
107
123
|
- spec/spec_helper.rb
|
108
124
|
homepage: https://github.com/corespring/corespring-ruby
|
109
125
|
licenses: []
|
@@ -124,10 +140,16 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
124
140
|
version: '0'
|
125
141
|
requirements: []
|
126
142
|
rubyforge_project: corespring
|
127
|
-
rubygems_version: 2.
|
143
|
+
rubygems_version: 2.4.6
|
128
144
|
signing_key:
|
129
145
|
specification_version: 4
|
130
146
|
summary: CoreSpring API Client
|
131
147
|
test_files:
|
132
148
|
- spec/corespring/api_client_spec.rb
|
149
|
+
- spec/corespring/api_model_spec.rb
|
150
|
+
- spec/corespring/item_session_spec.rb
|
151
|
+
- spec/corespring/item_spec.rb
|
152
|
+
- spec/corespring/player_options_spec.rb
|
153
|
+
- spec/corespring/player_token_spec.rb
|
154
|
+
- spec/corespring/prior_use_spec.rb
|
133
155
|
- spec/spec_helper.rb
|