readypulse 1.0.0 → 1.1.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 +4 -4
- data/lib/readypulse/image.rb +45 -5
- data/lib/readypulse/version.rb +1 -1
- data/spec/lib/readypulse/image_spec.rb +26 -2
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fe721caa7124aa1756b9a0dd36dd9f289351057d
|
4
|
+
data.tar.gz: 502184a64e3238a7a2880d481a205241edbf0d22
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8eda93a28d0ede6aa07e30635be2fae4d889fb063f01709ee4f90b810f464af82e6ff62ba3d261bc2c8748ed9761a0c5f5155e1ffdd3481f78a45584cce286c3
|
7
|
+
data.tar.gz: f9e72c6e25c9cb77bd7498be111ec54b3c49662c1e0f1e67c1c02e52cfa77a706b2c9b9c2060e545050f53bc4eb1b9a01e7eb54dc5125c536042acef0d689d9a
|
data/lib/readypulse/image.rb
CHANGED
@@ -54,14 +54,27 @@ module Readypulse
|
|
54
54
|
#
|
55
55
|
# returns an Image object with ImageType objects at the root too
|
56
56
|
|
57
|
-
|
57
|
+
STRING_ATTRIBUTES = %w(id uniq_id external_network_id content_source
|
58
|
+
content_index type story_url
|
59
|
+
external_conversation_link user_text
|
60
|
+
timestamp social_timestamp sentiment)
|
61
|
+
|
62
|
+
BOOLEAN_ATTRIBUTES = %w(has_media is_consented is_incentivized
|
63
|
+
is_compliant is_approved)
|
64
|
+
|
65
|
+
# String and Boolean Attribute attr_accessor generated dynamically
|
66
|
+
attr_accessor :products, :actor,
|
67
|
+
:readypulse_content_score, :social_attributes, :cta
|
58
68
|
|
59
69
|
def initialize(raw_image:)
|
60
|
-
|
61
|
-
|
62
|
-
@products = raw_image.fetch(:products, [])
|
63
|
-
@actor = raw_image[:actor]
|
70
|
+
build_string_attributes(raw_image)
|
71
|
+
build_boolean_attributes(raw_image)
|
64
72
|
|
73
|
+
@social_attributes = raw_image[:social_attributes]
|
74
|
+
@readypulse_content_score = raw_image[:readypulse_content_score]
|
75
|
+
@cta = raw_image[:cta]
|
76
|
+
@products = raw_image.fetch(:products, [{}])
|
77
|
+
@actor = raw_image.fetch(:actor, {})
|
65
78
|
|
66
79
|
raw_image.fetch(:media, {}).fetch(:images, []).each do |raw_type|
|
67
80
|
self.store(raw_type[:type], ImageType.new(raw_type: raw_type))
|
@@ -71,5 +84,32 @@ module Readypulse
|
|
71
84
|
def types
|
72
85
|
self.keys
|
73
86
|
end
|
87
|
+
|
88
|
+
def inspect
|
89
|
+
instance_variables.inject([
|
90
|
+
"\n#TestClass",
|
91
|
+
"\tObject_i = #{object_id}",
|
92
|
+
"\tInstance variables:"
|
93
|
+
]) do |result, item|
|
94
|
+
result << "\t\t#{item} = #{instance_variable_get(item)}"
|
95
|
+
result
|
96
|
+
end.join("\n")
|
97
|
+
end
|
98
|
+
|
99
|
+
private
|
100
|
+
|
101
|
+
def build_string_attributes(raw_image)
|
102
|
+
STRING_ATTRIBUTES.each do |attr_name|
|
103
|
+
self.class.send(:attr_accessor, attr_name)
|
104
|
+
instance_variable_set("@#{attr_name}", raw_image.fetch(attr_name.to_sym, nil))
|
105
|
+
end
|
106
|
+
end
|
107
|
+
|
108
|
+
def build_boolean_attributes(raw_image)
|
109
|
+
BOOLEAN_ATTRIBUTES.each do |attr_name|
|
110
|
+
self.class.send(:attr_accessor, attr_name)
|
111
|
+
instance_variable_set("@#{attr_name}", raw_image.fetch(attr_name.to_sym, nil))
|
112
|
+
end
|
113
|
+
end
|
74
114
|
end
|
75
115
|
end
|
data/lib/readypulse/version.rb
CHANGED
@@ -2,12 +2,36 @@ module Readypulse
|
|
2
2
|
RSpec.describe Image do
|
3
3
|
subject(:image) {Image.new(raw_image: from_client)}
|
4
4
|
|
5
|
-
|
5
|
+
# String Attribute
|
6
|
+
its(:id) {is_expected.to eq(from_client[:id])}
|
7
|
+
its(:uniq_id) {is_expected.to eq(from_client[:uniq_id])}
|
8
|
+
its(:external_network_id) {is_expected.to eq(from_client[:external_network_id])}
|
9
|
+
its(:content_source) {is_expected.to eq(from_client[:content_source])}
|
10
|
+
its(:content_index) {is_expected.to eq(from_client[:content_index])}
|
11
|
+
its(:type) {is_expected.to eq(from_client[:type])}
|
12
|
+
its(:story_url) {is_expected.to eq(from_client[:story_url])}
|
13
|
+
its(:user_text) {is_expected.to eq(from_client[:user_text])}
|
14
|
+
its(:timestamp) {is_expected.to eq(from_client[:timestamp])}
|
15
|
+
its(:social_timestamp) {is_expected.to eq(from_client[:social_timestamp])}
|
16
|
+
its(:sentiment) {is_expected.to eq(from_client[:sentiment])}
|
17
|
+
|
18
|
+
# Boolean Attributes
|
19
|
+
its(:sentiment) {is_expected.to eq(from_client[:sentiment])}
|
20
|
+
its(:is_consented) {is_expected.to eq(from_client[:is_consented])}
|
21
|
+
its(:is_incentivized) {is_expected.to eq(from_client[:is_incentivized])}
|
22
|
+
its(:is_compliant) {is_expected.to eq(from_client[:is_compliant])}
|
23
|
+
its(:is_approved) {is_expected.to eq(from_client[:is_approved])}
|
24
|
+
|
25
|
+
# Fixnum Attributes
|
6
26
|
its(:readypulse_content_score) {is_expected.to eq(from_client[:readypulse_content_score])}
|
7
|
-
|
27
|
+
|
28
|
+
# Collection Attributes
|
29
|
+
its(:social_attributes) {is_expected.to eq(from_client[:social_attributes])}
|
8
30
|
its(:products) {is_expected.to eq(from_client[:products])}
|
9
31
|
its(:actor) {is_expected.to eq(from_client[:actor])}
|
10
32
|
|
33
|
+
its(:types) {is_expected.to eq(["email", "tile", "square-tile", "mobile-tile", "large", "original"])}
|
34
|
+
|
11
35
|
it 'has image_type objects' do
|
12
36
|
expect(image["email"]).to be_an(ImageType)
|
13
37
|
expect(image["tile"]).to be_an(ImageType)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: readypulse
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Chad Metcalf
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-06-
|
11
|
+
date: 2015-06-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|