mosaic-foursquare 0.1.9 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,15 @@
1
+ ---
2
+ !binary "U0hBMQ==":
3
+ metadata.gz: !binary |-
4
+ YTVjOTg2YWI3M2RiOTIwY2EyOTBjMTk5M2RjOGU5N2I5YzVkMjdlNw==
5
+ data.tar.gz: !binary |-
6
+ MWE4MDMxNzA5ZjJiOGEwZjE5OGE5NWVjZDczZTNjZGRiOGM3Zjc0Mw==
7
+ !binary "U0hBNTEy":
8
+ metadata.gz: !binary |-
9
+ NmUyMWE1Mjk1N2Q4NjBiN2VjMzJjYjk0OTQ0YTVjOWQxZDJmYTQ2NTYzZGY2
10
+ ZmQ5YjcyZWY1Yzg4MDY2Y2JmMzYwOWNmMDE4Y2Q0OWVjMDBkYTQ5ZjkyNjRk
11
+ YmNiNWZlMjJiYTAzYzQ4YTQ1Njg3ZmNhNzM1M2Y2ZDQ2OTQwNGI=
12
+ data.tar.gz: !binary |-
13
+ MGE3OGY2MDQxYzlhZmNiMTYzNThkNTM4MDRmNzZiY2Q1OGMyNTY5MDAzOWE4
14
+ NjUzZDgyZGMwZDU4NDc2MjllMjZmNDVlYjYzNTI1MGM2NTIyN2E1ZjM2ZDM4
15
+ MTY3MzFjMDg3ZjI1MjdiYmFlZjFmNTdhY2MzYzhlNGUyNzIzZWM=
@@ -1 +1,2 @@
1
+ require 'mosaic/utils'
1
2
  require 'mosaic/foursquare'
@@ -3,3 +3,18 @@ require 'mosaic/foursquare/photo'
3
3
  require 'mosaic/foursquare/user'
4
4
  require 'mosaic/foursquare/venue'
5
5
  require 'mosaic/foursquare/version'
6
+ require 'mosaic/foursquare/update'
7
+
8
+ module Mosaic
9
+ module Foursquare
10
+ @config = {}
11
+
12
+ def self.configure(opts = {})
13
+ @config = opts
14
+ end
15
+
16
+ def self.config
17
+ @config
18
+ end
19
+ end
20
+ end
@@ -3,14 +3,16 @@ require 'httparty'
3
3
  module Mosaic
4
4
  module Foursquare
5
5
  class Object
6
+ include Mosaic::Utils::Helpers
6
7
  include HTTParty
7
8
  base_uri 'https://api.foursquare.com/v2'
8
9
 
9
10
  class << self
10
11
  def query(path, options)
12
+ options = Mosaic::Foursquare.config.merge(options)
11
13
  self.request_count += 1
12
14
  # STDERR.puts "REQUEST[#{self.request_count}]: #{path} with #{options.inspect}"
13
- response = get(path, :query => options)
15
+ response = get(path, :query => options.merge(:v =>20130614))
14
16
  # STDERR.puts "RESPONSE[#{self.request_count}]: #{response.inspect}"
15
17
  response.error! unless response.success?
16
18
  response
@@ -26,7 +28,7 @@ module Mosaic
26
28
  end
27
29
 
28
30
  def initialize(attributes = {})
29
- attributes.each { |key,value| instance_variable_set("@#{key.to_s.underscore}".to_sym, value) }
31
+ attributes.each { |key,value| instance_variable_set("@#{underscore_string(key.to_s)}".to_sym, value) }
30
32
  end
31
33
  end
32
34
  end
@@ -4,6 +4,10 @@ module Mosaic
4
4
  module Foursquare
5
5
  class Photo < Mosaic::Foursquare::Object
6
6
  attr_accessor :id, :url, :visibility
