hubotgf 0.0.1

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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 3081b3ac191abd7c00ec91e0d3f0f631ade1f3de
4
+ data.tar.gz: 1e5f660fe4af80c44ca49dded3802c2d8ce3672e
5
+ SHA512:
6
+ metadata.gz: a503182580bf19c75a6a4e9a5119a556e43c7f7228367ef049ac626f7adf1b421a66273ba9a2cc58e2ee418f202e533984ef6f915a75af490ac1193a65a629d2
7
+ data.tar.gz: 5b0fe56427428076505ea3f7ffceaec8a43a99bae25990c7d1fadaa13c61ef115d755d97709cc19bd6ecd328d6cab9ba170fee5c7cd94bceb751f0f075b07cd3
data/MIT-LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright 2014 YOURNAME
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/Rakefile ADDED
@@ -0,0 +1,20 @@
1
+ begin
2
+ require 'bundler/setup'
3
+ rescue LoadError
4
+ puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
5
+ end
6
+
7
+ require 'rdoc/task'
8
+
9
+ RDoc::Task.new(:rdoc) do |rdoc|
10
+ rdoc.rdoc_dir = 'rdoc'
11
+ rdoc.title = 'HubotGf'
12
+ rdoc.options << '--line-numbers'
13
+ rdoc.rdoc_files.include('README.rdoc')
14
+ rdoc.rdoc_files.include('lib/**/*.rb')
15
+ end
16
+
17
+ APP_RAKEFILE = File.expand_path("../spec/dummy/Rakefile", __FILE__)
18
+ load 'rails/tasks/engine.rake'
19
+
20
+ Bundler::GemHelper.install_tasks
@@ -0,0 +1,10 @@
1
+ module HubotGf
2
+ class TasksController < ActionController::Base
3
+
4
+ def create
5
+ result = HubotGf::Worker.start params[:command], { sender: params[:_sender], room: params[:_room] }
6
+ head (result ? :ok : :not_found)
7
+ end
8
+
9
+ end
10
+ end
data/config/routes.rb ADDED
@@ -0,0 +1,4 @@
1
+ HubotGf::Engine.routes.draw do
2
+ resources :tasks, only: :create
3
+ # post '/hubotgf/tasks', controller: 'hubot_gf/tasks', action: 'create'
4
+ end
@@ -0,0 +1,30 @@
1
+ module HubotGf
2
+ module Config
3
+ extend self
4
+
5
+ attr_accessor :perform, :performer, :hubot_url
6
+
7
+ def configure
8
+ yield self
9
+ end
10
+
11
+ def perform
12
+ @perform || lambda do |worker, args, metadata = {}|
13
+ arity = worker.instance_method(:perform).arity
14
+ args << metadata[:sender] if arity > args.length
15
+ args << metadata[:room] if arity > args.length
16
+
17
+ case performer
18
+ when :sidekiq
19
+ Sidekiq::Client.enqueue(worker, *args)
20
+ when :resque
21
+ Resque.enqueue(worker, *args)
22
+ else
23
+ worker.new.perform(*args)
24
+ end
25
+
26
+ end
27
+ end
28
+
29
+ end
30
+ end
@@ -0,0 +1,5 @@
1
+ module HubotGf
2
+ class Engine < ::Rails::Engine
3
+ isolate_namespace HubotGf
4
+ end
5
+ end
@@ -0,0 +1,27 @@
1
+ require "faraday"
2
+ require "faraday_middleware"
3
+
4
+ module HubotGf
5
+ class Messenger
6
+
7
+ def pm(jid, message)
8
+ Rails.logger.info "Sending message to #{jid}"
9
+ client.post '/hubot/pm', { replyTo: jid, message: message }
10
+ end
11
+
12
+ def room(room, message)
13
+ Rails.logger.info "Sending message to #{room}, message: #{message}"
14
+ client.post '/hubot/room', { room: room, message: message }
15
+ end
16
+
17
+ private
18
+
19
+ def client
20
+ @client ||= Faraday.new(url: HubotGf::Config.hubot_url) do |http|
21
+ http.request :json
22
+ http.adapter :net_http
23
+ end
24
+ end
25
+
26
+ end
27
+ end
@@ -0,0 +1,3 @@
1
+ module HubotGf
2
+ VERSION = "0.0.1"
3
+ end
@@ -0,0 +1,33 @@
1
+ module HubotGf
2
+ module Worker
3
+
4
+ def self.included(base)
5
+ @workers ||= []
6
+ @workers << base
7
+ base.extend ClassMethods
8
+ end
9
+
10
+ def self.start(command, metadata = {})
11
+ worker = @workers.find { |w| w.command =~ command }
12
+ if worker
13
+ arguments = worker.command.match(command).captures
14
+ HubotGf::Config.perform.call(worker, arguments, metadata)
15
+ end
16
+ end
17
+
18
+ def gf
19
+ HubotGf::Messenger.new
20
+ end
21
+
22
+ module ClassMethods
23
+ def command=(command)
24
+ @command = command
25
+ end
26
+
27
+ def command
28
+ @command || ''
29
+ end
30
+ end
31
+
32
+ end
33
+ end
data/lib/hubotgf.rb ADDED
@@ -0,0 +1,12 @@
1
+ require "hubotgf/engine"
2
+ require "hubotgf/config"
3
+ require "hubotgf/worker"
4
+ require "hubotgf/messenger"
5
+
6
+ require_relative "../app/controllers/hubotgf/tasks_controller"
7
+
8
+ module HubotGf
9
+ def self.configure(&block)
10
+ HubotGf::Config.configure(&block)
11
+ end
12
+ end
metadata ADDED
@@ -0,0 +1,168 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: hubotgf
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Logan Serman
8
+ - Michael Eatherly
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2014-04-02 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: rails
16
+ requirement: !ruby/object:Gem::Requirement
17
+ requirements:
18
+ - - '>='
19
+ - !ruby/object:Gem::Version
20
+ version: 4.0.0
21
+ type: :runtime
22
+ prerelease: false
23
+ version_requirements: !ruby/object:Gem::Requirement
24
+ requirements:
25
+ - - '>='
26
+ - !ruby/object:Gem::Version
27
+ version: 4.0.0
28
+ - !ruby/object:Gem::Dependency
29
+ name: faraday
30
+ requirement: !ruby/object:Gem::Requirement
31
+ requirements:
32
+ - - '>='
33
+ - !ruby/object:Gem::Version
34
+ version: '0'
35
+ type: :runtime
36
+ prerelease: false
37
+ version_requirements: !ruby/object:Gem::Requirement
38
+ requirements:
39
+ - - '>='
40
+ - !ruby/object:Gem::Version
41
+ version: '0'
42
+ - !ruby/object:Gem::Dependency
43
+ name: faraday_middleware
44
+ requirement: !ruby/object:Gem::Requirement
45
+ requirements:
46
+ - - '>='
47
+ - !ruby/object:Gem::Version
48
+ version: '0'
49
+ type: :runtime
50
+ prerelease: false
51
+ version_requirements: !ruby/object:Gem::Requirement
52
+ requirements:
53
+ - - '>='
54
+ - !ruby/object:Gem::Version
55
+ version: '0'
56
+ - !ruby/object:Gem::Dependency
57
+ name: sqlite3
58
+ requirement: !ruby/object:Gem::Requirement
59
+ requirements:
60
+ - - '>='
61
+ - !ruby/object:Gem::Version
62
+ version: '0'
63
+ type: :development
64
+ prerelease: false
65
+ version_requirements: !ruby/object:Gem::Requirement
66
+ requirements:
67
+ - - '>='
68
+ - !ruby/object:Gem::Version
69
+ version: '0'
70
+ - !ruby/object:Gem::Dependency
71
+ name: rspec-rails
72
+ requirement: !ruby/object:Gem::Requirement
73
+ requirements:
74
+ - - '>='
75
+ - !ruby/object:Gem::Version
76
+ version: '0'
77
+ type: :development
78
+ prerelease: false
79
+ version_requirements: !ruby/object:Gem::Requirement
80
+ requirements:
81
+ - - '>='
82
+ - !ruby/object:Gem::Version
83
+ version: '0'
84
+ - !ruby/object:Gem::Dependency
85
+ name: sidekiq
86
+ requirement: !ruby/object:Gem::Requirement
87
+ requirements:
88
+ - - '>='
89
+ - !ruby/object:Gem::Version
90
+ version: '0'
91
+ type: :development
92
+ prerelease: false
93
+ version_requirements: !ruby/object:Gem::Requirement
94
+ requirements:
95
+ - - '>='
96
+ - !ruby/object:Gem::Version
97
+ version: '0'
98
+ - !ruby/object:Gem::Dependency
99
+ name: resque
100
+ requirement: !ruby/object:Gem::Requirement
101
+ requirements:
102
+ - - '>='
103
+ - !ruby/object:Gem::Version
104
+ version: '0'
105
+ type: :development
106
+ prerelease: false
107
+ version_requirements: !ruby/object:Gem::Requirement
108
+ requirements:
109
+ - - '>='
110
+ - !ruby/object:Gem::Version
111
+ version: '0'
112
+ - !ruby/object:Gem::Dependency
113
+ name: webmock
114
+ requirement: !ruby/object:Gem::Requirement
115
+ requirements:
116
+ - - '>='
117
+ - !ruby/object:Gem::Version
118
+ version: '0'
119
+ type: :development
120
+ prerelease: false
121
+ version_requirements: !ruby/object:Gem::Requirement
122
+ requirements:
123
+ - - '>='
124
+ - !ruby/object:Gem::Version
125
+ version: '0'
126
+ description: Rails sidekick for Hubot
127
+ email:
128
+ - loganserman@gmail.com
129
+ - meatherly@gmail.com
130
+ executables: []
131
+ extensions: []
132
+ extra_rdoc_files: []
133
+ files:
134
+ - app/controllers/hubotgf/tasks_controller.rb
135
+ - config/routes.rb
136
+ - lib/hubotgf/config.rb
137
+ - lib/hubotgf/engine.rb
138
+ - lib/hubotgf/messenger.rb
139
+ - lib/hubotgf/version.rb
140
+ - lib/hubotgf/worker.rb
141
+ - lib/hubotgf.rb
142
+ - MIT-LICENSE
143
+ - Rakefile
144
+ homepage: https://github.com/lserman/hubotgf
145
+ licenses: []
146
+ metadata: {}
147
+ post_install_message:
148
+ rdoc_options: []
149
+ require_paths:
150
+ - lib
151
+ required_ruby_version: !ruby/object:Gem::Requirement
152
+ requirements:
153
+ - - '>='
154
+ - !ruby/object:Gem::Version
155
+ version: '0'
156
+ required_rubygems_version: !ruby/object:Gem::Requirement
157
+ requirements:
158
+ - - '>='
159
+ - !ruby/object:Gem::Version
160
+ version: '0'
161
+ requirements: []
162
+ rubyforge_project:
163
+ rubygems_version: 2.0.6
164
+ signing_key:
165
+ specification_version: 4
166
+ summary: Rails sidekick for Hubot
167
+ test_files: []
168
+ has_rdoc: