comufyrails 0.1.8 → 0.1.10

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -9,18 +9,23 @@ messages to your users.
9
9
 
10
10
  Add any of the lines to your application's Gemfile:
11
11
 
12
- gem 'comufyrails'
13
- gem 'comufyrails', :git => "git://github.com/plcstevens/comufyrails.git"
14
- gem 'comufyrails', :path => "/path/to/comufyrails/directory"
12
+ ```bash
13
+ $ gem 'comufyrails'
14
+ $ gem 'comufyrails', :git => "git://github.com/plcstevens/comufyrails.git"
15
+ $ gem 'comufyrails', :path => "/path/to/comufyrails/directory"
16
+ ```
15
17
 
16
18
  And then execute:
17
19
 
18
- $ bundle
20
+ ```bash
21
+ $ bundle
22
+ ```
19
23
 
20
24
  Or install it yourself:
21
25
 
22
- $ gem install comufyrails
23
-
26
+ ```bash
27
+ $ gem install comufyrails
28
+ ```
24
29
 
25
30
  ## Web servers
26
31
 
@@ -39,7 +44,12 @@ service you will need to find another way to get these values, listed below.
39
44
  If you are using this on your local development machine or elsewhere you have two ways to configure this gem. You
40
45
  can get these values by using this heroku command below and looking for all values starting with 'COMUFY_'.
41
46
 
42
- heroku config
47
+ ```bash
48
+ $ heroku config | grep COMUFY
49
+ COMUFY_APP_NAME: Your Facebook Application Name
50
+ COMUFY_TOKEN: Your Access Token
51
+ COMUFY_URL: The URL you use to access Comufys API
52
+ ```
43
53
 
44
54
  ### Application Name
45
55
 
@@ -63,7 +73,7 @@ config.comufy_rails.url = 'COMUFY'
63
73
 
64
74
  Alternatively you can set these in your environment/path.
65
75
 
66
- ```
76
+ ```text
67
77
  COMUFY_APP_NAME - Application name on Comufy, defaults to your Ruby on Rails application name.
68
78
  COMUFY_TOKEN - Token given to you by our Comufy Heroku service or from Comufy directly.
69
79
  COMUFY_URL - Full HTTP address to connect to, defaults to our service.
@@ -74,18 +74,18 @@ module Comufyrails
74
74
  message = JSON.parse(http.response)
75
75
  case message["cd"]
76
76
  when 388 then
77
- Comufyrails.logger.debug("388 - Success! - data = #{data} - message = #{message}.")
77
+ Comufyrails.logger.debug("Success! Method: store_users, data: #{data}, response: #{message}.")
78
78
  when 475 then
79
- Comufyrails.logger.debug("475 - Invalid parameter provided. - data = #{data} - message = #{message}.")
79
+ Comufyrails.logger.debug("Invalid parameter provided! Method: store_users, data: #{data}, response: #{message}.")
80
80
  when 617 then
81
- Comufyrails.logger.debug("617 - Some of the tags passed are not registered. - data = #{data} - message = #{message}.")
81
+ Comufyrails.logger.debug("Some of the tags passed are not registered! Method: store_users, data: #{data}, response: #{message}.")
82
82
  when 632 then
83
- Comufyrails.logger.debug("632 - _ERROR_FACEBOOK_PAGE_NOT_FOUND - data = #{data} - message = #{message}.")
83
+ Comufyrails.logger.debug("_ERROR_FACEBOOK_PAGE_NOT_FOUND! Method: store_users, data: #{data}, response: #{message}.")
84
84
  else
85
- Comufyrails.logger.debug("UNKNOWN RESPONSE - data = #{data} - message = #{message}.")
85
+ Comufyrails.logger.debug("Unknown response from server! Method: store_users, data: #{data}, response: #{message}.")
86
86
  end
87
87
  else
88
- Comufyrails.logger.warn("Server responded with #{http.response_header}.")
88
+ Comufyrails.logger.warn("Bad response from server: #{http.response_header}.")
89
89
  end
90
90
  end
