meetupevents 0.1.21 → 0.1.22
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/lib/meetupevents/city.rb +6 -2
- data/lib/meetupevents/event.rb +27 -7
- data/lib/meetupevents/meetupevents.rb +30 -1
- data/lib/meetupevents/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ffa7ca6b2984146b1cf0fcfa7a02c32971c0ff99
|
4
|
+
data.tar.gz: f4db03beb765de6bc253af91ccb60e583bb0c2fe
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6b132607df41d06c26f3afc0638dbf79b4d05e74f499eb609aff5a840224155774417764e2a7c13954c95c6579d1cfaba4df8fc6d7ec214e2b45e680d22c34dc
|
7
|
+
data.tar.gz: 0ca2c7c663779674976a46d646155cb11b00b754f27c2f7a6279307781c6c9319753f4f421a4850ef7ea80a529ed25c96207e725e885f4e8aa067f6d8a139bdf
|
data/lib/meetupevents/city.rb
CHANGED
@@ -11,11 +11,13 @@ module Meetup
|
|
11
11
|
attr_reader :country
|
12
12
|
attr_reader :events
|
13
13
|
attr_reader :groups
|
14
|
+
attr_reader :topic
|
14
15
|
|
15
|
-
def initialize(name:, location:, country:)
|
16
|
+
def initialize(name:, location:, country:, topic: 'none')
|
16
17
|
@name = name
|
17
18
|
@location = location
|
18
19
|
@country = country
|
20
|
+
@topic = topic
|
19
21
|
end
|
20
22
|
|
21
23
|
def groups
|
@@ -27,7 +29,9 @@ module Meetup
|
|
27
29
|
|
28
30
|
def events
|
29
31
|
return @events if @events
|
30
|
-
located_events = Meetup::LocatedEvents.new(
|
32
|
+
located_events = Meetup::LocatedEvents.new(city: @name,
|
33
|
+
country: @country,
|
34
|
+
topic: @topic)
|
31
35
|
@events = located_events.events
|
32
36
|
end
|
33
37
|
|
data/lib/meetupevents/event.rb
CHANGED
@@ -5,30 +5,50 @@ require_relative 'location'
|
|
5
5
|
module Meetup
|
6
6
|
# Class to set up a Meetup Event
|
7
7
|
class Event
|
8
|
-
attr_reader :name, :status, :city, :venue,
|
8
|
+
attr_reader :name, :status, :city, :venue,
|
9
|
+
:time, :location, :url, :topic
|
9
10
|
|
10
|
-
def initialize(name:, status:, city:, venue:, time:,
|
11
|
+
def initialize(name:, status:, city:, venue:, time:,
|
12
|
+
location:, url:, topic:)
|
11
13
|
@name = name
|
12
14
|
@status = status
|
13
15
|
@city = city
|
14
16
|
@time = time
|
15
17
|
@venue = venue
|
16
18
|
@location = location
|
19
|
+
@url = url
|
20
|
+
@topic = topic
|
17
21
|
end
|
18
22
|
end
|
19
23
|
|
20
24
|
# Class to extract the located events from meetup
|
21
25
|
class LocatedEvents
|
22
26
|
attr_reader :events
|
27
|
+
def get_event_location(e)
|
28
|
+
if e['venue']
|
29
|
+
Meetup::Location.new(e['venue']['lat'],
|
30
|
+
e['venue']['lon'])
|
31
|
+
else
|
32
|
+
Meetup::Location.new(e['group']['group_lat'],
|
33
|
+
e['group']['group_lon'])
|
34
|
+
end
|
35
|
+
end
|
36
|
+
# TOO SLOW
|
37
|
+
# def get_event_category(g)
|
38
|
+
# print g['group']['urlname']
|
39
|
+
# groupurl = g['group']['urlname'] #.encode(Encoding.find('ASCII'))
|
40
|
+
# g = Meetup::MeetupApi.find_group_by_url(groupurl)
|
41
|
+
# g['category'] ? g['category']['short_name'] : 'None'
|
42
|
+
# end
|
23
43
|
|
24
|
-
def initialize(
|
25
|
-
raw_events = MeetupApi.
|
26
|
-
location.lon)
|
44
|
+
def initialize(country:, city:, topic:)
|
45
|
+
raw_events = MeetupApi.get_events_city(country, city, topic)
|
27
46
|
@events = raw_events.map do |g|
|
28
47
|
Meetup::Event.new(name: g['name'], status: g['status'],
|
29
|
-
city:
|
48
|
+
city: city,
|
30
49
|
venue: g['venue'] ? g['venue']['name'] : '', # may nil
|
31
|
-
time: g['time'], location:
|
50
|
+
time: g['time'], location: get_event_location(g),
|
51
|
+
url: g['event_url'], topic: topic)
|
32
52
|
end
|
33
53
|
end
|
34
54
|
end
|
@@ -1,5 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
require 'http'
|
3
|
+
require 'cgi'
|
3
4
|
module Meetup
|
4
5
|
# Meetup api
|
5
6
|
class MeetupApi
|
@@ -51,8 +52,20 @@ module Meetup
|
|
51
52
|
response['results']
|
52
53
|
end
|
53
54
|
|
55
|
+
# Get all cities of a country
|
56
|
+
def self.get_cities_by_country(country)
|
57
|
+
api_url = URI.join(API_URL, "/#{API_VERSION}/", 'cities')
|
58
|
+
cities_response = HTTP.get(api_url,
|
59
|
+
params: { country: country,
|
60
|
+
signed: true,
|
61
|
+
key: access_key })
|
62
|
+
response = JSON.parse(cities_response.to_s)
|
63
|
+
# add_log(response, "events_at_#{place}")
|
64
|
+
response
|
65
|
+
end
|
66
|
+
|
54
67
|
# Gets events based on the location. Place var just for fixtures
|
55
|
-
def self.
|
68
|
+
def self.get_events_location(lat, lon)
|
56
69
|
api_url = URI.join(API_URL, '/find/events/')
|
57
70
|
events_response = HTTP.get(api_url,
|
58
71
|
params: { lon: lon,
|
@@ -64,6 +77,21 @@ module Meetup
|
|
64
77
|
response
|
65
78
|
end
|
66
79
|
|
80
|
+
def self.get_events_city(country, city, topic)
|
81
|
+
params = { country: country,
|
82
|
+
city: city,
|
83
|
+
topic: topic,
|
84
|
+
signed: true,
|
85
|
+
key: access_key }
|
86
|
+
params.tap{ |h| h.delete(:topic) } unless topic != 'none'
|
87
|
+
api_url = URI.join(API_URL, "/#{API_VERSION}/", 'open_events')
|
88
|
+
events_response = HTTP.get(api_url,
|
89
|
+
params: params)
|
90
|
+
response = JSON.parse(events_response.to_s)
|
91
|
+
# add_log(response, "events_at_#{place}")
|
92
|
+
response['results']
|
93
|
+
end
|
94
|
+
|
67
95
|
# Finds groups based on a location text query
|
68
96
|
def self.get_groups(country_code, location_raw_text)
|
69
97
|
api_url = URI.join(API_URL, '/find/groups')
|
@@ -79,6 +107,7 @@ module Meetup
|
|
79
107
|
|
80
108
|
# Finds groups based on a location text query
|
81
109
|
def self.find_group_by_url(urlname)
|
110
|
+
urlname = CGI.escape(urlname)
|
82
111
|
api_url = URI.join(API_URL, "/#{urlname}")
|
83
112
|
groups_response = HTTP.get(api_url,
|
84
113
|
params: { signed: true,
|
data/lib/meetupevents/version.rb
CHANGED