socialyzer 0.0.1
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.
- data/lib/socialyzer.rb +36 -0
- metadata +77 -0
data/lib/socialyzer.rb
ADDED
@@ -0,0 +1,36 @@
|
|
1
|
+
module Socialyzer
|
2
|
+
require "rest_client"
|
3
|
+
require "json"
|
4
|
+
require "socialyzer/engine" if defined?(Rails)
|
5
|
+
|
6
|
+
if ENV['SOCIALYZER_API_KEY']
|
7
|
+
API_KEY = ENV['SOCIALYZER_API_KEY']
|
8
|
+
elsif defined?(SOCIALYZER_API_KEY)
|
9
|
+
API_KEY = SOCIALYZER_API_KEY
|
10
|
+
end
|
11
|
+
|
12
|
+
def self.add_twitter_user(screen_name)
|
13
|
+
api_request(:add_twitter_account, :user => screen_name)
|
14
|
+
end
|
15
|
+
|
16
|
+
def self.optimize(screen_name, options={})
|
17
|
+
api_request(:optimize, options.merge(:user => screen_name))
|
18
|
+
end
|
19
|
+
|
20
|
+
def self.twitter_user(screen_name)
|
21
|
+
api_request(:twitter_user, :user => screen_name)
|
22
|
+
end
|
23
|
+
|
24
|
+
def self.api_request(action, options={})
|
25
|
+
env = options.delete(:env) || :production
|
26
|
+
options.merge!(:key => API_KEY)
|
27
|
+
res = RestClient.post api_action(action, env), options.to_json, :content_type => :json, :accept => :json
|
28
|
+
JSON.parse(res)
|
29
|
+
end
|
30
|
+
|
31
|
+
def self.api_action(action, env=:production)
|
32
|
+
subdomain = env == :production ? "api" : "dev"
|
33
|
+
"http://#{subdomain}.socialyzerhq.com/api/#{action}.json"
|
34
|
+
end
|
35
|
+
|
36
|
+
end
|
metadata
ADDED
@@ -0,0 +1,77 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: socialyzer
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Rocco Stanzione
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2012-12-27 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: rest-client
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '0'
|
22
|
+
type: :runtime
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ! '>='
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '0'
|
30
|
+
- !ruby/object:Gem::Dependency
|
31
|
+
name: json
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
33
|
+
none: false
|
34
|
+
requirements:
|
35
|
+
- - ! '>='
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: '0'
|
38
|
+
type: :runtime
|
39
|
+
prerelease: false
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ! '>='
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: '0'
|
46
|
+
description: A ruby library for dealing with the Socialyzer API
|
47
|
+
email: rocco@socialyzerhq.com
|
48
|
+
executables: []
|
49
|
+
extensions: []
|
50
|
+
extra_rdoc_files: []
|
51
|
+
files:
|
52
|
+
- lib/socialyzer.rb
|
53
|
+
homepage: http://www.socialyzerhq.com
|
54
|
+
licenses: []
|
55
|
+
post_install_message:
|
56
|
+
rdoc_options: []
|
57
|
+
require_paths:
|
58
|
+
- lib
|
59
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
60
|
+
none: false
|
61
|
+
requirements:
|
62
|
+
- - ! '>='
|
63
|
+
- !ruby/object:Gem::Version
|
64
|
+
version: '0'
|
65
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
66
|
+
none: false
|
67
|
+
requirements:
|
68
|
+
- - ! '>='
|
69
|
+
- !ruby/object:Gem::Version
|
70
|
+
version: '0'
|
71
|
+
requirements: []
|
72
|
+
rubyforge_project:
|
73
|
+
rubygems_version: 1.8.24
|
74
|
+
signing_key:
|
75
|
+
specification_version: 3
|
76
|
+
summary: A ruby library for dealing with the Socialyzer API
|
77
|
+
test_files: []
|