yaks 0.1.0 → 0.2.0

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,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- NTZhMTliZGU4NTNkZTNmYjYyOGRhYzFjZjAwNTIwYTI4YTdjNDJjNA==
4
+ MGFhOGExMjUyNjQxOWEwYzY3ZGQyOWI2Mzc0MDYyYzgwZDMyN2ZlMg==
5
5
  data.tar.gz: !binary |-
6
- MmVjN2NjZDI0ZDhjNjliYTczZjk3ODE0OTJmNGQzNDk3ZmE3ZDk0OQ==
6
+ ZjQzODE2NjIwMDVlNzg2YTVlMjBiMWJiNTcyZTY3NmNkMzVhYWE1Mg==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- M2E1ZWY2MzIyMzkyMmIxMDM3ZTFhZGRkODhhNzhiMjM1NTZiMTkxMDVjZjE2
10
- MTc5NTAwYWI4NGJiOWJjMjVkNGI5MjdmZmM3OWE3ODIwYWYwMDNmM2FkNGMy
11
- ZTcxNTRkNGIzMjgxZWU4OTdlYzMyMmUwYmEwYjRlM2FhODA1YTc=
9
+ Y2UzZjk4YTg1MzNhNTA2NDZjNDQzMmJkNzQxZjEyMjU3ZWQ0ZWJmYjAyYWRj
10
+ OGMwMzcxMDkzYjc2OGE2OGQwNWJjODc2NDdjNGZkZTk2NjdjOGNkNzk4Y2Vm
11
+ ZjEyY2U3MTU1M2FlN2ZhZWFiZWFjYjdhNTdhYTBjYmMzMTcxZTg=
12
12
  data.tar.gz: !binary |-
13
- NjJhM2ExODNhNGM2OTAzMzMzZDc3MjlkNTM0NWVmM2I1N2VlMjdkZmYxZWU2
14
- Mzg2MmQxZmYyNmZkZTJjODZlMDFiYjViZjA5OGVjMjI3ZDEyYzI3ZGEwZWUw
15
- MDc3NWU0MDBiYTk5OWQ3ZGU3OTJkMTVlMzQ1MmUwNjllM2ExZjU=
13
+ ZGZhMzA1OGQ3OTQxNTdmMWRiNTE0ZGQxOTgzZDc2MDllYzA5NjI3NmUwYTlj
14
+ M2EwYjhkZTVkYzBjMzBhOWRkZWFhODk0NDI3YmI2NjU1ZmQ0MDVlNzM1NmM2
15
+ MDJiZTllZTk0ZjM3ZDE4ZmU3N2E3YmQ2MDZiZTY4MWJjY2E5NjI=
data/.gitignore CHANGED
@@ -1,2 +1,3 @@
1
+ .pkg
1
2
  .bundle
2
3
  coverage
data/Gemfile.lock CHANGED
@@ -7,7 +7,7 @@ GIT
7
7
  PATH
8
8
  remote: .
9
9
  specs:
10
- yaks (0.1.0)
10
+ yaks (0.2.0)
11
11
  concord (~> 0.1.4)
12
12
  hamster (~> 0.4.3)
13
13
  inflection (~> 1.0.0)
@@ -19,7 +19,7 @@ GEM
19
19
  adamantium (0.1.0)
20
20
  ice_nine (~> 0.9)
21
21
  thread_safe (~> 0.1.2)
22
- atomic (1.1.14)
22
+ atomic (1.1.16)
23
23
  axiom-types (0.0.5)
24
24
  descendants_tracker (~> 0.0.1)
25
25
  ice_nine (~> 0.9)
data/README.md CHANGED
@@ -107,6 +107,19 @@ end
107
107
 
108
108
  To prevent a link to be expanded, add `expand: false` as an option. Now the actual template will be rendered in the result, so clients can use it to generate links from.
109
109
 
110
+ You can pass a symbol instead of a template, in that case the symbol will be used as a method name on the object to retrieve the link. You can override this behavior just like with attributes.
111
+
112
+ ```ruby
113
+ class FooMapper < Yaks::Mapper
114
+ link 'http://api.foo.com/rels/go_home', :home_url
115
+ # by default calls object.home_url
116
+
117
+ def home_url
118
+ object.setting('home_url')
119
+ end
120
+ end
121
+ ```
122
+
110
123
  ### Associations
111
124
 
112
125
  Use `has_one` for an association that returns a single object, or `has_many` for embedding a collection.
data/Rakefile ADDED
@@ -0,0 +1,11 @@
1
+ require 'rubygems/package_task'
2
+
3
+ spec = Gem::Specification.load(Pathname.glob('*.gemspec').first.to_s)
4
+ Gem::PackageTask.new(spec).define
5
+
6
+ desc "Push gem to rubygems.org"
7
+ task :push => :gem do
8
+ sh "git tag v#{Yaks::VERSION}"
9
+ sh "git push --tags"
10
+ sh "gem push pkg/yaks-#{Yaks::VERSION}.gem"
11
+ end
@@ -17,6 +17,7 @@ module Yaks
17
17
  end
18
18
 
19
19
  def expand_with(callable)
20
+ return callable.(template) if template.is_a? Symbol
20
21
  return template unless expand?
21
22
  expand(
22
23
  variables.map.with_object({}) do |var, hsh|
data/lib/yaks/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Yaks
2
- VERSION = '0.1.0'
2
+ VERSION = '0.2.0'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: yaks
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Arne Brasseur
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-03-07 00:00:00.000000000 Z
11
+ date: 2014-03-31 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  prerelease: false
@@ -135,6 +135,7 @@ files:
135
135
  - Gemfile
136
136
  - Gemfile.lock
137
137
  - README.md
138
+ - Rakefile
138
139
  - examples/hal01.rb
139
140
  - examples/jsonapi01.rb
140
141
  - examples/jsonapi02.rb