embark-journey 0.0.15 → 0.0.16

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: 2b77138254b5e0798166326dbc1c358ef737030d
4
- data.tar.gz: 004fb01ba67f78d0ff4a105c42c7e74f945fb048
3
+ metadata.gz: c6d78f81a0c332a5d7d5ef72812126b052abd680
4
+ data.tar.gz: 8fe48d192b99fed942963598e51fb6b5ab48a287
5
5
  SHA512:
6
- metadata.gz: 1c716e4eaa31dc97d3e7fb4580279d1e51dea714e4ba7d1f670d34e52e7d55b8f9f693d902c91123f06ba7a7dccba192eb7ddf8c35b222d51cf090787c981e55
7
- data.tar.gz: 44ab1288bc9095847d84438a16a4bff6c182df9e3eacad06cef241423c6d99c58212b33cf8dcc1b83082f5466ad9db8b2f12e6cf37f5aa2a3acac73a20e6896c
6
+ metadata.gz: fa4feb867e1e60e71cfb0348396319fb426ffc1e683aca9c5222a5001f8ed9fb20d3ae1221d29fce7d5aa3c72280f656414f73a325fd1c3eaa337b585deb0347
7
+ data.tar.gz: 81f92fdd978b3ea9dd49e79bcc89663742f3786e9e8c8a11d966637a2f587d89e332c84aac4da644fdded18ff3aa9e014682712b8d28847a7101496800c85252
data/CHANGELOG.md CHANGED
@@ -1,3 +1,6 @@
1
+ v0.0.16
2
+ - added attachment path helpers
3
+
1
4
  v0.0.15
2
5
  - added compatibility around enum_sets from Journey (using indices rather than text values)
3
6
 
@@ -19,23 +19,25 @@ module Journey
19
19
  end
20
20
 
21
21
  require 'journey/resource/api'
22
+ require 'journey/resource/attachments'
22
23
  require 'journey/resource/attribute_loading'
24
+ require 'journey/resource/count'
25
+ require 'journey/resource/embed'
23
26
  require 'journey/resource/enums'
24
27
  require 'journey/resource/enum_sets'
25
28
  require 'journey/resource/queries'
26
29
  require 'journey/resource/search'
27
- require 'journey/resource/embed'
28
- require 'journey/resource/count'
29
30
 
30
31
  class Journey::Resource
31
32
  include API
32
- include Queries
33
+ include Attachments
34
+ include AttributeLoading
35
+ include Count
36
+ include Embed
33
37
  include Enums
34
38
  include EnumSets
35
- include AttributeLoading
39
+ include Queries
36
40
  include Search
37
- include Embed
38
- include Count
39
41
  end
40
42
 
41
43
 
@@ -0,0 +1,26 @@
1
+ require 'active_support/concern'
2
+
3
+ module Journey::Resource::Attachments
4
+ extend ActiveSupport::Concern
5
+
6
+ included do
7
+ def self.attachment(attr)
8
+ define_method "#{attr}_path" do |size='original'|
9
+ if respond_to?(:display_attachments)
10
+ if display_attachments.respond_to?(attr) && paths = display_attachments.send(attr)
11
+ paths.send(size)
12
+ end
13
+ end
14
+ end
15
+
16
+ define_method "#{attr}_url" do |size='original'|
17
+ if path = send("#{attr}_path", size)
18
+ URI.parse(Journey.configuration.api_site).tap do |uri|
19
+ uri.path = path
20
+ end.to_s
21
+ end
22
+ end
23
+ end
24
+ end
25
+
26
+ end
@@ -12,6 +12,7 @@ module Journey::Resource::Enums
12
12
  end
13
13
 
14
14
  instance_eval do
15
+ # TODO deprecated?
15
16
  attr_accessor :"#{attr}_index"
16
17
  end
17
18
 
@@ -2,7 +2,7 @@ module Journey
2
2
  module VERSION
3
3
  MAJOR = 0
4
4
  MINOR = 0
5
- TINY = 15
5
+ TINY = 16
6
6
  PRE = nil
7
7
  STRING = [MAJOR, MINOR, TINY, PRE].compact.join('.')
8
8
  end
@@ -0,0 +1,50 @@
1
+ require 'spec_helper'
2
+
3
+ describe Journey::Resource::Attachments do
4
+
5
+ let(:klass) do
6
+ Class.new(Journey::Resource) do
7
+ self.element_name = 'job'
8
+ attachment :important_file
9
+ attachment :boring_file
10
+ end
11
+ end
12
+
13
+ describe '.attachment' do
14
+ let(:instance) do
15
+ klass.new(display_attachments: OpenStruct.new({
16
+ 'important_file' => OpenStruct.new({
17
+ 'original' => 'O.jpg',
18
+ 'thumbnail' => 'T.jpg'
19
+ })
20
+ }))
21
+ end
22
+
23
+ describe '##{attachment}_path' do
24
+
25
+ it 'defaults to original size' do
26
+ expect(instance.important_file_path).to eq 'O.jpg'
27
+ end
28
+
29
+ it 'returns path from #display_attachments for a given size' do
30
+ expect(instance.important_file_path(:thumbnail)).to eq 'T.jpg'
31
+ end
32
+
33
+ it 'is blank when attachment doesnt exist' do
34
+ expect(instance.boring_file_path).to be_nil
35
+ end
36
+
37
+ it 'handles missing display_attachments gracefully' do
38
+ instance.display_attachments = nil
39
+ expect{ instance.important_file_path }.not_to raise_error
40
+ end
41
+ end
42
+
43
+ describe '##{attachment}_url' do
44
+ it 'is blank when attachment doesnt exist' do
45
+ expect(instance.boring_file_url).to be_blank
46
+ end
47
+ end
48
+
49
+ end
50
+ end
@@ -52,6 +52,7 @@ describe Journey::Resource do
52
52
  r = klass.find(r.id)
53
53
  expect(r.status).to eq 'Inactive'
54
54
  end
55
+
55
56
  end
56
57
  end
57
58
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: embark-journey
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.15
4
+ version: 0.0.16
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dan Davey
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-06-16 00:00:00.000000000 Z
11
+ date: 2014-06-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: active_attr
@@ -148,6 +148,7 @@ files:
148
148
  - lib/journey/configuration.rb
149
149
  - lib/journey/resource.rb
150
150
  - lib/journey/resource/api.rb
151
+ - lib/journey/resource/attachments.rb
151
152
  - lib/journey/resource/attribute_loading.rb
152
153
  - lib/journey/resource/count.rb
153
154
  - lib/journey/resource/embed.rb
@@ -158,6 +159,7 @@ files:
158
159
  - lib/journey/version.rb
159
160
  - spec/models/journey/configurable_spec.rb
160
161
  - spec/models/journey/configuration_spec.rb
162
+ - spec/models/journey/resource/attachments_spec.rb
161
163
  - spec/models/journey/resource_spec.rb
162
164
  - spec/spec_helper.rb
163
165
  - spec/support/configuration_cache.rb
@@ -189,6 +191,7 @@ summary: Journey API wrapper for Ruby
189
191
  test_files:
190
192
  - spec/models/journey/configurable_spec.rb
191
193
  - spec/models/journey/configuration_spec.rb
194
+ - spec/models/journey/resource/attachments_spec.rb
192
195
  - spec/models/journey/resource_spec.rb
193
196
  - spec/spec_helper.rb
194
197
  - spec/support/configuration_cache.rb