7
+
8
+ def url(size = "original")
9
+ @url ||= @prefix.to_s + size + @suffix.to_s
10
+ end
7
11
  end
8
12
  end
9
13
  end
@@ -0,0 +1,22 @@
1
+ require 'mosaic/foursquare/object'
2
+
3
+ module Mosaic
4
+ module Foursquare
5
+ class Update < Mosaic::Foursquare::Object
6
+ attr_accessor :id, :created_at, :shout, :photos
7
+
8
+ class << self
9
+ def from_venue(venue_response_data)
10
+ venue_response_data["pageUpdates"]["items"].map do |update|
11
+ new(update)
12
+ end
13
+ end
14
+ end
15
+
16
+ def initialize(attributes = {})
17
+ super
18
+ self.photos &&= self.photos['items'].collect { |item| Mosaic::Foursquare::Photo.new(item) }
19
+ end
20
+ end
21
+ end
22
+ end
@@ -4,6 +4,11 @@ module Mosaic
4
4
  module Foursquare
5
5
  class User < Mosaic::Foursquare::Object
6
6
  attr_accessor :first_name, :id, :last_name, :photo
7
+
8
+ def initialize(options = {})
9
+ super
10
+ self.photo &&= Mosaic::Foursquare::Photo.new(photo)
11
+ end
7
12
  end
8
13
  end
9
14
  end
@@ -3,7 +3,7 @@ require 'mosaic/foursquare/object'
3
3
  module Mosaic
4
4
  module Foursquare
5
5
  class Venue < Mosaic::Foursquare::Object
6
- attr_accessor :canonical_url, :created_at, :description, :id, :location, :mayor, :name, :short_url, :stats, :tags, :url
6
+ attr_accessor :canonical_url, :created_at, :description, :id, :location, :mayor, :name, :short_url, :stats, :tags, :url, :updates
7
7
 
8
8
  class << self
9
9
  def find(id, options = {})
@@ -20,19 +20,28 @@ module Mosaic
20
20
  # locally defined stats object (general one is probably not required)
21
21
  class Stats < Mosaic::Foursquare::Object
22
22
  attr_reader :checkins_count, :users_count, :tip_count
23
+ attr_accessor :photos_count, :updates_count
23
24
  end
24
25
 
25
26
  def initialize(attributes = {})
26
27
  super
27
28
  self.location &&= Mosaic::Foursquare::Venue::Location.new(self.location)
29
+ self.updates = Mosaic::Foursquare::Update.from_venue(attributes)
28
30
  self.mayor &&= (self.mayor['user'] ? Mosaic::Foursquare::User.new(self.mayor['user']) : nil)
29
31
  self.stats &&= Mosaic::Foursquare::Venue::Stats.new(self.stats)
32
+ self.stats.photos_count = attributes["photos"]["count"]
33
+ self.stats.updates_count = attributes["pageUpdates"]["count"]
30
34
  end
31
35
 
32
36
  def herenow(options = {})
33
37
  response = self.class.query("/venues/#{id}/herenow", options)
34
38
  response['response']['hereNow']['items'].collect { |item| Mosaic::Foursquare::Checkin.new(item) }
35
39
  end
40
+
41
+ def photos(options = {})
42
+ response = self.class.query("/venues/#{id}/photos", options)
43
+ response['response']['photos']['items'].collect { |item| Mosaic::Foursquare::Photo.new(item) }
44
+ end
36
45
  end
37
46
  end
38
47
  end
@@ -1,5 +1,5 @@
1
1
  module Mosaic
2
2
  module Foursquare
3
- VERSION = "0.1.9"
3
+ VERSION = "0.2.0"
4
4
  end
5
5
  end
