hexe 0.0.666

Sign up to get free protection for your applications and to get access to all the features.
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/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in hexe.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2014 nilsding
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,44 @@
1
+ # Hexe
2
+
3
+ A witch for your terminal. Now **that's** witchcraft!
4
+
5
+ Demo video: [webm](http://nilsding.org/hexe/hexe.webm)
6
+ [mp4](http://nilsding.org/hexe/hexe.mp4)
7
+
8
+ Inspired by [gti](https://github.com/rwos/gti) and sl.
9
+
10
+ Also, don't forget that witches don't like windows.
11
+
12
+ ## Installation
13
+
14
+ Installation is easy!
15
+
16
+ $ gem install hexe
17
+
18
+ If you want to, you can add this line to your application's Gemfile:
19
+
20
+ gem 'hexe'
21
+
22
+ And then execute:
23
+
24
+ $ bundle install
25
+
26
+ to install it.
27
+
28
+ ## Usage
29
+
30
+ It's really easy!
31
+
32
+ $ hexe
33
+
34
+ If you installed it using Bundler, you can even do this:
35
+
36
+ $ bundle exec hexe
37
+
38
+ ## Contributing
39
+
40
+ 1. Fork it ( https://github.com/nilsding/hexe/fork )
41
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
42
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
43
+ 4. Push to the branch (`git push origin my-new-feature`)
44
+ 5. Create a new Pull Request
data/Rakefile ADDED
@@ -0,0 +1,2 @@
1
+ require "bundler/gem_tasks"
2
+
data/bin/hexe ADDED
@@ -0,0 +1,6 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'hexe'
4
+
5
+ Hexe.new.hex_hex!
6
+
data/hexe.gemspec ADDED
@@ -0,0 +1,23 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'hexe/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "hexe"
8
+ spec.version = Hexe::VERSION
9
+ spec.authors = ["nilsding"]
10
+ spec.email = ["nilsding@nilsding.org"]
11
+ spec.summary = %q{A witch for your terminal.}
12
+ spec.description = %q{A witch for your terminal. Now that's witchcraft!}
13
+ spec.homepage = "https://github.com/nilsding/hexe"
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.add_development_dependency "bundler", "~> 1.6"
22
+ spec.add_development_dependency "rake"
23
+ end
data/lib/hexe.rb ADDED
@@ -0,0 +1,85 @@
1
+ # hexe.rb
2
+ # made by nilsding in 2014
3
+ # license: MIT
4
+ #
5
+ # ASCII art is not mine, it was made by someone who names himself "ns", found
6
+ # this on http://ascii.co.uk/art/witch
7
+
8
+ require 'hexe/version'
9
+ require 'io/console'
10
+
11
+ class Hexe
12
+ def initialize
13
+ # The witch. Art by "ns", found on http://ascii.co.uk/art/witch
14
+ @witch = [
15
+ ' /\\',
16
+ ' _/__\\_',
17
+ ' /( o\\',
18
+ ' /| // \\-\'',
19
+ ' __ ( o, /\\',
20
+ ' ) / | / _\\',
21
+ '>>>>==(_(__u---(___ )-----',
22
+ ' //',
23
+ ' /__)'
24
+ ]
25
+ @witch_width = @witch.group_by.max.length
26
+ @witch_height = @witch.length
27
+ @height, @width = $stdout.winsize
28
+ end
29
+
30
+ # Moves the cursor up +@witch_height+ lines.
31
+ def move_to_top
32
+ $stdout.write "\033[#{@witch_height}A"
33
+ end
34
+
35
+ # Moves the x position of the cursor to +x+.
36
+ # @param x [Integer] The position to move the cursor to.
37
+ def move_to_x(x)
38
+ $stdout.write "\033[#{x}C"
39
+ end
40
+
41
+ # Prints a string starting at x position +start_x+. If the string is longer
42
+ # than the terminal width, it gets trimmed.
43
+ # @param start_x [Integer] Starting x position
44
+ # @param str [String] The string to be printed
45
+ def line_at(start_x, str)
46
+ x = start_x
47
+ move_to_x(start_x) if start_x > 1
48
+ str.length.times do |i|
49
+ $stdout.putc str[i] if x > 0 && x < @width
50
+ x += 1
51
+ end
52
+ $stdout.putc "\n"
53
+ end
54
+
55
+ # Draws the witch at x position +x+.
56
+ # @param x [Integer] The x position to draw the witch
57
+ def draw_witch(x)
58
+ move_to_top
59
+ @witch.each do |line|
60
+ line_at x, line
61
+ end
62
+ end
63
+
64
+ # Clears the first two characters at position +x+.
65
+ # @param x [Integer] The x position to start clearing from
66
+ def clear_witch(x)
67
+ move_to_top
68
+ @witch_height.times do
69
+ line_at x, " "
70
+ end
71
+ end
72
+
73
+ # Witchcraft!
74
+ def hex_hex!
75
+ wait_time = ((rand() * 100) % 60 + 20) / 1000
76
+ (@witch_height + 1).times { $stdout.write "\n" }
77
+ (-@witch_width..@width).each do |x|
78
+ draw_witch x
79
+ sleep wait_time
80
+ clear_witch(x)
81
+ end
82
+ move_to_top
83
+ puts ";-)"
84
+ end
85
+ end
@@ -0,0 +1,3 @@
1
+ class Hexe
2
+ VERSION = "0.0.666"
3
+ end
metadata ADDED
@@ -0,0 +1,89 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: hexe
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.666
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - nilsding
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2014-11-08 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: bundler
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ~>
20
+ - !ruby/object:Gem::Version
21
+ version: '1.6'
22
+ type: :development
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ~>
28
+ - !ruby/object:Gem::Version
29
+ version: '1.6'
30
+ - !ruby/object:Gem::Dependency
31
+ name: rake
32
+ requirement: !ruby/object:Gem::Requirement
33
+ none: false
34
+ requirements:
35
+ - - ! '>='
36
+ - !ruby/object:Gem::Version
37
+ version: '0'
38
+ type: :development
39
+ prerelease: false
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ! '>='
44
+ - !ruby/object:Gem::Version
45
+ version: '0'
46
+ description: A witch for your terminal. Now that's witchcraft!
47
+ email:
48
+ - nilsding@nilsding.org
49
+ executables:
50
+ - hexe
51
+ extensions: []
52
+ extra_rdoc_files: []
53
+ files:
54
+ - .gitignore
55
+ - Gemfile
56
+ - LICENSE.txt
57
+ - README.md
58
+ - Rakefile
59
+ - bin/hexe
60
+ - hexe.gemspec
61
+ - lib/hexe.rb
62
+ - lib/hexe/version.rb
63
+ homepage: https://github.com/nilsding/hexe
64
+ licenses:
65
+ - MIT
66
+ post_install_message:
67
+ rdoc_options: []
68
+ require_paths:
69
+ - lib
70
+ required_ruby_version: !ruby/object:Gem::Requirement
71
+ none: false
72
+ requirements:
73
+ - - ! '>='
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ required_rubygems_version: !ruby/object:Gem::Requirement
77
+ none: false
78
+ requirements:
79
+ - - ! '>='
80
+ - !ruby/object:Gem::Version
81
+ version: '0'
82
+ requirements: []
83
+ rubyforge_project:
84
+ rubygems_version: 1.8.23
85
+ signing_key:
86
+ specification_version: 3
87
+ summary: A witch for your terminal.
88
+ test_files: []
89
+ has_rdoc: