flashman 0.1.5
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 +7 -0
- data/.gitignore +9 -0
- data/.rspec +2 -0
- data/.travis.yml +4 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +21 -0
- data/README.md +54 -0
- data/Rakefile +6 -0
- data/bin/console +15 -0
- data/bin/setup +6 -0
- data/exe/flashman +21 -0
- data/exe/flashstop +25 -0
- data/flashman.gemspec +34 -0
- data/lib/flashman.rb +133 -0
- data/lib/flashman/version.rb +3 -0
- metadata +116 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: b94d9d651e8f28e1e4cd1862feeb4f137212eb65
|
4
|
+
data.tar.gz: e13be36a1a331b9c354c0cbadd2be230541df8c3
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 27cdaa2c80d0852a0e3c06549b8be416beac6d79b154fed22e997f0adbfb5bee1a77936dff43c7a728f3fd2e62113782d5540c271ffb13a9517d3566c821df90
|
7
|
+
data.tar.gz: 315ecfa2e34712fa083631128af054a63d156f22beb8a4836474d3f2bc03dc7cad0e6faa6a48ff220bd1b16ec9820e16e55769836ca769f795d4e9369680e4b9
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2015 Shinichi Tokunaga
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,54 @@
|
|
1
|
+
# Flashman
|
2
|
+
|
3
|
+
This is a gem for recording your terminal activity on a gif file.
|
4
|
+
You can also record any other window of your application.
|
5
|
+
**The gem works only for MacOS X!**
|
6
|
+
|
7
|
+