91
91
  end
@@ -160,30 +160,30 @@ module Comufyrails
160
160
  message = JSON.parse(http.response)
161
161
  case message["cd"]
162
162
  when 383 then
163
- Comufyrails.logger.debug("383 - Success! - data = #{data} - message = #{message}.")
163
+ Comufyrails.logger.debug("Success! Method: send_facebook_message, data: #{data}, response: #{message}.")
164
164
  when 416 then
165
- Comufyrails.logger.debug("416 - _ERROR_MSG_SEND_FAILED - data = #{data} - message = #{message}.")
165
+ Comufyrails.logger.debug("_ERROR_MSG_SEND_FAILED! Method: send_facebook_message, data: #{data}, response: #{message}.")
166
166
  when 475 then
167
- Comufyrails.logger.debug("475 - Invalid parameters provided - data = #{data} - message = #{message}.")
167
+ Comufyrails.logger.debug("Invalid parameters provided! Method: send_facebook_message, data: #{data}, response: #{message}.")
168
168
  when 551 then
169
- Comufyrails.logger.debug("551 _ERROR_TAG_VALUE_NOT_FOUND - data = #{data} - message = #{message}.")
169
+ Comufyrails.logger.debug("_ERROR_TAG_VALUE_NOT_FOUND! Method: send_facebook_message, data: #{data}, response: #{message}.")
170
170
  when 603 then
171
- Comufyrails.logger.debug("603 - _ERROR_DOMAIN_APPLICATION_NAME_NOT_FOUND - data = #{data} - message = #{message}.")
171
+ Comufyrails.logger.debug("_ERROR_DOMAIN_APPLICATION_NAME_NOT_FOUND! Method: send_facebook_message, data: #{data}, response: #{message}.")
172
172
  when 607 then
173
- Comufyrails.logger.debug("607 - _ERROR_UNAUTHORISED_ACTION - data = #{data} - message = #{message}.")
173
+ Comufyrails.logger.debug("_ERROR_UNAUTHORISED_ACTION! Method: send_facebook_message, data: #{data}, response: #{message}.")
174
174
  when 617 then
175
- Comufyrails.logger.debug("617 - _ERROR_DOMAIN_APPLICATION_TAG_NOT_FOUND - data = #{data} - message = #{message}.")
175
+ Comufyrails.logger.debug("_ERROR_DOMAIN_APPLICATION_TAG_NOT_FOUND! Method: send_facebook_message, data: #{data}, response: #{message}.")
176
176
  when 648 then
177
- Comufyrails.logger.debug("648 - _ERROR_FACEBOOK_APPLICATION_USER_NOT_FOUND - data = #{data} - message = #{message}.")
177
+ Comufyrails.logger.debug("_ERROR_FACEBOOK_APPLICATION_USER_NOT_FOUND! Method: send_facebook_message, data: #{data}, response: #{message}.")
178
178
  when 673 then
179
- Comufyrails.logger.debug("673 - Invalid time exception - data = #{data} - message = #{message}.")
179
+ Comufyrails.logger.debug("Invalid time exception! Method: send_facebook_message, data: #{data}, response: #{message}.")
180
180
  when 679 then
181
- Comufyrails.logger.debug("679 - _ERROR_MALFORMED_TARGETING_EXPRESSION - data = #{data} - message = #{message}.")
181
+ Comufyrails.logger.debug("_ERROR_MALFORMED_TARGETING_EXPRESSION! Method: send_facebook_message, data: #{data}, response: #{message}.")
182
182
  else
183
- Comufyrails.logger.debug("UNKNOWN RESPONSE - data = #{data} - message = #{message}.")
183
+ Comufyrails.logger.debug("Unknown response from server! Method: send_facebook_message, data: #{data}, response: #{message}.")
184
184
  end
185
185
  else
186
- Comufyrails.logger.warn("Server responded with #{http.response_header}.")
186
+ Comufyrails.logger.warn("Bad response from server: #{http.response_header}.")
187
187
  end
188
188
  end
189
189
  end
