tart 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/.gitignore ADDED
@@ -0,0 +1,17 @@
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
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in tart.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2012 Phillip Ridlen
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,72 @@
1
+ # Tart (Terminal art)
2
+
3
+ Draw pretty pictures in your terminal with ease
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ gem 'tart'
10
+
11
+ And then execute:
12
+
13
+ $ bundle
14
+
15
+ Or install it yourself as:
16
+
17
+ $ gem install tart
18
+
19
+ ## Usage
20
+
21
+ Build an image map like this one:
22
+
23
+ ```
24
+ ............KK...KK
25
+ ............KWKKKKK
26
+ ............KWWKGGGK
27
+ ............KKWWGGGGK
28
+ ...........KGKWGKKKKKKK
29
+ ...........KGGKKKKKKKKKK
30
+ ..........KGGKKKWWWWKK
31
+ .........KKKKKWWWKWK
32
+ .........KWWKKWWWKWKKK
33
+ .........KWWKKKWWWWWWWKKKKKKK
34
+ .........KWWWKWWKWWWWWKKRRRRKK
35
+ ..........KWWWWKKKWWWKRRKKKKRRK
36
+ ...........KKWWWWKKKKRRKRRRRKRRK
37
+ ............KKKWWWWKKRKRRRRRRKRK
38
+ ...........KKGGKKKKKRKRRRRRRRRKRK
39
+ ..........KKGGGGGKGKKRKRRRRRRKRKK
40
+ ..........KKGGGGGGKKKRRKRRRRKRRRKK
41
+ .........KKKKGGGGGKWWKRRKKKKRRRRRK
42
+ .KKKKKKKKKKKKKKGGKWWWWKKRRRRKRRKKK
43
+ KKGWWGGWWGKKKKKKKKWWWWKRRRRRRKKKWWK
44
+ KGGWWGGWWKKKKKKKWWKWWKKRRRRRRKWWWK
45
+ KGGWWGGWKGGKKKKKKKKKKGKKKKKKKWWKK
46
+ KKGWWGGKKGKKKKKKKKKGGGKWWWWWWWK
47
+ .KKKKKKKGGKKKKKKKKKGGGKKWWWWKK
48
+ .......KGGKKKKK...KGGKKKKKKKK
49
+ .......KGGKK.......KKK
50
+ ........KK
51
+ ```
52
+
53
+ Where K is black, G is green, etc.
54
+
55
+ Then run
56
+
57
+ ```
58
+ tart -b /path/to/file
59
+ ```
60
+
61
+ And something pretty happens:
62
+
63
+
64
+
65
+
66
+ ## Contributing
67
+
68
+ 1. Fork it
69
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
70
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
71
+ 4. Push to the branch (`git push origin my-new-feature`)
72
+ 5. Create new Pull Request
data/Rakefile ADDED
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
data/bin/tart ADDED
@@ -0,0 +1,9 @@
1
+ #!/usr/bin/ruby
2
+
3
+ require 'rubygems'
4
+ require 'tart'
5
+ require 'tart/cli'
6
+
7
+ Tart::CLI.start
8
+
9
+
@@ -0,0 +1,61 @@
1
+ # encoding: UTF-8
2
+ module Tart
3
+ class Builder
4
+
5
+ PIXEL = "██"
6
+ SPACE = " "
7
+
8
+ def initialize(filename, options={})
9
+ options = ({ :pixel_char => PIXEL, :space_char => SPACE}).merge(options)
10
+ @filename = filename
11
+ @pixel = options[:pixel_char]
12
+ @space = options[:space_char]
13
+ end
14
+
15
+ def process
16
+ output_str = ""
17
+ IO.foreach(@filename) do |l|
18
+ l.split('').each do |char|
19
+ output_str << draw(char).to_s
20
+ end
21
+ output_str << "\n"
22
+ end
23
+
24
+ output_str
25
+ end
26
+
27
+ def draw(char)
28
+ case char
29
+ when "." then space
30
+
31
+ when "K" then pixel :black
32
+ when "R" then pixel :red
33
+ when "G" then pixel :green
34
+ when "Y" then pixel :yellow
35
+ when "B" then pixel :blue
36
+ when "M" then pixel :magenta
37
+ when "C" then pixel :cyan
38
+ when "W" then pixel :white
39
+
40
+ when "k" then pixel :light_black
41
+ when "r" then pixel :light_red
42
+ when "g" then pixel :light_green
43
+ when "y" then pixel :light_yellow
44
+ when "b" then pixel :light_blue
45
+ when "m" then pixel :light_magenta
46
+ when "c" then pixel :light_cyan
47
+ when "w" then pixel :light_white
48
+
49
+ when "X","x" then pixel :default
50
+ end
51
+ end
52
+
53
+ def pixel(color)
54
+ @pixel.colorize(color)
55
+ end
56
+
57
+ def space
58
+ @space
59
+ end
60
+ end
61
+ end
data/lib/tart/cli.rb ADDED
@@ -0,0 +1,15 @@
1
+ require 'thor'
2
+
3
+ module Tart
4
+ class CLI < Thor
5
+ include Thor::Actions
6
+ map '-b' => :bake
7
+
8
+ desc "bake", "generate ascii art based on text file passed in"
9
+ def bake(filename=nil)
10
+ tart = Tart::Builder.new(filename)
11
+ say tart.process
12
+ end
13
+
14
+ end
15
+ end
@@ -0,0 +1,3 @@
1
+ module Tart
2
+ VERSION = "0.0.1"
3
+ end
data/lib/tart.rb ADDED
@@ -0,0 +1,6 @@
1
+ # encoding: UTF-8
2
+
3
+ require 'colorize'
4
+ require "tart/version"
5
+ require 'tart/builder'
6
+
data/tart.gemspec ADDED
@@ -0,0 +1,23 @@
1
+ # -*- encoding: utf-8 -*-
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'tart/version'
5
+
6
+ Gem::Specification.new do |gem|
7
+ gem.name = "tart"
8
+ gem.version = Tart::VERSION
9
+ gem.authors = ["Phillip Ridlen"]
10
+ gem.email = ["phillip@ovenbits.com"]
11
+ gem.description = %q{Draw pretty pictures in your terminal with ease}
12
+ gem.summary = %q{Terminal Art}
13
+ gem.homepage = "https://github.com/philtr/tart"
14
+
15
+ gem.files = `git ls-files`.split($/)
16
+ gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
17
+ gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
18
+ gem.executables = ["tart"]
19
+ gem.require_paths = ["lib"]
20
+
21
+ gem.add_dependency "colorize", ">= 0.5.8"
22
+ gem.add_dependency 'thor', '>=0.11.5'
23
+ end
metadata ADDED
@@ -0,0 +1,90 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: tart
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Phillip Ridlen
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2012-11-30 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: colorize
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: 0.5.8
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ! '>='
28
+ - !ruby/object:Gem::Version
29
+ version: 0.5.8
30
+ - !ruby/object:Gem::Dependency
31
+ name: thor
32
+ requirement: !ruby/object:Gem::Requirement
33
+ none: false
34
+ requirements:
35
+ - - ! '>='
36
+ - !ruby/object:Gem::Version
37
+ version: 0.11.5
38
+ type: :runtime
39
+ prerelease: false
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ! '>='
44
+ - !ruby/object:Gem::Version
45
+ version: 0.11.5
46
+ description: Draw pretty pictures in your terminal with ease
47
+ email:
48
+ - phillip@ovenbits.com
49
+ executables:
50
+ - tart
51
+ extensions: []
52
+ extra_rdoc_files: []
53
+ files:
54
+ - .gitignore
55
+ - Gemfile
56
+ - LICENSE.txt
57
+ - README.md
58
+ - Rakefile
59
+ - bin/tart
60
+ - lib/tart.rb
61
+ - lib/tart/builder.rb
62
+ - lib/tart/cli.rb
63
+ - lib/tart/version.rb
64
+ - tart.gemspec
65
+ homepage: https://github.com/philtr/tart
66
+ licenses: []
67
+ post_install_message:
68
+ rdoc_options: []
69
+ require_paths:
70
+ - lib
71
+ required_ruby_version: !ruby/object:Gem::Requirement
72
+ none: false
73
+ requirements:
74
+ - - ! '>='
75
+ - !ruby/object:Gem::Version
76
+ version: '0'
77
+ required_rubygems_version: !ruby/object:Gem::Requirement
78
+ none: false
79
+ requirements:
80
+ - - ! '>='
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ requirements: []
84
+ rubyforge_project:
85
+ rubygems_version: 1.8.24
86
+ signing_key:
87
+ specification_version: 3
88
+ summary: Terminal Art
89
+ test_files: []
90
+ has_rdoc: