let_it_fall 0.0.1

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: 5f5fe71f371aae3058c4e652c976ca22214aaa5b
4
+ data.tar.gz: 934f91a282917f151794033ab29755d22d45a2ca
5
+ SHA512:
6
+ metadata.gz: cf98499a677e4d482049632af61279443b9239317b7c3f9019ed1573cc77826ff607c31417369edbc4f7852f131f93b5c7656e92ef19558a2651b658034d8f84
7
+ data.tar.gz: f3425904e25ff941e1adbee85a05d224148b175dce08e6041d5d8d5a7730b1c5e98136b6f8b4981754d1a6450aa99570a380c976a7c6daebb44db2c4069422ba
data/.gitignore ADDED
@@ -0,0 +1,22 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
18
+ *.bundle
19
+ *.so
20
+ *.o
21
+ *.a
22
+ mkmf.log
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --format documentation
2
+ --color
data/.travis.yml ADDED
@@ -0,0 +1,3 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.1.1
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in let_it_fall.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2014 kyoendo
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,37 @@
1
+ # LetItFall
2
+
3
+ Let it snow or something in the Mac terminal.
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ gem 'let_it_fall'
10
+
11
+ And then execute:
12
+
13
+ $ bundle
14
+
15
+ Or install it yourself as:
16
+
17
+ $ gem install let_it_fall
18
+
19
+ ## Usage
20
+
21
+ open Mac terminal, then try following command.
22
+
23
+ $ let_it_fall beer
24
+
25
+ Or
26
+
27
+ $ let_it_fall code 0x2660 0x2666 -r
28
+
29
+ `let_it_fall help` for more info.
30
+
31
+ ## Contributing
32
+
33
+ 1. Fork it ( https://github.com/[my-github-username]/let_it_fall/fork )
34
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
35
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
36
+ 4. Push to the branch (`git push origin my-new-feature`)
37
+ 5. Create a new Pull Request
data/Rakefile ADDED
@@ -0,0 +1,7 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task :default => :spec
7
+
data/bin/let_it_fall ADDED
@@ -0,0 +1,5 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'let_it_fall'
4
+
5
+ LetItFall::CLI.start(ARGV)
@@ -0,0 +1,27 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'let_it_fall/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "let_it_fall"
8
+ spec.version = LetItFall::VERSION
9
+ spec.authors = ["kyoendo"]
10
+ spec.email = ["postagie@gmail.com"]
11
+ spec.summary = %q{Let it snow or something in the mac terminal.}
12
+ spec.description = %q{Let it snow or something in the mac terminal.}
13
+ spec.homepage = ""
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files -z`.split("\x0")
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.required_ruby_version = '>=2.0.0'
22
+
23
+ spec.add_dependency "thor"
24
+ spec.add_development_dependency "bundler", "~> 1.6"
25
+ spec.add_development_dependency "rake"
26
+ spec.add_development_dependency "rspec"
27
+ end
@@ -0,0 +1,38 @@
1
+ require "thor"
2
+ require "io/console"
3
+
4
+ module LetItFall
5
+ class CLI < Thor
6
+ LetItFall::CODESET.keys.each do |command|
7
+ desc "#{command}", "Let #{command} fall"
8
+ option :speed, aliases:'-s', default:1, type: :numeric
9
+ if [:snow, :kanji].include?(command)
10
+ option :color, aliases:'-c', default:true, type: :boolean
11
+ end
12
+ define_method(command) do
13
+ run(command, options[:speed], options[:color])
14
+ end
15
+ end
16
+
17
+ desc "code CODE", "Let specific character fall"
18
+ option :speed, aliases:'-s', default:1, type: :numeric
19
+ option :color, aliases:'-c', default:true, type: :boolean
20
+ option :range, aliases:'-r', default:false, type: :boolean
21
+ def code(*code)
22
+ if options[:range]
23
+ st, ed = code.minmax
24
+ code = Range.new(st.to_i(16), ed.to_i(16))
25
+ .to_a.map { |i| i.to_s(16) }
26
+ end
27
+ run(code, options[:speed], options[:color])
28
+ end
29
+
30
+ no_tasks do
31
+ def run(name, speed, color)
32
+ speed = 0.1 if speed < 0.1
33
+ interval = 0.05 / speed
34
+ Render.run(name, IO.console.winsize, interval:interval, colorize:color)
35
+ end
36
+ end
37
+ end
38
+ end
@@ -0,0 +1,48 @@
1
+ module LetItFall
2
+ CODESET = {
3
+ face: [*0x1F600..0x1F64F] - [*0x1F641..0x1F644],
4
+ kanji: (0x4E00..0x4F00),
5
+ snow: 0x2736,
6
+ time: (0x1F550..0x1f567),
7
+ animal: (0x1F40C..0x1F43C),
8
+ oreilly: (0x1F40C..0x1F43C),
9
+ food: (0x1F344..0x1F373),
10
+ love: (0x1F493..0x1F49F),
11
+ moon: (0x1F311..0x1F315),
12
+ gem: 0x1F48E,
13
+ python: 0x1F40D,
14
+ perl: 0x1F42A,
15
+ wine: 0x1F377,
16
+ cocktail: 0x1F378,
17
+ juice: 0x1F379,
18
+ beer: 0x1F37A,
19
+ beers: 0x1F37B,
20
+ cake: 0x1F382,
21
+ sparkle: 0x2728,
22
+ cyclone: 0x1F300,
23
+ octopus: 0x1F419,
24
+ bee: 0x1F41D,
25
+ dolphin: 0x1F42C,
26
+ paw: 0x1F43E,
27
+ eyes: 0x1F440,
28
+ ear: 0x1F442,
29
+ nose: 0x1F443,
30
+ mouth: 0x1F444,
31
+ tongue: 0x1F445,
32
+ bikini: 0x1F459,
33
+ dancer: 0x1F483,
34
+ poo: 0x1F4A9,
35
+ money: [0x1F4B0, 0x1F4B3, 0x1F4B4, 0x1F4B5, 0x1F4B6, 0x1F4B7, 0x1F4B8],
36
+ pushpin: 0x1F4CD,
37
+ hocho: 0x1F52A,
38
+ pistol: 0x1F52B,
39
+ beginner: 0x1F530,
40
+ helicopter: 0x1F681,
41
+ earth: [0x1F30D, 0x1F30E],
42
+ fuji: 0x1F5FB,
43
+ tower: 0x1F5FC,
44
+ japan: 0x1F5FE,
45
+ liberty: 0x1F5FD,
46
+
47
+ }
48
+ end
@@ -0,0 +1,3 @@
1
+ module LetItFall
2
+ VERSION = "0.0.1"
3
+ end
@@ -0,0 +1,61 @@
1
+ require "let_it_fall/code"
2
+ require "let_it_fall/cli"
3
+ require "let_it_fall/version"
4
+
5
+ module LetItFall
6
+ class Render
7
+ def self.run(mark, screen, colorize:false, interval:0.1)
8
+ new(mark, screen, colorize:colorize, interval:interval).run
9
+ end
10
+
11
+ def initialize(mark, screen, colorize:false, interval:0.1)
12
+ @y, @x = screen
13
+ @colorize = colorize
14
+ marks =
15
+ if Array===mark
16
+ mark.map { |m| m.to_i(16) }
17
+ else
18
+ CODESET[mark.intern] || CODESET[:snow]
19
+ end
20
+ @marks = Array(marks).map { |code| code.chr("UTF-8") }.cycle
21
+ @interval = interval
22
+ @screen = {}
23
+ $stdout.sync = true
24
+ end
25
+
26
+ def run
27
+ clear_screen
28
+ loop do
29
+ trap(:INT) do
30
+ print "\e[?25h\e[0;0H" # show cursor and set 0,0 pos
31
+ exit(0)
32
+ end
33
+ print_marks
34
+ sleep @interval
35
+ end
36
+ end
37
+
38
+ private
39
+ def clear_screen
40
+ print "\e[?25l\e[2J"
41
+ end
42
+
43
+ def print_marks
44
+ @screen[rand @x] = [0, @marks.dup]
45
+ @screen.each do |x, (y,mark)|
46
+ @screen[x][0] += 1 if @screen[x][0] <= @y*0.9
47
+ clear_prev_mark(x, y)
48
+ color = @colorize ? [*31..37].sample : 37
49
+ draw_mark(x, @screen[x][0], mark.next, color)
50
+ end
51
+ end
52
+
53
+ def clear_prev_mark(x, y)
54
+ draw_mark(x, y, " ")
55
+ end
56
+
57
+ def draw_mark(x, y, mark, color=37)
58
+ print "\e[%dm \e[%d;%dH%s \e[0;0H \e[0m" % [color, y, x, mark]
59
+ end
60
+ end
61
+ end
@@ -0,0 +1,11 @@
1
+ require 'spec_helper'
2
+
3
+ describe LetItFall do
4
+ it 'has a version number' do
5
+ expect(LetItFall::VERSION).not_to be nil
6
+ end
7
+
8
+ it 'does something useful' do
9
+ expect(false).to eq(true)
10
+ end
11
+ end
@@ -0,0 +1,2 @@
1
+ $LOAD_PATH.unshift File.expand_path('../../lib', __FILE__)
2
+ require 'let_it_fall'
metadata ADDED
@@ -0,0 +1,118 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: let_it_fall
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - kyoendo
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-05-01 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: thor
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: bundler
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '1.6'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '1.6'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rake
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rspec
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ description: Let it snow or something in the mac terminal.
70
+ email:
71
+ - postagie@gmail.com
72
+ executables:
73
+ - let_it_fall
74
+ extensions: []
75
+ extra_rdoc_files: []
76
+ files:
77
+ - ".gitignore"
78
+ - ".rspec"
79
+ - ".travis.yml"
80
+ - Gemfile
81
+ - LICENSE.txt
82
+ - README.md
83
+ - Rakefile
84
+ - bin/let_it_fall
85
+ - let_it_fall.gemspec
86
+ - lib/let_it_fall.rb
87
+ - lib/let_it_fall/cli.rb
88
+ - lib/let_it_fall/code.rb
89
+ - lib/let_it_fall/version.rb
90
+ - spec/let_it_fall_spec.rb
91
+ - spec/spec_helper.rb
92
+ homepage: ''
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: 2.0.0
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.2.2
113
+ signing_key:
114
+ specification_version: 4
115
+ summary: Let it snow or something in the mac terminal.
116
+ test_files:
117
+ - spec/let_it_fall_spec.rb
118
+ - spec/spec_helper.rb