comufy 0.0.2.pre2 → 0.0.3pre1
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +2 -2
- data/example/comufy_example.rb +4 -6
- data/lib/comufy/config.rb +18 -31
- data/lib/comufy/constants.rb +15 -0
- data/lib/comufy/version.rb +2 -2
- data/lib/comufy.rb +776 -11
- data/spec/comufy_spec.rb +18 -8
- data/yaml/config.yaml +2 -0
- metadata +20 -9
- data/lib/comufy/connector.rb +0 -774
data/README.md
CHANGED
@@ -6,7 +6,7 @@ This library allows customers to interact with the Comufy backend and perform co
|
|
6
6
|
|
7
7
|
Add this line to your application's Gemfile:
|
8
8
|
|
9
|
-
gem '
|
9
|
+
gem 'comufy'
|
10
10
|
|
11
11
|
And then execute:
|
12
12
|
|
@@ -14,7 +14,7 @@ And then execute:
|
|
14
14
|
|
15
15
|
Or install it yourself as:
|
16
16
|
|
17
|
-
$ gem install
|
17
|
+
$ gem install comufy
|
18
18
|
|
19
19
|
## Usage
|
20
20
|
|
data/example/comufy_example.rb
CHANGED
@@ -1,12 +1,10 @@
|
|
1
1
|
require 'comufy'
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
APPLICATION_NAME = ARGV[2]
|
6
|
-
FACEBOOK_USER_ID = ARGV[3]
|
3
|
+
APPLICATION_NAME = ARGV[2]
|
4
|
+
FACEBOOK_USER_ID = ARGV[3]
|
7
5
|
|
8
|
-
connect = Comufy.
|
9
|
-
tag = Array[{name: :other_details, type: Comufy::
|
6
|
+
connect = Comufy.new(logger: ARGV[0], yaml: ARGV[1])
|
7
|
+
tag = Array[{name: :other_details, type: Comufy::Constants::STRING_TYPE}]
|
10
8
|
puts connect.register_tags(APPLICATION_NAME, tag)
|
11
9
|
|
12
10
|
# register a tag!
|
data/lib/comufy/config.rb
CHANGED
@@ -1,46 +1,33 @@
|
|
1
|
-
|
1
|
+
class Comufy
|
2
2
|
class Config
|
3
|
-
include Comufy
|
4
3
|
|
5
4
|
attr_reader :user, :password, :base_api_url
|
6
5
|
attr_accessor :access_token, :expiry_time
|
7
6
|
|
8
7
|
# Sets the environment settings for Comufy to send and receive messages.
|
9
|
-
# @param [Hash]
|
10
|
-
# [
|
11
|
-
# [String]
|
12
|
-
# [String]
|
13
|
-
# [
|
14
|
-
|
15
|
-
|
8
|
+
# @param [Hash] opts - all are optional
|
9
|
+
# [String] username - sets the username
|
10
|
+
# [String] password - sets the password
|
11
|
+
# [String] token - sets the access token
|
12
|
+
# [String] time - sets the expiry time
|
13
|
+
# [String] url - sets the url
|
14
|
+
# [String] yaml - the absolute path to the yaml file to read, all previously mentioned options are valid
|
15
|
+
def initialize opts = {}
|
16
|
+
opts = Comufy.symbolize_keys(opts)
|
16
17
|
|
17
18
|
begin
|
18
|
-
yaml_location =
|
19
|
-
yaml
|
20
|
-
yaml
|
19
|
+
yaml_location = opts.delete(:yaml)
|
20
|
+
yaml = YAML.load_file(yaml_location)
|
21
|
+
yaml = Comufy.symbolize_keys(yaml)
|
21
22
|
rescue
|
22
|
-
# TODO: should it check the ENV for the username and password?
|
23
23
|
yaml = Hash.new()
|
24
24
|
end
|
25
25
|
|
26
|
-
user
|
27
|
-
password
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
if (user and not password) or (password and not user)
|
32
|
-
raise "You must supply both a username and password."
|
33
|
-
end
|
34
|
-
|
35
|
-
@user = user || yaml.fetch(:config, {})['user']
|
36
|
-
@password = password || yaml.fetch(:config, {})['password']
|
37
|
-
@access_token = no_env ? nil : ENV.fetch('access_token', nil)
|
38
|
-
@expiry_time = no_env ? nil : ENV.fetch('expiry_time', nil)
|
39
|
-
|
40
|
-
staging ?
|
41
|
-
@base_api_url = 'https://staging.comufy.com/xcoreweb/client' :
|
42
|
-
@base_api_url = 'https://social.comufy.com/xcoreweb/client'
|
43
|
-
|
26
|
+
@user = yaml.delete(:user) || opts.delete(:user) || ENV.fetch('COMUFY_USER', nil)
|
27
|
+
@password = yaml.delete(:password) || opts.delete(:password) || ENV.fetch('COMUFY_PASSWORD', nil)
|
28
|
+
@access_token = yaml.delete(:token) || opts.delete(:token) || ENV.fetch('COMUFY_TOKEN', nil)
|
29
|
+
@expiry_time = yaml.delete(:time) || opts.delete(:time) || ENV.fetch('COMUFY_EXPIRY_TIME', nil)
|
30
|
+
@base_api_url = yaml.delete(:url) || opts.delete(:url) || ENV.fetch('COMUFY_URL', 'http://www.sociableapi.com/xcoreweb/client')
|
44
31
|
end
|
45
32
|
end
|
46
33
|
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
class Comufy::Constants
|
2
|
+
|
3
|
+
# values types for TYPE_TAG
|
4
|
+
STRING_TYPE = :STRING
|
5
|
+
DATE_TYPE = :DATE
|
6
|
+
GENDER_TYPE = :GENDER
|
7
|
+
INT_TYPE = :INT
|
8
|
+
FLOAT_TYPE = :FLOAT
|
9
|
+
LEGAL_TYPES = [STRING_TYPE, DATE_TYPE, GENDER_TYPE, INT_TYPE, FLOAT_TYPE]
|
10
|
+
|
11
|
+
# key choices for tags
|
12
|
+
NAME_TAG = :name
|
13
|
+
TYPE_TAG = :type
|
14
|
+
LEGAL_TAGS = [NAME_TAG, TYPE_TAG]
|
15
|
+
end
|
data/lib/comufy/version.rb
CHANGED
@@ -1,3 +1,3 @@
|
|
1
|
-
|
2
|
-
VERSION = "0.0.
|
1
|
+
class Comufy
|
2
|
+
VERSION = "0.0.3pre1"
|
3
3
|
end
|