fbomb 3.2.0 → 4.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (5) hide show
  1. checksums.yaml +6 -14
  2. data/bin/fbomb +117 -167
  3. data/fbomb.gemspec +2 -2
  4. data/lib/fbomb.rb +14 -14
  5. metadata +35 -36
checksums.yaml CHANGED
@@ -1,15 +1,7 @@
1
1
  ---
2
- !binary "U0hBMQ==":
3
- metadata.gz: !binary |-
4
- ZDdhN2U3OGIxYmQ4ZjE5Y2M0MzUxY2RlYjUzOTQxYTMzM2FlMDI3OQ==
5
- data.tar.gz: !binary |-
6
- NDIwMDkzODk0MWUwMTJlYjFiNzk0YmE1ZGMzZmRmMDQ3MWI3MDczOQ==
7
- !binary "U0hBNTEy":
8
- metadata.gz: !binary |-
9
- YWE2YjY4N2FlZjg3ZGViYWNjY2Q3YmY0NmY4NjIwMDFiNGQwYWI3ZmEyN2Ew
10
- NzA5ZmY5Yjk1ZjE1ZWM3MDZhOWM5OWU5ZTA2ZjYwZTQ3OWFkMjQ4ZjEzOGIz
11
- NWNjN2RjZGQzZGEyNjgxNDMyM2U4MmYxMWYyZDkwMzYyNTFhNGE=
12
- data.tar.gz: !binary |-
13
- MzAxZDgyZjIyMzg2NDNlMWQwMjhmYmEzNjc4NGVjNWNmZWI0MjA4NTAxNDUx
14
- YzFkMzNmZWNmYzg5ZjM4YWI3YjJkMTg3OGY5NmM2MzI4MWZiN2Y5M2M5OGYx
15
- MDlhN2U3MTdiZTI3MjQxZDFmZDk5NmVhZGIyZDU3ODVlMTMxZDI=
2
+ SHA1:
3
+ metadata.gz: a9e4146c8c4534fc89e357da734af7be8aff1095
4
+ data.tar.gz: 501d1722d4edfa7a218b37fa8cf13574868ba86a
5
+ SHA512:
6
+ metadata.gz: 91f6d54b29756545ae4086f21dc480ade4516c2530430b75054775fce880641ee7dbe25d5f633062e1c96d9d8ccd196bc20f44fea31cb9aba534dc10ab75b295
7
+ data.tar.gz: 20e779789637cdccff56a067e6e680a6bdfd730ed9e85b104e548061ab62687d12b35034ff23fa467e179600c5a4bdf470f2229b0eff2da1cc91083d98a547d6
data/bin/fbomb CHANGED
@@ -28,13 +28,20 @@ Main {
28
28
  - builtin
29
29
  __
30
30
 
31
+ daemonizes!
31
32
 
32
33
  option('--force', '-f')
33
34
  option('--state=state', '-s')
34
35
 
36
+ ##
37
+ #
35
38
  def before_run
36
- if params[:state].given
37
- path = File.expand_path(params[:state].values.first)
39
+ $cmd = [Util.which_ruby, File.expand_path(__FILE__), *ARGV].join(' ')
40
+
41
+ state = (ENV['STATE'] || params[:state].values.first).to_s.strip
42
+
43
+ unless state.empty?
44
+ path = File.expand_path(state)
38
45
  dirname, basename = File.split(path)
39
46
 
40
47
  if dirname == '/'
@@ -47,12 +54,115 @@ Main {
47
54
  end
48
55
  end
49
56
 
50
- ##
51
- #
52
57
  def run
58
+ STDOUT.sync = true
59
+ STDERR.sync = true
60
+
53
61
  load_commands!
54
62
  load_flow!
55
- run_command! if argv.first =~ %r|^#{ Regexp.escape(FBomb.leader) }| unless argv.empty?
63
+ drop_fbombs!
64
+ end
65
+
66
+ def drop_fbombs!
67
+ #
68
+ at_exit{ @flow.leave }
69
+
70
+ # @flow.speak("fbomb (beta) in da house...")
71
+
72
+ trap('INT'){ exit }
73
+
74
+ =begin
75
+ {"event"=>"activity.user", "tags"=>[], "uuid"=>nil, "persist"=>false, "id"=>194342, "flow"=>"c6dbc029-2173-4fb6-a423-32293c373106", "content"=>{"last_activity"=>1399656686378}, "sent"=>1399657205286, "app"=>nil, "attachments"=>[], "user"=>"76002"}
76
+ =end
77
+
78
+ #
79
+ $inactive = true
80
+ $active_at = Time.now
81
+
82
+ @monitor =
83
+ Thread.new do
84
+ Thread.current.abort_on_exception = true
85
+
86
+ loop do
87
+ sleep(60)
88
+
89
+ if($inactive and ((Time.now - $active_at).abs > 300))
90
+ Kernel.exec($cmd)
91
+ end
92
+ end
93
+ end
94
+
95
+ #
96
+ loop do
97
+ logging_errors do
98
+ @flow.stream do |flow|
99
+ begin
100
+ $inactive = false
101
+ $active_at = Time.now
102
+
103
+ #
104
+ next unless %w[ message comment ].include?(flow[:event])
105
+
106
+ #
107
+ content = flow[:content]
108
+
109
+ case content
110
+ when Hash
111
+ content = content[:text].to_s
112
+ else
113
+ content = content.to_s
114
+ end
115
+
116
+ #
117
+ tokens = content.scan(%r/[^\s]+/)
118
+ arg, *args = tokens
119
+
120
+ #
121
+ FBomb::Command.table.each do |key, command|
122
+ if command.matches?(content)
123
+ user = @flow.user_for(flow[:user])
124
+ FBomb::Command.user = user
125
+ begin
126
+ logging_errors do
127
+ logger.info("#{ key } =~ #{ content }")
128
+ command.call(content)
129
+ end
130
+ ensure
131
+ FBomb::Command.user = nil
132
+ end
133
+ end
134
+ end
135
+
136
+ #
137
+ if arg =~ %r|^\s*#{ Regexp.escape(FBomb.leader) }|
138
+ key = arg.strip
139
+ command = FBomb::Command.table[key]
140
+
141
+ if command
142
+ user = @flow.user_for(flow[:user])
143
+ FBomb::Command.user = user
144
+ begin
145
+ logging_errors do
146
+ logger.info("#{ key } #{ args.join(' ') }")
147
+ command.call(*args)
148
+ end
149
+ ensure
150
+ FBomb::Command.user = nil
151
+ end
152
+ end
153
+ else
154
+ if @flow.yelling?
155
+ @flow.yell(content)
156
+ end
157
+ end
158
+ ensure
159
+ $inactive = true
160
+ end
161
+ end
162
+
163
+ sleep(rand(42))
164
+ end
165
+ end
56
166
  end
57
167
 
58
168
  def load_commands!
@@ -152,35 +262,6 @@ Main {
152
262
 
153
263
  ##
154
264
  #
155
- mode(:stop) do
156
- def run
157
- pid = IO.read(File.join(dotdir, 'pid')).to_i
158
- 10.times do
159
- begin
160
- Process.kill(-9, pid)
161
- rescue
162
- nil
163
- end
164
- end
165
- end
166
- end
167
-
168
- mode(:pid) do
169
- def run
170
- pid = IO.read(File.join(dotdir, 'pid')).to_i
171
- puts pid
172
- rescue
173
- nil
174
- end
175
- end
176
-
177
- mode(:log) do
178
- def run
179
- log = IO.read(File.join(dotdir, 'log'))
180
- exec "tail -F #{ log.inspect }"
181
- end
182
- end
183
-
184
265
  mode(:speak) do
185
266
  option('--tag=tag', '-t')
186
267
 
@@ -197,142 +278,11 @@ Main {
197
278
  end
198
279
  end
199
280
 
200
- mode(:run) do
201
- option('--daemon', '-d')
202
-
281
+ mode(:execute) do
203
282
  def run
204
- $cmd = [Util.which_ruby, File.expand_path(__FILE__), *ARGV].join(' ')
205
-
206
- if params['daemon'].given?
207
- Dir.chdir(dotdir)
208
-
209
- lock = File.join(dotdir, 'lock')
210
- FileUtils.touch(lock)
211
- open(lock, 'a+') do |fd|
212
- fd.flock(File::LOCK_EX|File::LOCK_NB) or exit!(42)
213
- end
214
-
215
- exit! if fork
216
- exit! if fork
217
-
218
- open(File.join(dotdir, 'pid'), 'w'){|fd| fd.write($$)}
219
-
220
- log = File.join(dotdir, 'log')
221
- FileUtils.touch(log)
222
-
223
- open(log, 'a+') do |fd|
224
- fd.puts "process #{ $$ } started..."
225
- STDOUT.reopen(fd)
226
- STDERR.reopen(fd)
227
- end
228
- end
229
-
230
283
  load_commands!
231
284
  load_flow!
232
- drop_fbombs!
233
- end
234
-
235
- def drop_fbombs!
236
- #
237
- at_exit{ @flow.leave }
238
-
239
- # @flow.speak("fbomb (beta) in da house...")
240
-
241
- trap('INT'){ exit }
242
-
243
- =begin
244
- {"event"=>"activity.user", "tags"=>[], "uuid"=>nil, "persist"=>false, "id"=>194342, "flow"=>"c6dbc029-2173-4fb6-a423-32293c373106", "content"=>{"last_activity"=>1399656686378}, "sent"=>1399657205286, "app"=>nil, "attachments"=>[], "user"=>"76002"}
245
- =end
246
-
247
- #
248
- $inactive = true
249
- $active_at = Time.now
250
-
251
- @monitor =
252
- Thread.new do
253
- Thread.current.abort_on_exception = true
254
-
255
- loop do
256
- sleep(60)
257
-
258
- if($inactive and ((Time.now - $active_at).abs > 300))
259
- p '$cmd' => $cmd
260
- Kernel.exec($cmd)
261
- end
262
- end
263
- end
264
-
265
- #
266
- loop do
267
- logging_errors do
268
- @flow.stream do |flow|
269
- begin
270
- $inactive = false
271
- $active_at = Time.now
272
-
273
- #
274
- next unless %w[ message comment ].include?(flow[:event])
275
-
276
- #
277
- content = flow[:content]
278
-
279
- case content
280
- when Hash
281
- content = content[:text].to_s
282
- else
283
- content = content.to_s
284
- end
285
-
286
- #
287
- tokens = content.scan(%r/[^\s]+/)
288
- arg, *args = tokens
289
-
290
- #
291
- FBomb::Command.table.each do |key, command|
292
- if command.matches?(content)
293
- user = @flow.user_for(flow[:user])
294
- FBomb::Command.user = user
295
- begin
296
- logging_errors do
297
- logger.info("#{ key } =~ #{ content }")
298
- command.call(content)
299
- end
300
- ensure
301
- FBomb::Command.user = nil
302
- end
303
- end
304
- end
305
-
306
- #
307
- if arg =~ %r|^\s*#{ Regexp.escape(FBomb.leader) }|
308
- key = arg.strip
309
- command = FBomb::Command.table[key]
310
-
311
- if command
312
- user = @flow.user_for(flow[:user])
313
- FBomb::Command.user = user
314
- begin
315
- logging_errors do
316
- logger.info("#{ key } #{ args.join(' ') }")
317
- command.call(*args)
318
- end
319
- ensure
320
- FBomb::Command.user = nil
321
- end
322
- end
323
- else
324
- if @flow.yelling?
325
- @flow.yell(content)
326
- end
327
- end
328
- ensure
329
- $inactive = true
330
- end
331
- end
332
-
333
- sleep(rand(42))
334
- end
335
- end
285
+ run_command! if argv.first =~ %r|^#{ Regexp.escape(FBomb.leader) }| unless argv.empty?
336
286
  end
337
287
  end
338
288
 
@@ -3,7 +3,7 @@
3
3
 
4
4
  Gem::Specification::new do |spec|
5
5
  spec.name = "fbomb"
6
- spec.version = "3.2.0"
6
+ spec.version = "4.0.0"
7
7
  spec.platform = Gem::Platform::RUBY
8
8
  spec.summary = "fbomb"
9
9
  spec.description = "description: fbomb kicks the ass"
@@ -96,7 +96,7 @@ Gem::Specification::new do |spec|
96
96
 
97
97
  spec.add_dependency(*["fukung", ">= 1.1.0"])
98
98
 
99
- spec.add_dependency(*["main", ">= 4.7.6"])
99
+ spec.add_dependency(*["main", ">= 6.1.0"])
100
100
 
101
101
  spec.add_dependency(*["nokogiri", ">= 1.5.0"])
102
102
 
@@ -13,7 +13,7 @@
13
13
  # libs
14
14
  #
15
15
  module FBomb
16
- Version = '3.2.0' unless defined?(Version)
16
+ Version = '4.0.0' unless defined?(Version)
17
17
 
18
18
  def version
19
19
  FBomb::Version
@@ -21,19 +21,19 @@
21
21
 
22
22
  def dependencies
23
23
  {
24
- 'flowdock' => [ 'flowdock' , '>= 0.4.0' ] ,
25
- 'eventmachine' => [ 'eventmachine' , '>= 1.0.3' ] ,
26
- 'em-http' => [ 'em-http-request' , '>= 1.1.2' ] ,
27
- 'json' => [ 'json' , '>= 1.8.1' ] ,
28
- 'coerce' => [ 'coerce' , '>= 0.0.6' ] ,
29
- 'fukung' => [ 'fukung' , '>= 1.1.0' ] ,
30
- 'main' => [ 'main' , '>= 4.7.6' ] ,
31
- 'nokogiri' => [ 'nokogiri' , '>= 1.5.0' ] ,
32
- 'google-search' => [ 'google-search' , '>= 1.0.2' ] ,
33
- 'unidecode' => [ 'unidecode' , '>= 1.0.0' ] ,
34
- 'systemu' => [ 'systemu' , '>= 2.3.0' ] ,
35
- 'pry' => [ 'pry' , '>= 0.9.6.2' ] ,
36
- 'mechanize' => [ 'mechanize' , '>= 2.7.3' ] ,
24
+ 'flowdock' => [ 'flowdock' , '>= 0.4.0' ] ,
25
+ 'eventmachine' => [ 'eventmachine' , '>= 1.0.3' ] ,
26
+ 'em-http' => [ 'em-http-request' , '>= 1.1.2' ] ,
27
+ 'json' => [ 'json' , '>= 1.8.1' ] ,
28
+ 'coerce' => [ 'coerce' , '>= 0.0.6' ] ,
29
+ 'fukung' => [ 'fukung' , '>= 1.1.0' ] ,
30
+ 'main' => [ 'main' , '>= 6.1.0' ] ,
31
+ 'nokogiri' => [ 'nokogiri' , '>= 1.5.0' ] ,
32
+ 'google-search' => [ 'google-search' , '>= 1.0.2' ] ,
33
+ 'unidecode' => [ 'unidecode' , '>= 1.0.0' ] ,
34
+ 'systemu' => [ 'systemu' , '>= 2.3.0' ] ,
35
+ 'pry' => [ 'pry' , '>= 0.9.6.2' ] ,
36
+ 'mechanize' => [ 'mechanize' , '>= 2.7.3' ] ,
37
37
  'mime/types' => [ 'mime-types' , '>= 1.16' ]
38
38
  }
39
39
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fbomb
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.2.0
4
+ version: 4.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ara T. Howard
@@ -14,199 +14,199 @@ dependencies:
14
14
  name: flowdock
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - ! '>='
17
+ - - ">="
18
18
  - !ruby/object:Gem::Version
19
19
  version: 0.4.0
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - ! '>='
24
+ - - ">="
25
25
  - !ruby/object:Gem::Version
26
26
  version: 0.4.0
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: eventmachine
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - ! '>='
31
+ - - ">="
32
32
  - !ruby/object:Gem::Version
33
33
  version: 1.0.3
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - ! '>='
38
+ - - ">="
39
39
  - !ruby/object:Gem::Version
40
40
  version: 1.0.3
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: em-http-request
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - ! '>='
45
+ - - ">="
46
46
  - !ruby/object:Gem::Version
47
47
  version: 1.1.2
48
48
  type: :runtime
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - ! '>='
52
+ - - ">="
53
53
  - !ruby/object:Gem::Version
54
54
  version: 1.1.2
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: json
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
- - - ! '>='
59
+ - - ">="
60
60
  - !ruby/object:Gem::Version
61
61
  version: 1.8.1
62
62
  type: :runtime
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
- - - ! '>='
66
+ - - ">="
67
67
  - !ruby/object:Gem::Version
68
68
  version: 1.8.1
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: coerce
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
- - - ! '>='
73
+ - - ">="
74
74
  - !ruby/object:Gem::Version
75
75
  version: 0.0.6
76
76
  type: :runtime
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
- - - ! '>='
80
+ - - ">="
81
81
  - !ruby/object:Gem::Version
82
82
  version: 0.0.6
83
83
  - !ruby/object:Gem::Dependency
84
84
  name: fukung
85
85
  requirement: !ruby/object:Gem::Requirement
86
86
  requirements:
87
- - - ! '>='
87
+ - - ">="
88
88
  - !ruby/object:Gem::Version
89
89
  version: 1.1.0
90
90
  type: :runtime
91
91
  prerelease: false
92
92
  version_requirements: !ruby/object:Gem::Requirement
93
93
  requirements:
94
- - - ! '>='
94
+ - - ">="
95
95
  - !ruby/object:Gem::Version
96
96
  version: 1.1.0
97
97
  - !ruby/object:Gem::Dependency
98
98
  name: main
99
99
  requirement: !ruby/object:Gem::Requirement
100
100
  requirements:
101
- - - ! '>='
101
+ - - ">="
102
102
  - !ruby/object:Gem::Version
103
- version: 4.7.6
103
+ version: 6.1.0
104
104
  type: :runtime
105
105
  prerelease: false
106
106
  version_requirements: !ruby/object:Gem::Requirement
107
107
  requirements:
108
- - - ! '>='
108
+ - - ">="
109
109
  - !ruby/object:Gem::Version
110
- version: 4.7.6
110
+ version: 6.1.0
111
111
  - !ruby/object:Gem::Dependency
112
112
  name: nokogiri
113
113
  requirement: !ruby/object:Gem::Requirement
114
114
  requirements:
115
- - - ! '>='
115
+ - - ">="
116
116
  - !ruby/object:Gem::Version
117
117
  version: 1.5.0
118
118
  type: :runtime
119
119
  prerelease: false
120
120
  version_requirements: !ruby/object:Gem::Requirement
121
121
  requirements:
122
- - - ! '>='
122
+ - - ">="
123
123
  - !ruby/object:Gem::Version
124
124
  version: 1.5.0
125
125
  - !ruby/object:Gem::Dependency
126
126
  name: google-search
127
127
  requirement: !ruby/object:Gem::Requirement
128
128
  requirements:
129
- - - ! '>='
129
+ - - ">="
130
130
  - !ruby/object:Gem::Version
131
131
  version: 1.0.2
132
132
  type: :runtime
133
133
  prerelease: false
134
134
  version_requirements: !ruby/object:Gem::Requirement
135
135
  requirements:
136
- - - ! '>='
136
+ - - ">="
137
137
  - !ruby/object:Gem::Version
138
138
  version: 1.0.2
139
139
  - !ruby/object:Gem::Dependency
140
140
  name: unidecode
141
141
  requirement: !ruby/object:Gem::Requirement
142
142
  requirements:
143
- - - ! '>='
143
+ - - ">="
144
144
  - !ruby/object:Gem::Version
145
145
  version: 1.0.0
146
146
  type: :runtime
147
147
  prerelease: false
148
148
  version_requirements: !ruby/object:Gem::Requirement
149
149
  requirements:
150
- - - ! '>='
150
+ - - ">="
151
151
  - !ruby/object:Gem::Version
152
152
  version: 1.0.0
153
153
  - !ruby/object:Gem::Dependency
154
154
  name: systemu
155
155
  requirement: !ruby/object:Gem::Requirement
156
156
  requirements:
157
- - - ! '>='
157
+ - - ">="
158
158
  - !ruby/object:Gem::Version
159
159
  version: 2.3.0
160
160
  type: :runtime
161
161
  prerelease: false
162
162
  version_requirements: !ruby/object:Gem::Requirement
163
163
  requirements:
164
- - - ! '>='
164
+ - - ">="
165
165
  - !ruby/object:Gem::Version
166
166
  version: 2.3.0
167
167
  - !ruby/object:Gem::Dependency
168
168
  name: pry
169
169
  requirement: !ruby/object:Gem::Requirement
170
170
  requirements:
171
- - - ! '>='
171
+ - - ">="
172
172
  - !ruby/object:Gem::Version
173
173
  version: 0.9.6.2
174
174
  type: :runtime
175
175
  prerelease: false
176
176
  version_requirements: !ruby/object:Gem::Requirement
177
177
  requirements:
178
- - - ! '>='
178
+ - - ">="
179
179
  - !ruby/object:Gem::Version
180
180
  version: 0.9.6.2
181
181
  - !ruby/object:Gem::Dependency
182
182
  name: mechanize
183
183
  requirement: !ruby/object:Gem::Requirement
184
184
  requirements:
185
- - - ! '>='
185
+ - - ">="
186
186
  - !ruby/object:Gem::Version
187
187
  version: 2.7.3
188
188
  type: :runtime
189
189
  prerelease: false
190
190
  version_requirements: !ruby/object:Gem::Requirement
191
191
  requirements:
192
- - - ! '>='
192
+ - - ">="
193
193
  - !ruby/object:Gem::Version
194
194
  version: 2.7.3
195
195
  - !ruby/object:Gem::Dependency
196
196
  name: mime-types
197
197
  requirement: !ruby/object:Gem::Requirement
198
198
  requirements:
199
- - - ! '>='
199
+ - - ">="
200
200
  - !ruby/object:Gem::Version
201
201
  version: '1.16'
202
202
  type: :runtime
203
203
  prerelease: false
204
204
  version_requirements: !ruby/object:Gem::Requirement
205
205
  requirements:
206
- - - ! '>='
206
+ - - ">="
207
207
  - !ruby/object:Gem::Version
208
208
  version: '1.16'
209
- description: ! 'description: fbomb kicks the ass'
209
+ description: 'description: fbomb kicks the ass'
210
210
  email: ara.t.howard@gmail.com
211
211
  executables:
212
212
  - fbomb
@@ -281,19 +281,18 @@ require_paths:
281
281
  - lib
282
282
  required_ruby_version: !ruby/object:Gem::Requirement
283
283
  requirements:
284
- - - ! '>='
284
+ - - ">="
285
285
  - !ruby/object:Gem::Version
286
286
  version: '0'
287
287
  required_rubygems_version: !ruby/object:Gem::Requirement
288
288
  requirements:
289
- - - ! '>='
289
+ - - ">="
290
290
  - !ruby/object:Gem::Version
291
291
  version: '0'
292
292
  requirements: []
293
293
  rubyforge_project: codeforpeople
294
- rubygems_version: 2.0.3
294
+ rubygems_version: 2.4.5.1
295
295
  signing_key:
296
296
  specification_version: 4
297
297
  summary: fbomb
298
298
  test_files: []
299
- has_rdoc: