formatador 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/.document ADDED
@@ -0,0 +1,5 @@
1
+ README.rdoc
2
+ lib/**/*.rb
3
+ bin/*
4
+ features/**/*.feature
5
+ LICENSE
data/.gitignore ADDED
@@ -0,0 +1,21 @@
1
+ ## MAC OS
2
+ .DS_Store
3
+
4
+ ## TEXTMATE
5
+ *.tmproj
6
+ tmtags
7
+
8
+ ## EMACS
9
+ *~
10
+ \#*
11
+ .\#*
12
+
13
+ ## VIM
14
+ *.swp
15
+
16
+ ## PROJECT::GENERAL
17
+ coverage
18
+ rdoc
19
+ pkg
20
+
21
+ ## PROJECT::SPECIFIC
data/README.rdoc ADDED
@@ -0,0 +1,28 @@
1
+ = formatador
2
+
3
+ STDOUT text formatting
4
+
5
+ == Copyright
6
+
7
+ (The MIT License)
8
+
9
+ Copyright (c) 2009 {geemus (Wesley Beary)}[http://github.com/geemus]
10
+
11
+ Permission is hereby granted, free of charge, to any person obtaining
12
+ a copy of this software and associated documentation files (the
13
+ "Software"), to deal in the Software without restriction, including
14
+ without limitation the rights to use, copy, modify, merge, publish,
15
+ distribute, sublicense, and/or sell copies of the Software, and to
16
+ permit persons to whom the Software is furnished to do so, subject to
17
+ the following conditions:
18
+
19
+ The above copyright notice and this permission notice shall be
20
+ included in all copies or substantial portions of the Software.
21
+
22
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
23
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
24
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
25
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
26
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
27
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
28
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/Rakefile ADDED
@@ -0,0 +1,49 @@
1
+ require 'rubygems'
2
+ require 'rake'
3
+
4
+ begin
5
+ require 'jeweler'
6
+ Jeweler::Tasks.new do |gem|
7
+ gem.name = "formatador"
8
+ gem.summary = %Q{Ruby STDOUT text formatting}
9
+ gem.description = %Q{STDOUT text formatting}
10
+ gem.email = "wbeary@engineyard.com"
11
+ gem.homepage = "http://github.com/geemus/formatador"
12
+ gem.authors = ["Wesley Beary"]
13
+ gem.add_development_dependency "shindo", ">= 0"
14
+ # gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
15
+ end
16
+ Jeweler::GemcutterTasks.new
17
+ rescue LoadError
18
+ puts "Jeweler (or a dependency) not available. Install it with: gem install jeweler"
19
+ end
20
+
21
+ require 'shindo/rake'
22
+ Shindo::Rake.new
23
+
24
+ begin
25
+ require 'rcov/rcovtask'
26
+ Rcov::RcovTask.new do |tests|
27
+ tests.libs << 'tests'
28
+ tests.pattern = 'tests/**/*_tests.rb'
29
+ tests.verbose = true
30
+ end
31
+ rescue LoadError
32
+ task :rcov do
33
+ abort "RCov is not available. In order to run rcov, you must: sudo gem install spicycode-rcov"
34
+ end
35
+ end
36
+
37
+ task :tests => :check_dependencies
38
+
39
+ task :default => :tests
40
+
41
+ require 'rake/rdoctask'
42
+ Rake::RDocTask.new do |rdoc|
43
+ version = File.exist?('VERSION') ? File.read('VERSION') : ""
44
+
45
+ rdoc.rdoc_dir = 'rdoc'
46
+ rdoc.title = "formatador #{version}"
47
+ rdoc.rdoc_files.include('README*')
48
+ rdoc.rdoc_files.include('lib/**/*.rb')
49
+ end
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.0.1
@@ -0,0 +1,48 @@
1
+ # Generated by jeweler
2
+ # DO NOT EDIT THIS FILE DIRECTLY
3
+ # Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
4
+ # -*- encoding: utf-8 -*-
5
+
6
+ Gem::Specification.new do |s|
7
+ s.name = %q{formatador}
8
+ s.version = "0.0.1"
9
+
10
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
+ s.authors = ["Wesley Beary"]
12
+ s.date = %q{2009-11-25}
13
+ s.description = %q{STDOUT text formatting}
14
+ s.email = %q{wbeary@engineyard.com}
15
+ s.extra_rdoc_files = [
16
+ "README.rdoc"
17
+ ]
18
+ s.files = [
19
+ ".document",
20
+ ".gitignore",
21
+ "README.rdoc",
22
+ "Rakefile",
23
+ "VERSION",
24
+ "formatador.gemspec",
25
+ "lib/formatador.rb",
26
+ "tests/formatador_tests.rb",
27
+ "tests/tests_helper.rb"
28
+ ]
29
+ s.homepage = %q{http://github.com/geemus/formatador}
30
+ s.rdoc_options = ["--charset=UTF-8"]
31
+ s.require_paths = ["lib"]
32
+ s.rubygems_version = %q{1.3.5}
33
+ s.summary = %q{Ruby STDOUT text formatting}
34
+
35
+ if s.respond_to? :specification_version then
36
+ current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
37
+ s.specification_version = 3
38
+
39
+ if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
40
+ s.add_development_dependency(%q<shindo>, [">= 0"])
41
+ else
42
+ s.add_dependency(%q<shindo>, [">= 0"])
43
+ end
44
+ else
45
+ s.add_dependency(%q<shindo>, [">= 0"])
46
+ end
47
+ end
48
+
data/lib/formatador.rb ADDED
@@ -0,0 +1,71 @@
1
+ class Formatador
2
+
3
+ STYLES = {
4
+ :reset => "\e[0m",
5
+ :bold => "\e[1m",
6
+ :underline => "\e[4m",
7
+ :blink_slow => "\e[5m",
8
+ :blink_fast => "\e[6m",
9
+ :negative => "\e[7m", # invert color/background_color
10
+ :normal => "\e[22m",
11
+ :underline_none => "\e[24m",
12
+ :blink_off => "\e[25m",
13
+ :positive => "\e[27m", # revert color/background_color
14
+ :foreground_black => "\e[30m",
15
+ :foreground_red => "\e[31m",
16
+ :foreground_green => "\e[32m",
17
+ :foreground_yellow => "\e[33m",
18
+ :foreground_blue => "\e[34m",
19
+ :foreground_magenta => "\e[35m",
20
+ :foreground_cyan => "\e[36m",
21
+ :foreground_white => "\e[37m",
22
+ :background_black => "\e[40m",
23
+ :background_red => "\e[41m",
24
+ :background_green => "\e[42m",
25
+ :background_yellow => "\e[43m",
26
+ :background_blue => "\e[44m",
27
+ :background_magenta => "\e[45m",
28
+ :background_cyan => "\e[46m",
29
+ :background_white => "\e[47m"
30
+ }
31
+
32
+ def initialize
33
+ @indent = 1
34
+ end
35
+
36
+ def display(string, styles = [])
37
+ print(format("#{indentation}#{string}", [*styles]))
38
+ end
39
+
40
+ def display_line(string, styles = [])
41
+ display(string, styles)
42
+ print("\n")
43
+ end
44
+
45
+ def format(string, styles, reset = true)
46
+ if STDOUT.tty? && !styles.empty?
47
+ formated = ''
48
+ for style in styles
49
+ formated << STYLES[style]
50
+ end
51
+ formated << string
52
+ if reset
53
+ formated << STYLES[:reset]
54
+ end
55
+ formated
56
+ else
57
+ string
58
+ end
59
+ end
60
+
61
+ def indent(&block)
62
+ @indent += 1
63
+ yield
64
+ @indent -= 1
65
+ end
66
+
67
+ def indentation
68
+ ' ' * @indent
69
+ end
70
+
71
+ end
@@ -0,0 +1,8 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/tests_helper')
2
+
3
+ Shindo.tests("Formatador") do
4
+ test("fails") do
5
+ "hey buddy, you should probably rename this file and start specing for real"
6
+ false
7
+ end
8
+ end
@@ -0,0 +1,5 @@
1
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
2
+ $LOAD_PATH.unshift(File.dirname(__FILE__))
3
+ require 'formatador'
4
+ require 'rubygems'
5
+ require 'shindo'
metadata ADDED
@@ -0,0 +1,72 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: formatador
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Wesley Beary
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+
12
+ date: 2009-11-25 00:00:00 -08:00
13
+ default_executable:
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ name: shindo
17
+ type: :development
18
+ version_requirement:
19
+ version_requirements: !ruby/object:Gem::Requirement
20
+ requirements:
21
+ - - ">="
22
+ - !ruby/object:Gem::Version
23
+ version: "0"
24
+ version:
25
+ description: STDOUT text formatting
26
+ email: wbeary@engineyard.com
27
+ executables: []
28
+
29
+ extensions: []
30
+
31
+ extra_rdoc_files:
32
+ - README.rdoc
33
+ files:
34
+ - .document
35
+ - .gitignore
36
+ - README.rdoc
37
+ - Rakefile
38
+ - VERSION
39
+ - formatador.gemspec
40
+ - lib/formatador.rb
41
+ - tests/formatador_tests.rb
42
+ - tests/tests_helper.rb
43
+ has_rdoc: true
44
+ homepage: http://github.com/geemus/formatador
45
+ licenses: []
46
+
47
+ post_install_message:
48
+ rdoc_options:
49
+ - --charset=UTF-8
50
+ require_paths:
51
+ - lib
52
+ required_ruby_version: !ruby/object:Gem::Requirement
53
+ requirements:
54
+ - - ">="
55
+ - !ruby/object:Gem::Version
56
+ version: "0"
57
+ version:
58
+ required_rubygems_version: !ruby/object:Gem::Requirement
59
+ requirements:
60
+ - - ">="
61
+ - !ruby/object:Gem::Version
62
+ version: "0"
63
+ version:
64
+ requirements: []
65
+
66
+ rubyforge_project:
67
+ rubygems_version: 1.3.5
68
+ signing_key:
69
+ specification_version: 3
70
+ summary: Ruby STDOUT text formatting
71
+ test_files: []
72
+