meetup-cli 1.0.0 → 1.0.2

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 93c032d3baa23c806007dddeafd90733fd44decf
4
- data.tar.gz: abda1aab2c944812fea3bec9a387b8e238fe3e52
3
+ metadata.gz: c9be64be27aabbf01dd647b970f362a4c904806f
4
+ data.tar.gz: e56c7cef2206246ec044d462fe2ea49c16691a86
5
5
  SHA512:
6
- metadata.gz: edf053605cdd27ea651eea52b28d178cc209493384975e847d983424e6657963a9af18ba38fbf0131726dad3c7c91bc511cbb6c6f4c0de0f6f5e9ae0d9e99886
7
- data.tar.gz: 22d1dd909fadb473cf47bf60a3dab0899b9c9b77397ea2ee14e0510d8f505a33e5733a5ac58da8e198c9366df8bc93c00bf750c942a367de8adfac5898c82191
6
+ metadata.gz: 37373ac49ae67f741edd7b76aad3fc74ddbacb8e5ea1ec6b5cce568fdc461468cc485d6352935401fd3ae39437fd06de9205f0e0f664d8eab3dbb35d2dce9782
7
+ data.tar.gz: c3e236427205905977aec1df6d48d464bd49409f8188b66cf3250625e6626d9ac0b8dbde6759a33465e08a732447741cd7d9e7d80e7890cf32d34b28825fb455
data/lib/meetup-cli.rb CHANGED
@@ -1,20 +1,25 @@
1
+ require 'gli'
1
2
  require 'yaml'
2
- require 'rMeetup'
3
+ require 'meetup-cli/api'
3
4
  require 'meetup-cli/version'
4
5
 
5
6
  APP_NAME = File.basename $0, File.extname($0)
6
7
  CONFIG_FILE = File.join(ENV['HOME'], ".#{APP_NAME}rc")
7
8
 
8
- # Convert to human friendly representation in user's time zone (almost RFC 2822)
9
- def date_str(date)
10
- date.to_time.strftime('%a, %-d %b %Y %H:%M:%S %Z')
11
- end
9
+ include GLI::App
10
+ program_desc "Meetup command line interface"
11
+ version MCLI::VERSION
12
+ default_command :upcoming
12
13
 
13
- begin
14
- $config = YAML.load_file(CONFIG_FILE)
15
- throw if $config['api_key'].nil? || $config['member_id'].nil?
16
- rescue
17
- puts <<-EOM
14
+ pre do
15
+ # Do not print stack trace when terminating due to a broken pipe
16
+ Signal.trap "SIGPIPE", "SYSTEM_DEFAULT"
17
+
18
+ begin
19
+ $config = YAML.load_file(CONFIG_FILE)
20
+ throw if $config['api_key'].nil?
21
+ rescue
22
+ exit_now! <<-EOM
18
23
  It looks like you are running #{APP_NAME} for the first time.
19
24
 
20
25
  Obtain an API key from: https://secure.meetup.com/meetup_api/key/
@@ -22,29 +27,39 @@ Obtain an API key from: https://secure.meetup.com/meetup_api/key/
22
27
  And save the following in ~/.#{APP_NAME}rc:
23
28
 
24
29
  api_key: <api-key>
25
- member_id: <member-id>
26
- EOM
27
- exit 0
30
+ EOM
31
+ end
32
+
33
+ true # Success
34
+ end
35
+
36
+ on_error do |exception|
37
+ puts exception.message
38
+
39
+ # Suppress GLI's built-in error handling
40
+ false
41
+ end
42
+
43
+ # Human friendly date/time in user's time zone (almost RFC 2822)
44
+ def date_str(date)
45
+ date.to_time.strftime('%a, %-d %b %Y %H:%M:%S %Z')
28
46
  end
29
47
 
30
- puts "This is #{APP_NAME} #{MCLI::VERSION}"
31
- puts
48
+ desc "List your upcoming meetups (default command)"
49
+ command :upcoming do |c|
50
+ c.action do
51
+ puts "Your upcoming events:"
52
+ puts "---"
53
+ puts
32
54
 
33
- # Obtain API key: https://secure.meetup.com/meetup_api/key/
34
- client = RMeetup::Client.new do |meetup_config|
35
- meetup_config.api_key = $config['api_key']
55
+ MCLI::get_upcoming_events.each do |event|
56
+ puts "#{event.name}"
57
+ puts " URL: #{event.event_url}"
58
+ puts " Date: #{date_str(event.time)}"
59
+ puts " Where: #{event.venue.address_1}, #{event.venue.city}, #{event.venue.state}"
60
+ puts
61
+ end
62
+ end
36
63
  end
37
64
 
38
- puts "Your upcoming events:"
39
- puts
40
-
41
- client.fetch(:events, {
42
- member_id: $config['member_id'],
43
- rsvp: 'yes'
44
- }).each do |res|
45
- puts "#{res.name}"
46
- puts " URL: #{res.event_url}"
47
- puts " Date: #{date_str(res.time)}"
48
- puts " Where: #{res.venue.address_1}, #{res.venue.city}, #{res.venue.state}"
49
- puts
50
- end
65
+ exit run(ARGV)
@@ -0,0 +1,13 @@
1
+ require 'rMeetup'
2
+
3
+ module MCLI
4
+ def self.init_api
5
+ RMeetup::Client.new do |meetup_config|
6
+ meetup_config.api_key = $config['api_key']
7
+ end
8
+ end
9
+
10
+ def self.get_upcoming_events
11
+ api = init_api.fetch(:events, {member_id: 'self', rsvp: 'yes'})
12
+ end
13
+ end
@@ -1,3 +1,3 @@
1
1
  module MCLI
2
- VERSION = '1.0.0'
2
+ VERSION = '1.0.2'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: meetup-cli
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ildar Sagdejev
@@ -19,6 +19,7 @@ extra_rdoc_files: []
19
19
  files:
20
20
  - bin/meetup-cli
21
21
  - lib/meetup-cli.rb
22
+ - lib/meetup-cli/api.rb
22
23
  - lib/meetup-cli/version.rb
23
24
  homepage: https://github.com/specious/meetup-cli
24
25
  licenses: