embark-journey 0.0.15 → 0.0.16
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/CHANGELOG.md +3 -0
- data/lib/journey/resource.rb +8 -6
- data/lib/journey/resource/attachments.rb +26 -0
- data/lib/journey/resource/enums.rb +1 -0
- data/lib/journey/version.rb +1 -1
- data/spec/models/journey/resource/attachments_spec.rb +50 -0
- data/spec/models/journey/resource_spec.rb +1 -0
- metadata +5 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c6d78f81a0c332a5d7d5ef72812126b052abd680
|
4
|
+
data.tar.gz: 8fe48d192b99fed942963598e51fb6b5ab48a287
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fa4feb867e1e60e71cfb0348396319fb426ffc1e683aca9c5222a5001f8ed9fb20d3ae1221d29fce7d5aa3c72280f656414f73a325fd1c3eaa337b585deb0347
|
7
|
+
data.tar.gz: 81f92fdd978b3ea9dd49e79bcc89663742f3786e9e8c8a11d966637a2f587d89e332c84aac4da644fdded18ff3aa9e014682712b8d28847a7101496800c85252
|
data/CHANGELOG.md
CHANGED
data/lib/journey/resource.rb
CHANGED
@@ -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
|
33
|
+
include Attachments
|
34
|
+
include AttributeLoading
|
35
|
+
include Count
|
36
|
+
include Embed
|
33
37
|
include Enums
|
34
38
|
include EnumSets
|
35
|
-
include
|
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
|
data/lib/journey/version.rb
CHANGED
@@ -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
|
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.
|
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-
|
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
|