spielbash 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 2dda7f053211da0e400d7d97ae8c5b525c86ac39
4
+ data.tar.gz: 949124904f77ce130434565a98274a918c2af07f
5
+ SHA512:
6
+ metadata.gz: e0f9f2d705c2f6fbe9bae098802ecf094104310b9d85a06d920f6c4ade2cda9450caa1429c3ef53f10631e7ab6bd0b88ff857965ae2e311b0bb76d855d29e172
7
+ data.tar.gz: 994acbeabd2adbd3bfcd5d586ba45af64fe8f424966584bf1eff6a0a29aa7329b2128aedaa2a9e47a8fe1532df72184c2b9a8e64a81fa861971944f975da89c3
data/.gitignore ADDED
@@ -0,0 +1,12 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /.idea/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
10
+
11
+ # rspec failure tracking
12
+ .rspec_status
data/.rspec ADDED
@@ -0,0 +1,5 @@
1
+ --format documentation
2
+ --color
3
+ --require spec_helper
4
+ --format RspecJunitFormatter --out spec/reports/rspec.xml
5
+ --format html --out spec/reports/rspec.html
data/.simplecov ADDED
@@ -0,0 +1,10 @@
1
+ require 'simplecov-json'
2
+
3
+ SimpleCov.formatters = [
4
+ SimpleCov::Formatter::HTMLFormatter,
5
+ SimpleCov::Formatter::JSONFormatter
6
+ ]
7
+ SimpleCov.minimum_coverage 80
8
+ SimpleCov.start do
9
+ add_filter '/spec/'
10
+ end
data/.travis.yml ADDED
@@ -0,0 +1,5 @@
1
+ sudo: false
2
+ language: ruby
3
+ rvm:
4
+ - 2.4.2
5
+ before_install: gem install bundler -v 1.16.1
@@ -0,0 +1,74 @@
1
+ # Contributor Covenant Code of Conduct
2
+
3
+ ## Our Pledge
4
+
5
+ In the interest of fostering an open and welcoming environment, we as
6
+ contributors and maintainers pledge to making participation in our project and
7
+ our community a harassment-free experience for everyone, regardless of age, body
8
+ size, disability, ethnicity, gender identity and expression, level of experience,
9
+ nationality, personal appearance, race, religion, or sexual identity and
10
+ orientation.
11
+
12
+ ## Our Standards
13
+
14
+ Examples of behavior that contributes to creating a positive environment
15
+ include:
16
+
17
+ * Using welcoming and inclusive language
18
+ * Being respectful of differing viewpoints and experiences
19
+ * Gracefully accepting constructive criticism
20
+ * Focusing on what is best for the community
21
+ * Showing empathy towards other community members
22
+
23
+ Examples of unacceptable behavior by participants include:
24
+
25
+ * The use of sexualized language or imagery and unwelcome sexual attention or
26
+ advances
27
+ * Trolling, insulting/derogatory comments, and personal or political attacks
28
+ * Public or private harassment
29
+ * Publishing others' private information, such as a physical or electronic
30
+ address, without explicit permission
31
+ * Other conduct which could reasonably be considered inappropriate in a
32
+ professional setting
33
+
34
+ ## Our Responsibilities
35
+
36
+ Project maintainers are responsible for clarifying the standards of acceptable
37
+ behavior and are expected to take appropriate and fair corrective action in
38
+ response to any instances of unacceptable behavior.
39
+
40
+ Project maintainers have the right and responsibility to remove, edit, or
41
+ reject comments, commits, code, wiki edits, issues, and other contributions
42
+ that are not aligned to this Code of Conduct, or to ban temporarily or
43
+ permanently any contributor for other behaviors that they deem inappropriate,
44
+ threatening, offensive, or harmful.
45
+
46
+ ## Scope
47
+
48
+ This Code of Conduct applies both within project spaces and in public spaces
49
+ when an individual is representing the project or its community. Examples of
50
+ representing a project or community include using an official project e-mail
51
+ address, posting via an official social media account, or acting as an appointed
52
+ representative at an online or offline event. Representation of a project may be
53
+ further defined and clarified by project maintainers.
54
+
55
+ ## Enforcement
56
+
57
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be
58
+ reported by contacting the project team at anton@malinskiy.com. All
59
+ complaints will be reviewed and investigated and will result in a response that
60
+ is deemed necessary and appropriate to the circumstances. The project team is
61
+ obligated to maintain confidentiality with regard to the reporter of an incident.
62
+ Further details of specific enforcement policies may be posted separately.
63
+
64
+ Project maintainers who do not follow or enforce the Code of Conduct in good
65
+ faith may face temporary or permanent repercussions as determined by other
66
+ members of the project's leadership.
67
+
68
+ ## Attribution
69
+
70
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
71
+ available at [http://contributor-covenant.org/version/1/4][version]
72
+
73
+ [homepage]: http://contributor-covenant.org
74
+ [version]: http://contributor-covenant.org/version/1/4/
data/Gemfile ADDED
@@ -0,0 +1,6 @@
1
+ source "https://rubygems.org"
2
+
3
+ git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
4
+
5
+ # Specify your gem's dependencies in spielbash.gemspec
6
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2018 Anton Malinskiy
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,87 @@
1
+ [![Gem](https://img.shields.io/gem/v/spielbash.svg)](https://rubygems.org/gems/spielbash)
2
+ [![Gem](https://img.shields.io/gem/dt/spielbash.svg)](https://rubygems.org/gems/spielbash)
3
+
4
+ # Spielbash
5
+
6
+ Spielbash helps you to automate asciicasts with asciinema.
7
+
8
+ ![Sample output](sample/sample.gif?raw=true "Sample")
9
+
10
+ Requirements
11
+ ------------
12
+
13
+ * asciinema > 1.0
14
+ * tmux
15
+ * resize
16
+ * pgrep
17
+
18
+ ## Installation
19
+
20
+ Add this line to your application's Gemfile:
21
+
22
+ ```ruby
23
+ gem 'spielbash'
24
+ ```
25
+
26
+ And then execute:
27
+
28
+ $ bundle
29
+
30
+ Or install it yourself as:
31
+
32
+ $ gem install spielbash
33
+
34
+ ## Usage
35
+
36
+ ```console
37
+ $ spielbash -h
38
+ NAME
39
+ spielbash - Tool to automate bash movie-making with asciinema. Be the Spielberg of bash
40
+
41
+ SYNOPSIS
42
+ spielbash [global options] command [command options] [arguments...]
43
+
44
+ GLOBAL OPTIONS
45
+ --help - Show this message
46
+ -v, --[no-]verbose - Be verbose
47
+
48
+ COMMANDS
49
+ help - Shows a list of commands or help for one command
50
+ record - Create a recording
51
+ ```
52
+
53
+ ```console
54
+ $ spielbash record -h
55
+ NAME
56
+ record - Create a recording
57
+
58
+ SYNOPSIS
59
+ spielbash [global options] record [command options]
60
+
61
+ COMMAND OPTIONS
62
+ -o, --output=arg - Output file (default: none)
63
+ --script=arg - Script file path (default: none)
64
+
65
+ ```
66
+
67
+ See [scenario_1.yaml](spec/fixtures/files/scenario_1.yaml) for more detail on the script file
68
+
69
+ ## Development
70
+
71
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
72
+
73
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
74
+
75
+ ## Contributing
76
+
77
+ Bug reports and pull requests are welcome on GitHub at https://github.com/Malinskiy/spielbash. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
78
+
79
+ ## License
80
+
81
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
82
+
83
+ This project is a complete rewrite of [spielbash by Red Hat Cloud Innovation Practice](https://github.com/redhat-cip/spielbash) in Ruby.
84
+
85
+ ## Code of Conduct
86
+
87
+ Everyone interacting in the Spielbash project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/spielbash/blob/master/CODE_OF_CONDUCT.md).
data/Rakefile ADDED
@@ -0,0 +1,9 @@
1
+ require 'bundler/gem_tasks'
2
+ begin
3
+ require 'rspec/core/rake_task'
4
+ RSpec::Core::RakeTask.new(:spec)
5
+ rescue LoadError
6
+ end
7
+
8
+ task :default => :spec
9
+ task :test => :spec
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "spielbash"
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(__FILE__)
data/bin/setup ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
data/exe/spielbash ADDED
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "spielbash"
@@ -0,0 +1,68 @@
1
+ require 'yaml'
2
+
3
+ module Spielbash
4
+ class RecordInteractor
5
+ def execute(script_path, output_path)
6
+ script = YAML.load_file(script_path)
7
+ title = script['title']
8
+ opts = script['options']
9
+
10
+ typing_delay_s = opts['typing_delay_s']
11
+ reading_delay_s = opts['reading_delay_s']
12
+ wait = opts['wait']
13
+ width = opts['width']
14
+ height = opts['height']
15
+
16
+ context = Spielbash::Context.new(typing_delay_s, reading_delay_s, wait, width, height)
17
+
18
+ actions = create_actions(context, script['scenes'])
19
+ pre_run_actions = create_actions(context, script['pre-run'])
20
+ post_run_actions = create_actions(context, script['post-run'])
21
+
22
+ movie = Spielbash::Movie.new(title, pre_run_actions, actions, post_run_actions, context, output_path)
23
+ movie.shoot
24
+ end
25
+
26
+ private
27
+ def create_actions(context, scenes)
28
+ actions = []
29
+ for scene in scenes do
30
+ action_opts = scene['options'].nil? ? Hash.new : scene['options']
31
+ action_context = Spielbash::ActionContext.new(context,
32
+ action_opts['typing_delay_s'],
33
+ action_opts['reading_delay_s'],
34
+ action_opts['wait'],
35
+ action_opts['width'],
36
+ action_opts['height'])
37
+
38
+ action = case
39
+ when scene.has_key?('message') then
40
+ value = scene['message']
41
+ message_context = Spielbash::MessageContext.new(context,
42
+ action_opts['typing_delay_s'],
43
+ action_opts['reading_delay_s'],
44
+ action_opts['wait'],
45
+ action_opts['width'],
46
+ action_opts['height'],
47
+ action_opts['delete'].nil? ? true : action_opts['delete'])
48
+ Spielbash::MessageAction.new(value, message_context)
49
+ when scene.has_key?('command') then
50
+ value = scene['command']
51
+ Spielbash::CommandAction.new(value, action_context)
52
+ when scene.has_key?('pause') then
53
+ value = scene['pause']
54
+ Spielbash::PauseAction.new(value, action_context)
55
+ when scene.has_key?('key') then
56
+ value = scene['key']
57
+ Spielbash::PressKeyAction.new(value, action_context)
58
+ else
59
+ not_implemented
60
+ end
61
+
62
+ actions << action
63
+ end
64
+
65
+ actions
66
+ end
67
+ end
68
+ end
@@ -0,0 +1,22 @@
1
+ module Spielbash
2
+ class ActionContext < Spielbash::Context
3
+ attr_accessor :base_context
4
+
5
+ def initialize(base_context, typing_delay_s, reading_delay_s, wait, width, height)
6
+ super(typing_delay_s, reading_delay_s, wait, width, height)
7
+ @base_context = base_context
8
+ end
9
+
10
+ def typing_delay_s
11
+ return @typing_delay_s.nil? ? base_context.typing_delay_s : @typing_delay_s
12
+ end
13
+
14
+ def reading_delay_s
15
+ return @reading_delay_s.nil? ? base_context.reading_delay_s : @reading_delay_s
16
+ end
17
+
18
+ def wait
19
+ return @wait.nil? ? base_context.wait : @wait
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,9 @@
1
+ module Spielbash
2
+ class BaseAction
3
+ attr_accessor :action_context
4
+
5
+ def initialize(action_context)
6
+ @action_context = action_context
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,22 @@
1
+ module Spielbash
2
+ class CommandAction < Spielbash::BaseAction
3
+ attr_accessor :command
4
+
5
+ def initialize(command, action_context)
6
+ super(action_context)
7
+ @command = command
8
+ end
9
+
10
+ def execute(session)
11
+ command.each_char do |c|
12
+ session.send_key(c)
13
+ sleep(action_context.typing_delay_s)
14
+ end
15
+ session.send_key('C-m')
16
+
17
+ session.wait if action_context.wait
18
+
19
+ sleep(action_context.reading_delay_s)
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,20 @@
1
+ module Spielbash
2
+ class MessageAction < Spielbash::BaseAction
3
+ attr_accessor :message
4
+
5
+ def initialize(message, action_context)
6
+ super(action_context)
7
+ @message = message
8
+ end
9
+
10
+ def execute(session)
11
+ message.each_char do |c|
12
+ session.send_key(c)
13
+ sleep(action_context.typing_delay_s)
14
+ end
15
+ sleep(action_context.reading_delay_s)
16
+
17
+ session.send_key('C-h', message.length) if (action_context.delete)
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,10 @@
1
+ module Spielbash
2
+ class MessageContext < Spielbash::ActionContext
3
+ attr_accessor :delete
4
+
5
+ def initialize(base_context, typing_delay_s, reading_delay_s, wait, width, height, delete)
6
+ super(base_context, typing_delay_s, reading_delay_s, wait, width, height)
7
+ @delete = delete
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,14 @@
1
+ module Spielbash
2
+ class PauseAction < Spielbash::BaseAction
3
+ attr_accessor :length
4
+
5
+ def initialize(length, action_context)
6
+ super(action_context)
7
+ @length = length
8
+ end
9
+
10
+ def execute(_session)
11
+ sleep(length)
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,14 @@
1
+ module Spielbash
2
+ class PressKeyAction < Spielbash::BaseAction
3
+ attr_accessor :key
4
+
5
+ def initialize(key, action_context)
6
+ super(action_context)
7
+ @key = key
8
+ end
9
+
10
+ def execute(session)
11
+ session.send_key(key)
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,13 @@
1
+ module Spielbash
2
+ class Context
3
+ attr_accessor :typing_delay_s, :reading_delay_s, :wait, :width, :height
4
+
5
+ def initialize(typinig_delay_s, reading_delay_s, wait, width, height)
6
+ @typing_delay_s = typinig_delay_s
7
+ @reading_delay_s = reading_delay_s
8
+ @wait = wait
9
+ @width = width
10
+ @height = height
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,42 @@
1
+ module Spielbash
2
+ class Movie
3
+ attr_accessor :title, :pre_run_actions, :actions, :post_run_actions, :context, :output_path, :session
4
+
5
+ def initialize(title, pre_run_actions, actions, post_run_actions, context, output_path)
6
+ @title = title
7
+ @pre_run_actions = pre_run_actions
8
+ @actions = actions
9
+ @post_run_actions = post_run_actions
10
+ @context = context
11
+ @output_path = output_path
12
+ end
13
+
14
+ def shoot
15
+ session = Spielbash::Session.new(title.downcase.split.join('_'), output_path, context)
16
+ session.new_session
17
+
18
+ pre_run_actions.each do |action|
19
+ action.execute(session)
20
+ end
21
+
22
+ session.start_recording
23
+
24
+ actions.each do |action|
25
+ action.execute(session)
26
+ end
27
+
28
+ session.stop_recording
29
+
30
+ post_run_actions.each do |action|
31
+ action.execute(session)
32
+ end
33
+
34
+ session.stop_recording
35
+ session.close_session
36
+ end
37
+
38
+ def interrupt
39
+ Spielbash::PressKeyAction.new('C-c', context).execute(session) unless session.nil?
40
+ end
41
+ end
42
+ end
@@ -0,0 +1,123 @@
1
+ require 'childprocess'
2
+ require 'tempfile'
3
+ require 'mkmf'
4
+
5
+ module Spielbash
6
+ class Session
7
+ attr_accessor :context, :name, :output_path
8
+ attr_reader :last_stdout, :last_stderr
9
+
10
+ def initialize(name, output_path, context)
11
+ @context = context
12
+ @name = name
13
+ @output_path = output_path
14
+
15
+ ChildProcess.posix_spawn = true
16
+ end
17
+
18
+ def new_session
19
+ execute_with('resize', "-s #{context.height} #{context.width}", false, false, false)
20
+ execute_tmux_with("new-session -s #{name} -d")
21
+ wait
22
+ end
23
+
24
+ def stop_recording
25
+ send_key('C-d')
26
+ end
27
+
28
+ def close_session
29
+ send_key("exit")
30
+ send_key('C-m')
31
+
32
+ wait
33
+ end
34
+
35
+ # This will wait for tmux session pid to not have any child processes
36
+ def wait
37
+ execute_tmux_with('list-panes -F #{pane_pid}' + " -t #{name}", true)
38
+ pid = last_stdout.strip
39
+ return if pid.empty?
40
+
41
+ loop do
42
+ execute_with('pgrep', "-P #{pid}", true)
43
+ children = last_stdout
44
+ break if children.empty?
45
+ end
46
+ end
47
+
48
+ def send_key(key, count=1)
49
+ key = 'Space' if key == ' '
50
+ execute_tmux_with("send-keys -t #{name} -N #{count} #{key}")
51
+ end
52
+
53
+ def start_recording
54
+ execute_tmux_with('list-panes -F #{pane_pid}' + " -t #{name}", true)
55
+ pid = last_stdout.strip
56
+ execute_with('pgrep', "-P #{pid}", true)
57
+ execute_with_exactly('asciinema', false, true, false, "rec", "-y", "-c", "tmux attach -t #{name}", "#{output_path}")
58
+ end
59
+
60
+ private
61
+
62
+ def execute_tmux_with(arguments, wait = false)
63
+ execute_with('tmux', arguments, wait)
64
+ end
65
+
66
+ def execute_with(cmd, arguments, wait = false, leader = true, io_inherit = false)
67
+ args = arguments.split
68
+ execute_with_exactly cmd, wait, io_inherit, leader, *args
69
+ end
70
+
71
+ def execute_with_exactly(cmd, wait, io_inherit, leader, *arguments)
72
+ raise "Please install #{cmd}" if which(cmd).nil?
73
+
74
+ process = ChildProcess.build(cmd, *arguments)
75
+ process.leader = leader
76
+
77
+ if io_inherit
78
+ process.io.inherit!
79
+ process.start
80
+ process.wait if wait
81
+ else
82
+ process.io.stdout, process.io.stderr = std_out_err(cmd)
83
+ process.start
84
+ process.wait if wait
85
+ @last_stdout = output(process.io.stdout)
86
+ @last_stderr = output(process.io.stderr)
87
+ end
88
+
89
+ process
90
+ end
91
+
92
+ def output(file)
93
+ file.rewind
94
+ out = file.read
95
+ file.close
96
+ file.unlink
97
+ out
98
+ end
99
+
100
+
101
+ def std_out_err(cmd)
102
+ return ::Tempfile.new(filename_for("#{cmd}-out")), ::Tempfile.new(filename_for("#{cmd}-err"))
103
+ end
104
+
105
+ def filename_for(prefix)
106
+ "#{prefix}-#{Time.new.to_s.gsub(' ', '_').gsub(':', '_')}"
107
+ end
108
+
109
+ # Cross-platform way of finding an executable in the $PATH.
110
+ #
111
+ # which('ruby') #=> /usr/bin/ruby
112
+ def which(cmd)
113
+ exts = ENV['PATHEXT'] ? ENV['PATHEXT'].split(';') : ['']
114
+ ENV['PATH'].split(File::PATH_SEPARATOR).each do |path|
115
+ exts.each {|ext|
116
+ exe = File.join(path, "#{cmd}#{ext}")
117
+ return exe if File.executable?(exe) && !File.directory?(exe)
118
+ }
119
+ end
120
+ return nil
121
+ end
122
+ end
123
+ end
@@ -0,0 +1,11 @@
1
+ require 'spielbash/interactor/record_interactor'
2
+ require 'spielbash/model/movie'
3
+ require 'spielbash/model/context'
4
+ require 'spielbash/model/session'
5
+ require 'spielbash/model/action/base_action'
6
+ require 'spielbash/model/action/message_action'
7
+ require 'spielbash/model/action/press_key_action'
8
+ require 'spielbash/model/action/command_action'
9
+ require 'spielbash/model/action/pause_action'
10
+ require 'spielbash/model/action/action_context'
11
+ require 'spielbash/model/action/message_context'
@@ -0,0 +1,3 @@
1
+ module Spielbash
2
+ VERSION = "0.1.0"
3
+ end
@@ -0,0 +1,32 @@
1
+ module Spielbash
2
+ module CLI
3
+ require 'gli'
4
+
5
+ include GLI::App
6
+ extend self
7
+
8
+ program_desc 'Tool to automate bash movie-making with asciinema. Be the Spielberg of bash'
9
+
10
+ desc 'Be verbose'
11
+ switch [:v, :verbose]
12
+
13
+ # pre do |global_options, command, options, args|
14
+ # end
15
+
16
+ desc 'Create a recording'
17
+ command :record do |c|
18
+ c.desc 'Script file path'
19
+ c.flag [:script]
20
+ c.desc 'Output file'
21
+ c.flag [:o, :output]
22
+
23
+ c.action do |_, options, _|
24
+ script_path = options[:script]
25
+ output_path = options[:output]
26
+ Spielbash::RecordInteractor.new().execute(script_path, output_path)
27
+ end
28
+ end
29
+
30
+ exit run(ARGV)
31
+ end
32
+ end
data/lib/spielbash.rb ADDED
@@ -0,0 +1,7 @@
1
+ require 'spielbash/version'
2
+ require 'spielbash/spielbash'
3
+ require 'spielbash/view/cli'
4
+
5
+ module Spielbash
6
+ include Spielbash::CLI
7
+ end
data/sample/sample.gif ADDED
Binary file
data/spielbash.gemspec ADDED
@@ -0,0 +1,34 @@
1
+
2
+ lib = File.expand_path("../lib", __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require "spielbash/version"
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "spielbash"
8
+ spec.version = Spielbash::VERSION
9
+ spec.authors = ["Anton Malinskiy"]
10
+ spec.email = ["anton@malinskiy.com"]
11
+
12
+ spec.summary = %q{Spielbash helps you to automate asciicasts with asciinema.}
13
+ spec.description = %q{Tool to automate bash movie-making with asciinema. Be the Spielberg of bash.}
14
+ spec.homepage = "https://github.com/Malinskiy/spielbash"
15
+ spec.license = "MIT"
16
+
17
+
18
+ spec.files = `git ls-files -z`.split("\x0").reject do |f|
19
+ f.match(%r{^(test|coverage|spec|features)/})
20
+ end
21
+ spec.bindir = "exe"
22
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
23
+ spec.require_paths = ["lib"]
24
+
25
+ spec.add_runtime_dependency 'gli', '~> 2.17'
26
+ spec.add_runtime_dependency 'childprocess', '~> 0.9'
27
+
28
+ spec.add_development_dependency 'bundler', '~> 1.16'
29
+ spec.add_development_dependency 'rake', '~> 10.0'
30
+ spec.add_development_dependency 'rspec', '~> 3.5'
31
+ spec.add_development_dependency 'rspec_junit_formatter', '~> 0.2'
32
+ spec.add_development_dependency 'simplecov', '~> 0.14'
33
+ spec.add_development_dependency 'simplecov-json', '~> 0.2'
34
+ end
metadata ADDED
@@ -0,0 +1,187 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: spielbash
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Anton Malinskiy
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2018-04-06 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: gli
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '2.17'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '2.17'
27
+ - !ruby/object:Gem::Dependency
28
+ name: childprocess
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '0.9'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '0.9'
41
+ - !ruby/object:Gem::Dependency
42
+ name: bundler
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '1.16'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '1.16'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rake
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '10.0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '10.0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: rspec
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '3.5'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '3.5'
83
+ - !ruby/object:Gem::Dependency
84
+ name: rspec_junit_formatter
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: '0.2'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - "~>"
95
+ - !ruby/object:Gem::Version
96
+ version: '0.2'
97
+ - !ruby/object:Gem::Dependency
98
+ name: simplecov
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - "~>"
102
+ - !ruby/object:Gem::Version
103
+ version: '0.14'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - "~>"
109
+ - !ruby/object:Gem::Version
110
+ version: '0.14'
111
+ - !ruby/object:Gem::Dependency
112
+ name: simplecov-json
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - "~>"
116
+ - !ruby/object:Gem::Version
117
+ version: '0.2'
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - "~>"
123
+ - !ruby/object:Gem::Version
124
+ version: '0.2'
125
+ description: Tool to automate bash movie-making with asciinema. Be the Spielberg of
126
+ bash.
127
+ email:
128
+ - anton@malinskiy.com
129
+ executables:
130
+ - spielbash
131
+ extensions: []
132
+ extra_rdoc_files: []
133
+ files:
134
+ - ".gitignore"
135
+ - ".rspec"
136
+ - ".simplecov"
137
+ - ".travis.yml"
138
+ - CODE_OF_CONDUCT.md
139
+ - Gemfile
140
+ - LICENSE.txt
141
+ - README.md
142
+ - Rakefile
143
+ - bin/console
144
+ - bin/setup
145
+ - exe/spielbash
146
+ - lib/spielbash.rb
147
+ - lib/spielbash/interactor/record_interactor.rb
148
+ - lib/spielbash/model/action/action_context.rb
149
+ - lib/spielbash/model/action/base_action.rb
150
+ - lib/spielbash/model/action/command_action.rb
151
+ - lib/spielbash/model/action/message_action.rb
152
+ - lib/spielbash/model/action/message_context.rb
153
+ - lib/spielbash/model/action/pause_action.rb
154
+ - lib/spielbash/model/action/press_key_action.rb
155
+ - lib/spielbash/model/context.rb
156
+ - lib/spielbash/model/movie.rb
157
+ - lib/spielbash/model/session.rb
158
+ - lib/spielbash/spielbash.rb
159
+ - lib/spielbash/version.rb
160
+ - lib/spielbash/view/cli.rb
161
+ - sample/sample.gif
162
+ - spielbash.gemspec
163
+ homepage: https://github.com/Malinskiy/spielbash
164
+ licenses:
165
+ - MIT
166
+ metadata: {}
167
+ post_install_message:
168
+ rdoc_options: []
169
+ require_paths:
170
+ - lib
171
+ required_ruby_version: !ruby/object:Gem::Requirement
172
+ requirements:
173
+ - - ">="
174
+ - !ruby/object:Gem::Version
175
+ version: '0'
176
+ required_rubygems_version: !ruby/object:Gem::Requirement
177
+ requirements:
178
+ - - ">="
179
+ - !ruby/object:Gem::Version
180
+ version: '0'
181
+ requirements: []
182
+ rubyforge_project:
183
+ rubygems_version: 2.6.14
184
+ signing_key:
185
+ specification_version: 4
186
+ summary: Spielbash helps you to automate asciicasts with asciinema.
187
+ test_files: []