lolerrors 0.1.1 → 0.1.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 +4 -4
- data/.gitignore +4 -0
- data/README.md +25 -0
- data/lib/lolerrors/adapters/adapter.rb +32 -0
- data/lib/lolerrors/adapters/linux_adapter.rb +40 -0
- data/lib/lolerrors/adapters/os.rb +19 -0
- data/lib/lolerrors/adapters/osx_adapter.rb +61 -0
- data/lib/lolerrors/middleware.rb +5 -71
- data/lib/lolerrors/version.rb +1 -1
- data/lib/lolerrors.rb +5 -0
- metadata +6 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 8726dba33a82af03f510fad6ef76db9c45850d58
|
|
4
|
+
data.tar.gz: 4db2f0bd2e8eb22401140f2c6eb5ac736795f8f9
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: eb27b013efdb3f5089aca24b8ac4b0c1f01516df85ea6f3d047ef8ed1f22014e6fd288067f3a86a225c9a2b43ffd74aebeb4cf673e82cc641971688eb010b56b
|
|
7
|
+
data.tar.gz: 826779e6741d24857f0fe30bb6e05579f2ccff3ab5f75720f7cc8d128a188bce119828afd1fd116298efad6c203f9a488b006c79038a3d68a756538b1dc90f72
|
data/.gitignore
CHANGED
data/README.md
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
lolerrors
|
|
2
|
+
=========
|
|
3
|
+
|
|
4
|
+
A ruby gem to record your facial expressions when app errors occur during development
|
|
5
|
+
|
|
6
|
+
Installation
|
|
7
|
+
------------
|
|
8
|
+
|
|
9
|
+
You’ll need `ImageMagick` and `FFmpeg` installed. If you use Homebrew, then it is as simple as:
|
|
10
|
+
|
|
11
|
+
```
|
|
12
|
+
brew install imagemagick
|
|
13
|
+
brew install ffmpeg
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
Install the gem by including it in the Gemfile in your app.
|
|
17
|
+
|
|
18
|
+
```
|
|
19
|
+
gem 'lolerrors', group: :development
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
Usage
|
|
23
|
+
-----
|
|
24
|
+
|
|
25
|
+
It will taking animated snapshots each time an app error occurs. Resulting animations will be output in `~/lolerrors`
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
module Lolerrors
|
|
2
|
+
class Adapter
|
|
3
|
+
def capture(message)
|
|
4
|
+
raise NotImplementedError("Must use concrete subclass for capture")
|
|
5
|
+
end
|
|
6
|
+
|
|
7
|
+
def set_executable_permission
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
def rename_gif
|
|
11
|
+
%x( mv #{gif_file_path} ~/lolerrors/snapshot_#{Time.now.to_i}.gif )
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
def video_file_path
|
|
15
|
+
"#{save_location}/snapshot.mov"
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
def gif_file_path
|
|
19
|
+
"#{save_location}/snapshot.gif"
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
def save_location
|
|
23
|
+
'~/lolerrors'
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
def self.get_adapter
|
|
27
|
+
return ::Lolerrors::OSXAdapter.new if OS.mac?
|
|
28
|
+
return ::Lolerrors::LinuxAdapter.new if OS.linux?
|
|
29
|
+
return ::Lolerrors::Adapter.new
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
end
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
module Lolerrors
|
|
2
|
+
class LinuxAdapter < Lolerrors::Adapter
|
|
3
|
+
def capture(message)
|
|
4
|
+
Thread.new do
|
|
5
|
+
puts 'Taking animated gif'
|
|
6
|
+
%x( mkdir -p #{save_location} )
|
|
7
|
+
%x( rm -vf #{video_file_path} #{gif_file_path} )
|
|
8
|
+
create_intermediate_gif_file
|
|
9
|
+
make_caption message
|
|
10
|
+
#optimize_gif
|
|
11
|
+
rename_gif
|
|
12
|
+
#{}%x( rm -vf #{video_file_path} )
|
|
13
|
+
puts 'Took gif successfully'
|
|
14
|
+
end
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
private
|
|
18
|
+
|
|
19
|
+
def create_intermediate_gif_file
|
|
20
|
+
%x( ffmpeg -f v4l2 \
|
|
21
|
+
-i /dev/video0 \
|
|
22
|
+
-s 320x240 \
|
|
23
|
+
-r 10 \
|
|
24
|
+
-ss 0.7 \
|
|
25
|
+
-to 3.7 \
|
|
26
|
+
#{gif_file_path} )
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
def make_caption(message)
|
|
30
|
+
%x( convert #{gif_file_path} \
|
|
31
|
+
-gravity South \
|
|
32
|
+
-fill white \
|
|
33
|
+
-stroke black \
|
|
34
|
+
-strokewidth 1 \
|
|
35
|
+
-pointsize 18 \
|
|
36
|
+
-annotate +0+10 "! #{message}" \
|
|
37
|
+
#{gif_file_path} )
|
|
38
|
+
end
|
|
39
|
+
end
|
|
40
|
+
end
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
module Lolerrors
|
|
2
|
+
module OS
|
|
3
|
+
def OS.windows?
|
|
4
|
+
(/cygwin|mswin|mingw|bccwin|wince|emx/ =~ RUBY_PLATFORM) != nil
|
|
5
|
+
end
|
|
6
|
+
|
|
7
|
+
def OS.mac?
|
|
8
|
+
(/darwin/ =~ RUBY_PLATFORM) != nil
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
def OS.unix?
|
|
12
|
+
!OS.windows?
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
def OS.linux?
|
|
16
|
+
OS.unix? and not OS.mac?
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
end
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
module Lolerrors
|
|
2
|
+
class OSXAdapter < Lolerrors::Adapter
|
|
3
|
+
def capture(message)
|
|
4
|
+
Thread.new do
|
|
5
|
+
puts 'Taking animated gif'
|
|
6
|
+
%x( mkdir -p #{save_location} )
|
|
7
|
+
%x( rm -vf #{video_file_path} #{gif_file_path} )
|
|
8
|
+
create_movie_file
|
|
9
|
+
create_intermediate_gif_file
|
|
10
|
+
make_caption message
|
|
11
|
+
optimize_gif
|
|
12
|
+
rename_gif
|
|
13
|
+
%x( rm -vf #{video_file_path} )
|
|
14
|
+
puts 'Took gif successfully'
|
|
15
|
+
end
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
def set_executable_permission
|
|
19
|
+
executables = %w(
|
|
20
|
+
vendor/ext/videosnap
|
|
21
|
+
)
|
|
22
|
+
system "bash -c \"chmod +x #{executables.join(' ')}\""
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
def create_movie_file
|
|
26
|
+
%x( #{videosnap_path} -t 3.7 -s 240 --no-audio #{video_file_path} )
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
def create_intermediate_gif_file
|
|
30
|
+
%x( ffmpeg -ss 0.7 -i #{video_file_path} -r 10 -f gif #{gif_file_path} )
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
def make_caption(message)
|
|
34
|
+
%x( convert #{gif_file_path} \
|
|
35
|
+
-coalesce \
|
|
36
|
+
-gravity South \
|
|
37
|
+
-font #{font_path} \
|
|
38
|
+
-fill white \
|
|
39
|
+
-stroke black \
|
|
40
|
+
-strokewidth 2 \
|
|
41
|
+
-pointsize 24 \
|
|
42
|
+
-annotate +0+10 "! #{message}" \
|
|
43
|
+
#{gif_file_path} )
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
def optimize_gif
|
|
48
|
+
%x( convert -layers Optimize #{gif_file_path} #{gif_file_path} )
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
private
|
|
52
|
+
|
|
53
|
+
def font_path
|
|
54
|
+
'/Library/Fonts/Impact.ttf'
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
def videosnap_path
|
|
58
|
+
File.join(Configuration::LOLERRORS_ROOT, 'vendor', 'ext', 'videosnap')
|
|
59
|
+
end
|
|
60
|
+
end
|
|
61
|
+
end
|
data/lib/lolerrors/middleware.rb
CHANGED
|
@@ -2,7 +2,10 @@ module Lolerrors
|
|
|
2
2
|
class Middleware
|
|
3
3
|
def initialize(app)
|
|
4
4
|
@app = app
|
|
5
|
-
|
|
5
|
+
|
|
6
|
+
@adapter = ::Lolerrors::Adapter.get_adapter
|
|
7
|
+
|
|
8
|
+
@adapter.set_executable_permission
|
|
6
9
|
end
|
|
7
10
|
|
|
8
11
|
def call(env)
|
|
@@ -12,78 +15,9 @@ module Lolerrors
|
|
|
12
15
|
end
|
|
13
16
|
|
|
14
17
|
private
|
|
15
|
-
|
|
16
|
-
def set_executable_permission
|
|
17
|
-
executables = %w(
|
|
18
|
-
vendor/ext/videosnap
|
|
19
|
-
)
|
|
20
|
-
system "bash -c \"chmod +x #{executables.join(' ')}\""
|
|
21
|
-
end
|
|
22
|
-
|
|
23
18
|
def capture(exception)
|
|
24
|
-
|
|
25
|
-
Thread.new do
|
|
26
|
-
puts 'Taking animated gif'
|
|
27
|
-
%x( mkdir -p #{save_location} )
|
|
28
|
-
%x( rm -vf #{video_file_path} #{gif_file_path} )
|
|
29
|
-
create_movie_file
|
|
30
|
-
create_intermediate_gif_file
|
|
31
|
-
make_caption message
|
|
32
|
-
optimize_gif
|
|
33
|
-
rename_gif
|
|
34
|
-
%x( rm -vf #{video_file_path} )
|
|
35
|
-
puts 'Took gif successfully'
|
|
36
|
-
end
|
|
19
|
+
@adapter.capture exception.message.truncate(32)
|
|
37
20
|
raise exception
|
|
38
21
|
end
|
|
39
|
-
|
|
40
|
-
def create_movie_file
|
|
41
|
-
%x( #{videosnap_path} -t 3.7 -s 240 --no-audio #{video_file_path} )
|
|
42
|
-
end
|
|
43
|
-
|
|
44
|
-
def create_intermediate_gif_file
|
|
45
|
-
%x( ffmpeg -ss 0.7 -i #{video_file_path} -r 10 -f gif #{gif_file_path} )
|
|
46
|
-
end
|
|
47
|
-
|
|
48
|
-
def make_caption(message)
|
|
49
|
-
%x( convert #{gif_file_path} \
|
|
50
|
-
-coalesce \
|
|
51
|
-
-gravity South \
|
|
52
|
-
-font #{font_path} \
|
|
53
|
-
-fill white \
|
|
54
|
-
-stroke black \
|
|
55
|
-
-strokewidth 2 \
|
|
56
|
-
-pointsize 24 \
|
|
57
|
-
-annotate +0+10 "! #{message}" \
|
|
58
|
-
#{gif_file_path} )
|
|
59
|
-
end
|
|
60
|
-
|
|
61
|
-
def rename_gif
|
|
62
|
-
%x( mv #{gif_file_path} ~/lolerrors/snapshot_#{Time.now.to_i}.gif )
|
|
63
|
-
end
|
|
64
|
-
|
|
65
|
-
def optimize_gif
|
|
66
|
-
%x( convert -layers Optimize #{gif_file_path} #{gif_file_path} )
|
|
67
|
-
end
|
|
68
|
-
|
|
69
|
-
def font_path
|
|
70
|
-
'/Library/Fonts/Impact.ttf'
|
|
71
|
-
end
|
|
72
|
-
|
|
73
|
-
def videosnap_path
|
|
74
|
-
File.join(Configuration::LOLERRORS_ROOT, 'vendor', 'ext', 'videosnap')
|
|
75
|
-
end
|
|
76
|
-
|
|
77
|
-
def video_file_path
|
|
78
|
-
"#{save_location}/snapshot.mov"
|
|
79
|
-
end
|
|
80
|
-
|
|
81
|
-
def gif_file_path
|
|
82
|
-
"#{save_location}/snapshot.gif"
|
|
83
|
-
end
|
|
84
|
-
|
|
85
|
-
def save_location
|
|
86
|
-
'~/lolerrors'
|
|
87
|
-
end
|
|
88
22
|
end
|
|
89
23
|
end
|
data/lib/lolerrors/version.rb
CHANGED
data/lib/lolerrors.rb
CHANGED
|
@@ -3,6 +3,11 @@ require 'lolerrors/middleware'
|
|
|
3
3
|
require 'lolerrors/rails' if defined? Rails
|
|
4
4
|
# require '../vendor/ext/videosnap'
|
|
5
5
|
|
|
6
|
+
require 'lolerrors/adapters/adapter'
|
|
7
|
+
require 'lolerrors/adapters/linux_adapter'
|
|
8
|
+
require 'lolerrors/adapters/osx_adapter'
|
|
9
|
+
require 'lolerrors/adapters/os'
|
|
10
|
+
|
|
6
11
|
module Lolerrors
|
|
7
12
|
|
|
8
13
|
end
|
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.1.
|
|
4
|
+
version: 0.1.2
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Jeep Kiddee
|
|
@@ -20,7 +20,12 @@ extensions: []
|
|
|
20
20
|
extra_rdoc_files: []
|
|
21
21
|
files:
|
|
22
22
|
- ".gitignore"
|
|
23
|
+
- README.md
|
|
23
24
|
- lib/lolerrors.rb
|
|
25
|
+
- lib/lolerrors/adapters/adapter.rb
|
|
26
|
+
- lib/lolerrors/adapters/linux_adapter.rb
|
|
27
|
+
- lib/lolerrors/adapters/os.rb
|
|
28
|
+
- lib/lolerrors/adapters/osx_adapter.rb
|
|
24
29
|
- lib/lolerrors/configuration.rb
|
|
25
30
|
- lib/lolerrors/middleware.rb
|
|
26
31
|
- lib/lolerrors/rails.rb
|