littlebird_api_client 0.0.8 → 0.0.9

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- OGFiMGQ0YTEzOGZjOWNiY2E3NzA4MGNhMThlNDg5NTdiYTU0NTJhNg==
4
+ Nzc5MWFmMmUxMzU2YjI0MzM2MGUzOGY3ZTI2MGVjOTU5ZTcxNmE4NA==
5
5
  data.tar.gz: !binary |-
6
- NDI4MmVkN2Y3YzBmZWUzYjg2YWZlNGVjZGI4ZmVjYWVmYWRmMTVkNA==
6
+ ZTc4ZjM4YmMxMmI4NGM2MTAxYzY2MDMyMmYzZTU4NjhhYjM4M2ZmMQ==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- MGJlODg1MWRlODk5YjEyMTEzN2Q1NWFmYjE5NzMwZDRkMjhjNWZjNzEwMTQ4
10
- YTg5NjcxNDBjMWZiMDA0NWE1YjA2YTdlZTk5YjFiOWRhZGUxMzJhYWU0N2E2
11
- NzljNWZiY2JjYjVjNDlkY2QxNjUyNjc4NWFhNWZlNGI1ZjRhMGM=
9
+ ZjFlMjY1MmUyMDg1NDljMDVkOTBhY2Y2MTMwM2RjZjI1MTZlMGE2ZDdlNWQy
10
+ ZDRlZDZhZWEzMTZiNDM3NjdiZTNjODc1ZmRiOTQ1YzRhY2FlOWI4NWQyY2Iy
11
+ OWE3YjI5MWIwMGIwYmExY2E5ZGJmNzI0ZDU3NzRmYjU5YTFjNWM=
12
12
  data.tar.gz: !binary |-
13
- MDIxMTdjZWIwMWJiZjRhMjczZDI3NzdjOTI4MjEzZWZlOTg5NzUyODBjYjQ1
14
- YWMwZjNhOGRjY2ZlNDI2MmEzODU5NGNhNjdkYjhkMGFjZjkyYTNmZTYzNmY0
15
- MDUyYzkwMmFlNjYxNDU2YzcxNTk5ZDcwMmQzNzY1MzljMGU5MzU=
13
+ MGUzNjIyNmYxY2M1MjdlYTM3MzM2M2UxMmYxOThiYmUzNzYzMDc3YTFhMTdk
14
+ ZDYyMTNkY2JmNGUwNDI4MjA4NzQyZmI0Mjk4Y2Q3ZmExNmFlMzk1ZGZhNWNh
15
+ OGU0YjQ4NmQxYzcyZGUzODA0MjA4ZWVjN2VkZDQzODc4Mjk5MDc=
@@ -1,4 +1,6 @@
1
- class AuthorizationError < Exception
2
- include LittleBirdErrors
3
- attr_reader :response
1
+ module LittleBird
2
+ class AuthorizationError < Exception
3
+ include LittleBirdErrors
4
+ attr_reader :response
5
+ end
4
6
  end
@@ -1,4 +1,6 @@
1
- class InternalError < StandardError
2
- include LittleBirdErrors
3
- attr_reader :response
1
+ module LittleBird
2
+ class InternalError < StandardError
3
+ include LittleBirdErrors
4
+ attr_reader :response
5
+ end
4
6
  end
@@ -1,4 +1,6 @@
1
- class ParameterError < Exception
2
- include LittleBirdErrors
3
- attr_reader :response
1
+ module LittleBird
2
+ class ParameterError < Exception
3
+ include LittleBirdErrors
4
+ attr_reader :response
5
+ end
4
6
  end
@@ -1,4 +1,6 @@
1
- class RateLimitError < Exception
2
- include LittleBirdErrors
3
- attr_reader :response
1
+ module LittleBird
2
+ class RateLimitError < Exception
3
+ include LittleBirdErrors
4
+ attr_reader :response
5
+ end
4
6
  end
