conversocial 0.0.4 → 0.0.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/conversocial.rb +1 -0
- data/lib/conversocial/resources/models/base.rb +6 -1
- data/lib/conversocial/resources/models/content.rb +16 -0
- data/lib/conversocial/resources/models/conversation.rb +3 -0
- data/lib/conversocial/resources/query_engines/base.rb +31 -8
- data/lib/conversocial/resources/query_engines/conversation.rb +4 -0
- data/lib/conversocial/version.rb +1 -1
- metadata +2 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4ab11c32b300c1ed689033d453cd12f5adf2b878
|
4
|
+
data.tar.gz: ec30b42553642dc80875d15bb793bd9546694bcf
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ca7341f396e2cbe583cb948783880eb72b96035705c432c535809635a2696a5a00751a0b4e7be09381447795821675830d888590559da6f744b5def21460ef69
|
7
|
+
data.tar.gz: b4dde8d4c0429669fc3b724b2d3d819927edba1ff77ef5117ac9fc7dbc186cacbbcf84b3fb2257084e87848b04d53c5cff12c97752c9e9c408d0d8298fa915fd
|
data/lib/conversocial.rb
CHANGED
@@ -6,6 +6,7 @@ require 'conversocial/resources/models/base'
|
|
6
6
|
require 'conversocial/resources/models/account'
|
7
7
|
require 'conversocial/resources/models/author'
|
8
8
|
require 'conversocial/resources/models/channel'
|
9
|
+
require 'conversocial/resources/models/content'
|
9
10
|
require 'conversocial/resources/models/conversation'
|
10
11
|
require 'conversocial/resources/models/keyvalue'
|
11
12
|
require 'conversocial/resources/models/report'
|
@@ -2,11 +2,12 @@ module Conversocial
|
|
2
2
|
module Resources
|
3
3
|
module Models
|
4
4
|
class Base
|
5
|
-
attr_reader :loaded_attributes
|
5
|
+
attr_reader :loaded_attributes, :contents
|
6
6
|
|
7
7
|
def initialize params={}
|
8
8
|
disable_association_resolving do
|
9
9
|
@loaded_attributes = {}
|
10
|
+
@contents = []
|
10
11
|
assign_attributes params
|
11
12
|
end
|
12
13
|
end
|
@@ -144,6 +145,10 @@ module Conversocial
|
|
144
145
|
@query_engine = v
|
145
146
|
end
|
146
147
|
|
148
|
+
def append_content content
|
149
|
+
@contents << content
|
150
|
+
end
|
151
|
+
|
147
152
|
def association_attribute? attribute_value
|
148
153
|
if attribute_value.kind_of? Hash
|
149
154
|
return true if attribute_value['url'].present?
|
@@ -0,0 +1,16 @@
|
|
1
|
+
module Conversocial
|
2
|
+
module Resources
|
3
|
+
module Models
|
4
|
+
class Content < Base
|
5
|
+
def self.fields
|
6
|
+
%w{attachments parent author is_priority text tags sentiment channels platform link created_date type id is_private}
|
7
|
+
end
|
8
|
+
attributize_tags
|
9
|
+
|
10
|
+
|
11
|
+
|
12
|
+
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
@@ -60,20 +60,14 @@ module Conversocial
|
|
60
60
|
self
|
61
61
|
end
|
62
62
|
|
63
|
-
def new params={}
|
64
|
-
new_instance = model_klass.new params
|
65
|
-
new_instance.send :assign_client, client
|
66
|
-
new_instance.send :assign_query_engine, self
|
67
|
-
new_instance
|
68
|
-
end
|
69
|
-
|
70
63
|
def find find_id
|
71
64
|
@query_params[:fields] ||= model_klass.fields.join(',')
|
72
65
|
|
73
66
|
json = get_json add_query_params("/#{find_id}", default_find_query_params.merge(@query_params))
|
74
67
|
clear
|
75
68
|
if json
|
76
|
-
new json[resource_name]
|
69
|
+
item = new json[resource_name]
|
70
|
+
attach_content_to_items( [item], json['content']).first
|
77
71
|
end
|
78
72
|
end
|
79
73
|
|
@@ -135,13 +129,31 @@ module Conversocial
|
|
135
129
|
clear
|
136
130
|
items = []
|
137
131
|
if json
|
132
|
+
|
133
|
+
|
138
134
|
items = json[plural_resource_name].map do |instance_params|
|
139
135
|
new instance_params
|
140
136
|
end
|
137
|
+
items = attach_content_to_items items, json['content']
|
141
138
|
end
|
142
139
|
{:items => items, :json => json}
|
143
140
|
end
|
144
141
|
|
142
|
+
def attach_content_to_items items, content_json_array
|
143
|
+
if content_json_array.present?
|
144
|
+
items.each do |item|
|
145
|
+
item.content_ids.each do |content_id|
|
146
|
+
content_json = content_json_array.find{ |ct| ct['id'] == content_id }
|
147
|
+
if content_json
|
148
|
+
item.send :append_content, new_instance_of_klass(Conversocial::Resources::Models::Content, content_json)
|
149
|
+
end
|
150
|
+
end
|
151
|
+
end
|
152
|
+
end
|
153
|
+
items
|
154
|
+
end
|
155
|
+
|
156
|
+
|
145
157
|
|
146
158
|
def resource_name
|
147
159
|
demodulize(model_klass.name).downcase
|
@@ -211,6 +223,17 @@ module Conversocial
|
|
211
223
|
end
|
212
224
|
end
|
213
225
|
|
226
|
+
def new params={}
|
227
|
+
new_instance_of_klass model_klass, params
|
228
|
+
end
|
229
|
+
|
230
|
+
def new_instance_of_klass klass, params
|
231
|
+
new_instance = klass.new params
|
232
|
+
new_instance.send :assign_client, client
|
233
|
+
new_instance.send :assign_query_engine, self
|
234
|
+
new_instance
|
235
|
+
end
|
236
|
+
|
214
237
|
end
|
215
238
|
end
|
216
239
|
end
|
data/lib/conversocial/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: conversocial
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Misha Conway
|
@@ -60,6 +60,7 @@ files:
|
|
60
60
|
- lib/conversocial/resources/models/author.rb
|
61
61
|
- lib/conversocial/resources/models/base.rb
|
62
62
|
- lib/conversocial/resources/models/channel.rb
|
63
|
+
- lib/conversocial/resources/models/content.rb
|
63
64
|
- lib/conversocial/resources/models/conversation.rb
|
64
65
|
- lib/conversocial/resources/models/keyvalue.rb
|
65
66
|
- lib/conversocial/resources/models/report.rb
|