@@ -203,17 +203,18 @@ module Comufyrails
203
203
  if http.response_header.status == 200
204
204
  message = JSON.parse(http.response)
205
205
  if block_given?
206
+ # TODO: Cut into the response to make it easier for users to use this function.
206
207
  yield message
207
208
  else
208
209
  case message["cd"]
209
210
  when 219 then
210
- Comufyrails.logger.debug("219 - Success! - data = #{data} - message = #{message}.")
211
+ Comufyrails.logger.debug("Success! method: tags, data: #{data}, response: #{message}.")
211
212
  else
212
- Comufyrails.logger.debug("UNKNOWN RESPONSE - data = #{data} - message = #{message}.")
213
+ Comufyrails.logger.debug("Unknown response from server! Method: tags, data: #{data}, response: #{message}.")
213
214
  end
214
215
  end
215
216
  else
216
- Comufyrails.logger.warn("Server responded with #{http.response_header}.")
217
+ Comufyrails.logger.warn("Bad response from server: #{http.response_header}.")
217
218
  end
218
219
  end
219
220
  end
@@ -259,18 +260,18 @@ module Comufyrails
259
260
  else
260
261
  case message["cd"]
261
262
  when 382 then
262
- Comufyrails.logger.debug("382 - Success! - data = #{data} - message = #{message}.")
263
+ Comufyrails.logger.debug("Success! Method: users, data: #{data}, response: #{message}.")
263
264
  Comufyrails.logger.info("#{total} user(s) were found matching your filter.\n #{users}")
264
265
  when 692 then
265
- Comufyrails.logger.debug("692 - Invalid filter/filter not found - data = #{data} - message = #{message}.")
266
- Comufyrails.logger.info("Invalid filter/filter not found.\n #{users}")
266
+ Comufyrails.logger.debug("Invalid filter/filter not found! Method: users, data: #{data}, response: #{message}.")
267
+ Comufyrails.logger.info("Invalid filter/filter not found. #{users}")
267
268
  else
268
- Comufyrails.logger.debug("UNKNOWN RESPONSE - data = #{data} - message = #{message}.")
269
- Comufyrails.logger.info("Unknown response from server.\n #{users}")
269
+ Comufyrails.logger.debug("Unknown response from server! Method: users, data: #{data}, response: #{message}.")
270
+ Comufyrails.logger.info("Unknown response from server. #{users}")
270
271
  end
271
272
  end
272
273
  else
273
- Comufyrails.logger.warn("Server responded with #{http.response_header}, rather than the expected 200.")
274
+ Comufyrails.logger.warn("Bad response from server: #{http.response_header}.")
274
275
  end
275
276
  end
276
277
  end
@@ -1,4 +1,4 @@
1
1
  module Comufyrails
2
2
  # Current version of this gem.
3
- VERSION = "0.1.8"
3
+ VERSION = "0.1.10"
4
4
  end
@@ -10,21 +10,23 @@ namespace :comufy do
10
10
  raise ArgumentError, "Must specify a name for the tag." unless args.name
11
11
  args.with_defaults(type: 'STRING')
12
12
 
13
+ Comufyrails.logger = Logger.new(STDOUT) if Rails.env.development?
14
+
13
15
  if Comufyrails.config.app_name.blank?
