rubymeetup 3.0
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/rmeetup.rb +82 -0
- data/lib/rmeetup/collection.rb +58 -0
- data/lib/rmeetup/fetcher.rb +38 -0
- data/lib/rmeetup/fetcher/base.rb +84 -0
- data/lib/rmeetup/fetcher/cities.rb +14 -0
- data/lib/rmeetup/fetcher/comments.rb +14 -0
- data/lib/rmeetup/fetcher/events.rb +14 -0
- data/lib/rmeetup/fetcher/groups.rb +14 -0
- data/lib/rmeetup/fetcher/members.rb +14 -0
- data/lib/rmeetup/fetcher/photos.rb +14 -0
- data/lib/rmeetup/fetcher/rsvps.rb +14 -0
- data/lib/rmeetup/fetcher/topics.rb +14 -0
- data/lib/rmeetup/poster.rb +17 -0
- data/lib/rmeetup/poster/base.rb +81 -0
- data/lib/rmeetup/poster/event_comment.rb +14 -0
- data/lib/rmeetup/type.rb +8 -0
- data/lib/rmeetup/type/city.rb +39 -0
- data/lib/rmeetup/type/comment.rb +42 -0
- data/lib/rmeetup/type/event.rb +47 -0
- data/lib/rmeetup/type/group.rb +47 -0
- data/lib/rmeetup/type/member.rb +38 -0
- data/lib/rmeetup/type/photo.rb +32 -0
- data/lib/rmeetup/type/rsvp.rb +35 -0
- data/lib/rmeetup/type/topic.rb +38 -0
- metadata +69 -0
data/lib/rmeetup.rb
ADDED
@@ -0,0 +1,82 @@
|
|
1
|
+
require 'net/http'
|
2
|
+
require 'date'
|
3
|
+
require 'rubygems'
|
4
|
+
require 'json'
|
5
|
+
require 'rmeetup/type'
|
6
|
+
require 'rmeetup/collection'
|
7
|
+
require 'rmeetup/fetcher'
|
8
|
+
require 'rmeetup/poster'
|
9
|
+
|
10
|
+
module RMeetup
|
11
|
+
|
12
|
+
# RMeetup Errors
|
13
|
+
class NotConfiguredError < StandardError
|
14
|
+
def initialize
|
15
|
+
super "Please provide your Meetup API key before fetching data."
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
class InvalidRequestTypeError < StandardError
|
20
|
+
def initialize(type)
|
21
|
+
super "Fetch type '#{type}' not a valid."
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
# == RMeetup::Client
|
26
|
+
#
|
27
|
+
# Essentially a simple wrapper to delegate requests to
|
28
|
+
# different fetcher classes who are responsible for fetching
|
29
|
+
# and parsing their own responses.
|
30
|
+
class Client
|
31
|
+
FETCH_TYPES = [:topics, :cities, :members, :rsvps, :events, :groups, :comments, :photos]
|
32
|
+
|
33
|
+
POST_TYPES = [:event_comment]
|
34
|
+
# Meetup API Key
|
35
|
+
# Get one at http://www.meetup.com/meetup_api/key/
|
36
|
+
# Needs to be the group organizers API Key
|
37
|
+
# to be able to RSVP for other people
|
38
|
+
@@api_key = nil
|
39
|
+
def self.api_key; @@api_key; end;
|
40
|
+
def self.api_key=(key); @@api_key = key; end;
|
41
|
+
|
42
|
+
def self.fetch(type, options = {})
|
43
|
+
check_configuration!
|
44
|
+
|
45
|
+
# Merge in all the standard options
|
46
|
+
# Keeping whatever was passed in
|
47
|
+
options = default_options.merge(options)
|
48
|
+
|
49
|
+
if FETCH_TYPES.include?(type.to_sym)
|
50
|
+
# Get the custom fetcher used to manage options, api call to get a type of response
|
51
|
+
fetcher = RMeetup::Fetcher.for(type)
|
52
|
+
return fetcher.fetch(options)
|
53
|
+
else
|
54
|
+
raise InvalidRequestTypeError.new(type)
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
def self.post(type, options = {})
|
59
|
+
check_configuration!
|
60
|
+
options = default_options.merge(options)
|
61
|
+
|
62
|
+
if POST_TYPES.include?(type.to_sym)
|
63
|
+
poster = RMeetup::Poster.for(type)
|
64
|
+
return poster.post(options)
|
65
|
+
else
|
66
|
+
raise InvalidRequestTypeError.new(type)
|
67
|
+
end
|
68
|
+
end
|
69
|
+
protected
|
70
|
+
def self.default_options
|
71
|
+
{
|
72
|
+
:key => api_key
|
73
|
+
}
|
74
|
+
end
|
75
|
+
|
76
|
+
# Raise an error if RMeetup has not been
|
77
|
+
# provided with an api key
|
78
|
+
def self.check_configuration!
|
79
|
+
raise NotConfiguredError.new unless api_key
|
80
|
+
end
|
81
|
+
end
|
82
|
+
end
|
@@ -0,0 +1,58 @@
|
|
1
|
+
module RMeetup
|
2
|
+
class Collection < Array
|
3
|
+
attr_accessor :page_size, :total_results
|
4
|
+
attr_writer :current_page
|
5
|
+
|
6
|
+
def self.build(response)
|
7
|
+
collection = Collection.new()
|
8
|
+
|
9
|
+
# Setup the attributes needed for WillPaginate style paging
|
10
|
+
request_url = response['meta']['url']
|
11
|
+
request_parameters = parse_parameters_from_url(request_url)
|
12
|
+
collection.page_size = request_parameters['page'] ? request_parameters['page'].to_i : nil
|
13
|
+
collection.total_results = response['meta']['total_count'].to_i
|
14
|
+
collection.current_page = request_parameters['offset'] ? (request_parameters['offset'].to_i + 1) : 1
|
15
|
+
|
16
|
+
# Load the collection with all
|
17
|
+
# of the results we passed in
|
18
|
+
response['results'].each do |result|
|
19
|
+
collection << result
|
20
|
+
end
|
21
|
+
|
22
|
+
collection
|
23
|
+
end
|
24
|
+
|
25
|
+
# = WillPaginate Helper Methods
|
26
|
+
#
|
27
|
+
# These methods are implementded so that
|
28
|
+
# you may pass this collection to the will_paginate
|
29
|
+
# view helper to render pagination links.
|
30
|
+
def current_page
|
31
|
+
@current_page
|
32
|
+
end
|
33
|
+
|
34
|
+
def total_pages
|
35
|
+
@page_size ? (@total_results.to_f / @page_size.to_f).ceil : 1
|
36
|
+
end
|
37
|
+
|
38
|
+
def previous_page
|
39
|
+
self.current_page == 1 ? nil : self.current_page.to_i-1
|
40
|
+
end
|
41
|
+
|
42
|
+
def next_page
|
43
|
+
self.current_page == self.total_pages ? nil : self.current_page.to_i+1
|
44
|
+
end
|
45
|
+
|
46
|
+
protected
|
47
|
+
def self.parse_parameters_from_url(url)
|
48
|
+
query = URI.parse(url).query
|
49
|
+
parameters = {}
|
50
|
+
|
51
|
+
query.split("&").each do |kv|
|
52
|
+
kv = kv.split("=")
|
53
|
+
parameters[kv[0]] = kv[1]
|
54
|
+
end
|
55
|
+
parameters
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
require "rmeetup/fetcher/base"
|
2
|
+
require "rmeetup/fetcher/topics"
|
3
|
+
require "rmeetup/fetcher/cities"
|
4
|
+
require "rmeetup/fetcher/members"
|
5
|
+
require "rmeetup/fetcher/rsvps"
|
6
|
+
require "rmeetup/fetcher/events"
|
7
|
+
require "rmeetup/fetcher/groups"
|
8
|
+
require "rmeetup/fetcher/comments"
|
9
|
+
require "rmeetup/fetcher/photos"
|
10
|
+
|
11
|
+
module RMeetup
|
12
|
+
module Fetcher
|
13
|
+
|
14
|
+
class << self
|
15
|
+
# Return a fetcher for given type
|
16
|
+
def for(type)
|
17
|
+
return case type.to_sym
|
18
|
+
when :topics
|
19
|
+
Topics.new
|
20
|
+
when :cities
|
21
|
+
Cities.new
|
22
|
+
when :members
|
23
|
+
Members.new
|
24
|
+
when :rsvps
|
25
|
+
Rsvps.new
|
26
|
+
when :events
|
27
|
+
Events.new
|
28
|
+
when :groups
|
29
|
+
Groups.new
|
30
|
+
when :comments
|
31
|
+
Comments.new
|
32
|
+
when :photos
|
33
|
+
Photos.new
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
@@ -0,0 +1,84 @@
|
|
1
|
+
module RMeetup
|
2
|
+
module Fetcher
|
3
|
+
class ApiError < StandardError
|
4
|
+
def initialize(error_message, request_url)
|
5
|
+
super "Meetup API Error: #{error_message} - API URL: #{request_url}"
|
6
|
+
end
|
7
|
+
end
|
8
|
+
|
9
|
+
class NoResponseError < StandardError
|
10
|
+
def initialize
|
11
|
+
super "No Response was returned from the Meetup API."
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
# == RMeetup::Fetcher::Base
|
16
|
+
#
|
17
|
+
# Base fetcher class that other fetchers
|
18
|
+
# will inherit from.
|
19
|
+
class Base
|
20
|
+
def initialize
|
21
|
+
@type = nil
|
22
|
+
end
|
23
|
+
|
24
|
+
# Fetch and parse a response
|
25
|
+
# based on a set of options.
|
26
|
+
# Override this method to ensure
|
27
|
+
# neccessary options are passed
|
28
|
+
# for the request.
|
29
|
+
def fetch(options = {})
|
30
|
+
url = build_url(options)
|
31
|
+
|
32
|
+
json = get_response(url)
|
33
|
+
data = JSON.parse(json)
|
34
|
+
|
35
|
+
# Check to see if the api returned an error
|
36
|
+
raise ApiError.new(data['details'],url) if data.has_key?('problem')
|
37
|
+
|
38
|
+
collection = RMeetup::Collection.build(data)
|
39
|
+
|
40
|
+
# Format each result in the collection and return it
|
41
|
+
collection.map!{|result| format_result(result)}
|
42
|
+
end
|
43
|
+
|
44
|
+
protected
|
45
|
+
# OVERRIDE this method to format a result section
|
46
|
+
# as per Result type.
|
47
|
+
# Takes a result in a collection and
|
48
|
+
# formats it to be put back into the collection.
|
49
|
+
def format_result(result)
|
50
|
+
result
|
51
|
+
end
|
52
|
+
|
53
|
+
def build_url(options)
|
54
|
+
options = encode_options(options)
|
55
|
+
|
56
|
+
base_url + params_for(options)
|
57
|
+
end
|
58
|
+
|
59
|
+
def base_url
|
60
|
+
"http://api.meetup.com/#{@type}.json/"
|
61
|
+
end
|
62
|
+
|
63
|
+
# Create a query string from an options hash
|
64
|
+
def params_for(options)
|
65
|
+
params = []
|
66
|
+
options.each do |key, value|
|
67
|
+
params << "#{key}=#{value}"
|
68
|
+
end
|
69
|
+
"?#{params.join("&")}"
|
70
|
+
end
|
71
|
+
|
72
|
+
# Encode a hash of options to be used as request parameters
|
73
|
+
def encode_options(options)
|
74
|
+
options.each do |key,value|
|
75
|
+
options[key] = URI.encode(value.to_s)
|
76
|
+
end
|
77
|
+
end
|
78
|
+
|
79
|
+
def get_response(url)
|
80
|
+
Net::HTTP.get_response(URI.parse(url)).body || raise(NoResponseError.new)
|
81
|
+
end
|
82
|
+
end
|
83
|
+
end
|
84
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
require "rmeetup/poster/base"
|
2
|
+
require "rmeetup/poster/event_comment"
|
3
|
+
|
4
|
+
module RMeetup
|
5
|
+
module Poster
|
6
|
+
|
7
|
+
class << self
|
8
|
+
# Return a fetcher for given type
|
9
|
+
def for(type)
|
10
|
+
return case type.to_sym
|
11
|
+
when :event_comment
|
12
|
+
EventComment.new
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,81 @@
|
|
1
|
+
require 'net/http'
|
2
|
+
require 'net/https'
|
3
|
+
|
4
|
+
module RMeetup
|
5
|
+
module Poster
|
6
|
+
class ApiError < StandardError
|
7
|
+
def initialize(error_message, request_url)
|
8
|
+
super "Meetup API Error: #{error_message} - API URL: #{request_url}"
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
class NoResponseError < StandardError
|
13
|
+
def initialize
|
14
|
+
super "No Response was returned from the Meetup API."
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
# == RMeetup::Fetcher::Base
|
19
|
+
#
|
20
|
+
# Base fetcher class that other fetchers
|
21
|
+
# will inherit from.
|
22
|
+
class Base
|
23
|
+
def initialize
|
24
|
+
@type = nil
|
25
|
+
end
|
26
|
+
|
27
|
+
# Fetch and parse a response
|
28
|
+
# based on a set of options.
|
29
|
+
# Override this method to ensure
|
30
|
+
# neccessary options are passed
|
31
|
+
# for the request.
|
32
|
+
def post(options = {})
|
33
|
+
url = build_url(options)
|
34
|
+
ret = post_response(url, options)
|
35
|
+
ret
|
36
|
+
end
|
37
|
+
|
38
|
+
protected
|
39
|
+
# OVERRIDE this method to format a result section
|
40
|
+
# as per Result type.
|
41
|
+
# Takes a result in a collection and
|
42
|
+
# formats it to be put back into the collection.
|
43
|
+
def format_result(result)
|
44
|
+
result
|
45
|
+
end
|
46
|
+
|
47
|
+
def build_url(options)
|
48
|
+
base_url
|
49
|
+
end
|
50
|
+
|
51
|
+
def base_url
|
52
|
+
"https://api.meetup.com/2/#{@type}/"
|
53
|
+
end
|
54
|
+
|
55
|
+
# Create a query string from an options hash
|
56
|
+
def params_for(options)
|
57
|
+
params = []
|
58
|
+
options.each do |key, value|
|
59
|
+
params << "#{key}=#{value}"
|
60
|
+
end
|
61
|
+
"?#{params.join("&")}"
|
62
|
+
end
|
63
|
+
|
64
|
+
# Encode a hash of options to be used as request parameters
|
65
|
+
def encode_options(options)
|
66
|
+
options.each do |key,value|
|
67
|
+
options[key] = URI.encode(value.to_s)
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
71
|
+
def post_response(url, options)
|
72
|
+
sslurl = URI.parse(url)
|
73
|
+
https = Net::HTTP.new(sslurl.host, sslurl.port)
|
74
|
+
https.use_ssl = true
|
75
|
+
req = Net::HTTP::Post.new(sslurl.path)
|
76
|
+
req.set_form_data(options)
|
77
|
+
resp = https.request(req)
|
78
|
+
end
|
79
|
+
end
|
80
|
+
end
|
81
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
module RMeetup
|
2
|
+
module Poster
|
3
|
+
class EventComment < Base
|
4
|
+
def initialize
|
5
|
+
@type = :event_comment
|
6
|
+
end
|
7
|
+
|
8
|
+
# Turn the result hash into a Comment Class
|
9
|
+
def format_result(result)
|
10
|
+
RMeetup::Type::EventComment.new(result)
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
data/lib/rmeetup/type.rb
ADDED
@@ -0,0 +1,39 @@
|
|
1
|
+
module RMeetup
|
2
|
+
module Type
|
3
|
+
|
4
|
+
# == RMeetup::Type::City
|
5
|
+
#
|
6
|
+
# Data wraper for a City fethcing response
|
7
|
+
# Used to access result attributes as well
|
8
|
+
# as progammatically fetch relative data types
|
9
|
+
# based on this city.
|
10
|
+
|
11
|
+
# Edited by Jason Berlinsky on 1/20/11 to allow for arbitrary data access
|
12
|
+
# See http://www.meetup.com/meetup_api/docs/cities/ for available fields
|
13
|
+
|
14
|
+
class City
|
15
|
+
|
16
|
+
attr_accessor :city
|
17
|
+
|
18
|
+
def initialize(city = {})
|
19
|
+
self.city = city
|
20
|
+
end
|
21
|
+
|
22
|
+
def method_missing(id, *args)
|
23
|
+
return self.city[id.id2name]
|
24
|
+
end
|
25
|
+
|
26
|
+
# Special accessors that need typecasting or other parsing
|
27
|
+
|
28
|
+
def lat
|
29
|
+
return self.city['lat'].to_f
|
30
|
+
end
|
31
|
+
def lon
|
32
|
+
return self.city['lon'].to_f
|
33
|
+
end
|
34
|
+
def members
|
35
|
+
return self.city['members'].to_i
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
@@ -0,0 +1,42 @@
|
|
1
|
+
module RMeetup
|
2
|
+
module Type
|
3
|
+
|
4
|
+
# == RMeetup::Type::Comment
|
5
|
+
#
|
6
|
+
# Data wraper for a Comment fethcing response
|
7
|
+
# Used to access result attributes as well
|
8
|
+
# as progammatically fetch relative data types
|
9
|
+
# based on this comment.
|
10
|
+
|
11
|
+
# Edited by Jason Berlinsky on 1/20/11 to allow for arbitrary data access
|
12
|
+
# See http://www.meetup.com/meetup_api/docs/ew/comment/ for available fields
|
13
|
+
|
14
|
+
class Comment
|
15
|
+
|
16
|
+
attr_accessor :comment
|
17
|
+
|
18
|
+
def initialize(comment = {})
|
19
|
+
self.comment = comment
|
20
|
+
end
|
21
|
+
|
22
|
+
def method_missing(id, *args)
|
23
|
+
return self.comment[id.id2name]
|
24
|
+
end
|
25
|
+
|
26
|
+
# Special accessors that need typecasting or other parsing
|
27
|
+
|
28
|
+
def rating
|
29
|
+
return self.comment['rating'].to_i
|
30
|
+
end
|
31
|
+
def created
|
32
|
+
return DateTime.parse(self.comment['created'])
|
33
|
+
end
|
34
|
+
def lat
|
35
|
+
return self.comment['lat'].to_f
|
36
|
+
end
|
37
|
+
def lon
|
38
|
+
return self.comment['lon'].to_f
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
@@ -0,0 +1,47 @@
|
|
1
|
+
module RMeetup
|
2
|
+
module Type
|
3
|
+
|
4
|
+
# == RMeetup::Type::Event
|
5
|
+
#
|
6
|
+
# Data wraper for a Event fethcing response
|
7
|
+
# Used to access result attributes as well
|
8
|
+
# as progammatically fetch relative data types
|
9
|
+
# based on this event.
|
10
|
+
|
11
|
+
# Edited by Jason Berlinsky on 1/20/11 to allow for arbitrary data access
|
12
|
+
# See http://www.meetup.com/meetup_api/docs/events/ for available fields
|
13
|
+
|
14
|
+
class Event
|
15
|
+
|
16
|
+
attr_accessor :event
|
17
|
+
|
18
|
+
def initialize(event = {})
|
19
|
+
self.event = event
|
20
|
+
end
|
21
|
+
|
22
|
+
def method_missing(id, *args)
|
23
|
+
return self.event[id.id2name]
|
24
|
+
end
|
25
|
+
|
26
|
+
# Special accessors that need typecasting or other parsing
|
27
|
+
def id
|
28
|
+
self.event['id'].to_i
|
29
|
+
end
|
30
|
+
def lat
|
31
|
+
self.event['lat'].to_f
|
32
|
+
end
|
33
|
+
def lon
|
34
|
+
self.event['lon'].to_f
|
35
|
+
end
|
36
|
+
def rsvpcount
|
37
|
+
self.event['rsvpcount'].to_i
|
38
|
+
end
|
39
|
+
def updated
|
40
|
+
DateTime.parse(self.event['updated'])
|
41
|
+
end
|
42
|
+
def time
|
43
|
+
DateTime.parse(self.event['time'])
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
@@ -0,0 +1,47 @@
|
|
1
|
+
module RMeetup
|
2
|
+
module Type
|
3
|
+
|
4
|
+
# == RMeetup::Type::Group
|
5
|
+
#
|
6
|
+
# Data wraper for a Group fethcing response
|
7
|
+
# Used to access result attributes as well
|
8
|
+
# as progammatically fetch relative data types
|
9
|
+
# based on this group.
|
10
|
+
|
11
|
+
# Edited by Jason Berlinsky on 1/20/11 to allow for arbitrary data access
|
12
|
+
# See http://www.meetup.com/meetup_api/docs/groups/ for available fields
|
13
|
+
|
14
|
+
class Group
|
15
|
+
attr_accessor :group
|
16
|
+
|
17
|
+
def initialize(group = {})
|
18
|
+
self.group = group
|
19
|
+
end
|
20
|
+
|
21
|
+
def method_missing(id, *args)
|
22
|
+
return self.group[id.id2name]
|
23
|
+
end
|
24
|
+
|
25
|
+
# Special accessors that need typecasting or other parsing
|
26
|
+
|
27
|
+
def id
|
28
|
+
return self.group['id'].to_i
|
29
|
+
end
|
30
|
+
def updated
|
31
|
+
return DateTime.parse(self.group['updated'])
|
32
|
+
end
|
33
|
+
def created
|
34
|
+
return DateTime.parse(self.group['created'])
|
35
|
+
end
|
36
|
+
def lat
|
37
|
+
return self.group['lat'].to_f
|
38
|
+
end
|
39
|
+
def lon
|
40
|
+
return self.group['lon'].to_f
|
41
|
+
end
|
42
|
+
def daysleft
|
43
|
+
return self.group['daysleft'].to_i
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
module RMeetup
|
2
|
+
module Type
|
3
|
+
|
4
|
+
# == RMeetup::Type::Member
|
5
|
+
#
|
6
|
+
# Data wraper for a Member fethcing response
|
7
|
+
# Used to access result attributes as well
|
8
|
+
# as progammatically fetch relative data types
|
9
|
+
# based on this member.
|
10
|
+
|
11
|
+
# Edited by Jason Berlinsky on 1/20/11 to allow for arbitrary data access
|
12
|
+
# See http://www.meetup.com/meetup_api/docs/members/ for available fields
|
13
|
+
|
14
|
+
class Member
|
15
|
+
attr_accessor :member
|
16
|
+
|
17
|
+
def initialize(member = {})
|
18
|
+
self.member = member
|
19
|
+
end
|
20
|
+
|
21
|
+
def method_missing(id, *args)
|
22
|
+
return self.member[id.id2name]
|
23
|
+
end
|
24
|
+
|
25
|
+
# Special accessors that need typecasting or other parsing
|
26
|
+
|
27
|
+
def id
|
28
|
+
return self.member['id'].to_i
|
29
|
+
end
|
30
|
+
def lat
|
31
|
+
return self.member['lat'].to_f
|
32
|
+
end
|
33
|
+
def lon
|
34
|
+
return self.member['lon'].to_f
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
module RMeetup
|
2
|
+
module Type
|
3
|
+
|
4
|
+
# == RMeetup::Type::Photo
|
5
|
+
#
|
6
|
+
# Data wraper for a Photo fethcing response
|
7
|
+
# Used to access result attributes as well
|
8
|
+
# as progammatically fetch relative data types
|
9
|
+
# based on this photo.
|
10
|
+
|
11
|
+
# Edited by Jason Berlinsky on 1/20/11 to allow for arbitrary data access
|
12
|
+
# See http://www.meetup.com/meetup_api/docs/photos/ for available fields
|
13
|
+
|
14
|
+
class Photo
|
15
|
+
attr_accessor :photo
|
16
|
+
|
17
|
+
def initialize(photo = {})
|
18
|
+
self.photo = photo
|
19
|
+
end
|
20
|
+
|
21
|
+
def method_missing(id, *args)
|
22
|
+
return self.photo[id.id2name]
|
23
|
+
end
|
24
|
+
|
25
|
+
# Special accessors that need typecasting or other parsing
|
26
|
+
|
27
|
+
def created
|
28
|
+
return DateTime.parse(self.photo['created'])
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
module RMeetup
|
2
|
+
module Type
|
3
|
+
|
4
|
+
# == RMeetup::Type::Rsvp
|
5
|
+
#
|
6
|
+
# Data wraper for a Rsvp fethcing response
|
7
|
+
# Used to access result attributes as well
|
8
|
+
# as progammatically fetch relative data types
|
9
|
+
# based on this rsvp.
|
10
|
+
|
11
|
+
# Edited by Jason Berlinsky on 1/20/11 to allow for arbitrary data access
|
12
|
+
# See http://www.meetup.com/meetup_api/docs/ew/rsvps/ for available fields
|
13
|
+
|
14
|
+
class Rsvp
|
15
|
+
attr_accessor :rsvp
|
16
|
+
|
17
|
+
def initialize(rsvp = {})
|
18
|
+
self.rsvp = rsvp
|
19
|
+
end
|
20
|
+
|
21
|
+
def method_missing(id, *args)
|
22
|
+
return self.rsvp[id.id2name]
|
23
|
+
end
|
24
|
+
|
25
|
+
# Special accessors that need typecasting or other parsing
|
26
|
+
|
27
|
+
def lat
|
28
|
+
return self.rsvp['lat'].to_f
|
29
|
+
end
|
30
|
+
def lon
|
31
|
+
return self.rsvp['lon'].to_f
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
module RMeetup
|
2
|
+
module Type
|
3
|
+
|
4
|
+
# == RMeetup::Type::Topic
|
5
|
+
#
|
6
|
+
# Data wraper for a Topic fethcing response
|
7
|
+
# Used to access result attributes as well
|
8
|
+
# as progammatically fetch relative data types
|
9
|
+
# based on this topic.
|
10
|
+
|
11
|
+
# Edited by Jason Berlinsky on 1/20/11 to allow for arbitrary data access
|
12
|
+
# See http://www.meetup.com/meetup_api/docs/topics/ for available fields
|
13
|
+
|
14
|
+
class Topic
|
15
|
+
attr_accessor :topic
|
16
|
+
|
17
|
+
def initialize(topic = {})
|
18
|
+
self.topic = topic
|
19
|
+
end
|
20
|
+
|
21
|
+
def method_missing(id, *args)
|
22
|
+
return self.topic[id.id2name]
|
23
|
+
end
|
24
|
+
|
25
|
+
# Special accessors that need typecasting or other parsing
|
26
|
+
|
27
|
+
def id
|
28
|
+
return self.topic['id'].to_i
|
29
|
+
end
|
30
|
+
def members
|
31
|
+
return self.topic['members'].to_i
|
32
|
+
end
|
33
|
+
def updated
|
34
|
+
return DateTime.parse(self.topic['updated'])
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
metadata
ADDED
@@ -0,0 +1,69 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: rubymeetup
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: '3.0'
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Joshua Calloway
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2013-10-15 00:00:00.000000000 Z
|
13
|
+
dependencies: []
|
14
|
+
description: A gem that accesses meetup api
|
15
|
+
email: joshua.calloway@gmail.com
|
16
|
+
executables: []
|
17
|
+
extensions: []
|
18
|
+
extra_rdoc_files: []
|
19
|
+
files:
|
20
|
+
- lib/rmeetup.rb
|
21
|
+
- lib/rmeetup/collection.rb
|
22
|
+
- lib/rmeetup/fetcher.rb
|
23
|
+
- lib/rmeetup/poster.rb
|
24
|
+
- lib/rmeetup/type.rb
|
25
|
+
- lib/rmeetup/poster/base.rb
|
26
|
+
- lib/rmeetup/poster/event_comment.rb
|
27
|
+
- lib/rmeetup/fetcher/base.rb
|
28
|
+
- lib/rmeetup/fetcher/cities.rb
|
29
|
+
- lib/rmeetup/fetcher/comments.rb
|
30
|
+
- lib/rmeetup/fetcher/events.rb
|
31
|
+
- lib/rmeetup/fetcher/groups.rb
|
32
|
+
- lib/rmeetup/fetcher/members.rb
|
33
|
+
- lib/rmeetup/fetcher/photos.rb
|
34
|
+
- lib/rmeetup/fetcher/rsvps.rb
|
35
|
+
- lib/rmeetup/fetcher/topics.rb
|
36
|
+
- lib/rmeetup/type/city.rb
|
37
|
+
- lib/rmeetup/type/comment.rb
|
38
|
+
- lib/rmeetup/type/event.rb
|
39
|
+
- lib/rmeetup/type/group.rb
|
40
|
+
- lib/rmeetup/type/member.rb
|
41
|
+
- lib/rmeetup/type/photo.rb
|
42
|
+
- lib/rmeetup/type/rsvp.rb
|
43
|
+
- lib/rmeetup/type/topic.rb
|
44
|
+
homepage: http://rubygems.org/gems/rubymeetup
|
45
|
+
licenses:
|
46
|
+
- MIT
|
47
|
+
post_install_message:
|
48
|
+
rdoc_options: []
|
49
|
+
require_paths:
|
50
|
+
- lib
|
51
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
52
|
+
none: false
|
53
|
+
requirements:
|
54
|
+
- - ! '>='
|
55
|
+
- !ruby/object:Gem::Version
|
56
|
+
version: '0'
|
57
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
58
|
+
none: false
|
59
|
+
requirements:
|
60
|
+
- - ! '>='
|
61
|
+
- !ruby/object:Gem::Version
|
62
|
+
version: '0'
|
63
|
+
requirements: []
|
64
|
+
rubyforge_project:
|
65
|
+
rubygems_version: 1.8.23
|
66
|
+
signing_key:
|
67
|
+
specification_version: 3
|
68
|
+
summary: rubymeetup
|
69
|
+
test_files: []
|