pragmatic_context 0.0.1 → 0.0.2

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: 4bc6e4f0095dfc065bdc39301e9199ccf86dc34a
4
- data.tar.gz: 1befe8820a2a6540868a07773b255c88e28fd9d2
3
+ metadata.gz: c7c1851a206e8b77ffbaaae7c8fd88ab89c3e5fe
4
+ data.tar.gz: 824579bd6aeda691cd918acb53f5690c47d31b60
5
5
  SHA512:
6
- metadata.gz: 0369df6d7cd4d81bcbd7d7581dab2f282245f51266c2ceb1f71199e97975baa7c3042e03a08c9328a2e3688360cbd113c8c526aedb439679afee2e1213abd8c5
7
- data.tar.gz: 049c0729133a59bb9ff14398ae0826614b1a46c68ffb9b9a79bd7edc818b2106715a239daaea79fe4cdc639801b7ec3261638e82e52a638446c7cacc2d5003b1
6
+ metadata.gz: 11801a92e11a66751f968cc97322f6f56fee0695c92c1b3618e7b81bb8f1a2694546ba664f0b11d0ac369d7c1c76777a8aae2bd05289ea060fae3db09a6ee80e
7
+ data.tar.gz: 91fdf01fe732d12623c74246b17d8cdd5961fd09effd0487166167ced7ae235b08025507186b502a8993bb43c21ea44b6d518f82eb0196b05bbbb6fa11416b83
@@ -29,6 +29,10 @@ module PragmaticContext
29
29
  end
30
30
  end
31
31
 
32
+ def as_jsonld(opts = nil)
33
+ as_json(opts).merge("@context" => context)
34
+ end
35
+
32
36
  def context
33
37
  self.class.contextualizer.definitions_for_terms(terms)
34
38
  end
@@ -1,3 +1,3 @@
1
1
  module PragmaticContext
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
@@ -23,4 +23,5 @@ Gem::Specification.new do |spec|
23
23
  spec.add_development_dependency "rspec", "~> 2.6"
24
24
 
25
25
  spec.add_dependency "activesupport"
26
+ spec.add_dependency "activemodel"
26
27
  end
@@ -1,6 +1,8 @@
1
1
  require 'pragmatic_context'
2
+ require 'active_model'
2
3
 
3
4
  class Stub
5
+ include ActiveModel::Serializers::JSON
4
6
  include PragmaticContext::Contextualizable
5
7
 
6
8
  attr_accessor :bacon
@@ -54,6 +56,16 @@ describe PragmaticContext::Contextualizable do
54
56
  subject.class.contextualize_with contextualizer_class
55
57
  end
56
58
 
59
+ describe 'as_jsonld' do
60
+ it 'should respond with the underlying as_json result plus the context' do
61
+ @contextualizer.stub(:definitions_for_terms) do |terms|
62
+ { 'bacon' => { "@id" => "http://bacon.yum" } }.slice(*terms)
63
+ end
64
+ subject.bacon = 'crispy'
65
+ subject.as_jsonld.should == subject.as_json.merge("@context" => subject.context)
66
+ end
67
+ end
68
+
57
69
  describe 'context' do
58
70
  it 'should properly marshall together term definitions with the appropriate terms' do
59
71
  @contextualizer.stub(:definitions_for_terms) do |terms|
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pragmatic_context
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mat Trudel
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-03-27 00:00:00.000000000 Z
11
+ date: 2014-03-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -66,6 +66,20 @@ dependencies:
66
66
  - - '>='
67
67
  - !ruby/object:Gem::Version
68
68
  version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: activemodel
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - '>='
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :runtime
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - '>='
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
69
83
  description: A library to declaratively add JSON-LD support to your ActiveModel models
70
84
  email:
71
85
  - mat@geeky.net