14
- Comufyrails.logger.info("Cannot find the application name, is it currently set to nil or an empty string? Please check
15
- config.comufy_rails.app_name in your environment initializer or the environment variable
16
+ Comufyrails.logger.error("Cannot find the application name, is it currently set to nil or an empty string? Please
17
+ check config.comufy_rails.app_name in your environment initializer or the environment variable
16
18
  COMUFY_APP_NAME are valid strings. And remember you need to register your application with Comufy
17
19
  first with the comufy:app rake command.")
18
20
  elsif Comufyrails.config.url.blank?
19
- Comufyrails.logger.info("Cannot find the base api url, is it currently set to nil or an empty string?\n
21
+ Comufyrails.logger.error("Cannot find the base api url, is it currently set to nil or an empty string?
20
22
  Please check config.comufy_rails.url in your environment initializer or the environment variable
21
23
  COMUFY_URL are valid strings.")
22
24
  elsif Comufyrails.config.access_token.blank?
23
- Comufyrails.logger.info("Cannot find the access token, is it currently set to nil or an empty string?\n
25
+ Comufyrails.logger.error("Cannot find the access token, is it currently set to nil or an empty string?
24
26
  Please check config.comufy_rails.access_token in your environment initializer or the environment
25
27
  variable COMUFY_TOKEN are valid strings.")
26
28
  elsif not Comufyrails::LEGAL_TYPES.include?(args.type)
27
- Comufyrails.logger.info("The type must be #{Comufyrails::LEGAL_TYPES.to_sentence(last_word_connector: ', or ')}")
29
+ Comufyrails.logger.error("The type must be #{Comufyrails::LEGAL_TYPES.to_sentence(last_word_connector: ', or ')}")
28
30
  else
29
31
  data = {
30
32
  cd: 86,
@@ -36,6 +38,7 @@ namespace :comufy do
36
38
  }]
37
39
  }
38
40
 
41
+ Comufyrails.logger.debug("Preparing to add your tag #{args.name} to your application #{Comufyrails.config.app_name}.")
39
42
  uri = URI.parse(Comufyrails.config.url)
40
43
  http = Net::HTTP.new(uri.host, uri.port)
41
44
  http.use_ssl = true
@@ -48,20 +51,26 @@ namespace :comufy do
48
51
  case message["cd"]
49
52
  when 386 then
50
53
  Comufyrails.logger.debug("386 - Success! - data = #{data} - message = #{message}.")
54
+ Comufyrails.logger.info("Successfully added the tag #{args.name} to your application #{Comufyrails.config.app_name}.")
51
55
  when 475 then
52
56
  Comufyrails.logger.debug("475 - Invalid parameters provided - data = #{data} - message = #{message}.")
57
+ Comufyrails.logger.warn("Unable to add your tag #{args.name} to your application #{Comufyrails.config.app_name}.")
53
58
  when 603 then
54
59
  Comufyrails.logger.debug("603 - _ERROR_DOMAIN_APPLICATION_NAME_NOT_FOUND - data = #{data} - message = #{message}.")
60
+ Comufyrails.logger.warn("Unable to add your tag #{args.name} to your application #{Comufyrails.config.app_name}.")
55
61
  when 607 then
56
62
  Comufyrails.logger.debug("607 - _ERROR_UNAUTHORISED_ACTION - data = #{data} - message = #{message}.")
63
+ Comufyrails.logger.warn("Unable to add your tag #{args.name} to your application #{Comufyrails.config.app_name}.")
57
64
  when 618 then
58
65
  Comufyrails.logger.debug("618 - _ERROR_DOMAIN_APPLICATION_TAG_ALREADY_REGISTERED - data = #{data} - message = #{message}.")
66
+ Comufyrails.logger.warn("Unable to add your tag #{args.name} to your application #{Comufyrails.config.app_name}.")
59
67
  else
60
68
  Comufyrails.logger.debug("UNKNOWN RESPONSE - data = #{data} - message = #{message}.")
69
+ Comufyrails.logger.warn("Unable to add your tag #{args.name} to your application #{Comufyrails.config.app_name}.")
61
70
  end
62
71
  else
63
72
  Comufyrails.logger.debug("Rake task comufy:tag failed when sending #{data}.")
64
- Comufyrails.logger.warn("Authentication failed. Please get in touch with Comufy if you cannot resolve this.")
73
+ Comufyrails.logger.error("Authentication failed. Please get in touch with Comufy if you cannot resolve this.")
65
74
  end
66
75
  end
67
76
  end
@@ -70,17 +79,19 @@ namespace :comufy do
70
79
  task :detag , [:name] => :environment do |t, args|
71
80
  raise ArgumentError, "Must specify a name for the tag." unless args.name
72
81
 
82
+ Comufyrails.logger = Logger.new(STDOUT) if Rails.env.development?
83
+
73
84
  if Comufyrails.config.app_name.blank?
74
- Comufyrails.logger.info("Cannot find the application name, is it currently set to nil or an empty string? Please check
75
- config.comufy_rails.app_name in your environment initializer or the environment variable
85
+ Comufyrails.logger.error("Cannot find the application name, is it currently set to nil or an empty string? Please
86
+ check config.comufy_rails.app_name in your environment initializer or the environment variable
76
87
  COMUFY_APP_NAME are valid strings. And remember you need to register your application with Comufy
77
88
  first with the comufy:app rake command.")
78
89
  elsif Comufyrails.config.url.blank?
79
- Comufyrails.logger.info("Cannot find the base api url, is it currently set to nil or an empty string?\n
90
+ Comufyrails.logger.error("Cannot find the base api url, is it currently set to nil or an empty string?
80
91
  Please check config.comufy_rails.url in your environment initializer or the environment variable
81
92
  COMUFY_URL are valid strings.")
82
93
  elsif Comufyrails.config.access_token.blank?
83
- Comufyrails.logger.info("Cannot find the access token, is it currently set to nil or an empty string?\n
94
+ Comufyrails.logger.error("Cannot find the access token, is it currently set to nil or an empty string?
84
95
  Please check config.comufy_rails.access_token in your environment initializer or the environment
85
96
  variable COMUFY_TOKEN are valid strings.")
86
97
  else
@@ -91,6 +102,7 @@ namespace :comufy do
91
102
  tag: args.name
92
103
  }
93
104
 
105
+ Comufyrails.logger.debug("Preparing to send request to unregister the tag: #{args.name}")
94
106
  uri = URI.parse(Comufyrails.config.url)
95
107
  http = Net::HTTP.new(uri.host, uri.port)
96
108
  http.use_ssl = true
@@ -103,20 +115,26 @@ namespace :comufy do
103
115
  case message['cd']
104
116
  when 385 then
105
117
  Comufyrails.logger.debug("385 - Success! - data = #{data} - message = #{message}.")
118
+ Comufyrails.logger.warn("Success! Removed your tag #{args.name} from your application #{Comufyrails.config.app_name}.")
106
119
  when 475 then
107
120
  Comufyrails.logger.debug("475 - Invalid parameters provided - data = #{data} - message = #{message}.")
121
+ Comufyrails.logger.warn("Unable to remove your tag #{args.name} from your application #{Comufyrails.config.app_name}.")
108
122
  when 603 then
109
123
  Comufyrails.logger.debug("603 - _ERROR_DOMAIN_APPLICATION_NAME_NOT_FOUND - data = #{data} - message = #{message}.")
124
+ Comufyrails.logger.warn("Unable to remove your tag #{args.name} from your application #{Comufyrails.config.app_name}.")
110
125
  when 607 then
111
126
  Comufyrails.logger.debug("607 - _ERROR_UNAUTHORISED_ACTION - data = #{data} - message = #{message}.")
127
+ Comufyrails.logger.warn("Unable to remove your tag #{args.name} from your application #{Comufyrails.config.app_name}.")
112
128
  when 617 then
113
129
  Comufyrails.logger.debug("617 - _ERROR_DOMAIN_APPLICATION_TAG_NOT_FOUND - data = #{data} - message = #{message}.")
130
+ Comufyrails.logger.warn("Unable to remove your tag #{args.name} from your application #{Comufyrails.config.app_name}.")
114
131
  else
115
132
  Comufyrails.logger.debug("UNKNOWN RESPONSE - data = #{data} - message = #{message}.")
133
+ Comufyrails.logger.warn("Unable to remove your tag #{args.name} from your application #{Comufyrails.config.app_name}.")
116
134
  end
117
135
  else
118
136
  Comufyrails.logger.debug("Rake task comufy:tag failed when sending #{data}.")
119
- Comufyrails.logger.warn("Authentication failed. Please get in touch with Comufy if you cannot resolve this.")
137
+ Comufyrails.logger.error("Authentication failed. Please get in touch with Comufy if you cannot resolve this.")
120
138
  end
121
139
  end
122
140
  end
@@ -128,12 +146,14 @@ namespace :comufy do
128
146
  raise ArgumentError, "Must specify a facebook secret for the application." unless args.secret
129
147
  raise ArgumentError, "Must specify a description for the application." unless args.description
130
148
 
149
+ Comufyrails.logger = Logger.new(STDOUT) if Rails.env.development?
150
+
131
151
  if Comufyrails.config.url.blank?
132
- Comufyrails.logger.info("Cannot find the base api url, is it currently set to nil or an empty string?
152
+ Comufyrails.logger.error("Cannot find the base api url, is it currently set to nil or an empty string?
133
153
  Please check config.comufy_rails.url in your environment initializer or the environment variable
134
154
  COMUFY_URL are valid strings.")
135
155
  elsif Comufyrails.config.access_token.blank?
136
- Comufyrails.logger.info("Cannot find the access token, is it currently set to nil or an empty string?
156
+ Comufyrails.logger.error("Cannot find the access token, is it currently set to nil or an empty string?
137
157
  Please check config.comufy_rails.access_token in your environment initializer or the environment
138
158
  variable COMUFY_TOKEN are valid strings.")
139
159
  else
@@ -146,6 +166,7 @@ namespace :comufy do
146
166
  applicationSecret: args.secret
147
167
  }
148
168
 
169
+ Comufyrails.logger.debug("Preparing to add your application #{args.name} to Comufy.")
149
170
  uri = URI.parse(Comufyrails.config.url)
150
171
  http = Net::HTTP.new(uri.host, uri.port)
151
172
  http.use_ssl = true
@@ -158,18 +179,23 @@ namespace :comufy do
158
179
  case message['cd']
159
180
  when 205 then
160
181
  Comufyrails.logger.debug("205 - Success! - data = #{data} - message = #{message}.")
182
+ Comufyrails.logger.warn("Success! Able to add your application #{args.name} to Comufy.")
161
183
  when 602 then
162
184
  Comufyrails.logger.debug("602 - _ERROR_DOMAIN_APPLICATION_NAME_ALREADY_REGISTERED - data = #{data} - message = #{message}.")
185
+ Comufyrails.logger.warn("Unable to add your application #{args.name}.")
163
186
  when 619 then
164
187
  Comufyrails.logger.debug("619 - _ERROR_DOMAIN_APPLICATION_ALREADY_REGISTERED_UNDER_DIFFERENT_NAME - data = #{data} - message = #{message}.")
188
+ Comufyrails.logger.warn("Unable to add your application #{args.name}.")
165
189
  when 645 then
166
190
  Comufyrails.logger.debug("645 - _ERROR_FACEBOOK_AUTHORISATION_FAILURE - data = #{data} - message = #{message}.")
191
+ Comufyrails.logger.warn("Unable to add your application #{args.name}.")
167
192
  else
168
193
  Comufyrails.logger.debug("UNKNOWN RESPONSE - data = #{data} - message = #{message}.")
194
+ Comufyrails.logger.warn("Unable to add your application #{args.name}.")
169
195
  end
170
196
  else
171
197
  Comufyrails.logger.debug("Rake task comufy:tag failed when sending #{data}.")
172
- Comufyrails.logger.warn("Authentication failed. Please get in touch with Comufy if you cannot resolve this.")
198
+ Comufyrails.logger.error("Authentication failed. Please get in touch with Comufy if you cannot resolve this.")
173
199
  end
174
200
  end
175
201
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: comufyrails
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.8
4
+ version: 0.1.10
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-01-14 00:00:00.000000000 Z
12
+ date: 2013-01-17 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: activesupport
@@ -134,5 +134,5 @@ rubyforge_project:
134
134
  rubygems_version: 1.8.24
135
135
  signing_key:
136
136
  specification_version: 3
137
- summary: comufyrails-0.1.8
137
+ summary: comufyrails-0.1.10
138
138
  test_files: []