@@ -0,0 +1 @@
1
+ require 'mosaic/utils/helpers'
@@ -0,0 +1,16 @@
1
+ # Don't particularly want to require ActiveSupport for one method, so here's the implementation of it.
2
+ module Mosaic
3
+ module Utils
4
+ module Helpers
5
+ def underscore_string(str)
6
+ word = str.to_s.dup
7
+ word.gsub!(/::/, '/')
8
+ word.gsub!(/([A-Z\d]+)([A-Z][a-z])/,'\1_\2')
9
+ word.gsub!(/([a-z\d])([A-Z])/,'\1_\2')
10
+ word.tr!("-", "_")
11
+ word.downcase!
12
+ word
13
+ end
14
+ end
15
+ end
16
+ end
@@ -14,7 +14,12 @@ Gem::Specification.new do |s|
14
14
  s.description = "Wrapper for the Foursquare API with support for the venues API."
15
15
 
16
16
  s.files =`git ls-files`.split($/)
17
- #s.test_files = Dir["test/**/*"]
17
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
18
18
 
19
19
  s.add_dependency "httparty", "~> 0.10.2"
20
+
21
+ s.add_development_dependency "rspec"
22
+ s.add_development_dependency "rake"
23
+ s.add_development_dependency "vcr"
24
+ s.add_development_dependency "webmock"
20
25
  end
metadata CHANGED
@@ -1,20 +1,45 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mosaic-foursquare
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.9
5
- prerelease:
4
+ version: 0.2.0
6
5
  platform: ruby
7
6
  authors:
8
7
  - S. Brent Faulkner
9
8
  autorequire:
10
9
  bindir: bin
11
- cert_chain: []
12
- date: 2013-03-12 00:00:00.000000000 Z
10
+ cert_chain:
11
+ - !binary |-
12
+ LS0tLS1CRUdJTiBDRVJUSUZJQ0FURS0tLS0tCk1JSURNakNDQWhxZ0F3SUJB
13
+ Z0lCQURBTkJna3Foa2lHOXcwQkFRVUZBREEvTVJBd0RnWURWUVFEREFkcWIy
14
+ VXUKY0hsdE1SWXdGQVlLQ1pJbWlaUHlMR1FCR1JZR2JXOXpZV2xqTVJNd0VR
15
+ WUtDWkltaVpQeUxHUUJHUllEWTI5dApNQjRYRFRFek1ETXdOVEU0TVRrME5G
16
+ b1hEVEUwTURNd05URT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ZvbTdlY3N6WWV3ZlZXSVhpeVRURWhTeXFyZQp3MGZBN1FZ
33
+ UmVVSHBlMEpiS1dmRW9CcG5QazRyL2tidHZobXZESklYdnM1TmZ6eVJyU25u
34
+ S29jRHI1T29RK2lPCldoa2ZabTFyOTgyWTRLWmg4eVI5aVp4QURQSjBVMDJn
35
+ cWkwT1ZqMjAvRCsvcjJxRkNqV2cwVjAzdTdGNDg2UkwKbkVBa3lXL3NaTjRX
36
+ Q29RbmpoeDF3MmYrd2FnVURBTzY4L0E1U0kxaUdyZVlRb3VvN1lRS0xNWC9p
37
+ WlFKYng2QwpzTERtRXdUcgotLS0tLUVORCBDRVJUSUZJQ0FURS0tLS0tCg==
38
+ date: 2013-06-14 00:00:00.000000000 Z
13
39
  dependencies:
14
40
  - !ruby/object:Gem::Dependency
15
41
  name: httparty
16
42
  requirement: !ruby/object:Gem::Requirement
17
- none: false
18
43
  requirements:
19
44
  - - ~>
20
45
  - !ruby/object:Gem::Version
@@ -22,11 +47,66 @@ dependencies:
22
47
  type: :runtime
23
48
  prerelease: false
24
49
  version_requirements: !ruby/object:Gem::Requirement
25
- none: false
26
50
  requirements:
27
51
  - - ~>
28
52
  - !ruby/object:Gem::Version
29
53
  version: 0.10.2
