glomper 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,5 @@
1
+ lib/**/*.rb
2
+ bin/*
3
+ -
4
+ features/**/*.feature
5
+ LICENSE.txt
data/Gemfile ADDED
@@ -0,0 +1,21 @@
1
+ source "http://rubygems.org"
2
+ # Add dependencies required to use your gem here.
3
+ # Example:
4
+ # gem "activesupport", ">= 2.3.5"
5
+
6
+ gem 'faraday', '>= 0.6', '< 0.8'
7
+ gem 'faraday_middleware', '>= 0.6', '< 0.8'
8
+ gem 'hashie', '~> 1.0'
9
+
10
+ # Add dependencies to develop your gem here.
11
+ # Include everything needed to run rake, tests, features, etc.
12
+ group :development do
13
+ gem "shoulda", ">= 0"
14
+ gem "bundler", "~> 1.0.0"
15
+ gem "jeweler", "~> 1.6.4"
16
+ gem "rcov", ">= 0"
17
+ gem 'fakeweb', '~> 1.3'
18
+ gem 'jnunemaker-matchy', '~> 0.4'
19
+ gem 'json_pure', '~> 1.4'
20
+ gem 'multi_json', '>= 0.0.5', '< 2.0.0'
21
+ end
@@ -0,0 +1,41 @@
1
+ GEM
2
+ remote: http://rubygems.org/
3
+ specs:
4
+ addressable (2.2.6)
5
+ fakeweb (1.3.0)
6
+ faraday (0.7.4)
7
+ addressable (~> 2.2.6)
8
+ multipart-post (~> 1.1.0)
9
+ rack (>= 1.1.0, < 2)
10
+ faraday_middleware (0.7.0)
11
+ faraday (~> 0.7.3)
12
+ git (1.2.5)
13
+ hashie (1.1.0)
14
+ jeweler (1.6.4)
15
+ bundler (~> 1.0)
16
+ git (>= 1.2.5)
17
+ rake
18
+ jnunemaker-matchy (0.4.0)
19
+ json_pure (1.6.1)
20
+ multi_json (1.0.3)
21
+ multipart-post (1.1.3)
22
+ rack (1.3.3)
23
+ rake (0.9.2)
24
+ rcov (0.9.10)
25
+ shoulda (2.11.3)
26
+
27
+ PLATFORMS
28
+ ruby
29
+
30
+ DEPENDENCIES
31
+ bundler (~> 1.0.0)
32
+ fakeweb (~> 1.3)
33
+ faraday (>= 0.6, < 0.8)
34
+ faraday_middleware (>= 0.6, < 0.8)
35
+ hashie (~> 1.0)
36
+ jeweler (~> 1.6.4)
37
+ jnunemaker-matchy (~> 0.4)
38
+ json_pure (~> 1.4)
39
+ multi_json (>= 0.0.5, < 2.0.0)
40
+ rcov
41
+ shoulda
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2011 linchus
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.
@@ -0,0 +1,19 @@
1
+ = glomper-client
2
+
3
+ Description goes here.
4
+
5
+ == Contributing to glomper-client
6
+
7
+ * Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet
8
+ * Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it
9
+ * Fork the project
10
+ * Start a feature/bugfix branch
11
+ * Commit and push until you are happy with your contribution
12
+ * Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
13
+ * 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.
14
+
15
+ == Copyright
16
+
17
+ Copyright (c) 2011 linchus. See LICENSE.txt for
18
+ further details.
19
+
@@ -0,0 +1,53 @@
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 = "glomper"
18
+ gem.homepage = "http://github.com/linchus/glomper"
19
+ gem.license = "MIT"
20
+ gem.summary = %Q{Wrapper for Glomper API}
21
+ gem.description = %Q{Gives access to all endpoints Glomper API}
22
+ gem.email = "linchus@gmail.com"
23
+ gem.authors = ["linchus"]
24
+ # dependencies defined in Gemfile
25
+ end
26
+ Jeweler::RubygemsDotOrgTasks.new
27
+
28
+ require 'rake/testtask'
29
+ Rake::TestTask.new(:test) do |test|
30
+ test.libs << 'lib' << 'test'
31
+ test.pattern = 'test/**/test_*.rb'
32
+ test.verbose = true
33
+ end
34
+
35
+ require 'rcov/rcovtask'
36
+ Rcov::RcovTask.new do |test|
37
+ test.libs << 'test'
38
+ test.pattern = 'test/**/test_*.rb'
39
+ test.verbose = true
40
+ test.rcov_opts << '--exclude "gems/*"'
41
+ end
42
+
43
+ task :default => :test
44
+
45
+ require 'rake/rdoctask'
46
+ Rake::RDocTask.new do |rdoc|
47
+ version = File.exist?('VERSION') ? File.read('VERSION') : ""
48
+
49
+ rdoc.rdoc_dir = 'rdoc'
50
+ rdoc.title = "glomper #{version}"
51
+ rdoc.rdoc_files.include('README*')
52
+ rdoc.rdoc_files.include('lib/**/*.rb')
53
+ end
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.1.1
@@ -0,0 +1,88 @@
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 = %q{glomper}
8
+ s.version = "0.1.1"
9
+
10
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
+ s.authors = ["linchus"]
12
+ s.date = %q{2011-10-05}
13
+ s.description = %q{Gives access to all endpoints Glomper API}
14
+ s.email = %q{linchus@gmail.com}
15
+ s.extra_rdoc_files = [
16
+ "LICENSE.txt",
17
+ "README.rdoc"
18
+ ]
19
+ s.files = [
20
+ ".document",
21
+ "Gemfile",
22
+ "Gemfile.lock",
23
+ "LICENSE.txt",
24
+ "README.rdoc",
25
+ "Rakefile",
26
+ "VERSION",
27
+ "glomper.gemspec",
28
+ "lib/glomper.rb",
29
+ "lib/glomper/client.rb",
30
+ "lib/glomper/request.rb",
31
+ "lib/glomper/version.rb",
32
+ "test/fixtures/place.json",
33
+ "test/fixtures/search_places.json",
34
+ "test/fixtures/user.json",
35
+ "test/helper.rb",
36
+ "test/test_client.rb",
37
+ "test/test_place.rb",
38
+ "test/test_users.rb"
39
+ ]
40
+ s.homepage = %q{http://github.com/linchus/glomper}
41
+ s.licenses = ["MIT"]
42
+ s.require_paths = ["lib"]
43
+ s.rubygems_version = %q{1.6.2}
44
+ s.summary = %q{Wrapper for Glomper API}
45
+
46
+ if s.respond_to? :specification_version then
47
+ s.specification_version = 3
48
+
49
+ if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
50
+ s.add_runtime_dependency(%q<faraday>, ["< 0.8", ">= 0.6"])
51
+ s.add_runtime_dependency(%q<faraday_middleware>, ["< 0.8", ">= 0.6"])
52
+ s.add_runtime_dependency(%q<hashie>, ["~> 1.0"])
53
+ s.add_development_dependency(%q<shoulda>, [">= 0"])
54
+ s.add_development_dependency(%q<bundler>, ["~> 1.0.0"])
55
+ s.add_development_dependency(%q<jeweler>, ["~> 1.6.4"])
56
+ s.add_development_dependency(%q<rcov>, [">= 0"])
57
+ s.add_development_dependency(%q<fakeweb>, ["~> 1.3"])
58
+ s.add_development_dependency(%q<jnunemaker-matchy>, ["~> 0.4"])
59
+ s.add_development_dependency(%q<json_pure>, ["~> 1.4"])
60
+ s.add_development_dependency(%q<multi_json>, ["< 2.0.0", ">= 0.0.5"])
61
+ else
62
+ s.add_dependency(%q<faraday>, ["< 0.8", ">= 0.6"])
63
+ s.add_dependency(%q<faraday_middleware>, ["< 0.8", ">= 0.6"])
64
+ s.add_dependency(%q<hashie>, ["~> 1.0"])
65
+ s.add_dependency(%q<shoulda>, [">= 0"])
66
+ s.add_dependency(%q<bundler>, ["~> 1.0.0"])
67
+ s.add_dependency(%q<jeweler>, ["~> 1.6.4"])
68
+ s.add_dependency(%q<rcov>, [">= 0"])
69
+ s.add_dependency(%q<fakeweb>, ["~> 1.3"])
70
+ s.add_dependency(%q<jnunemaker-matchy>, ["~> 0.4"])
71
+ s.add_dependency(%q<json_pure>, ["~> 1.4"])
72
+ s.add_dependency(%q<multi_json>, ["< 2.0.0", ">= 0.0.5"])
73
+ end
74
+ else
75
+ s.add_dependency(%q<faraday>, ["< 0.8", ">= 0.6"])
76
+ s.add_dependency(%q<faraday_middleware>, ["< 0.8", ">= 0.6"])
77
+ s.add_dependency(%q<hashie>, ["~> 1.0"])
78
+ s.add_dependency(%q<shoulda>, [">= 0"])
79
+ s.add_dependency(%q<bundler>, ["~> 1.0.0"])
80
+ s.add_dependency(%q<jeweler>, ["~> 1.6.4"])
81
+ s.add_dependency(%q<rcov>, [">= 0"])
82
+ s.add_dependency(%q<fakeweb>, ["~> 1.3"])
83
+ s.add_dependency(%q<jnunemaker-matchy>, ["~> 0.4"])
84
+ s.add_dependency(%q<json_pure>, ["~> 1.4"])
85
+ s.add_dependency(%q<multi_json>, ["< 2.0.0", ">= 0.0.5"])
86
+ end
87
+ end
88
+
@@ -0,0 +1,39 @@
1
+ $LOAD_PATH << File.dirname(__FILE__)
2
+
3
+ require 'faraday'
4
+ require 'faraday_middleware'
5
+
6
+ directory = File.expand_path(File.dirname(__FILE__))
7
+
8
+ require 'glomper/request'
9
+ require 'glomper/client'
10
+
11
+ module Glomper
12
+ API = {
13
+ User: {
14
+ url: 'users',
15
+ methods: {
16
+ },
17
+ actions: {
18
+ },
19
+ aspects: {
20
+ info: []
21
+ }
22
+ },
23
+ Place: {
24
+ url: 'places',
25
+ methods: {
26
+ nearby: ['latitude', 'longitude']
27
+ },
28
+ actions: {
29
+ },
30
+ aspects: {
31
+ info: [],
32
+ feed: [],
33
+ checkins_count:[]
34
+ }
35
+ }
36
+ }
37
+
38
+ end
39
+
@@ -0,0 +1,57 @@
1
+ require 'forwardable'
2
+
3
+ module Glomper
4
+ class Client
5
+ extend Forwardable
6
+
7
+ # include Users
8
+ # include Places
9
+
10
+ attr_reader :client_id, :client_secret, :oauth_token
11
+
12
+ def initialize(options={})
13
+ @client_id = options[:client_id]
14
+ @client_secret = options[:client_secret]
15
+ @oauth_token = options[:oauth_token]
16
+ end
17
+
18
+ def method_missing(meth, *args, &block)
19
+ m = meth.to_s.capitalize.to_sym
20
+ if Glomper::API[m]
21
+ Glomper::Request.new(self, Glomper::API[m], *args, &block)
22
+ else
23
+ super
24
+ end
25
+ end
26
+
27
+ def api_url
28
+ "http://life.geogame.ru/api"
29
+ end
30
+
31
+ def return_error_or_body(response, response_body)
32
+ response.body
33
+ #response.body.meta.code == 200 ? response_body : response.body
34
+ end
35
+
36
+ def connection
37
+ params = {}
38
+ params[:client_id] = @client_id if @client_id
39
+ params[:client_secret] = @client_secret if @client_secret
40
+ params[:access_token] = @oauth_token if @oauth_token
41
+ @connection ||= Faraday::Connection.new(:url => api_url, :params => params, :headers => default_headers) do |builder|
42
+ builder.adapter Faraday.default_adapter
43
+ builder.use Faraday::Response::Mashify
44
+ builder.use Faraday::Response::ParseJson
45
+ end
46
+ end
47
+
48
+ private
49
+
50
+ def default_headers
51
+ headers = {
52
+ :accept => 'application/json',
53
+ :user_agent => 'Ruby gem'
54
+ }
55
+ end
56
+ end
57
+ end
@@ -0,0 +1,38 @@
1
+ module Glomper
2
+ class Request
3
+
4
+ def initialize(client, api, *args, &block)
5
+ @client = client
6
+ @api = api
7
+ @id = args.first
8
+ @method = 'post'
9
+ end
10
+
11
+ def method_missing(meth, *args, &block)
12
+ if @api[:methods][meth] || @api[:actions][meth] || @api[:aspects][meth]
13
+ @method = 'get' if @api[:aspects][meth]
14
+ send_request(meth, *args, &block)
15
+ else
16
+ super
17
+ end
18
+ end
19
+
20
+ def send_request(meth, *args, &block)
21
+ response = @client.connection.send(@method) do |req|
22
+ req.url build_url(meth), *args
23
+ end
24
+ @client.return_error_or_body(response, response.body)
25
+ end
26
+
27
+ def build_url meth
28
+ url = '/api/%s/' % @api[:url]
29
+ if @api[:methods][meth]
30
+ url += meth.to_s
31
+ else
32
+ url += '%s/%s' % [@id?@id:'self', meth]
33
+ end
34
+ url
35
+ end
36
+
37
+ end
38
+ end
@@ -0,0 +1,3 @@
1
+ module Glomper
2
+ VERSION = "0.0.1"
3
+ end
@@ -0,0 +1,18 @@
1
+ {
2
+ "code":"OMCTM",
3
+ "created_at":"2011-08-01T11:22:13+04:00",
4
+ "dislikes":0,
5
+ "id":855631,
6
+ "likes":0,
7
+ "name":"\u041e\u0444\u0438\u0441 \u043d\u0430 \u0411 \u0422\u0443\u043b\u044c\u0441\u043a\u043e\u0439 44",
8
+ "type":"Place",
9
+ "categories":[],
10
+ "dots":[
11
+ {"latitude":55.7053161,"longitude":37.6208033,"radius":15.0}
12
+ ],
13
+ "address":"\u0411\u043e\u043b\u044c\u0448\u0430\u044f \u0422\u0443\u043b\u044c\u0441\u043a\u0430\u044f 44",
14
+ "phone":"",
15
+ "wifi":true,
16
+ "url":"",
17
+ "text":""
18
+ }
@@ -0,0 +1 @@
1
+ [{"code":"OMCTM","created_at":"2011-08-01T14:22:13+07:00","dislikes":0,"id":855631,"likes":0,"name":"\u041e\u0444\u0438\u0441 \u043d\u0430 \u0411 \u0422\u0443\u043b\u044c\u0441\u043a\u043e\u0439 44","type":"Place","categories":[],"dots":[{"latitude":55.7053161,"longitude":37.6208033,"radius":15.0}],"address":"\u0411\u043e\u043b\u044c\u0448\u0430\u044f \u0422\u0443\u043b\u044c\u0441\u043a\u0430\u044f 44","phone":"","wifi":true,"url":"","text":""},{"code":"1TXK","created_at":"2010-12-14T23:10:17+07:00","dislikes":0,"id":23575,"likes":0,"name":"\u0410\u0439\u0422\u0438 \u0422\u0435\u0440\u0440\u0438\u0442\u043e\u0440\u0438\u044f","type":"Place","categories":[],"dots":[{"latitude":55.705316,"longitude":37.620803,"radius":15.0}],"address":"\u0411. \u0422\u0443\u043b\u044c\u0441\u043a\u0430\u044f \u0443\u043b\u0438\u0446\u0430, 44","phone":null,"wifi":true,"url":null,"text":""},{"code":"MABH","created_at":"2010-12-17T18:28:17+07:00","dislikes":0,"id":37490,"likes":0,"name":"\u0410\u0432\u0442\u043e\u0441\u0442\u043e\u044f\u043d\u043a\u0430","type":"Place","categories":[{"id":77,"name":"\u0421\u0435\u0440\u0432\u0438\u0441-\u0446\u0435\u043d\u0442\u0440"}],"dots":[{"latitude":55.70569699,"longitude":37.620586,"radius":15.0}],"address":"\u0411. \u0422\u0443\u043b\u044c\u0441\u043a\u0430\u044f \u0443\u043b\u0438\u0446\u0430","phone":null,"wifi":false,"url":null,"text":""},{"code":"82EE","created_at":"2010-12-14T20:36:17+07:00","dislikes":0,"id":10436,"likes":0,"name":"\u0411\u0430\u043d\u043a\u043e\u043c\u0430\u0442 \u041f\u0435\u0442\u0440\u043e\u043a\u043e\u043c\u043c\u0435\u0440\u0446 \u0432 \u041e\u0410\u041e \u00ab\u042d\u043d\u0435\u0440\u0433\u043e\u0431\u0430\u043b\u0430\u043d\u0441 \u0421\u0442\u043e\u043b\u0438\u0446\u0430\u00bb","type":"Place","categories":[],"dots":[{"latitude":55.7049863,"longitude":37.6227668,"radius":15.0}],"address":"\u0420\u043e\u0441\u0441\u0438\u0439\u0441\u043a\u0430\u044f \u0424\u0435\u0434\u0435\u0440\u0430\u0446\u0438\u044f, 115191, \u0433\u043e\u0440\u043e\u0434 \u041c\u043e\u0441\u043a\u0432\u0430, \u0411\u043e\u043b. \u0422\u0443\u043b\u044c\u0441\u043a\u0430\u044f \u0443\u043b., 43","phone":null,"wifi":false,"url":null,"text":""},{"code":"X7ACM","created_at":"2011-06-16T15:10:15+07:00","dislikes":0,"id":843141,"likes":0,"name":"\u041e\u0447\u043a\u0430\u0440\u0438\u043a","type":"Place","categories":[],"dots":[{"latitude":55.7061435,"longitude":37.6196692,"radius":15.0}],"address":null,"phone":null,"wifi":false,"url":null,"text":null},{"code":"HKXM","created_at":"2010-12-16T21:01:44+07:00","dislikes":0,"id":32703,"likes":0,"name":"McDonald's","type":"Place","categories":[{"id":104,"name":"\u0424\u0430\u0441\u0442\u0444\u0443\u0434\u044b"}],"dots":[{"latitude":55.70668,"longitude":37.621007,"radius":15.0}],"address":"\u0411. \u0422\u0443\u043b\u044c\u0441\u043a\u0430\u044f \u0443\u043b\u0438\u0446\u0430, 11 \u0441\u0442\u0440\u043e\u0435\u043d\u0438\u0435 3","phone":null,"wifi":true,"url":null,"text":""},{"code":"YCTK","created_at":"2010-12-14T23:09:22+07:00","dislikes":0,"id":22670,"likes":0,"name":"\u041f\u043b\u0430\u043d\u0435\u0442\u0430 \u0441\u0443\u0448\u0438","type":"Place","categories":[{"id":2,"name":"\u041a\u0430\u0444\u0435"}],"dots":[{"latitude":55.70668,"longitude":37.621007,"radius":15.0}],"address":"\u0411. \u0422\u0443\u043b\u044c\u0441\u043a\u0430\u044f \u0443\u043b\u0438\u0446\u0430, 8","phone":"(495) 287-3183, (495) 287-3184, (495) 287-3185","wifi":true,"url":"http://planet-sushi.rosinter.ru/","text":""},{"code":"MYMK","created_at":"2010-12-14T22:57:09+07:00","dislikes":0,"id":20501,"likes":0,"name":"Drimmi","type":"Place","categories":[],"dots":[{"latitude":55.70615,"longitude":37.619312,"radius":15.0}],"address":"\u0411. \u0422\u0443\u043b\u044c\u0441\u043a\u0430\u044f \u0443\u043b\u0438\u0446\u0430, 10 \u0441\u0442\u0440\u043e\u0435\u043d\u0438\u0435 9","phone":"(495) 787-27-90","wifi":false,"url":"http://www.drimmi.ru","text":""},{"code":"O14B","created_at":"2010-12-10T21:34:05+07:00","dislikes":0,"id":6874,"likes":0,"name":"\u041c\u043e\u0441\u043a\u043e\u0432\u0441\u043a\u0438\u0439 \u0433\u043e\u0440\u043e\u0434\u0441\u043a\u043e\u0439 \u043f\u0435\u0434\u0430\u0433\u043e\u0433\u0438\u0447\u0435\u0441\u043a\u0438\u0439 \u0443\u043d\u0438\u0432\u0435\u0440\u0441\u0438\u0442\u0435\u0442 (\u041c\u0413\u041f\u0423). \u0413\u0435\u043e\u0433\u0440\u0430\u0444\u0438\u0447\u0435\u0441\u043a\u0438\u0439 \u0444\u0430\u043a\u0443\u043b\u044c\u0442\u0435\u0442","type":"Place","categories":[],"dots":[{"latitude":55.7039518,"longitude":37.6198925,"radius":15.0}],"address":"\u0420\u043e\u0441\u0441\u0438\u0439\u0441\u043a\u0430\u044f \u0424\u0435\u0434\u0435\u0440\u0430\u0446\u0438\u044f, 115191, \u0433\u043e\u0440\u043e\u0434 \u041c\u043e\u0441\u043a\u0432\u0430, 2-\u0439 \u0422\u0443\u043b\u044c\u0441\u043a\u0438\u0439 \u043f\u0435\u0440., 4","phone":"+7 (499) 181 2177, +7 (495) 958 0460","wifi":false,"url":null,"text":""},{"code":"Y7ACM","created_at":"2011-06-16T15:10:15+07:00","dislikes":0,"id":843140,"likes":1,"name":"\u0418\u043d\u0433\u043e\u0441\u0441\u0442\u0440\u0430\u0445","type":"Place","categories":[],"dots":[{"latitude":55.7061327,"longitude":37.6190832,"radius":15.0}],"address":null,"phone":null,"wifi":false,"url":null,"text":null}]
@@ -0,0 +1,8 @@
1
+ {
2
+ "first_name":"Sergey",
3
+ "glomp_rate":"248.5",
4
+ "id":6,
5
+ "last_name":"Sein",
6
+ "full_name":"Sergey Sein",
7
+ "avatar":"http://graph.facebook.com/1469130771/picture"
8
+ }
@@ -0,0 +1,52 @@
1
+ require 'rubygems'
2
+ require 'bundler'
3
+ begin
4
+ Bundler.setup(:default, :development)
5
+ rescue Bundler::BundlerError => e
6
+ $stderr.puts e.message
7
+ $stderr.puts "Run `bundle install` to install missing gems"
8
+ exit e.status_code
9
+ end
10
+ require 'test/unit'
11
+ require 'shoulda'
12
+ require 'matchy'
13
+ require 'fakeweb'
14
+
15
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
16
+ $LOAD_PATH.unshift(File.dirname(__FILE__))
17
+ require 'glomper'
18
+
19
+ FakeWeb.allow_net_connect = false
20
+
21
+ def glomper_test_client
22
+ Glomper::Client.new(:oauth_token => 'yeehaw')
23
+ end
24
+
25
+ def glomper_url(url)
26
+ "http://life.geogame.ru/api#{url}"
27
+ end
28
+
29
+ def fixture_file(filename)
30
+ return '' if filename == ''
31
+ file_path = File.expand_path(File.dirname(__FILE__) + '/fixtures/' + filename)
32
+ File.read(file_path)
33
+ end
34
+
35
+ def stub_get(url, filename, options={})
36
+ opts = {
37
+ :body => fixture_file(filename),
38
+ :content_type => 'application/json; charset=utf-8'
39
+ }.merge(options)
40
+ FakeWeb.register_uri(:get, glomper_url(url), opts)
41
+ end
42
+
43
+ def stub_post(url, filename, options={})
44
+ opts = {
45
+ :body => fixture_file(filename),
46
+ :content_type => 'application/json; charset=utf-8'
47
+ }.merge(options)
48
+ FakeWeb.register_uri(:post, glomper_url(url), opts)
49
+ end
50
+
51
+ class Test::Unit::TestCase
52
+ end
@@ -0,0 +1,23 @@
1
+ require 'helper'
2
+
3
+ class TestClient < Test::Unit::TestCase
4
+
5
+ context "when instantiating a client instance" do
6
+ should "use the correct url for api requests" do
7
+ @client = Glomper::Client.new
8
+ @client.api_url.should == "http://life.geogame.ru/api"
9
+ end
10
+
11
+ should "retain oauth token for requests" do
12
+ @client = Glomper::Client.new(:oauth_token => 'yeehaw')
13
+ @client.oauth_token.should == "yeehaw"
14
+ end
15
+
16
+ should "retain client id/secret for requests" do
17
+ @client = Glomper::Client.new(:client_id => 'awesome', :client_secret => 'sauce')
18
+ @client.client_id.should == 'awesome'
19
+ @client.client_secret.should == 'sauce'
20
+ end
21
+
22
+ end
23
+ end
@@ -0,0 +1,24 @@
1
+ require 'helper'
2
+
3
+ class TestPlace < Test::Unit::TestCase
4
+
5
+ context "When using the Glomper API and working with venues" do
6
+ setup do
7
+ @client = glomper_test_client
8
+ end
9
+
10
+ should "fetch info for a single venue" do
11
+ stub_get("/places/855631/info?access_token=#{@client.oauth_token}", "place.json")
12
+ place = @client.place('855631').info
13
+ place.code.should == 'OMCTM'
14
+ place.dots.first.latitude.should == 55.7053161
15
+ end
16
+
17
+ should "search for venues based on passed criteria" do
18
+ stub_post("/places/nearby?access_token=#{@client.oauth_token}&latitude=55.7052131&longitude=37.6215232", "search_places.json")
19
+ venues = @client.place.nearby(:latitude => "55.7052131", :longitude => "37.6215232")
20
+ venues[1].code.should == '1TXK'
21
+ end
22
+ end
23
+
24
+ end
@@ -0,0 +1,16 @@
1
+ require 'helper'
2
+
3
+ class TestUsers < Test::Unit::TestCase
4
+
5
+ context "When using the Glomper API and working with users" do
6
+ setup do
7
+ @client = glomper_test_client
8
+ end
9
+
10
+ should "fetch info for a single user" do
11
+ stub_get("/users/self/info?access_token=#{@client.oauth_token}", "user.json")
12
+ user = @client.user.info
13
+ user.first_name.should == 'Sergey'
14
+ end
15
+ end
16
+ end
metadata ADDED
@@ -0,0 +1,201 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: glomper
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.1
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - linchus
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2011-10-05 00:00:00.000000000 +04:00
13
+ default_executable:
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ name: faraday
17
+ requirement: &2153084640 !ruby/object:Gem::Requirement
18
+ none: false
19
+ requirements:
20
+ - - <
21
+ - !ruby/object:Gem::Version
22
+ version: '0.8'
23
+ - - ! '>='
24
+ - !ruby/object:Gem::Version
25
+ version: '0.6'
26
+ type: :runtime
27
+ prerelease: false
28
+ version_requirements: *2153084640
29
+ - !ruby/object:Gem::Dependency
30
+ name: faraday_middleware
31
+ requirement: &2153082940 !ruby/object:Gem::Requirement
32
+ none: false
33
+ requirements:
34
+ - - <
35
+ - !ruby/object:Gem::Version
36
+ version: '0.8'
37
+ - - ! '>='
38
+ - !ruby/object:Gem::Version
39
+ version: '0.6'
40
+ type: :runtime
41
+ prerelease: false
42
+ version_requirements: *2153082940
43
+ - !ruby/object:Gem::Dependency
44
+ name: hashie
45
+ requirement: &2153081200 !ruby/object:Gem::Requirement
46
+ none: false
47
+ requirements:
48
+ - - ~>
49
+ - !ruby/object:Gem::Version
50
+ version: '1.0'
51
+ type: :runtime
52
+ prerelease: false
53
+ version_requirements: *2153081200
54
+ - !ruby/object:Gem::Dependency
55
+ name: shoulda
56
+ requirement: &2153080020 !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ! '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: *2153080020
65
+ - !ruby/object:Gem::Dependency
66
+ name: bundler
67
+ requirement: &2153078960 !ruby/object:Gem::Requirement
68
+ none: false
69
+ requirements:
70
+ - - ~>
71
+ - !ruby/object:Gem::Version
72
+ version: 1.0.0
73
+ type: :development
74
+ prerelease: false
75
+ version_requirements: *2153078960
76
+ - !ruby/object:Gem::Dependency
77
+ name: jeweler
78
+ requirement: &2153077980 !ruby/object:Gem::Requirement
79
+ none: false
80
+ requirements:
81
+ - - ~>
82
+ - !ruby/object:Gem::Version
83
+ version: 1.6.4
84
+ type: :development
85
+ prerelease: false
86
+ version_requirements: *2153077980
87
+ - !ruby/object:Gem::Dependency
88
+ name: rcov
89
+ requirement: &2153076340 !ruby/object:Gem::Requirement
90
+ none: false
91
+ requirements:
92
+ - - ! '>='
93
+ - !ruby/object:Gem::Version
94
+ version: '0'
95
+ type: :development
96
+ prerelease: false
97
+ version_requirements: *2153076340
98
+ - !ruby/object:Gem::Dependency
99
+ name: fakeweb
100
+ requirement: &2153073540 !ruby/object:Gem::Requirement
101
+ none: false
102
+ requirements:
103
+ - - ~>
104
+ - !ruby/object:Gem::Version
105
+ version: '1.3'
106
+ type: :development
107
+ prerelease: false
108
+ version_requirements: *2153073540
109
+ - !ruby/object:Gem::Dependency
110
+ name: jnunemaker-matchy
111
+ requirement: &2153072960 !ruby/object:Gem::Requirement
112
+ none: false
113
+ requirements:
114
+ - - ~>
115
+ - !ruby/object:Gem::Version
116
+ version: '0.4'
117
+ type: :development
118
+ prerelease: false
119
+ version_requirements: *2153072960
120
+ - !ruby/object:Gem::Dependency
121
+ name: json_pure
122
+ requirement: &2153071560 !ruby/object:Gem::Requirement
123
+ none: false
124
+ requirements:
125
+ - - ~>
126
+ - !ruby/object:Gem::Version
127
+ version: '1.4'
128
+ type: :development
129
+ prerelease: false
130
+ version_requirements: *2153071560
131
+ - !ruby/object:Gem::Dependency
132
+ name: multi_json
133
+ requirement: &2153070360 !ruby/object:Gem::Requirement
134
+ none: false
135
+ requirements:
136
+ - - <
137
+ - !ruby/object:Gem::Version
138
+ version: 2.0.0
139
+ - - ! '>='
140
+ - !ruby/object:Gem::Version
141
+ version: 0.0.5
142
+ type: :development
143
+ prerelease: false
144
+ version_requirements: *2153070360
145
+ description: Gives access to all endpoints Glomper API
146
+ email: linchus@gmail.com
147
+ executables: []
148
+ extensions: []
149
+ extra_rdoc_files:
150
+ - LICENSE.txt
151
+ - README.rdoc
152
+ files:
153
+ - .document
154
+ - Gemfile
155
+ - Gemfile.lock
156
+ - LICENSE.txt
157
+ - README.rdoc
158
+ - Rakefile
159
+ - VERSION
160
+ - glomper.gemspec
161
+ - lib/glomper.rb
162
+ - lib/glomper/client.rb
163
+ - lib/glomper/request.rb
164
+ - lib/glomper/version.rb
165
+ - test/fixtures/place.json
166
+ - test/fixtures/search_places.json
167
+ - test/fixtures/user.json
168
+ - test/helper.rb
169
+ - test/test_client.rb
170
+ - test/test_place.rb
171
+ - test/test_users.rb
172
+ has_rdoc: true
173
+ homepage: http://github.com/linchus/glomper
174
+ licenses:
175
+ - MIT
176
+ post_install_message:
177
+ rdoc_options: []
178
+ require_paths:
179
+ - lib
180
+ required_ruby_version: !ruby/object:Gem::Requirement
181
+ none: false
182
+ requirements:
183
+ - - ! '>='
184
+ - !ruby/object:Gem::Version
185
+ version: '0'
186
+ segments:
187
+ - 0
188
+ hash: -4386962564935529
189
+ required_rubygems_version: !ruby/object:Gem::Requirement
190
+ none: false
191
+ requirements:
192
+ - - ! '>='
193
+ - !ruby/object:Gem::Version
194
+ version: '0'
195
+ requirements: []
196
+ rubyforge_project:
197
+ rubygems_version: 1.6.2
198
+ signing_key:
199
+ specification_version: 3
200
+ summary: Wrapper for Glomper API
201
+ test_files: []