@@ -1,11 +1,13 @@
1
- module LittleBirdErrors
2
-
3
- def initialize(response)
4
- @response = response
5
- end
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
- class ResponseType
2
- def initialize(attrs)
3
- attrs.each do |key, value|
4
- self.instance_eval { class << self; self end }.send(:attr_accessor, key.to_sym)
5
- self.send(key+"=", parse_value(key, value))
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
- def parse_value(key, value)
11
- set_as_time_if_timestamp(key, value)
12
- end
11
+ def parse_value(key, value)
12
+ set_as_time_if_timestamp(key, value)
13
+ end
13
14
 
14
- def set_as_time_if_timestamp(key, value)
15
- self.class.timestamped_keys.include?(key) && !value.nil? ? Time.parse(value) : value
16
- end
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
- def self.timestamped_keys
19
- ["created_at", "started_at", "updated_at", "finished_at"]
20
- end
19
+ def self.timestamped_keys
20
+ ["created_at", "started_at", "updated_at", "finished_at"]
21
+ end
21
22
 
22
- def to_json(*a)
23
- {
24
- 'json_class' => self.class.name,
25
- 'data' => attributes
26
- }.to_json(*a)
27
- end
23
+ def to_json(*a)
24
+ {
25
+ 'json_class' => self.class.name,
26
+ 'data' => attributes
27
+ }.to_json(*a)
28
+ end
28
29
 
29
- def attributes
30
- Hash[useful_attribute_names.zip(useful_attribute_names.map{|attribute| self.send(attribute)})]
31
- end
30
+ def attributes
31
+ Hash[useful_attribute_names.zip(useful_attribute_names.map{|attribute| self.send(attribute)})]
32
+ end
32
33
 
33
- def attribute_names
34
- instance_variables.collect{|ivar| ivar.to_s.gsub("@", "")}
35
- end
34
+ def attribute_names
35
+ instance_variables.collect{|ivar| ivar.to_s.gsub("@", "")}
36
+ end
36
37
 
37
- def useful_attribute_names
38
- attribute_names-["client"]
38
+ def useful_attribute_names
39
+ attribute_names-["client"]
40
+ end
39
41
  end
40
42
  end
@@ -1,2 +1,4 @@
1
- class APIStructure < ResponseType
1
+ module LittleBird
2
+ class APIStructure < ResponseType
3
+ end
2
4
  end
@@ -1,2 +1,4 @@
1
- class Community < ResponseType
1
+ module LittleBird
2
+ class Community < ResponseType
3
+ end
2
4
  end
@@ -1,9 +1,11 @@
1
- class CompareResult < ResponseType
2
- def initialize(data)
3
- result = {}
4
- data.each do |relation_type, user_data|
5
- result[relation_type] = user_data.values.collect{|u| User.new(u)}
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,2 +1,4 @@
1
- class DiscoverURL < ResponseType
1
+ module LittleBird
2
+ class DiscoverURL < ResponseType
3
+ end
2
4
  end
@@ -0,0 +1,9 @@
1
+ module LittleBird
2
+ class Download < ResponseType
3
+ def to_file(file=StringIO.new)
4
+ file.write(self.result)
5
+ file.rewind
6
+ file
7
+ end
8
+ end
9
+ end
@@ -1,67 +1,68 @@
1
- class Graph < ResponseType
2
- def add(ids, opts={})
3
- client.graph_add({identities: [ids].flatten, id: id}.merge(opts))
4
- end
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
- def download_gexf_to(analysis_id, file=StringIO.new)
7
- client.graph_download(analysis_id: analysis_id, format: "gexf").to_file(file)
8
- end
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
- def download_csv_to(analysis_id, file=StringIO.new)
11
- client.graph_download(analysis_id: analysis_id, format: "csv").to_file(file)
12
- end
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
- def analyze
15
- client.graph_analyze(id: id)
16
- end
15
+ def analyze
16
+ client.graph_analyze(id: id)
17
+ end
17
18
 
