rMeetup 2.0.1 → 2.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +22 -1
- data/Rakefile +16 -0
- data/lib/rmeetup/client.rb +6 -0
- data/lib/rmeetup/destroyer.rb +20 -0
- data/lib/rmeetup/destroyer/base.rb +80 -0
- data/lib/rmeetup/destroyer/event.rb +10 -0
- data/lib/rmeetup/destroyer/event_comment.rb +10 -0
- data/lib/rmeetup/destroyer/member_photo.rb +10 -0
- data/lib/rmeetup/destroyer/photo.rb +10 -0
- data/lib/rmeetup/fetcher.rb +1 -0
- data/lib/rmeetup/fetcher/open_venues.rb +14 -0
- data/lib/rmeetup/poster.rb +2 -1
- data/lib/rmeetup/poster/base.rb +32 -6
- data/lib/rmeetup/poster/event.rb +16 -0
- data/lib/rmeetup/poster/event_comment.rb +1 -0
- data/lib/rmeetup/type/event.rb +2 -2
- data/lib/rmeetup/version.rb +2 -2
- data/rmeetup.gemspec +4 -4
- data/spec/client_spec.rb +10 -0
- data/spec/destroyer_spec.rb +18 -0
- data/spec/fetcher_spec.rb +1 -1
- data/spec/poster_spec.rb +18 -0
- metadata +19 -19
- data/spec/fixtures/vcr_cassettes/fetching_cities.yml +0 -358
- data/spec/fixtures/vcr_cassettes/fetching_events.yml +0 -54
- data/spec/fixtures/vcr_cassettes/fetching_groups.yml +0 -8627
- data/spec/fixtures/vcr_cassettes/fetching_members.yml +0 -3984
- data/spec/fixtures/vcr_cassettes/fetching_photos.yml +0 -54
- data/spec/fixtures/vcr_cassettes/fetching_rsvps.yml +0 -54
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e31f77c105bc14eefafc383da2bae51c365c0dce
|
4
|
+
data.tar.gz: e135da4c41f3c61a405692744e2bf9ba840e1f9e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4cd02a96e2de75875b70c1644715ca663ff4ef65284e909a3ad057e1f3341d809248a9b0cd8fbc67e3c0984acf91147f60217e55a1fe695b6f4749e2a37dd67c
|
7
|
+
data.tar.gz: 0fd930ec363af303c89da98986db620eb8b6a6905b56416d5e667000d5d3066d400672e6d2a98a9c9a70b1c000202fada1d3358bd592796ce198e751584f1c14
|
data/README.md
CHANGED
@@ -22,6 +22,12 @@ Sample code is worth a thousand words:
|
|
22
22
|
results.each do |result|
|
23
23
|
# Do something with the result
|
24
24
|
end
|
25
|
+
|
26
|
+
event = client.post(:event, {:group_id => 'some_group_id',
|
27
|
+
:group_urlname => 'some_group_urlname',
|
28
|
+
:name => 'My Event'})
|
29
|
+
|
30
|
+
client.delete(:event, 'event_id') # May throw exceptions or returns true
|
25
31
|
```
|
26
32
|
|
27
33
|
Fetch
|
@@ -37,6 +43,7 @@ RMeetup::Client#fetch takes a data model type and set of options as arguments. P
|
|
37
43
|
* :members
|
38
44
|
* :photos
|
39
45
|
* :venues
|
46
|
+
* :open_venues
|
40
47
|
|
41
48
|
The options that may be passed can be found on the Meetup API documentation. Please see http://www.meetup.com/meetup_api/docs/ and look up the model that you are calling (i.e. for :events, look at the API call "GET /2/events" at http://www.meetup.com/meetup_api/docs/2/events/).
|
42
49
|
|
@@ -45,9 +52,22 @@ Post
|
|
45
52
|
|
46
53
|
RMeetup::Client#post takes a data model type and set of options as arguments. Possible data models are:
|
47
54
|
|
55
|
+
* :event
|
56
|
+
* :event_comment
|
57
|
+
|
58
|
+
The options that may be passed can be found on the Meetup API documentation. Please see http://www.meetup.com/meetup_api/docs/ and look up the model that you are calling (i.e. for :event, look at the API call ```POST /2/event``` at http://www.meetup.com/meetup_api/docs/2/event).
|
59
|
+
|
60
|
+
|
61
|
+
Delete
|
62
|
+
------
|
63
|
+
|
64
|
+
RMeetup::Client#delete takes a data model type, object's id and set of options as arguments. Possible data models are:
|
65
|
+
|
66
|
+
* :event
|
48
67
|
* :event_comment
|
68
|
+
* :member_photo
|
69
|
+
* :photo
|
49
70
|
|
50
|
-
The options that may be passed can be found on the Meetup API documentation. Please see http://www.meetup.com/meetup_api/docs/ and look up the model that you are calling (i.e. for :event_comment, look at the API call ```POST /2/event_comment``` at http://www.meetup.com/meetup_api/docs/2/event_comment).
|
51
71
|
|
52
72
|
Installation
|
53
73
|
------------
|
@@ -63,3 +83,4 @@ Credits
|
|
63
83
|
* [Joshua Calloway](https://github.com/joshuacalloway/rmeetup) - added post functionality and event comment creation
|
64
84
|
* [Zishan Ahmad](https://github.com/zishan/rmeetup) - consolidated changes, updated docs
|
65
85
|
* [Nikica Jokić](https://github.com/neektza/rmeetup) - thread-safe client refactoring, setup for TravisCI, CodeClimate, Coveralls...
|
86
|
+
* [Emin Bugra Saral](https://github.com/eminbugrasaral/rmeetup) - added delete functionality along with several data models, added event creation
|
data/Rakefile
CHANGED
@@ -6,3 +6,19 @@ RSpec::Core::RakeTask.new(:spec)
|
|
6
6
|
task :test => :spec
|
7
7
|
|
8
8
|
task :default => [:spec]
|
9
|
+
|
10
|
+
require "bundler/gem_tasks"
|
11
|
+
|
12
|
+
task :console do
|
13
|
+
require 'pry'
|
14
|
+
require 'rmeetup'
|
15
|
+
|
16
|
+
def reload!
|
17
|
+
# Change 'gem_name' here too:
|
18
|
+
files = $LOADED_FEATURES.select { |feat| feat =~ /\/rmeetup\// }
|
19
|
+
files.each { |file| load file }
|
20
|
+
end
|
21
|
+
|
22
|
+
ARGV.clear
|
23
|
+
Pry.start
|
24
|
+
end
|
data/lib/rmeetup/client.rb
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
require 'rmeetup/errors'
|
2
2
|
require 'rmeetup/fetcher'
|
3
3
|
require 'rmeetup/poster'
|
4
|
+
require 'rmeetup/destroyer'
|
4
5
|
|
5
6
|
module RMeetup
|
6
7
|
|
@@ -47,6 +48,11 @@ module RMeetup
|
|
47
48
|
RMeetup::Poster.for(type).post options.merge(auth)
|
48
49
|
end
|
49
50
|
|
51
|
+
# Delegates to appropriate RMeetup::Destroyer
|
52
|
+
def delete(type, id, options = {})
|
53
|
+
RMeetup::Destroyer.for(type, id).delete options.merge(auth)
|
54
|
+
end
|
55
|
+
|
50
56
|
private
|
51
57
|
# Creates or returns Client configuration
|
52
58
|
#
|
@@ -0,0 +1,20 @@
|
|
1
|
+
require 'rmeetup/destroyer/base'
|
2
|
+
require 'rmeetup/destroyer/event'
|
3
|
+
require 'rmeetup/destroyer/event_comment'
|
4
|
+
require 'rmeetup/destroyer/member_photo'
|
5
|
+
require 'rmeetup/destroyer/photo'
|
6
|
+
|
7
|
+
module RMeetup
|
8
|
+
module Destroyer
|
9
|
+
|
10
|
+
def self.for(type, id)
|
11
|
+
name = type.to_s.camel_case.to_sym
|
12
|
+
if (name && constants.include?(name))
|
13
|
+
const_get(name).new(id)
|
14
|
+
else
|
15
|
+
raise RMeetup::Error::InvalidRequestTypeError.new(type)
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,80 @@
|
|
1
|
+
module RMeetup
|
2
|
+
module Destroyer
|
3
|
+
DOMAIN = "api.meetup.com"
|
4
|
+
|
5
|
+
class ApiError < StandardError
|
6
|
+
def initialize(error_message, request_url)
|
7
|
+
super "Meetup API Error: #{error_message} - API URL: #{request_url}"
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
class NoResponseError < StandardError
|
12
|
+
def initialize
|
13
|
+
super "No Response was returned from the Meetup API."
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
# == RMeetup::Destroyer::Base
|
18
|
+
#
|
19
|
+
# Base destroyer class that other destroyers will inherit from.
|
20
|
+
class Base
|
21
|
+
def initialize
|
22
|
+
@type = nil
|
23
|
+
@id = nil
|
24
|
+
end
|
25
|
+
|
26
|
+
# Delete and return a response based on a set of options.
|
27
|
+
# Override this method to ensure necessary options are passed for the request.
|
28
|
+
#
|
29
|
+
# @param options [Hash] Options for deleting, it's usually empty except the api key
|
30
|
+
# @return True on success
|
31
|
+
def delete(options = {})
|
32
|
+
raise NotConfiguredError, /deletes only possible with a concrete destroyer/ if @type.nil?
|
33
|
+
|
34
|
+
res = delete_response(base_url, options)
|
35
|
+
data = JSON.parse(res.body)
|
36
|
+
|
37
|
+
unless res.is_a?(Net::HTTPSuccess)
|
38
|
+
|
39
|
+
# Check to see if the api returned an error
|
40
|
+
if data.has_key?('problem')
|
41
|
+
raise ApiError.new(data['details'], build_path(options))
|
42
|
+
else
|
43
|
+
raise NoResponseError.new
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
true
|
48
|
+
end
|
49
|
+
|
50
|
+
def build_path(options)
|
51
|
+
base_url + query(options)
|
52
|
+
end
|
53
|
+
|
54
|
+
# Create a query string from an options hash
|
55
|
+
def query(options)
|
56
|
+
'?' + URI.encode_www_form(options)
|
57
|
+
end
|
58
|
+
|
59
|
+
protected
|
60
|
+
# OVERRIDE this method to format a result section
|
61
|
+
# as per Result type.
|
62
|
+
# Takes a result in a collection and
|
63
|
+
# formats it to be put back into the collection.
|
64
|
+
def format_result(result)
|
65
|
+
result
|
66
|
+
end
|
67
|
+
|
68
|
+
def base_url
|
69
|
+
"https://api.meetup.com/2/#{@type}/#{@id}"
|
70
|
+
end
|
71
|
+
|
72
|
+
def delete_response(url, options)
|
73
|
+
path = url + query(options)
|
74
|
+
req = Net::HTTP.new DOMAIN, 443
|
75
|
+
req.use_ssl = true
|
76
|
+
req.delete(path)
|
77
|
+
end
|
78
|
+
end
|
79
|
+
end
|
80
|
+
end
|
data/lib/rmeetup/fetcher.rb
CHANGED
data/lib/rmeetup/poster.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
require "rmeetup/poster/base"
|
2
|
+
require "rmeetup/poster/event"
|
2
3
|
require "rmeetup/poster/event_comment"
|
3
4
|
|
4
5
|
module RMeetup
|
@@ -9,7 +10,7 @@ module RMeetup
|
|
9
10
|
if (name && constants.include?(name))
|
10
11
|
const_get(name).new
|
11
12
|
else
|
12
|
-
raise InvalidRequestTypeError.new(type)
|
13
|
+
raise RMeetup::Error::InvalidRequestTypeError.new(type)
|
13
14
|
end
|
14
15
|
end
|
15
16
|
|
data/lib/rmeetup/poster/base.rb
CHANGED
@@ -14,14 +14,20 @@ module RMeetup
|
|
14
14
|
super "No Response was returned from the Meetup API."
|
15
15
|
end
|
16
16
|
end
|
17
|
-
|
18
|
-
|
17
|
+
|
18
|
+
module ResponseType
|
19
|
+
BASIC_RESPONSE = 1
|
20
|
+
OBJECT = 2
|
21
|
+
end
|
22
|
+
|
23
|
+
# == RMeetup::Poster::Base
|
19
24
|
#
|
20
|
-
# Base
|
25
|
+
# Base poster class that other posters
|
21
26
|
# will inherit from.
|
22
27
|
class Base
|
23
28
|
def initialize
|
24
29
|
@type = nil
|
30
|
+
@response_type = ResponseType::BASIC_RESPONSE
|
25
31
|
end
|
26
32
|
|
27
33
|
# Fetch and parse a response
|
@@ -30,9 +36,28 @@ module RMeetup
|
|
30
36
|
# neccessary options are passed
|
31
37
|
# for the request.
|
32
38
|
def post(options = {})
|
39
|
+
raise NotConfiguredError, /posts only possible with a concrete type/ if @type.nil?
|
40
|
+
|
33
41
|
url = build_url(options)
|
34
|
-
|
35
|
-
|
42
|
+
res = post_response(url, options)
|
43
|
+
response_body = res.body
|
44
|
+
data = JSON.parse(response_body)
|
45
|
+
|
46
|
+
unless res.is_a?(Net::HTTPSuccess)
|
47
|
+
# Check to see if the api returned an error
|
48
|
+
if data.has_key?('problem')
|
49
|
+
raise ApiError.new(data['details'], url)
|
50
|
+
else
|
51
|
+
raise NoResponseError.new
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
case @response_type
|
56
|
+
when ResponseType::OBJECT
|
57
|
+
format_result(data)
|
58
|
+
else
|
59
|
+
res
|
60
|
+
end
|
36
61
|
end
|
37
62
|
|
38
63
|
protected
|
@@ -70,11 +95,12 @@ module RMeetup
|
|
70
95
|
|
71
96
|
def post_response(url, options)
|
72
97
|
sslurl = URI.parse(url)
|
98
|
+
|
73
99
|
https = Net::HTTP.new(sslurl.host, sslurl.port)
|
74
100
|
https.use_ssl = true
|
75
101
|
req = Net::HTTP::Post.new(sslurl.path)
|
76
102
|
req.set_form_data(options)
|
77
|
-
|
103
|
+
res = https.request(req)
|
78
104
|
end
|
79
105
|
end
|
80
106
|
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
module RMeetup
|
2
|
+
module Poster
|
3
|
+
class Event < Base
|
4
|
+
def initialize
|
5
|
+
@type = :event
|
6
|
+
@response_type = ResponseType::OBJECT
|
7
|
+
end
|
8
|
+
|
9
|
+
# Turn the result hash into an Event Class
|
10
|
+
def format_result(result)
|
11
|
+
RMeetup::Type::Event.new(result)
|
12
|
+
end
|
13
|
+
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
data/lib/rmeetup/type/event.rb
CHANGED
@@ -3,9 +3,9 @@ module RMeetup
|
|
3
3
|
|
4
4
|
# == RMeetup::Type::Event
|
5
5
|
#
|
6
|
-
# Data
|
6
|
+
# Data wrapper for an Event
|
7
7
|
# Used to access result attributes as well
|
8
|
-
# as
|
8
|
+
# as programatically fetch relative data types
|
9
9
|
# based on this event.
|
10
10
|
|
11
11
|
class Event
|
data/lib/rmeetup/version.rb
CHANGED
data/rmeetup.gemspec
CHANGED
@@ -7,17 +7,17 @@ Gem::Specification.new do |spec|
|
|
7
7
|
spec.platform = Gem::Platform::RUBY
|
8
8
|
|
9
9
|
spec.name = 'rMeetup'
|
10
|
-
spec.description = 'meetup.com
|
10
|
+
spec.description = 'meetup.com API wrapper for Ruby'
|
11
11
|
spec.authors = ['Jared Pace', 'Jason Berlinsky', 'Tommy Chan', 'Tanner Mares', 'Zishan Ahmad', 'Nikica Jokić']
|
12
12
|
spec.email = ['jdpace@github.com', 'jason@jasonberlinsky.com', 'tommytcchan@gmail.com', 'tannermares@gmail.com', 'me@zishanahmad.com', 'neektza@gmail.com']
|
13
|
-
spec.homepage = 'https://github.com/
|
14
|
-
spec.summary = 'A Ruby wrapper for the Meetup
|
13
|
+
spec.homepage = 'https://github.com/floatingpointio/rmeetup'
|
14
|
+
spec.summary = 'A Ruby wrapper for the Meetup API v2'
|
15
15
|
|
16
16
|
spec.required_rubygems_version = '>= 1.3.6'
|
17
17
|
|
18
18
|
spec.add_dependency 'json', '~> 1.8'
|
19
19
|
spec.add_dependency 'buftok', '~> 0.2'
|
20
|
-
spec.add_dependency 'http', '~> 0.
|
20
|
+
spec.add_dependency 'http', '~> 0.7'
|
21
21
|
spec.add_dependency 'http_parser.rb', '~> 0.6'
|
22
22
|
|
23
23
|
spec.add_development_dependency 'bundler', '~> 1.6'
|
data/spec/client_spec.rb
CHANGED
@@ -39,6 +39,16 @@ describe RMeetup::Client do
|
|
39
39
|
end
|
40
40
|
end
|
41
41
|
|
42
|
+
context 'when fetching :open_events' do
|
43
|
+
it 'returns a collection of Events' do
|
44
|
+
VCR.use_cassette('fetching_open_events') do
|
45
|
+
client.fetch(:open_events, {country: 'US', :zip=>"95120", :state=>"CA"}).each do |result|
|
46
|
+
result.should be_kind_of(RMeetup::Type::Event)
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
42
52
|
context 'when fetching :rsvps' do
|
43
53
|
it 'returns a collection of RSVPs' do
|
44
54
|
VCR.use_cassette('fetching_rsvps') do
|