lolerrors 0.0.1 → 0.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: 7cb8c64368fb679d0e5366d72723455c0bbb3f95
4
- data.tar.gz: 22444801ad83003861ed7f5c27caa41fb6d23071
3
+ metadata.gz: c008556991ddb48139531e4967da7f40f5f5cf72
4
+ data.tar.gz: 526933f3ad49cfd9a867158711c3adba30c8db5b
5
5
  SHA512:
6
- metadata.gz: 8c590c9a47323f933aa02f265d8454e8263c41dc8b8e1f537184f91c378b9115f848a51ee3297bade26092d64c326cff09ff50cbd5b12043e580595a21674a37
7
- data.tar.gz: 24d72f4d490185ed317334fb39708bf38e87a52994955f2fd12abbc3afdd1d486aedbd65d5f886a5c6012bfb5ca25faccc22eea9ea67350bd98faf0fce872967
6
+ metadata.gz: 203b10f351f18c5c579c5e7ee3cd8f3fbf78d3deda550f147cc0f9891d187d0be3b6948b1895e0f9d7e5bd20504b162f55013538ef5a4df74f93de6904f2b905
7
+ data.tar.gz: c9a8c2d0bbce9d0be8764f360ad1d0b9a3ba8a462b1ec874697377a19a73086d3ad5b649f9355a4f78067f25839332dab6bd12dae92478f77eea304995dd90fa
@@ -2,38 +2,77 @@ module Lolerrors
2
2
  class Middleware
3
3
  def initialize(app)
4
4
  @app = app
5
+ set_executable_permission
5
6
  end
6
7
 
7
8
  def call(env)
8
9
  @app.call env
9
10
  rescue => ex
10
- snap ex
11
+ capture ex
11
12
  end
12
13
 
13
14
  private
14
15
 
15
- def snap(exception)
16
- message = exception.message[0..32].gsub(/\s\w+\s*$/, '..')
17
- command = Thread.new do
16
+ def videosnap_path
17
+ 'vendor/ext/videosnap'
18
+ end
19
+
20
+ def font_path
21
+ '/Library/Fonts/Impact.ttf'
22
+ end
23
+
24
+ def set_executable_permission
25
+ executables = %w(
26
+ vendor/ext/videosnap
27
+ )
28
+ system "bash -c \"chmod +x #{executables.join(' ')}\""
29
+ end
30
+
31
+ def capture(exception)
32
+ message = exception.message.truncate(32)
33
+ Thread.new do
18
34
  puts 'Taking animated gif'
19
- %x( mkdir -p ~/snaps )
20
- %x( rm -vf ~/snaps/snap.mov ~/snaps/snap.gif )
21
- %x( videosnap -t 3 -s 240 --no-audio ~/snaps/snap.mov )
22
- %x( ffmpeg -ss 0.7 -i ~/snaps/snap.mov -r 10 -pix_fmt rgb24 -f gif ~/snaps/snap.gif )
23
- %x( convert ~/snaps/snap.gif \
24
- -gravity South \
25
- -font /Library/Fonts/Impact.ttf \
26
- -fill white \
27
- -stroke black \
28
- -strokewidth 2 \
29
- -pointsize 24 \
30
- -annotate +0+10 "! #{message}" \
31
- ~/snaps/snap_#{Time.now.to_i}.gif )
32
- # %x( convert -fuzz 10% -layers Optimize ~/snaps/snap.gif ~/snaps/snap_#{Time.now.to_i}.gif )
33
- %x( rm -vf ~/snaps/snap.mov ~/snaps/snap.gif )
35
+ %x( mkdir -p ~/lolerrors )
36
+ %x( rm -vf ~/lolerrors/snapshot.mov ~/lolerrors/snapshot.gif )
37
+ create_movie_file
38
+ create_intermediate_gif_file
39
+ make_caption message
40
+ optimize_gif
41
+ rename_gif
42
+ %x( rm -vf ~/lolerrors/snapshot.mov )
34
43
  puts 'Took gif successfully'
35
44
  end
36
45
  raise exception
37
46
  end
47
+
48
+ def create_movie_file
49
+ %x( #{videosnap_path} -t 3.7 -s 240 --no-audio ~/lolerrors/snapshot.mov )
50
+ end
51
+
52
+ def create_intermediate_gif_file
53
+ %x( ffmpeg -ss 0.7 -i ~/lolerrors/snapshot.mov -r 10 -pix_fmt rgb24 -f gif ~/lolerrors/snapshot.gif )
54
+ end
55
+
56
+ def make_caption(message)
57
+ %x( convert ~/lolerrors/snapshot.gif \
58
+ -coalesce \
59
+ -gravity South \
60
+ -font #{font_path} \
61
+ -fill white \
62
+ -stroke black \
63
+ -strokewidth 2 \
64
+ -pointsize 24 \
65
+ -annotate +0+10 "! #{message}" \
66
+ ~/lolerrors/snapshot.gif )
67
+ end
68
+
69
+ def rename_gif
70
+ %x( mv ~/lolerrors/snapshot.gif ~/lolerrors/snapshot_#{Time.now.to_i}.gif )
71
+ end
72
+
73
+ def optimize_gif
74
+ %x( convert -layers Optimize ~/lolerrors/snapshot.gif ~/lolerrors/snapshot.gif )
75
+ end
76
+
38
77
  end
39
78
  end
data/lib/lolerrors.rb CHANGED
@@ -2,8 +2,6 @@ require 'lolerrors/middleware'
2
2
  require 'lolerrors/rails' if defined? Rails
3
3
 
4
4
  module Lolerrors
5
- def self.hello
6
- 'hello world'
7
- end
5
+
8
6
  end
9
7
 
Binary file
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lolerrors
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jeep Kiddee
@@ -10,8 +10,11 @@ bindir: bin
10
10
  cert_chain: []
11
11
  date: 2014-11-05 00:00:00.000000000 Z
12
12
  dependencies: []
13
- description: Will add later
14
- email: jeep@oozou.com
13
+ description: |2
14
+ lolerrors take a videosnap shot with your webcam
15
+ every time exception or error occurs. Then make animated GIF with the error message
16
+ email:
17
+ - nutthawut.ki@gmail.com
15
18
  executables: []
16
19
  extensions: []
17
20
  extra_rdoc_files: []
@@ -19,6 +22,7 @@ files:
19
22
  - lib/lolerrors.rb
20
23
  - lib/lolerrors/middleware.rb
21
24
  - lib/lolerrors/rails.rb
25
+ - vendor/ext/videosnap
22
26
  homepage: http://rubygems.org/gems/lolerrors
23
27
  licenses:
24
28
  - MIT
@@ -42,5 +46,5 @@ rubyforge_project:
42
46
  rubygems_version: 2.2.2
43
47
  signing_key:
44
48
  specification_version: 4
45
- summary: A gem that capturing your funny reaction to application errors
49
+ summary: Capture animation of your funny reaction to rails app errors
46
50
  test_files: []