54
+ - !ruby/object:Gem::Dependency
55
+ name: rspec
56
+ requirement: !ruby/object:Gem::Requirement
57
+ requirements:
58
+ - - ! '>='
59
+ - !ruby/object:Gem::Version
60
+ version: '0'
61
+ type: :development
62
+ prerelease: false
63
+ version_requirements: !ruby/object:Gem::Requirement
64
+ requirements:
65
+ - - ! '>='
66
+ - !ruby/object:Gem::Version
67
+ version: '0'
68
+ - !ruby/object:Gem::Dependency
69
+ name: rake
70
+ requirement: !ruby/object:Gem::Requirement
71
+ requirements:
72
+ - - ! '>='
73
+ - !ruby/object:Gem::Version
74
+ version: '0'
75
+ type: :development
76
+ prerelease: false
77
+ version_requirements: !ruby/object:Gem::Requirement
78
+ requirements:
79
+ - - ! '>='
80
+ - !ruby/object:Gem::Version
81
+ version: '0'
82
+ - !ruby/object:Gem::Dependency
83
+ name: vcr
84
+ requirement: !ruby/object:Gem::Requirement
85
+ requirements:
86
+ - - ! '>='
87
+ - !ruby/object:Gem::Version
88
+ version: '0'
89
+ type: :development
90
+ prerelease: false
91
+ version_requirements: !ruby/object:Gem::Requirement
92
+ requirements:
93
+ - - ! '>='
94
+ - !ruby/object:Gem::Version
95
+ version: '0'
96
+ - !ruby/object:Gem::Dependency
97
+ name: webmock
98
+ requirement: !ruby/object:Gem::Requirement
99
+ requirements:
100
+ - - ! '>='
101
+ - !ruby/object:Gem::Version
102
+ version: '0'
103
+ type: :development
104
+ prerelease: false
105
+ version_requirements: !ruby/object:Gem::Requirement
106
+ requirements:
107
+ - - ! '>='
108
+ - !ruby/object:Gem::Version
109
+ version: '0'
30
110
  description: Wrapper for the Foursquare API with support for the venues API.
31
111
  email:
32
112
  - brent.faulkner@mosaic.com
@@ -44,33 +124,36 @@ files:
44
124
  - lib/mosaic/foursquare/checkin.rb
45
125
  - lib/mosaic/foursquare/object.rb
46
126
  - lib/mosaic/foursquare/photo.rb
127
+ - lib/mosaic/foursquare/update.rb
47
128
  - lib/mosaic/foursquare/user.rb
48
129
  - lib/mosaic/foursquare/venue.rb
49
130
  - lib/mosaic/foursquare/version.rb
131
+ - lib/mosaic/utils.rb
132
+ - lib/mosaic/utils/helpers.rb
50
133
  - lib/tasks/mosaic-foursquare_tasks.rake
51
134
  - mosaic-foursquare.gemspec
52
135
  homepage: http://github.com/mosaicxm/mosaic-foursquare
53
136
  licenses: []
137
+ metadata: {}
54
138
  post_install_message:
55
139
  rdoc_options: []
56
140
  require_paths:
57
141
  - lib
58
142
  required_ruby_version: !ruby/object:Gem::Requirement
59
- none: false
60
143
  requirements:
61
144
  - - ! '>='
62
145
  - !ruby/object:Gem::Version
63
146
  version: '0'
64
147
  required_rubygems_version: !ruby/object:Gem::Requirement
65
- none: false
66
148
  requirements:
67
149
  - - ! '>='
68
150
  - !ruby/object:Gem::Version
69
151
  version: '0'
70
152
  requirements: []
71
153
  rubyforge_project:
72
- rubygems_version: 1.8.23
154
+ rubygems_version: 2.0.3
73
155
  signing_key:
74
- specification_version: 3
156
+ specification_version: 4
75
157
  summary: Mosaic Sales Solutions Foursquare API wrapper.
76
158
  test_files: []
159
+ has_rdoc: