failtrain 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
data/README ADDED
@@ -0,0 +1,12 @@
1
+ o o o o o o o . . . __________________________ ________________________ ______________________________
2
+ o _____ | | | | | |
3
+ .][__n_n_|DD[ ====_____ | gem install failtrain | | failtrain choo choo | | cat lines.txt | failtrain |
4
+ >(________|__|_[_________]__|________________________|_|______________________|_|____________________________|
5
+ _/oo OOOOO oo` ooo ooo 'o!o!o o!o!o` 'o!o!o o!o!o` 'o!o!o o!o!o`
6
+ -+-+-+-+-+-+-+-+-+-+-+-+-+--+-+-+-+-+-+-+-+-+-+-+-+-+--+-+-+-+-+-+-+-+-+-+-+-+--+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-
7
+ ____________________________ ________________
8
+ | | | |
9
+ | fun for the whole family | | no specs lol |
10
+ _|__________________________|_|______________|
11
+ 'o!o!o o!o!o` 'o!o!o o!o!o`
12
+ -+-+-+-+-+-+-+-+-+-+-+-+-+-+--+-+-+-+-+-+-+-+-
@@ -0,0 +1,5 @@
1
+ gem install failtrain
2
+ failtrain choo choo
3
+ cat lines.txt | failtrain
4
+ fun for the whole family
5
+ no specs lol
@@ -0,0 +1,12 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ $LOAD_PATH.unshift File.expand_path("../../lib", __FILE__)
4
+
5
+ require 'failtrain'
6
+ train = if ARGV.length > 0
7
+ Failtrain.construct(ARGV)
8
+ else
9
+ Failtrain.construct(ARGF.read.lines.map(&:chomp))
10
+ end
11
+
12
+ puts train
@@ -0,0 +1,18 @@
1
+ Gem::Specification.new do |s|
2
+ s.name = 'failtrain'
3
+ s.version = '1.0.0'
4
+ s.summary = 'All aboard the fail train'
5
+ s.platform = Gem::Platform::RUBY
6
+ s.authors = ["Xavier Shay"]
7
+ s.email = ["hello@xaviershay.com"]
8
+ s.homepage = "http://github.com/xaviershay/failtrain"
9
+ s.has_rdoc = false
10
+
11
+ s.files = Dir.glob("lib/**/*.rb") +
12
+ Dir.glob("bin/*") +
13
+ %w(README.train README failtrain.gemspec)
14
+
15
+ s.bindir = 'bin'
16
+ s.require_path = 'lib'
17
+ s.executables << %q{failtrain}
18
+ end
@@ -0,0 +1,67 @@
1
+ class Failtrain
2
+ def self.construct(sentences)
3
+ head = <<-EOS
4
+ o o o o o o o . . .
5
+ o _____
6
+ .][__n_n_|DD[ ====_____
7
+ >(________|__|_[_________]_
8
+ _/oo OOOOO oo` ooo ooo
9
+ -+-+-+-+-+-+-+-+-+-+-+-+-+-
10
+ EOS
11
+
12
+ carriage_start = <<-EOS
13
+ _______
14
+ |
15
+ | XXXXX
16
+ _|______
17
+ 'o!o!o
18
+ -+-+-+-+
19
+ EOS
20
+ carriage_middle = <<-EOS
21
+ __
22
+
23
+ XX
24
+ __
25
+
26
+ -+
27
+ EOS
28
+ carriage_end = <<-EOS
29
+ _______
30
+ |
31
+ XXXXX |
32
+ ______|
33
+ o!o!o`
34
+ -+-+-+-
35
+ EOS
36
+
37
+ parts = [head]
38
+ line_length = head.lines.first.length
39
+ sentences.each do |word|
40
+ len = word.length
41
+ line_length += len + 4
42
+ mid_n = ([0, (len - 10)].max + 1) / 2
43
+ parts << carriage_start.gsub("XXXXX", "%5s" % word[0..4])
44
+ mid_n.times do |n|
45
+ parts << carriage_middle.gsub("XX", "%-2s" % word[5 + n * 2 .. 6 + n * 2])
46
+ end
47
+ parts << carriage_end.gsub("XXXXX", "%-5s" % word[5 + mid_n * 2 .. -1])
48
+ if line_length > 80
49
+ line_length = 0
50
+ parts << :break
51
+ end
52
+ end
53
+
54
+ buffer = ''
55
+ a = parts.first
56
+ parts[1..-1].each do |v|
57
+ a = if v == :break
58
+ buffer += a + "\n"
59
+ "\n" * 6
60
+ else
61
+ a.lines.to_a.map(&:chomp).zip(v.lines.to_a.map(&:chomp)).map(&:join).join("\n")
62
+ end
63
+ end
64
+ buffer += a if a.length > 6
65
+ buffer
66
+ end
67
+ end
metadata ADDED
@@ -0,0 +1,72 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: failtrain
3
+ version: !ruby/object:Gem::Version
4
+ hash: 23
5
+ prerelease:
6
+ segments:
7
+ - 1
8
+ - 0
9
+ - 0
10
+ version: 1.0.0
11
+ platform: ruby
12
+ authors:
13
+ - Xavier Shay
14
+ autorequire:
15
+ bindir: bin
16
+ cert_chain: []
17
+
18
+ date: 2011-09-21 00:00:00 -07:00
19
+ default_executable:
20
+ dependencies: []
21
+
22
+ description:
23
+ email:
24
+ - hello@xaviershay.com
25
+ executables:
26
+ - failtrain
27
+ extensions: []
28
+
29
+ extra_rdoc_files: []
30
+
31
+ files:
32
+ - lib/failtrain.rb
33
+ - bin/failtrain
34
+ - README.train
35
+ - README
36
+ - failtrain.gemspec
37
+ has_rdoc: true
38
+ homepage: http://github.com/xaviershay/failtrain
39
+ licenses: []
40
+
41
+ post_install_message:
42
+ rdoc_options: []
43
+
44
+ require_paths:
45
+ - lib
46
+ required_ruby_version: !ruby/object:Gem::Requirement
47
+ none: false
48
+ requirements:
49
+ - - ">="
50
+ - !ruby/object:Gem::Version
51
+ hash: 3
52
+ segments:
53
+ - 0
54
+ version: "0"
55
+ required_rubygems_version: !ruby/object:Gem::Requirement
56
+ none: false
57
+ requirements:
58
+ - - ">="
59
+ - !ruby/object:Gem::Version
60
+ hash: 3
61
+ segments:
62
+ - 0
63
+ version: "0"
64
+ requirements: []
65
+
66
+ rubyforge_project:
67
+ rubygems_version: 1.6.2
68
+ signing_key:
69
+ specification_version: 3
70
+ summary: All aboard the fail train
71
+ test_files: []
72
+