littlebird_api_client 0.0.8 → 0.0.9
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 +8 -8
- data/lib/littlebird_api_client/errors/authorization.rb +5 -3
- data/lib/littlebird_api_client/errors/internal.rb +5 -3
- data/lib/littlebird_api_client/errors/parameter.rb +5 -3
- data/lib/littlebird_api_client/errors/rate_limit.rb +5 -3
- data/lib/littlebird_api_client/little_bird_errors.rb +11 -9
- data/lib/littlebird_api_client/response_type.rb +32 -30
- data/lib/littlebird_api_client/response_types/api_structure.rb +3 -1
- data/lib/littlebird_api_client/response_types/community.rb +3 -1
- data/lib/littlebird_api_client/response_types/compare_result.rb +8 -6
- data/lib/littlebird_api_client/response_types/discover_url.rb +3 -1
- data/lib/littlebird_api_client/response_types/download.rb +9 -0
- data/lib/littlebird_api_client/response_types/graph.rb +52 -51
- data/lib/littlebird_api_client/response_types/graph_attribute.rb +3 -1
- data/lib/littlebird_api_client/response_types/screen_name_resolution.rb +3 -1
- data/lib/littlebird_api_client/response_types/topic.rb +3 -1
- data/lib/littlebird_api_client/response_types/tweet.rb +3 -1
- data/lib/littlebird_api_client/response_types/user.rb +5 -3
- data/lib/littlebird_api_client/response_types/user_metric.rb +3 -1
- data/lib/littlebird_api_client.rb +1 -1
- data/littlebird_api_client.gemspec +1 -1
- metadata +2 -2
- data/lib/littlebird_api_client/response_types/gexf.rb +0 -7
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
Nzc5MWFmMmUxMzU2YjI0MzM2MGUzOGY3ZTI2MGVjOTU5ZTcxNmE4NA==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
ZTc4ZjM4YmMxMmI4NGM2MTAxYzY2MDMyMmYzZTU4NjhhYjM4M2ZmMQ==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
ZjFlMjY1MmUyMDg1NDljMDVkOTBhY2Y2MTMwM2RjZjI1MTZlMGE2ZDdlNWQy
|
10
|
+
ZDRlZDZhZWEzMTZiNDM3NjdiZTNjODc1ZmRiOTQ1YzRhY2FlOWI4NWQyY2Iy
|
11
|
+
OWE3YjI5MWIwMGIwYmExY2E5ZGJmNzI0ZDU3NzRmYjU5YTFjNWM=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
MGUzNjIyNmYxY2M1MjdlYTM3MzM2M2UxMmYxOThiYmUzNzYzMDc3YTFhMTdk
|
14
|
+
ZDYyMTNkY2JmNGUwNDI4MjA4NzQyZmI0Mjk4Y2Q3ZmExNmFlMzk1ZGZhNWNh
|
15
|
+
OGU0YjQ4NmQxYzcyZGUzODA0MjA4ZWVjN2VkZDQzODc4Mjk5MDc=
|
@@ -1,11 +1,13 @@
|
|
1
|
-
module
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
def message
|
8
|
-
@response.error+"\n"+@response.inspect
|
9
|
-
end
|
1
|
+
module LittleBird
|
2
|
+
module LittleBirdErrors
|
3
|
+
|
4
|
+
def initialize(response)
|
5
|
+
@response = response
|
6
|
+
end
|
10
7
|
|
8
|
+
def message
|
9
|
+
@response.error+"\n"+@response.inspect
|
10
|
+
end
|
11
|
+
|
12
|
+
end
|
11
13
|
end
|
@@ -1,40 +1,42 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
attrs
|
4
|
-
|
5
|
-
|
1
|
+
module LittleBird
|
2
|
+
class ResponseType
|
3
|
+
def initialize(attrs)
|
4
|
+
attrs.each do |key, value|
|
5
|
+
self.instance_eval { class << self; self end }.send(:attr_accessor, key.to_sym)
|
6
|
+
self.send(key+"=", parse_value(key, value))
|
7
|
+
end
|
8
|
+
self
|
6
9
|
end
|
7
|
-
self
|
8
|
-
end
|
9
10
|
|
10
|
-
|
11
|
-
|
12
|
-
|
11
|
+
def parse_value(key, value)
|
12
|
+
set_as_time_if_timestamp(key, value)
|
13
|
+
end
|
13
14
|
|
14
|
-
|
15
|
-
|
16
|
-
|
15
|
+
def set_as_time_if_timestamp(key, value)
|
16
|
+
self.class.timestamped_keys.include?(key) && !value.nil? ? Time.parse(value) : value
|
17
|
+
end
|
17
18
|
|
18
|
-
|
19
|
-
|
20
|
-
|
19
|
+
def self.timestamped_keys
|
20
|
+
["created_at", "started_at", "updated_at", "finished_at"]
|
21
|
+
end
|
21
22
|
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
23
|
+
def to_json(*a)
|
24
|
+
{
|
25
|
+
'json_class' => self.class.name,
|
26
|
+
'data' => attributes
|
27
|
+
}.to_json(*a)
|
28
|
+
end
|
28
29
|
|
29
|
-
|
30
|
-
|
31
|
-
|
30
|
+
def attributes
|
31
|
+
Hash[useful_attribute_names.zip(useful_attribute_names.map{|attribute| self.send(attribute)})]
|
32
|
+
end
|
32
33
|
|
33
|
-
|
34
|
-
|
35
|
-
|
34
|
+
def attribute_names
|
35
|
+
instance_variables.collect{|ivar| ivar.to_s.gsub("@", "")}
|
36
|
+
end
|
36
37
|
|
37
|
-
|
38
|
-
|
38
|
+
def useful_attribute_names
|
39
|
+
attribute_names-["client"]
|
40
|
+
end
|
39
41
|
end
|
40
42
|
end
|
@@ -1,9 +1,11 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
1
|
+
module LittleBird
|
2
|
+
class CompareResult < ResponseType
|
3
|
+
def initialize(data)
|
4
|
+
result = {}
|
5
|
+
data.each do |relation_type, user_data|
|
6
|
+
result[relation_type] = user_data.values.collect{|u| User.new(u)}
|
7
|
+
end
|
8
|
+
super(result)
|
6
9
|
end
|
7
|
-
super(result)
|
8
10
|
end
|
9
11
|
end
|
@@ -1,67 +1,68 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
1
|
+
module LittleBird
|
2
|
+
class Graph < ResponseType
|
3
|
+
def add(ids, opts={})
|
4
|
+
client.graph_add({identities: [ids].flatten, id: id}.merge(opts))
|
5
|
+
end
|
5
6
|
|
6
|
-
|
7
|
-
|
8
|
-
|
7
|
+
def download_gexf_to(analysis_id, file=StringIO.new)
|
8
|
+
client.graph_download(analysis_id: analysis_id, format: "gexf").to_file(file)
|
9
|
+
end
|
9
10
|
|
10
|
-
|
11
|
-
|
12
|
-
|
11
|
+
def download_csv_to(analysis_id, file=StringIO.new)
|
12
|
+
client.graph_download(analysis_id: analysis_id, format: "csv").to_file(file)
|
13
|
+
end
|
13
14
|
|
14
|
-
|
15
|
-
|
16
|
-
|
15
|
+
def analyze
|
16
|
+
client.graph_analyze(id: id)
|
17
|
+
end
|
17
18
|
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
19
|
+
def clear_attributes(opts)
|
20
|
+
names = opts.delete(:names) || opts.delete("names")
|
21
|
+
names.each do |name|
|
22
|
+
client.graph_clear_attribute(opts.merge(id: id, name: name))
|
23
|
+
end
|
22
24
|
end
|
23
|
-
end
|
24
25
|
|
25
|
-
|
26
|
-
|
27
|
-
|
26
|
+
def clear_attribute(opts)
|
27
|
+
client.graph_analyze(opts.merge(id: id))
|
28
|
+
end
|
28
29
|
|
29
|
-
|
30
|
-
|
31
|
-
|
30
|
+
def communities(analysis_id)
|
31
|
+
client.graph_community(analysis_id: analysis_id)
|
32
|
+
end
|
32
33
|
|
33
|
-
|
34
|
-
|
35
|
-
|
34
|
+
def community(analysis_id, community_id)
|
35
|
+
client.graph_community(analysis_id: analysis_id, community_id: community_id)
|
36
|
+
end
|
36
37
|
|
37
|
-
|
38
|
-
|
39
|
-
|
38
|
+
def communities_users(analysis_id)
|
39
|
+
client.graph_community(analysis_id: analysis_id, users: true)
|
40
|
+
end
|
40
41
|
|
41
|
-
|
42
|
-
|
43
|
-
|
42
|
+
def community_users(analysis_id, community_id)
|
43
|
+
client.graph_community(analysis_id: analysis_id, community_id: community_id, users: true)
|
44
|
+
end
|
44
45
|
|
45
|
-
|
46
|
-
|
47
|
-
|
46
|
+
def drop
|
47
|
+
client.graph_drop(id: id)
|
48
|
+
end
|
48
49
|
|
49
|
-
|
50
|
-
|
51
|
-
|
50
|
+
def info
|
51
|
+
client.graph_info(id: id)
|
52
|
+
end
|
52
53
|
|
53
|
-
|
54
|
-
|
55
|
-
|
54
|
+
def set_attribute
|
55
|
+
client.graph_set_attribute(opts.merge(id: id))
|
56
|
+
end
|
56
57
|
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
58
|
+
#usage params = {api_key: "533c98700765e035b1000001", term: "SNA", nodes: [19512246, 18911399, 2192301], attributes: {"name" => {"19512246" => 1, "18911399" => 2}}`, domain: "twitter"}
|
59
|
+
def self.run(opts={})
|
60
|
+
opts[:api_version] ||= 1
|
61
|
+
opts[:host] ||= "0.0.0.0:8083"
|
62
|
+
client = LittleBird::Client.new(opts[:api_key], opts[:api_version], opts[:host])
|
63
|
+
sub_graph = client.graph_create(term: opts[:term])
|
64
|
+
sub_graph.add(opts[:nodes], domain: opts[:domain])
|
65
|
+
sub_graph.analyze
|
66
|
+
end
|
65
67
|
end
|
66
|
-
|
67
68
|
end
|
@@ -15,7 +15,7 @@ require 'littlebird_api_client/response_types/api_structure'
|
|
15
15
|
require 'littlebird_api_client/response_types/community'
|
16
16
|
require 'littlebird_api_client/response_types/compare_result'
|
17
17
|
require 'littlebird_api_client/response_types/discover_url'
|
18
|
-
require 'littlebird_api_client/response_types/
|
18
|
+
require 'littlebird_api_client/response_types/download'
|
19
19
|
require 'littlebird_api_client/response_types/graph'
|
20
20
|
require 'littlebird_api_client/response_types/graph_attribute'
|
21
21
|
require 'littlebird_api_client/response_types/screen_name_resolution'
|
@@ -4,7 +4,7 @@ puts lib
|
|
4
4
|
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
5
5
|
Gem::Specification.new do |spec|
|
6
6
|
spec.name = "littlebird_api_client"
|
7
|
-
spec.version = '0.0.
|
7
|
+
spec.version = '0.0.9'
|
8
8
|
spec.authors = ["Devin Gaffney"]
|
9
9
|
spec.email = ["devin@getlittlebird.com"]
|
10
10
|
spec.summary = %q{A thin wrapper for the Little Bird api (http://api.getlittlebird.com/index.html)}
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: littlebird_api_client
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.9
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Devin Gaffney
|
@@ -65,7 +65,7 @@ files:
|
|
65
65
|
- lib/littlebird_api_client/response_types/community.rb
|
66
66
|
- lib/littlebird_api_client/response_types/compare_result.rb
|
67
67
|
- lib/littlebird_api_client/response_types/discover_url.rb
|
68
|
-
- lib/littlebird_api_client/response_types/
|
68
|
+
- lib/littlebird_api_client/response_types/download.rb
|
69
69
|
- lib/littlebird_api_client/response_types/graph.rb
|
70
70
|
- lib/littlebird_api_client/response_types/graph_attribute.rb
|
71
71
|
- lib/littlebird_api_client/response_types/screen_name_resolution.rb
|