rgigya 1.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.rvmrc +1 -0
- data/Gemfile +18 -0
- data/Gemfile.lock +54 -0
- data/LICENSE.txt +20 -0
- data/README.rdoc +135 -0
- data/Rakefile +36 -0
- data/VERSION +1 -0
- data/lib/rgigya.rb +196 -0
- data/rgigya.gemspec +118 -0
- data/spec/helpers.rb +8 -0
- data/spec/rgigya_spec.rb +310 -0
- data/spec/spec_helper.rb +12 -0
- data/test/dummy/Gemfile +40 -0
- data/test/dummy/Gemfile.lock +119 -0
- data/test/dummy/README.rdoc +261 -0
- data/test/dummy/Rakefile +7 -0
- data/test/dummy/app/assets/images/rails.png +0 -0
- data/test/dummy/app/assets/javascripts/application.js +15 -0
- data/test/dummy/app/assets/stylesheets/application.css +23 -0
- data/test/dummy/app/controllers/application_controller.rb +3 -0
- data/test/dummy/app/controllers/welcome_controller.rb +22 -0
- data/test/dummy/app/helpers/application_helper.rb +2 -0
- data/test/dummy/app/mailers/.gitkeep +0 -0
- data/test/dummy/app/models/.gitkeep +0 -0
- data/test/dummy/app/views/layouts/application.html.erb +44 -0
- data/test/dummy/app/views/welcome/index.html +0 -0
- data/test/dummy/app/views/welcome/index.html.erb +14 -0
- data/test/dummy/config/application.rb +62 -0
- data/test/dummy/config/boot.rb +6 -0
- data/test/dummy/config/database.yml +25 -0
- data/test/dummy/config/environment.rb +5 -0
- data/test/dummy/config/environments/development.rb +42 -0
- data/test/dummy/config/environments/production.rb +67 -0
- data/test/dummy/config/environments/test.rb +37 -0
- data/test/dummy/config/initializers/backtrace_silencers.rb +7 -0
- data/test/dummy/config/initializers/inflections.rb +15 -0
- data/test/dummy/config/initializers/mime_types.rb +5 -0
- data/test/dummy/config/initializers/secret_token.rb +7 -0
- data/test/dummy/config/initializers/session_store.rb +8 -0
- data/test/dummy/config/initializers/wrap_parameters.rb +14 -0
- data/test/dummy/config/locales/en.yml +5 -0
- data/test/dummy/config/routes.rb +60 -0
- data/test/dummy/config.ru +4 -0
- data/test/dummy/db/development.sqlite3 +0 -0
- data/test/dummy/db/seeds.rb +7 -0
- data/test/dummy/lib/assets/.gitkeep +0 -0
- data/test/dummy/lib/tasks/.gitkeep +0 -0
- data/test/dummy/log/.gitkeep +0 -0
- data/test/dummy/log/development.log +1130 -0
- data/test/dummy/public/404.html +26 -0
- data/test/dummy/public/422.html +26 -0
- data/test/dummy/public/500.html +25 -0
- data/test/dummy/public/favicon.ico +0 -0
- data/test/dummy/public/robots.txt +5 -0
- data/test/dummy/script/rails +6 -0
- data/test/dummy/test/fixtures/.gitkeep +0 -0
- data/test/dummy/test/functional/.gitkeep +0 -0
- data/test/dummy/test/integration/.gitkeep +0 -0
- data/test/dummy/test/performance/browsing_test.rb +12 -0
- data/test/dummy/test/test_helper.rb +13 -0
- data/test/dummy/test/unit/.gitkeep +0 -0
- data/test/dummy/vendor/assets/javascripts/.gitkeep +0 -0
- data/test/dummy/vendor/assets/stylesheets/.gitkeep +0 -0
- data/test/dummy/vendor/plugins/.gitkeep +0 -0
- metadata +180 -0
data/.rvmrc
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
rvm use ruby-1.9.3-p125@rgigya --create
|
data/Gemfile
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
source "http://rubygems.org"
|
2
|
+
# Add dependencies required to use your gem here.
|
3
|
+
# Example:
|
4
|
+
# gem "activesupport", ">= 2.3.5"
|
5
|
+
|
6
|
+
# Add dependencies to develop your gem here.
|
7
|
+
# Include everything needed to run rake, tests, features, etc.
|
8
|
+
group :development do
|
9
|
+
gem "jeweler", "~> 1.8.4"
|
10
|
+
gem "shoulda", ">= 0"
|
11
|
+
gem "rdoc", "~> 3.12"
|
12
|
+
gem "bundler", "~> 1.3.4"
|
13
|
+
gem "rspec"
|
14
|
+
end
|
15
|
+
|
16
|
+
|
17
|
+
|
18
|
+
gem 'httparty', "~> 0.11.0"
|
data/Gemfile.lock
ADDED
@@ -0,0 +1,54 @@
|
|
1
|
+
GEM
|
2
|
+
remote: http://rubygems.org/
|
3
|
+
specs:
|
4
|
+
activesupport (3.2.13)
|
5
|
+
i18n (= 0.6.1)
|
6
|
+
multi_json (~> 1.0)
|
7
|
+
bourne (1.4.0)
|
8
|
+
mocha (~> 0.13.2)
|
9
|
+
diff-lcs (1.2.3)
|
10
|
+
git (1.2.5)
|
11
|
+
httparty (0.11.0)
|
12
|
+
multi_json (~> 1.0)
|
13
|
+
multi_xml (>= 0.5.2)
|
14
|
+
i18n (0.6.1)
|
15
|
+
jeweler (1.8.4)
|
16
|
+
bundler (~> 1.0)
|
17
|
+
git (>= 1.2.5)
|
18
|
+
rake
|
19
|
+
rdoc
|
20
|
+
json (1.7.7)
|
21
|
+
metaclass (0.0.1)
|
22
|
+
mocha (0.13.3)
|
23
|
+
metaclass (~> 0.0.1)
|
24
|
+
multi_json (1.7.2)
|
25
|
+
multi_xml (0.5.3)
|
26
|
+
rake (10.0.4)
|
27
|
+
rdoc (3.12.2)
|
28
|
+
json (~> 1.4)
|
29
|
+
rspec (2.13.0)
|
30
|
+
rspec-core (~> 2.13.0)
|
31
|
+
rspec-expectations (~> 2.13.0)
|
32
|
+
rspec-mocks (~> 2.13.0)
|
33
|
+
rspec-core (2.13.1)
|
34
|
+
rspec-expectations (2.13.0)
|
35
|
+
diff-lcs (>= 1.1.3, < 2.0)
|
36
|
+
rspec-mocks (2.13.1)
|
37
|
+
shoulda (3.4.0)
|
38
|
+
shoulda-context (~> 1.0, >= 1.0.1)
|
39
|
+
shoulda-matchers (~> 1.0, >= 1.4.1)
|
40
|
+
shoulda-context (1.1.0)
|
41
|
+
shoulda-matchers (1.5.6)
|
42
|
+
activesupport (>= 3.0.0)
|
43
|
+
bourne (~> 1.3)
|
44
|
+
|
45
|
+
PLATFORMS
|
46
|
+
ruby
|
47
|
+
|
48
|
+
DEPENDENCIES
|
49
|
+
bundler (~> 1.3.4)
|
50
|
+
httparty (~> 0.11.0)
|
51
|
+
jeweler (~> 1.8.4)
|
52
|
+
rdoc (~> 3.12)
|
53
|
+
rspec
|
54
|
+
shoulda
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2013 Scott
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.rdoc
ADDED
@@ -0,0 +1,135 @@
|
|
1
|
+
= RGigya
|
2
|
+
|
3
|
+
RGigya is an sdk wrapper around the Gigya Rest Api.
|
4
|
+
|
5
|
+
== Install
|
6
|
+
|
7
|
+
gem install rgigya
|
8
|
+
|
9
|
+
== Getting started
|
10
|
+
|
11
|
+
Please read the documentation at gigya for best practices. http://developers.gigya.com/037_API_reference. You may need to create a developers account to access the documentation.
|
12
|
+
|
13
|
+
=== Get your api key and secret.
|
14
|
+
|
15
|
+
You will need to setup your own dev site on the gigya platform for testing.
|
16
|
+
|
17
|
+
* Go to https://platform.gigya.com/login.aspx to login.
|
18
|
+
* Once you have logged into the platform. Click "add site"
|
19
|
+
* Enter a domain and description and click add site
|
20
|
+
* Remember the api key and secret for later
|
21
|
+
|
22
|
+
=== Without Rails (Standalone)
|
23
|
+
|
24
|
+
require 'RGigya'
|
25
|
+
|
26
|
+
GIGYA_API_KEY = "<add api key here>"
|
27
|
+
GIGYA_API_SECRET = "<add api secret here>"
|
28
|
+
|
29
|
+
RGigya.socialize_notifyLogin({:siteUID => '1'})
|
30
|
+
|
31
|
+
|
32
|
+
=== With Rails
|
33
|
+
|
34
|
+
Edit your config/environments/development.rb file and add the following constants
|
35
|
+
|
36
|
+
|
37
|
+
GIGYA_API_KEY = "<add api key here>"
|
38
|
+
GIGYA_API_SECRET = "<add api secret here>"
|
39
|
+
|
40
|
+
Then add your api calls in your controllers, models, libraries, etc.
|
41
|
+
|
42
|
+
RGigya.socialize_notifyLogin({:siteUID => '1'})
|
43
|
+
|
44
|
+
|
45
|
+
== Examples
|
46
|
+
|
47
|
+
=== socialize.notifyLogin
|
48
|
+
|
49
|
+
http://developers.gigya.com/037_API_reference/010_Socialize/socialize.notifyLogin
|
50
|
+
|
51
|
+
userInfo = {
|
52
|
+
'nickname' => 'Gigems',
|
53
|
+
'email' => 'ralph@cloudspace.com',
|
54
|
+
'firstName' => 'Ralph',
|
55
|
+
'lastName' => 'Masterson'
|
56
|
+
}
|
57
|
+
|
58
|
+
RGigya.socialize_notifyLogin({:siteUID => '1', :userInfo => userInfo.to_json} )
|
59
|
+
|
60
|
+
=== gm.notifyAction
|
61
|
+
|
62
|
+
http://developers.gigya.com/037_API_reference/040_GM/gm.notifyAction
|
63
|
+
|
64
|
+
RGigya.gm_notifyAction(:uid => '1',:action => 'comment_upvote')
|
65
|
+
|
66
|
+
=== comments.flagComment
|
67
|
+
|
68
|
+
http://developers.gigya.com/037_API_reference/030_Comments/comments.flagComment
|
69
|
+
|
70
|
+
gigya_params = {
|
71
|
+
:commentID => params[:commentID],
|
72
|
+
:categoryID => params[:categoryID],
|
73
|
+
:streamID => params[:streamID]
|
74
|
+
}
|
75
|
+
|
76
|
+
RGigya.comments_flagComment(gigya_params)
|
77
|
+
|
78
|
+
== Rspec Tests
|
79
|
+
|
80
|
+
We have included rspec unit tests.
|
81
|
+
|
82
|
+
=== Configuration
|
83
|
+
|
84
|
+
Edit spec/spec_helper.rb
|
85
|
+
|
86
|
+
Replace <add api key here> with your api key
|
87
|
+
Replace <add api secret here> with your api secret
|
88
|
+
|
89
|
+
|
90
|
+
=== Running tests
|
91
|
+
|
92
|
+
cd <root of the project>
|
93
|
+
rspec rgigya_spec.rb
|
94
|
+
|
95
|
+
|
96
|
+
== Rails dummy site
|
97
|
+
|
98
|
+
We have included a rails dummy site to give you an idea of how to integrate the gem within rails. It just peforms a simple login.
|
99
|
+
|
100
|
+
=== Configuration
|
101
|
+
|
102
|
+
* Edit app/views/layouts/application.html.erb
|
103
|
+
* replace <add api key here> with your api key. You do NOT need a secret on this page.
|
104
|
+
* replace the callback to be appropriate to your dev site.
|
105
|
+
* In my case I added dev.rgigya.com to my hosts file and pointed it to localhost (127.0.0.1)
|
106
|
+
* I then made the callback http://dev.rgigya.com/welcome.html in application.html.erb
|
107
|
+
* Edit config/environments/development.rb and add the following constants
|
108
|
+
* GIGYA_API_KEY = "<add api key here>"
|
109
|
+
* GIGYA_API_SECRET = "<add api secret here>"
|
110
|
+
|
111
|
+
=== Running the rails app
|
112
|
+
|
113
|
+
cd test/dummy
|
114
|
+
bundle
|
115
|
+
sudo rails s -p80
|
116
|
+
|
117
|
+
== New Feature Ideas
|
118
|
+
|
119
|
+
* Rake tasks that help manage the data in gigya such as removing test users.
|
120
|
+
|
121
|
+
== Contributing to RGigya
|
122
|
+
|
123
|
+
* Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet.
|
124
|
+
* Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it.
|
125
|
+
* Fork the project.
|
126
|
+
* Start a feature/bugfix branch.
|
127
|
+
* Commit and push until you are happy with your contribution.
|
128
|
+
* Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
|
129
|
+
* Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.
|
130
|
+
|
131
|
+
== Copyright
|
132
|
+
|
133
|
+
Copyright (c) 2013 Cloudspace. See LICENSE.txt for
|
134
|
+
further details.
|
135
|
+
|
data/Rakefile
ADDED
@@ -0,0 +1,36 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require 'rubygems'
|
4
|
+
require 'bundler'
|
5
|
+
begin
|
6
|
+
Bundler.setup(:default, :development)
|
7
|
+
rescue Bundler::BundlerError => e
|
8
|
+
$stderr.puts e.message
|
9
|
+
$stderr.puts "Run `bundle install` to install missing gems"
|
10
|
+
exit e.status_code
|
11
|
+
end
|
12
|
+
require 'rake'
|
13
|
+
|
14
|
+
require 'jeweler'
|
15
|
+
Jeweler::Tasks.new do |gem|
|
16
|
+
# gem is a Gem::Specification... see http://docs.rubygems.org/read/chapter/20 for more options
|
17
|
+
gem.name = "rgigya"
|
18
|
+
gem.homepage = "http://github.com/scottsampson/rgigya"
|
19
|
+
gem.license = "MIT"
|
20
|
+
gem.summary = %Q{Ruby Wrapper/SDK for the Gigya api}
|
21
|
+
gem.description = %Q{This is a ruby SDK for the Gigya api.}
|
22
|
+
gem.email = "scott@cloudspace.com"
|
23
|
+
gem.authors = ["Scott Sampson"]
|
24
|
+
# dependencies defined in Gemfile
|
25
|
+
end
|
26
|
+
Jeweler::RubygemsDotOrgTasks.new
|
27
|
+
|
28
|
+
require 'rdoc/task'
|
29
|
+
Rake::RDocTask.new do |rdoc|
|
30
|
+
version = File.exist?('VERSION') ? File.read('VERSION') : ""
|
31
|
+
|
32
|
+
rdoc.rdoc_dir = 'rdoc'
|
33
|
+
rdoc.title = "rgigya #{version}"
|
34
|
+
rdoc.rdoc_files.include('README*')
|
35
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
36
|
+
end
|
data/VERSION
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
1.0.1
|
data/lib/rgigya.rb
ADDED
@@ -0,0 +1,196 @@
|
|
1
|
+
require 'json'
|
2
|
+
require 'httparty'
|
3
|
+
require 'CGI'
|
4
|
+
|
5
|
+
#
|
6
|
+
# Quick sdk for the gigya api
|
7
|
+
#
|
8
|
+
# You can reference api calls at http://developers.gigya.com/037_API_reference
|
9
|
+
#
|
10
|
+
# Example call
|
11
|
+
# RGigya.socialize_setStatus(:uid => @user.id,:status => 'hello')
|
12
|
+
#
|
13
|
+
# We split the method name by the underscore and then map
|
14
|
+
# the first token to the correct url using the @@urls class variable
|
15
|
+
# The example above calls the url https://socialize.gigya.com/socialize.setStatus
|
16
|
+
#
|
17
|
+
# @author Scott Sampson
|
18
|
+
|
19
|
+
|
20
|
+
#
|
21
|
+
# Constants to be used for the gigya key and secret.
|
22
|
+
# These should be commented out and set in your environments for your rails project.
|
23
|
+
# Uncomment below for testing without rails
|
24
|
+
#
|
25
|
+
# GIGYA_API_KEY = "12345"
|
26
|
+
# GIGYA_API_SECRET = "12345"
|
27
|
+
|
28
|
+
|
29
|
+
class RGigya
|
30
|
+
|
31
|
+
# Mapping to different urls based on api groupings
|
32
|
+
@@urls = {
|
33
|
+
socialize: "https://socialize-api.gigya.com",
|
34
|
+
gm: "https://gm.gigya.com",
|
35
|
+
comments: "https://comments.gigya.com",
|
36
|
+
accounts: "https://accounts.gigya.com",
|
37
|
+
reports: "https://reports.gigya.com",
|
38
|
+
chat: "https://chat.gigya.com",
|
39
|
+
ds: "https://ds.gigya.com"
|
40
|
+
}
|
41
|
+
|
42
|
+
#
|
43
|
+
# Custom Exceptions so we know it came from the library
|
44
|
+
# When in use please namespace them appropriately RGigya::ResponseError for readability
|
45
|
+
#
|
46
|
+
exceptions = %w[ UIDParamIsNil SiteUIDParamIsNil ResponseError BadParamsOrMethodName ErrorCodeReturned ]
|
47
|
+
exceptions.each { |e| const_set(e, Class.new(StandardError)) }
|
48
|
+
RGigya::JSONParseError = Class.new(JSON::ParserError)
|
49
|
+
|
50
|
+
class << self
|
51
|
+
|
52
|
+
#
|
53
|
+
# Adds the required params for all api calls
|
54
|
+
#
|
55
|
+
def required_parameters
|
56
|
+
params = "apiKey=#{CGI.escape(GIGYA_API_KEY)}"
|
57
|
+
params += "&secret=#{CGI.escape(GIGYA_API_SECRET)}"
|
58
|
+
params += "&format=json"
|
59
|
+
end
|
60
|
+
|
61
|
+
#
|
62
|
+
# builds the url to be sent to the api
|
63
|
+
#
|
64
|
+
# @param [String] method The method name to be called in the gigya api
|
65
|
+
# @param [Hash] options Hash of key value pairs passed to the gigya api
|
66
|
+
#
|
67
|
+
# @return [String] the full url to be sent to the api
|
68
|
+
#
|
69
|
+
# @author Scott Sampson
|
70
|
+
def build_url(method, options = {})
|
71
|
+
if options && options.has_key?(:uid) && options[:uid].nil?
|
72
|
+
raise RGigya::UIDParamIsNil, ""
|
73
|
+
end
|
74
|
+
|
75
|
+
if options && options.has_key?(:siteUID) && options[:siteUID].nil?
|
76
|
+
raise RGigya::SiteUIDParamIsNil, ""
|
77
|
+
end
|
78
|
+
|
79
|
+
method_type,method_name = method.split(".")
|
80
|
+
url = "#{@@urls[method_type.to_sym]}/#{method}?#{required_parameters}"
|
81
|
+
if(options)
|
82
|
+
options.each do |key,value|
|
83
|
+
url += "&#{key}=#{CGI.escape(value.to_s)}"
|
84
|
+
end
|
85
|
+
end
|
86
|
+
url
|
87
|
+
end
|
88
|
+
|
89
|
+
#
|
90
|
+
# sends the https call to gigya and parses the result
|
91
|
+
#
|
92
|
+
# @param [String] method The method name to be called in the gigya api
|
93
|
+
# @param [Hash] options Hash of key value pairs passed to the gigya api
|
94
|
+
#
|
95
|
+
# @return [Hash] hash of the api results in key/value format
|
96
|
+
#
|
97
|
+
# @author Scott Sampson
|
98
|
+
def parse_results(method, options = {})
|
99
|
+
# options = {} if options.is_a?(String) && options.blank?
|
100
|
+
begin
|
101
|
+
response = HTTParty.get(build_url(method, options),{:timeout => 10})
|
102
|
+
rescue SocketError,Timeout::Error => e
|
103
|
+
raise RGigya::ResponseError, e.message
|
104
|
+
end
|
105
|
+
return false if response.nil? || response.body == "Bad Request"
|
106
|
+
|
107
|
+
begin
|
108
|
+
doc = JSON(response.body)
|
109
|
+
rescue JSON::ParserError => e
|
110
|
+
raise RGigya::JSONParseError, e.message
|
111
|
+
end
|
112
|
+
doc
|
113
|
+
end
|
114
|
+
|
115
|
+
#
|
116
|
+
# Error handling of the results
|
117
|
+
#
|
118
|
+
# @param [String] The method name to be called in the gigya api
|
119
|
+
# @param [Hash] results Hash of key value pairs returned by the results
|
120
|
+
#
|
121
|
+
# @return [String] hash of a successful api call
|
122
|
+
#
|
123
|
+
# TODO: Shouldn't fail so hard. If there is a temporary connectivity problem we should fail more gracefully.
|
124
|
+
# You can find a list of response codes at http://developers.gigya.com/037_API_reference/zz_Response_Codes_and_Errors
|
125
|
+
#
|
126
|
+
# @author Scott Sampson
|
127
|
+
def check_for_errors(results)
|
128
|
+
case results['errorCode'].to_s
|
129
|
+
when '0'
|
130
|
+
return results
|
131
|
+
when '400124'
|
132
|
+
#Limit Reached error - don't fail so bad
|
133
|
+
when '400002'
|
134
|
+
raise RGigya::BadParamsOrMethodName, results['errorDetails']
|
135
|
+
else
|
136
|
+
log("RGigya returned Error code #{results['errorCode']}.\n\nError Message: #{results['errorMessage']}\n\nError Details: #{results['errorDetails']}")
|
137
|
+
raise RGigya::ErrorCodeReturned, "returned Error code #{results['errorCode']}: #{results['errorMessage']}"
|
138
|
+
end
|
139
|
+
end
|
140
|
+
|
141
|
+
##
|
142
|
+
# Override method_missing so we don't have to write all the dang methods
|
143
|
+
#
|
144
|
+
# @param [Symbol] sym The method symbol
|
145
|
+
# @param [*Array] args The splatted array of method arguments passed in
|
146
|
+
#
|
147
|
+
# @author Scott Sampson
|
148
|
+
def method_missing(sym, *args)
|
149
|
+
|
150
|
+
method = sym.to_s.gsub("_",".")
|
151
|
+
method_type,method_name = method.split(".")
|
152
|
+
if(@@urls.has_key?(method_type.to_sym))
|
153
|
+
results = parse_results(method, args.first)
|
154
|
+
else
|
155
|
+
results = false
|
156
|
+
end
|
157
|
+
|
158
|
+
if results
|
159
|
+
return check_for_errors(results)
|
160
|
+
else
|
161
|
+
super
|
162
|
+
end
|
163
|
+
end
|
164
|
+
|
165
|
+
|
166
|
+
##
|
167
|
+
# Override respond_to? We can't really give an accurate return here
|
168
|
+
# I am only allowing those methods that start with those methods in the @urls hash
|
169
|
+
#
|
170
|
+
# @param [Symbol] sym The method symbol
|
171
|
+
# @param [Boolean] include_private Whether you want to include private or not.
|
172
|
+
#
|
173
|
+
# @author Scott Sampson
|
174
|
+
def respond_to?(sym, include_private = false)
|
175
|
+
method = sym.to_s.gsub("_",".")
|
176
|
+
method_type,method_name = method.split(".")
|
177
|
+
return @@urls.has_key?(method_type.to_sym)
|
178
|
+
end
|
179
|
+
|
180
|
+
|
181
|
+
|
182
|
+
##
|
183
|
+
# Custom log method, if we are in rails we should log any errors for debugging purposes
|
184
|
+
#
|
185
|
+
# @param [String] log_str string to log
|
186
|
+
#
|
187
|
+
# @author Scott Sampson
|
188
|
+
def log(log_str)
|
189
|
+
if Object.const_defined?('Rails')
|
190
|
+
Rails.logger.info(log_str)
|
191
|
+
else
|
192
|
+
puts log_str
|
193
|
+
end
|
194
|
+
end
|
195
|
+
end
|
196
|
+
end
|
data/rgigya.gemspec
ADDED
@@ -0,0 +1,118 @@
|
|
1
|
+
# Generated by jeweler
|
2
|
+
# DO NOT EDIT THIS FILE DIRECTLY
|
3
|
+
# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
|
4
|
+
# -*- encoding: utf-8 -*-
|
5
|
+
|
6
|
+
Gem::Specification.new do |s|
|
7
|
+
s.name = "rgigya"
|
8
|
+
s.version = "1.0.1"
|
9
|
+
|
10
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
|
+
s.authors = ["Scott Sampson"]
|
12
|
+
s.date = "2013-04-17"
|
13
|
+
s.description = "This is a ruby SDK for the Gigya api."
|
14
|
+
s.email = "scott@cloudspace.com"
|
15
|
+
s.extra_rdoc_files = [
|
16
|
+
"LICENSE.txt",
|
17
|
+
"README.rdoc"
|
18
|
+
]
|
19
|
+
s.files = [
|
20
|
+
".rvmrc",
|
21
|
+
"Gemfile",
|
22
|
+
"Gemfile.lock",
|
23
|
+
"LICENSE.txt",
|
24
|
+
"README.rdoc",
|
25
|
+
"Rakefile",
|
26
|
+
"VERSION",
|
27
|
+
"lib/rgigya.rb",
|
28
|
+
"rgigya.gemspec",
|
29
|
+
"spec/helpers.rb",
|
30
|
+
"spec/rgigya_spec.rb",
|
31
|
+
"spec/spec_helper.rb",
|
32
|
+
"test/dummy/Gemfile",
|
33
|
+
"test/dummy/Gemfile.lock",
|
34
|
+
"test/dummy/README.rdoc",
|
35
|
+
"test/dummy/Rakefile",
|
36
|
+
"test/dummy/app/assets/images/rails.png",
|
37
|
+
"test/dummy/app/assets/javascripts/application.js",
|
38
|
+
"test/dummy/app/assets/stylesheets/application.css",
|
39
|
+
"test/dummy/app/controllers/application_controller.rb",
|
40
|
+
"test/dummy/app/controllers/welcome_controller.rb",
|
41
|
+
"test/dummy/app/helpers/application_helper.rb",
|
42
|
+
"test/dummy/app/mailers/.gitkeep",
|
43
|
+
"test/dummy/app/models/.gitkeep",
|
44
|
+
"test/dummy/app/views/layouts/application.html.erb",
|
45
|
+
"test/dummy/app/views/welcome/index.html",
|
46
|
+
"test/dummy/app/views/welcome/index.html.erb",
|
47
|
+
"test/dummy/config.ru",
|
48
|
+
"test/dummy/config/application.rb",
|
49
|
+
"test/dummy/config/boot.rb",
|
50
|
+
"test/dummy/config/database.yml",
|
51
|
+
"test/dummy/config/environment.rb",
|
52
|
+
"test/dummy/config/environments/development.rb",
|
53
|
+
"test/dummy/config/environments/production.rb",
|
54
|
+
"test/dummy/config/environments/test.rb",
|
55
|
+
"test/dummy/config/initializers/backtrace_silencers.rb",
|
56
|
+
"test/dummy/config/initializers/inflections.rb",
|
57
|
+
"test/dummy/config/initializers/mime_types.rb",
|
58
|
+
"test/dummy/config/initializers/secret_token.rb",
|
59
|
+
"test/dummy/config/initializers/session_store.rb",
|
60
|
+
"test/dummy/config/initializers/wrap_parameters.rb",
|
61
|
+
"test/dummy/config/locales/en.yml",
|
62
|
+
"test/dummy/config/routes.rb",
|
63
|
+
"test/dummy/db/development.sqlite3",
|
64
|
+
"test/dummy/db/seeds.rb",
|
65
|
+
"test/dummy/lib/assets/.gitkeep",
|
66
|
+
"test/dummy/lib/tasks/.gitkeep",
|
67
|
+
"test/dummy/log/.gitkeep",
|
68
|
+
"test/dummy/log/development.log",
|
69
|
+
"test/dummy/public/404.html",
|
70
|
+
"test/dummy/public/422.html",
|
71
|
+
"test/dummy/public/500.html",
|
72
|
+
"test/dummy/public/favicon.ico",
|
73
|
+
"test/dummy/public/robots.txt",
|
74
|
+
"test/dummy/script/rails",
|
75
|
+
"test/dummy/test/fixtures/.gitkeep",
|
76
|
+
"test/dummy/test/functional/.gitkeep",
|
77
|
+
"test/dummy/test/integration/.gitkeep",
|
78
|
+
"test/dummy/test/performance/browsing_test.rb",
|
79
|
+
"test/dummy/test/test_helper.rb",
|
80
|
+
"test/dummy/test/unit/.gitkeep",
|
81
|
+
"test/dummy/vendor/assets/javascripts/.gitkeep",
|
82
|
+
"test/dummy/vendor/assets/stylesheets/.gitkeep",
|
83
|
+
"test/dummy/vendor/plugins/.gitkeep"
|
84
|
+
]
|
85
|
+
s.homepage = "http://github.com/scottsampson/rgigya"
|
86
|
+
s.licenses = ["MIT"]
|
87
|
+
s.require_paths = ["lib"]
|
88
|
+
s.rubygems_version = "1.8.17"
|
89
|
+
s.summary = "Ruby Wrapper/SDK for the Gigya api"
|
90
|
+
|
91
|
+
if s.respond_to? :specification_version then
|
92
|
+
s.specification_version = 3
|
93
|
+
|
94
|
+
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
95
|
+
s.add_runtime_dependency(%q<httparty>, ["~> 0.11.0"])
|
96
|
+
s.add_development_dependency(%q<jeweler>, ["~> 1.8.4"])
|
97
|
+
s.add_development_dependency(%q<shoulda>, [">= 0"])
|
98
|
+
s.add_development_dependency(%q<rdoc>, ["~> 3.12"])
|
99
|
+
s.add_development_dependency(%q<bundler>, ["~> 1.3.4"])
|
100
|
+
s.add_development_dependency(%q<rspec>, [">= 0"])
|
101
|
+
else
|
102
|
+
s.add_dependency(%q<httparty>, ["~> 0.11.0"])
|
103
|
+
s.add_dependency(%q<jeweler>, ["~> 1.8.4"])
|
104
|
+
s.add_dependency(%q<shoulda>, [">= 0"])
|
105
|
+
s.add_dependency(%q<rdoc>, ["~> 3.12"])
|
106
|
+
s.add_dependency(%q<bundler>, ["~> 1.3.4"])
|
107
|
+
s.add_dependency(%q<rspec>, [">= 0"])
|
108
|
+
end
|
109
|
+
else
|
110
|
+
s.add_dependency(%q<httparty>, ["~> 0.11.0"])
|
111
|
+
s.add_dependency(%q<jeweler>, ["~> 1.8.4"])
|
112
|
+
s.add_dependency(%q<shoulda>, [">= 0"])
|
113
|
+
s.add_dependency(%q<rdoc>, ["~> 3.12"])
|
114
|
+
s.add_dependency(%q<bundler>, ["~> 1.3.4"])
|
115
|
+
s.add_dependency(%q<rspec>, [">= 0"])
|
116
|
+
end
|
117
|
+
end
|
118
|
+
|