18
- def clear_attributes(opts)
19
- names = opts.delete(:names) || opts.delete("names")
20
- names.each do |name|
21
- client.graph_clear_attribute(opts.merge(id: id, name: name))
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
- def clear_attribute(opts)
26
- client.graph_analyze(opts.merge(id: id))
27
- end
26
+ def clear_attribute(opts)
27
+ client.graph_analyze(opts.merge(id: id))
28
+ end
28
29
 
29
- def communities(analysis_id)
30
- client.graph_community(analysis_id: analysis_id)
31
- end
30
+ def communities(analysis_id)
31
+ client.graph_community(analysis_id: analysis_id)
32
+ end
32
33
 
33
- def community(analysis_id, community_id)
34
- client.graph_community(analysis_id: analysis_id, community_id: community_id)
35
- end
34
+ def community(analysis_id, community_id)
35
+ client.graph_community(analysis_id: analysis_id, community_id: community_id)
36
+ end
36
37
 
37
- def communities_users(analysis_id)
38
- client.graph_community(analysis_id: analysis_id, users: true)
39
- end
38
+ def communities_users(analysis_id)
39
+ client.graph_community(analysis_id: analysis_id, users: true)
40
+ end
40
41
 
41
- def community_users(analysis_id, community_id)
42
- client.graph_community(analysis_id: analysis_id, community_id: community_id, users: true)
43
- end
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
- def drop
46
- client.graph_drop(id: id)
47
- end
46
+ def drop
47
+ client.graph_drop(id: id)
48
+ end
48
49
 
49
- def info
50
- client.graph_info(id: id)
51
- end
50
+ def info
51
+ client.graph_info(id: id)
52
+ end
52
53
 
53
- def set_attribute
54
- client.graph_set_attribute(opts.merge(id: id))
55
- end
54
+ def set_attribute
55
+ client.graph_set_attribute(opts.merge(id: id))
56
+ end
56
57
 
57
- #usage params = {api_key: "533c98700765e035b1000001", term: "SNA", nodes: [19512246, 18911399, 2192301], attributes: {"name" => {"19512246" => 1, "18911399" => 2}}`, domain: "twitter"}
58
- def self.run(opts={})
59
- opts[:api_version] ||= 1
60
- opts[:host] ||= "0.0.0.0:8083"
61
- client = LittleBird::Client.new(opts[:api_key], opts[:api_version], opts[:host])
62
- sub_graph = client.graph_create(term: opts[:term])
63
- sub_graph.add(opts[:nodes], domain: opts[:domain])
64
- sub_graph.analyze
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
@@ -1,2 +1,4 @@
1
- class GraphAttribute < ResponseType
1
+ module LittleBird
2
+ class GraphAttribute < ResponseType
3
+ end
2
4
  end
@@ -1,2 +1,4 @@
1
- class ScreenNameResolution < ResponseType
1
+ module LittleBird
2
+ class ScreenNameResolution < ResponseType
3
+ end
2
4
  end
@@ -1,2 +1,4 @@
1
- class Topic < ResponseType
1
+ module LittleBird
2
+ class Topic < ResponseType
3
+ end
2
4
  end
@@ -1,2 +1,4 @@
1
- class Tweet < ResponseType
1
+ module LittleBird
2
+ class Tweet < ResponseType
3
+ end
2
4
  end
@@ -1,5 +1,7 @@
1
- class User < ResponseType
2
- def topics
3
- client.influencer_discover(domain: "twitter", identity: user.id)
1
+ module LittleBird
2
+ class User < ResponseType
3
+ def topics
4
+ client.influencer_discover(domain: "twitter", identity: user.id)
5
+ end
4
6
  end
5
7
  end
@@ -1,2 +1,4 @@
1
- class UserMetric < ResponseType
1
+ module LittleBird
2
+ class UserMetric < ResponseType
3
+ end
2
4
  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/gexf'
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.8'
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.8
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/gexf.rb
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
@@ -1,7 +0,0 @@
1
- class Download < ResponseType
2
- def to_file(file=StringIO.new)
3
- file.write(self.result)
4
- file.rewind
5
- file
6
- end
7
- end