|
8
|
+
|
9
|
+
## Installation
|
10
|
+
|
11
|
+
You need to install [gifsicle](https://www.lcdf.org/gifsicle/ "gifsicle") at first.
|
12
|
+
|
13
|
+
$ brew install gifsicle
|
14
|
+
|
15
|
+
Then, please install flashman from rubygems.
|
16
|
+
|
17
|
+
$ gem install flashman
|
18
|
+
|
19
|
+
## Usage
|
20
|
+
|
21
|
+
Start to record your Terminal.
|
22
|
+
|
23
|
+
$ flashman
|
24
|
+
|
25
|
+
Stop the recording. It could take a while.
|
26
|
+
|
27
|
+
$ flashstop
|
28
|
+
|
29
|
+
The output file 'out.gif' is placed at the directory where flashman was executed.
|
30
|
+
|
31
|
+
$ open out.gif
|
32
|
+
|
33
|
+
## Options
|
34
|
+
|
35
|
+
Specify other terminal or application with -w.
|
36
|
+
|
37
|
+
$ flashman -w iTerm
|
38
|
+
|
39
|
+
flashman records the window every second by default. You can change the interval with -i.
|
40
|
+
|
41
|
+
$ flashman -i 0.5
|
42
|
+
|
43
|
+
You can change the playback speed of the output file with -s. 2 means the speed will be doubled.
|
44
|
+
|
45
|
+
$ flashman -s 2
|
46
|
+
|
47
|
+
See the detailed description with -h.
|
48
|
+
|
49
|
+
$ flashman -h
|
50
|
+
|
51
|
+
## Contributing
|
52
|
+
|
53
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/deepneko/flashman.
|
54
|
+
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "flashman"
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
# require "pry"
|
11
|
+
# Pry.start
|
12
|
+
|
13
|
+
require "irb"
|
14
|
+
IRB.start
|
15
|
+
|
data/bin/setup
ADDED
data/exe/flashman
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'flashman'
|
4
|
+
require 'slop'
|
5
|
+
|
6
|
+
opts = Slop.parse do |o|
|
7
|
+
o.string '-w', '--window', default: 'Terminal'
|
8
|
+
o.float '-i', '--interval', default: 1
|
9
|
+
o.string '-o', '--output', default: 'out.gif'
|
10
|
+
o.integer '-s', '--speed', default: 1
|
11
|
+
o.integer '-t', '--times', default: 0
|
12
|
+
o.bool '-h', '--help', ''
|
13
|
+
end
|
14
|
+
|
15
|
+
if opts[:h]
|
16
|
+
Flashman.usage
|
17
|
+
exit 0
|
18
|
+
end
|
19
|
+
|
20
|
+
flashman = Flashman.init(opts[:window], opts[:output], opts[:interval], opts[:speed], opts[:times])
|
21
|
+
flashman.run
|
data/exe/flashstop
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
pid_file = File.join(Dir.home, '.flashman/flashman.pid')
|
4
|
+
unless File.exist?(pid_file)
|
5
|
+
puts "flashman isn't running."
|
6
|
+
exit 1
|
7
|
+
end
|
8
|
+
pid = File.open(pid_file).first.to_i
|
9
|
+
|
10
|
+
stop_pid = File.join(Dir.home, '.flashman/flashstop.pid')
|
11
|
+
open(stop_pid, 'w') {|f| f << Process.pid}
|
12
|
+
|
13
|
+
finish_trap = false
|
14
|
+
Signal.trap(:TERM) {finish_trap = true}
|
15
|
+
|
16
|
+
Process.kill("TERM", pid)
|
17
|
+
|
18
|
+
puts "Waiting for flashman to be done..."
|
19
|
+
loop do
|
20
|
+
break if finish_trap
|
21
|
+
sleep 1
|
22
|
+
end
|
23
|
+
|
24
|
+
File.unlink stop_pid
|
25
|
+
puts "Done."
|
data/flashman.gemspec
ADDED
@@ -0,0 +1,34 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'flashman/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "flashman"
|
8
|
+
spec.version = Flashman::VERSION
|
9
|
+
spec.authors = ["deepneko"]
|
10
|
+
spec.email = ["deep.inu@gmail.com"]
|
11
|
+
|
12
|
+
spec.summary = %q{Record your live console/terminal log in a gif file.}
|
13
|
+
spec.homepage = "https://github.com/deepneko/flashman"
|
14
|
+
spec.license = "MIT"
|
15
|
+
spec.required_ruby_version = ">=1.9"
|
16
|
+
|
17
|
+
# Prevent pushing this gem to RubyGems.org by setting 'allowed_push_host', or
|
18
|
+
# delete this section to allow pushing this gem to any host.
|
19
|
+
#if spec.respond_to?(:metadata)
|
20
|
+
# spec.metadata['allowed_push_host'] = "TODO: Set to 'http://mygemserver.com'"
|
21
|
+
#else
|
22
|
+
# raise "RubyGems 2.0 or newer is required to protect against public gem pushes."
|
23
|
+
#end
|
24
|
+
|
25
|
+
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
26
|
+
spec.bindir = "exe"
|
27
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
28
|
+
spec.require_paths = ["lib"]
|
29
|
+
|
30
|
+
spec.add_development_dependency "bundler", "~> 1.10"
|
31
|
+
spec.add_development_dependency "rake", ">= 0"
|
32
|
+
spec.add_runtime_dependency "sys-proctable", ">= 0.9.9"
|
33
|
+
spec.add_runtime_dependency "slop", ">= 4.2.0"
|
34
|
+
end
|
data/lib/flashman.rb
ADDED
@@ -0,0 +1,133 @@
|
|
1
|
+
require "flashman/version"
|
2
|
+
require "sys/proctable"
|
3
|
+
include Sys
|
4
|
+
|
5
|
+
module Flashman
|
6
|
+
def self.init(window, output, interval, speed, times)
|
7
|
+
Flashman.new(window, output, interval, speed, times)
|
8
|
+
end
|
9
|
+
|
10
|
+
def self.usage
|
11
|
+
puts "flashman [-w appname] [-o output-file] [-i interval] [-s speed]"
|
12
|
+
puts
|
13
|
+
puts "Options are as follows:"
|
14
|
+
puts " -w Specify an application name which you want to record. The default is 'Terminal'."
|
15
|
+
puts " -o Specify the output file. The default is to put 'out.gif' in the directory where flashman was executed."
|
16
|
+
puts " -i Specify the interval in seconds. The screen of the application is recorded every 'interval' seconds."
|
17
|
+
puts " -s Specify the number of the speed. If you specify '2', the playback speed will be doubled."
|
18
|
+
puts " -t Specify how many times the output gif loops. The default is '0' which means infinite."
|
19
|
+
end
|
20
|
+
|
21
|
+
class Flashman
|
22
|
+
def initialize(window, output, interval, speed, times)
|
23
|
+
@work_dir = File.join(Dir.home, '.flashman')
|
24
|
+
begin
|
25
|
+
Dir.mkdir(@work_dir, 0755)
|
26
|
+
rescue Errno::EEXIST
|
27
|
+
# Do nothing
|
28
|
+
end
|
29
|
+
@pid_file = "#{@work_dir}/flashman.pid"
|
30
|
+
@stop_pid = "#{@work_dir}/flashstop.pid"
|
31
|
+
|
32
|
+
check_macosx
|
33
|
+
check_multirun
|
34
|
+
optcheck(output, interval, speed, times)
|
35
|
+
|
36
|
+
@windowid = `osascript -e 'tell app \"#{window}\" to id of window 1' 2>/dev/null`.strip
|
37
|
+
unless @windowid =~ /^\d+$/
|
38
|
+
puts "#{window} isn't the actual application name running on your mac."
|
39
|
+
exit 1
|
40
|
+
end
|
41
|
+
|
42
|
+
@output = output
|
43
|
+
@interval = interval
|
44
|
+
@delay = (100 * @interval / speed).to_i
|
45
|
+
@times = times.to_i
|
46
|
+
@finish_trap = false
|
47
|
+
end
|
48
|
+
|
49
|
+
def run
|
50
|
+
begin
|
51
|
+
Process.daemon(true, true)
|
52
|
+
set_trap
|
53
|
+
open(@pid_file, 'w') {|f| f << Process.pid}
|
54
|
+
|
55
|
+
i = 0
|
56
|
+
loop do
|
57
|
+
break if @finish_trap
|
58
|
+
file = "#{@work_dir}/#{i.to_s.rjust(6, "0")}"
|
59
|
+
`screencapture -t gif -o -l #{@windowid} #{file}.gif 2>&1 >/dev/null`
|
60
|
+
sleep(@interval)
|
61
|
+
i += 1
|
62
|
+
end
|
63
|
+
rescue => e
|
64
|
+
STDERR.puts "[ERROR][#{self.class.name}.run] #{e}"
|
65
|
+
exit 1
|
66
|
+
end
|
67
|
+
|
68
|
+
`gifsicle -O2 --delay=#{@delay} --loopcount=#{@times} #{@work_dir}/*.gif > #{@output} 2>/dev/null`
|
69
|
+
File.unlink *Dir.glob("#{@work_dir}/*.png")
|
70
|
+
File.unlink *Dir.glob("#{@work_dir}/*.gif")
|
71
|
+
File.unlink @pid_file
|
72
|
+
|
73
|
+
if File.exist?(@stop_pid)
|
74
|
+
pid = File.open(@stop_pid).first.to_i
|
75
|
+
Process.kill("TERM", pid)
|
76
|
+
end
|
77
|
+
end
|
78
|
+
|
79
|
+
def usage
|
80
|
+
puts "flashman [-w appname] [-o output-file] [-i interval] [-s speed] [-t loop-times]"
|
81
|
+
end
|
82
|
+
|
83
|
+
def set_trap
|
84
|
+
Signal.trap(:TERM) {@finish_trap = true}
|
85
|
+
end
|
86
|
+
|
87
|
+
def check_macosx
|
88
|
+
os = `uname`
|
89
|
+
unless os =~ /^Darwin/
|
90
|
+
puts "flashman is only for MacOSX."
|
91
|
+
exit 1
|
92
|
+
end
|
93
|
+
end
|
94
|
+
|
95
|
+
# TODO: There must be any good way to check multirunning.
|
96
|
+
def check_multirun
|
97
|
+
if File.exist?(@pid_file)
|
98
|
+
pid = File.open(@pid_file).first.to_i
|
99
|
+
ps = ProcTable.ps(pid)
|
100
|
+
if ps.cmdline =~ /flashman\s+/
|
101
|
+
puts "flashman has already been running."
|
102
|
+
exit 1
|
103
|
+
end
|
104
|
+
end
|
105
|
+
end
|
106
|
+
|
107
|
+
def optcheck(output, interval, speed, times)
|
108
|
+
unless output
|
109
|
+
usage
|
110
|
+
exit 1
|
111
|
+
end
|
112
|
+
|
113
|
+
if interval < 0.1 or interval > 10
|
114
|
+
usage
|
115
|
+
puts "-i option has to be the range between 0.1 and 10."
|
116
|
+
exit 1
|
117
|
+
end
|
118
|
+
|
119
|
+
if speed < 1 or speed > 10
|
120
|
+
usage
|
121
|
+
puts "-s option has to be the range between 1 and 10."
|
122
|
+
exit 1
|
123
|
+
end
|
124
|
+
|
125
|
+
if times < 0
|
126
|
+
usage
|
127
|
+
puts "-t option has to be 0 or more."
|
128
|
+
exit 1
|
129
|
+
end
|
130
|
+
end
|
131
|
+
end
|
132
|
+
end
|
133
|
+
|
metadata
ADDED
@@ -0,0 +1,116 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: flashman
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.5
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- deepneko
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2015-11-20 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.10'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.10'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: sys-proctable
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: 0.9.9
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: 0.9.9
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: slop
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: 4.2.0
|
62
|
+
type: :runtime
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: 4.2.0
|
69
|
+
description:
|
70
|
+
email:
|
71
|
+
- deep.inu@gmail.com
|
72
|
+
executables:
|
73
|
+
- flashman
|
74
|
+
- flashstop
|
75
|
+
extensions: []
|
76
|
+
extra_rdoc_files: []
|
77
|
+
files:
|
78
|
+
- ".gitignore"
|
79
|
+
- ".rspec"
|
80
|
+
- ".travis.yml"
|
81
|
+
- Gemfile
|
82
|
+
- LICENSE.txt
|
83
|
+
- README.md
|
84
|
+
- Rakefile
|
85
|
+
- bin/console
|
86
|
+
- bin/setup
|
87
|
+
- exe/flashman
|
88
|
+
- exe/flashstop
|
89
|
+
- flashman.gemspec
|
90
|
+
- lib/flashman.rb
|
91
|
+
- lib/flashman/version.rb
|
92
|
+
homepage: https://github.com/deepneko/flashman
|
93
|
+
licenses:
|
94
|
+
- MIT
|
95
|
+
metadata: {}
|
96
|
+
post_install_message:
|
97
|
+
rdoc_options: []
|
98
|
+
require_paths:
|
99
|
+
- lib
|
100
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
101
|
+
requirements:
|
102
|
+
- - ">="
|
103
|
+
- !ruby/object:Gem::Version
|
104
|
+
version: '1.9'
|
105
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
106
|
+
requirements:
|
107
|
+
- - ">="
|
108
|
+
- !ruby/object:Gem::Version
|
109
|
+
version: '0'
|
110
|
+
requirements: []
|
111
|
+
rubyforge_project:
|
112
|
+
rubygems_version: 2.4.8
|
113
|
+
signing_key:
|
114
|
+
specification_version: 4
|
115
|
+
summary: Record your live console/terminal log in a gif file.
|
116
|
+
test_files: []
|