flowterm 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 5b62f2a7bf5a63c9a95a135463aabadc8e88feeb
4
+ data.tar.gz: d650017f36eb867db264ed08de69312d647b68d1
5
+ SHA512:
6
+ metadata.gz: 9a7463f0f6cb74972e2b7b94c485c6dae34ed772da14447cf06018eeb728d1d05b5f1f34b0274dbd945ea38ab14ee3d11a15e8cce4bf8a586f29cdf64e53f3e5
7
+ data.tar.gz: 2a28092a48035a7e0aa27f2261e476ac9e061bc45775784bd5dec9b8eeb5e03f1753758cec5bde7f5010861e459d3865e856e1dcc2060c4e1bcc2fd7f206c616
@@ -0,0 +1,9 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source "https://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in flowterm.gemspec
4
+ gemspec
@@ -0,0 +1,65 @@
1
+ # Flowterm
2
+
3
+ String flows in a terminal.
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ ```ruby
10
+ gem 'flowterm'
11
+ ```
12
+
13
+ And then execute:
14
+
15
+ $ bundle
16
+
17
+ Or install it yourself as:
18
+
19
+ $ gem install flowterm
20
+
21
+ ## Basic Usage
22
+
23
+ ```bash
24
+ # "meow" flows in the terminal.
25
+ $ echo meow | flowterm
26
+
27
+ # "meow"(ASCII Art) flows in the terminal.
28
+ $ banner meow | flowterm
29
+
30
+ # "meow" that is said by a cow flows in the terminal.
31
+ $ cowsay meow | flowterm
32
+
33
+ $ flowterm --help
34
+ Usage: flowterm [options]
35
+ --speed=speed
36
+ --[no-]trap
37
+ ```
38
+
39
+ ![basic-usage-animation](https://user-images.githubusercontent.com/4361134/27766824-dbc14eda-5f19-11e7-9b74-6f7c679bde82.gif)
40
+
41
+ ![cowsay-animation](https://user-images.githubusercontent.com/4361134/27766843-d7e6297e-5f1a-11e7-9fab-7e83bdc13621.gif)
42
+
43
+ ## Advanced Usage
44
+
45
+ If you use zsh, you can run a command by this command when you typo the command.
46
+
47
+ ```zsh
48
+ # .zshrc
49
+ command_not_found_handler()
50
+ {
51
+ banner "$*" | flowterm
52
+ echo "command not found: $*"
53
+ return 127
54
+ }
55
+ ```
56
+
57
+
58
+ ![command-not-found-usage](https://user-images.githubusercontent.com/4361134/27766826-04215de8-5f1a-11e7-88dd-95b829581b69.gif)
59
+
60
+ License
61
+ -------
62
+
63
+ These codes are licensed under CC0.
64
+
65
+ [![CC0](http://i.creativecommons.org/p/zero/1.0/88x31.png "CC0")](http://creativecommons.org/publicdomain/zero/1.0/deed.en)
@@ -0,0 +1,2 @@
1
+ require "bundler/gem_tasks"
2
+ task :default => :spec
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "flowterm"
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__)
@@ -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
@@ -0,0 +1,5 @@
1
+ #!ruby
2
+
3
+ require 'flowterm'
4
+
5
+ Flowterm.new(ARGV, STDIN).run
@@ -0,0 +1,25 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path("../lib", __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require "flowterm/version"
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "flowterm"
8
+ spec.version = Flowterm::VERSION
9
+ spec.authors = ["Masataka Kuwabara"]
10
+ spec.email = ["kuwabara@pocke.me"]
11
+
12
+ spec.summary = %q{String flows in a terminal}
13
+ spec.description = %q{String flows in a terminal}
14
+ spec.homepage = "https://github.com/pocke/flowterm"
15
+
16
+ spec.files = `git ls-files -z`.split("\x0").reject do |f|
17
+ f.match(%r{^(test|spec|features)/})
18
+ end
19
+ spec.bindir = "exe"
20
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
21
+ spec.require_paths = ["lib"]
22
+
23
+ spec.add_development_dependency "bundler", "~> 1.15"
24
+ spec.add_development_dependency "rake", "~> 10.0"
25
+ end
@@ -0,0 +1,43 @@
1
+ require 'curses'
2
+ require 'optparse'
3
+ require "flowterm/version"
4
+
5
+ class Flowterm
6
+ def initialize(argv, input)
7
+ @sleep = 1 / 25.0
8
+ @trap = true
9
+
10
+ opt = OptionParser.new
11
+ opt.on('--speed=speed') { |v| @sleep = 1 / v.to_f }
12
+ opt.on('--[no-]trap') { |v| @trap = v }
13
+ opt.parse!(argv)
14
+
15
+ Signal.trap(:INT, nil) if @trap
16
+ @str = input.read
17
+ end
18
+
19
+ def run
20
+ Curses.init_screen
21
+ begin
22
+ Curses.cols.times do |idx|
23
+ render(@str, -idx)
24
+ sleep @sleep
25
+ end
26
+ ensure
27
+ Curses.close_screen
28
+ end
29
+ end
30
+
31
+ def render(str, col_offset)
32
+ col = Curses.cols - str.each_line.max_by(&:size).size + col_offset
33
+ line = (Curses.lines - str.each_line.count) / 2
34
+
35
+ Curses.clear
36
+ str.each_line.with_index do |str_line, index|
37
+ Curses.setpos(line + index, [col, 0].max)
38
+ str_line = str_line[-col..-1] || '' if col < 0
39
+ Curses.addstr(str_line)
40
+ end
41
+ Curses.refresh
42
+ end
43
+ end
@@ -0,0 +1,3 @@
1
+ class Flowterm
2
+ VERSION = "0.1.0"
3
+ end
metadata ADDED
@@ -0,0 +1,82 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: flowterm
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Masataka Kuwabara
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2017-07-02 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.15'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.15'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '10.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '10.0'
41
+ description: String flows in a terminal
42
+ email:
43
+ - kuwabara@pocke.me
44
+ executables:
45
+ - flowterm
46
+ extensions: []
47
+ extra_rdoc_files: []
48
+ files:
49
+ - ".gitignore"
50
+ - Gemfile
51
+ - README.md
52
+ - Rakefile
53
+ - bin/console
54
+ - bin/setup
55
+ - exe/flowterm
56
+ - flowterm.gemspec
57
+ - lib/flowterm.rb
58
+ - lib/flowterm/version.rb
59
+ homepage: https://github.com/pocke/flowterm
60
+ licenses: []
61
+ metadata: {}
62
+ post_install_message:
63
+ rdoc_options: []
64
+ require_paths:
65
+ - lib
66
+ required_ruby_version: !ruby/object:Gem::Requirement
67
+ requirements:
68
+ - - ">="
69
+ - !ruby/object:Gem::Version
70
+ version: '0'
71
+ required_rubygems_version: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ requirements: []
77
+ rubyforge_project:
78
+ rubygems_version: 2.6.10
79
+ signing_key:
80
+ specification_version: 4
81
+ summary: String flows in a terminal
82
+ test_files: []