gistmeetup 0.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. data/bin/gistmeetup +61 -0
  2. data/lib/gistmeetup.rb +41 -0
  3. metadata +80 -0
data/bin/gistmeetup ADDED
@@ -0,0 +1,61 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'optparse'
4
+ require File.expand_path('../../lib/gistmeetup', __FILE__)
5
+
6
+ # For the holdings of options.
7
+ options = {}
8
+ filenames = []
9
+
10
+ parser = OptionParser.new do |opts|
11
+ opts.banner = "Usage:"
12
+ executable_name = File.split($0)[1]
13
+
14
+ opts.on("-m", "--require MEETUP",
15
+ "Require the Meetup name") do |meetup|
16
+ options[:meetup] = meetup
17
+ end
18
+ opts.on("-c", "--require COMMENT",
19
+ "Require the Comments to the code") do |comment|
20
+ options[:comment] = comment
21
+ end
22
+
23
+ opts.on("--login", "Authenticate gist on this computer.") do
24
+ Gistmeetup.login!
25
+ exit
26
+ end
27
+ end
28
+
29
+ parser.parse!
30
+
31
+ if options[:meetup] == nil
32
+ print parser
33
+ exit 1
34
+ end
35
+ if options[:comment] == nil
36
+ print parser
37
+ exit 1
38
+ end
39
+
40
+ to_read = ARGV.empty? ? ['-'] : ARGV
41
+ files = {}
42
+ error = false
43
+ to_read.zip(filenames).each do |(file, name)|
44
+ files[name || file] =
45
+ begin
46
+ File.read(File.expand_path(file))
47
+ rescue => e
48
+ puts "File #{file} does not exist or is not readable."
49
+ error = true
50
+ end
51
+ end
52
+ #puts "options[:meetup] : #{options[:meetup]}"
53
+ #puts "files : #{files}"
54
+ #puts "options : #{options}"
55
+ if !error
56
+ ret = Gistmeetup.post(options[:meetup], options[:comment], files, options)
57
+ puts ""
58
+ puts "#{ret}"
59
+ end
60
+
61
+
data/lib/gistmeetup.rb ADDED
@@ -0,0 +1,41 @@
1
+ require 'gist'
2
+ require 'rmeetup'
3
+
4
+ module Gistmeetup
5
+ extend self
6
+
7
+ VERSION = '0.0.1'
8
+
9
+ module Error;
10
+ def self.exception(*args)
11
+ RuntimeError.new(*args).extend(self)
12
+ end
13
+ end
14
+
15
+ def post(meetup, comment, files, options={})
16
+ ret = Gist.multi_gist(files, options)
17
+
18
+ RMeetup::Client.api_key = "311e1e54e55667752236e673758662c"
19
+
20
+ events = RMeetup::Client.fetch(:events, {:group_urlname => "#{meetup}"})
21
+ if events.empty?
22
+ groups = RMeetup::Client.fetch(:groups, {:group_urlname => "#{meetup}"})
23
+ ret = ""
24
+ if groups.empty?
25
+ ret = "The meetup '#{meetup}' does not exist."
26
+ else
27
+ ret = "No meetup events exist for '#{meetup}'"
28
+ end
29
+ ret
30
+ else
31
+ nextEvent = events[0]
32
+ url = ret["html_url"]
33
+ RMeetup::Client.post(:event_comment, {:event_id => "#{nextEvent.id}", :comment => "#{comment} - #{url}" })
34
+ "Posted to github on '#{url}' and link to it on '#{meetup}' comments"
35
+ end
36
+ end
37
+
38
+ def login!(credentials={})
39
+ Gist.login!(credentials)
40
+ end
41
+ end
metadata ADDED
@@ -0,0 +1,80 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: gistmeetup
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.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
+ - !ruby/object:Gem::Dependency
15
+ name: gist
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: 4.1.1
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ! '>='
28
+ - !ruby/object:Gem::Version
29
+ version: 4.1.1
30
+ - !ruby/object:Gem::Dependency
31
+ name: rubymeetup
32
+ requirement: !ruby/object:Gem::Requirement
33
+ none: false
34
+ requirements:
35
+ - - ! '>='
36
+ - !ruby/object:Gem::Version
37
+ version: '3.0'
38
+ type: :runtime
39
+ prerelease: false
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ! '>='
44
+ - !ruby/object:Gem::Version
45
+ version: '3.0'
46
+ description: A gem that uploads to gist and meetup
47
+ email: joshua.calloway@gmail.com
48
+ executables:
49
+ - gistmeetup
50
+ extensions: []
51
+ extra_rdoc_files: []
52
+ files:
53
+ - lib/gistmeetup.rb
54
+ - bin/gistmeetup
55
+ homepage: http://rubygems.org/gems/gistmeetup
56
+ licenses:
57
+ - MIT
58
+ post_install_message:
59
+ rdoc_options: []
60
+ require_paths:
61
+ - lib
62
+ required_ruby_version: !ruby/object:Gem::Requirement
63
+ none: false
64
+ requirements:
65
+ - - ! '>='
66
+ - !ruby/object:Gem::Version
67
+ version: '0'
68
+ required_rubygems_version: !ruby/object:Gem::Requirement
69
+ none: false
70
+ requirements:
71
+ - - ! '>='
72
+ - !ruby/object:Gem::Version
73
+ version: '0'
74
+ requirements: []
75
+ rubyforge_project:
76
+ rubygems_version: 1.8.23
77
+ signing_key:
78
+ specification_version: 3
79
+ summary: gistmeetup
80
+ test_files: []