terminal_markup 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
data.tar.gz.sig ADDED
Binary file
data/History.txt ADDED
@@ -0,0 +1,4 @@
1
+ === 0.0.1 2009-11-13
2
+
3
+ * 1 major enhancement:
4
+ * Initial release
data/Manifest.txt ADDED
@@ -0,0 +1,10 @@
1
+ History.txt
2
+ Manifest.txt
3
+ README.rdoc
4
+ Rakefile
5
+ lib/terminal_markup.rb
6
+ script/console
7
+ script/destroy
8
+ script/generate
9
+ test/test_helper.rb
10
+ test/test_terminal_markup.rb
data/README.rdoc ADDED
@@ -0,0 +1,46 @@
1
+ = TerminalMarkup
2
+
3
+ * http://lemurheavy.com
4
+
5
+ == DESCRIPTION:
6
+
7
+ Easy coloring/markup for terminal output
8
+
9
+ == SYNOPSIS:
10
+
11
+ "print this in red".in_red
12
+ "print this on blue".on_blue
13
+ "print this with underline".as_underline
14
+
15
+ == REQUIREMENTS:
16
+
17
+ none
18
+
19
+ == INSTALL:
20
+
21
+ sudo gem i terminal_markup
22
+
23
+ == LICENSE:
24
+
25
+ (The MIT License)
26
+
27
+ Copyright (c) 2009 FIXME full name
28
+
29
+ Permission is hereby granted, free of charge, to any person obtaining
30
+ a copy of this software and associated documentation files (the
31
+ 'Software'), to deal in the Software without restriction, including
32
+ without limitation the rights to use, copy, modify, merge, publish,
33
+ distribute, sublicense, and/or sell copies of the Software, and to
34
+ permit persons to whom the Software is furnished to do so, subject to
35
+ the following conditions:
36
+
37
+ The above copyright notice and this permission notice shall be
38
+ included in all copies or substantial portions of the Software.
39
+
40
+ THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
41
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
42
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
43
+ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
44
+ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
45
+ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
46
+ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/Rakefile ADDED
@@ -0,0 +1,28 @@
1
+ require 'rubygems'
2
+ gem 'hoe', '>= 2.1.0'
3
+ require 'hoe'
4
+ require 'fileutils'
5
+ require './lib/terminal_markup'
6
+
7
+ Hoe.plugin :newgem
8
+ # Hoe.plugin :website
9
+ # Hoe.plugin :cucumberfeatures
10
+
11
+ # Generate all the Rake tasks
12
+ # Run 'rake -T' to see list of generated tasks (from gem root directory)
13
+ $hoe = Hoe.spec 'terminal_markup' do
14
+ self.developer 'Nick Merwin', 'nick@lemurheavy.com'
15
+ # self.post_install_message = 'PostInstall.txt' # TODO remove if post-install message not required
16
+ self.rubyforge_name = self.name # TODO this is default value
17
+ # self.extra_deps = [['activesupport','>= 2.0.2']]
18
+ self.spec_extras[:rdoc_options] = ""
19
+ self.spec_extras[:homepage] = %q{http://lemurheavy.com}
20
+
21
+ end
22
+
23
+ require 'newgem/tasks'
24
+ Dir['tasks/**/*.rake'].each { |t| load t }
25
+
26
+ # TODO - want other tests/tasks run by default? Add them to the list
27
+ # remove_task :default
28
+ # task :default => [:spec, :features]
@@ -0,0 +1,97 @@
1
+ $:.unshift(File.dirname(__FILE__)) unless
2
+ $:.include?(File.dirname(__FILE__)) || $:.include?(File.expand_path(File.dirname(__FILE__)))
3
+
4
+ =begin rdoc
5
+ TerminalMarkup
6
+ by Nick Merwin
7
+
8
+ Usage:
9
+ "string".in_red.as_underline
10
+
11
+ obj = Object.new
12
+ obj.in_blue
13
+
14
+ Extra:
15
+
16
+ To see examples of all markup:
17
+ ruby terminal_markup.rb
18
+
19
+ =end
20
+
21
+ module TerminalMarkup
22
+ VERSION = "0.0.1"
23
+ DATE = "11.13.09"
24
+ CREDITS = "TerminalMarkup v.#{VERSION}\n by Nick Merwin (http://lemurheavy.com) #{DATE}"
25
+
26
+ FORMATTING = {
27
+ :bright => 1,
28
+ :dim => 2,
29
+ :underline => 4,
30
+ :blink => 5,
31
+ :reverse => 7,
32
+ :hidden => 8
33
+ }
34
+
35
+ COLOR = {
36
+ :black => 30,
37
+ :red => 31,
38
+ :green => 32,
39
+ :yellow => 33,
40
+ :blue => 34,
41
+ :magenta => 35,
42
+ :cyan => 36,
43
+ :white => 37
44
+ }
45
+
46
+ BACKGROUND_COLOR = {
47
+ :black => 40,
48
+ :red => 41,
49
+ :green => 42,
50
+ :yellow => 43,
51
+ :blue => 44,
52
+ :magenta => 45,
53
+ :cyan => 46,
54
+ :white => 47
55
+ }
56
+
57
+ PREPOSITION_MAP = {
58
+ FORMATTING => "as",
59
+ COLOR => "in",
60
+ BACKGROUND_COLOR => "on"
61
+ }
62
+
63
+ module InstanceMethods
64
+ TerminalMarkup::PREPOSITION_MAP.each do |markup, preposition|
65
+ markup.each do |name, code|
66
+ module_eval "def #{preposition}_#{name}; with_escape_code #{code} end"
67
+ end
68
+ end
69
+
70
+ # returns the string wrapped in the supplied escape code
71
+ def with_escape_code(code)
72
+ "\\e[#{code}m#{self.to_s}\\e[0m"
73
+ end
74
+
75
+ # for printing to console with escape codes intact
76
+ def escape
77
+ eval '"'+ gsub(/\"/,'\"') + '"'
78
+ end
79
+ end
80
+ end
81
+
82
+ class String
83
+ include TerminalMarkup::InstanceMethods
84
+ end
85
+
86
+ class Object
87
+ include TerminalMarkup::InstanceMethods
88
+ end
89
+
90
+ if $0 == __FILE__
91
+ include TerminalMarkup
92
+ puts "\n#{CREDITS}\n\n"
93
+ PREPOSITION_MAP.each do |markup, preposition|
94
+ markup.each{|name,code| puts eval("\"#{preposition}_#{name}\".#{preposition}_#{name}").escape}
95
+ end
96
+ puts "\n"
97
+ end
data/script/console ADDED
@@ -0,0 +1,10 @@
1
+ #!/usr/bin/env ruby
2
+ # File: script/console
3
+ irb = RUBY_PLATFORM =~ /(:?mswin|mingw)/ ? 'irb.bat' : 'irb'
4
+
5
+ libs = " -r irb/completion"
6
+ # Perhaps use a console_lib to store any extra methods I may want available in the cosole
7
+ # libs << " -r #{File.dirname(__FILE__) + '/../lib/console_lib/console_logger.rb'}"
8
+ libs << " -r #{File.dirname(__FILE__) + '/../lib/terminal_markup.rb'}"
9
+ puts "Loading terminal_markup gem"
10
+ exec "#{irb} #{libs} --simple-prompt"
data/script/destroy ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+ APP_ROOT = File.expand_path(File.join(File.dirname(__FILE__), '..'))
3
+
4
+ begin
5
+ require 'rubigen'
6
+ rescue LoadError
7
+ require 'rubygems'
8
+ require 'rubigen'
9
+ end
10
+ require 'rubigen/scripts/destroy'
11
+
12
+ ARGV.shift if ['--help', '-h'].include?(ARGV[0])
13
+ RubiGen::Base.use_component_sources! [:rubygems, :newgem, :newgem_theme, :test_unit]
14
+ RubiGen::Scripts::Destroy.new.run(ARGV)
data/script/generate ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+ APP_ROOT = File.expand_path(File.join(File.dirname(__FILE__), '..'))
3
+
4
+ begin
5
+ require 'rubigen'
6
+ rescue LoadError
7
+ require 'rubygems'
8
+ require 'rubigen'
9
+ end
10
+ require 'rubigen/scripts/generate'
11
+
12
+ ARGV.shift if ['--help', '-h'].include?(ARGV[0])
13
+ RubiGen::Base.use_component_sources! [:rubygems, :newgem, :newgem_theme, :test_unit]
14
+ RubiGen::Scripts::Generate.new.run(ARGV)
@@ -0,0 +1,3 @@
1
+ require 'stringio'
2
+ require 'test/unit'
3
+ require File.dirname(__FILE__) + '/../lib/terminal_markup'
@@ -0,0 +1,11 @@
1
+ require File.dirname(__FILE__) + '/test_helper.rb'
2
+
3
+ class TestTerminalMarkup < Test::Unit::TestCase
4
+
5
+ def setup
6
+ end
7
+
8
+ def test_truth
9
+ assert true
10
+ end
11
+ end
metadata ADDED
@@ -0,0 +1,97 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: terminal_markup
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Nick Merwin
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain:
11
+ - |
12
+ -----BEGIN CERTIFICATE-----
13
+ MIIDNDCCAhygAwIBAgIBADANBgkqhkiG9w0BAQUFADBAMQ0wCwYDVQQDDARuaWNr
14
+ MRowGAYKCZImiZPyLGQBGRYKbGVtdXJoZWF2eTETMBEGCgmSJomT8ixkARkWA2Nv
15
+ bTAeFw0wOTA5MjkyMzEzMDVaFw0xMDA5MjkyMzEzMDVaMEAxDTALBgNVBAMMBG5p
16
+ Y2sxGjAYBgoJkiaJk/IsZAEZFgpsZW11cmhlYXZ5MRMwEQYKCZImiZPyLGQBGRYD
17
+ Y29tMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA3uflg3FiN5qVj79C
18
+ hL+IdQJI+t1bGLrcx38cgFk9wzsBWb4OuGJdfRfUputDQ1f0q+tmRO834YuiEzq9
19
+ Ekhv8GMQ4KepU6E6d1mbBVSovuDljxpprGDP1Aj/ahiG4vU26gE9IjNFxwlkRPov
20
+ jVgUNVU2iXtd7pAM3EeEIzSFXfoTOGl1sk6UXMlMRyD6rkuIHiM08+7Q6UMdkO49
21
+ fMqF49DeMrlJfY4HBbegAF4dpWNY3SPhFWtOcdtCRF0AplB7HtR5laBsAdHjz3gM
22
+ klk+KNM5vptxWJPIqvXWS4pPudBCwz40gXRGR+BpU0UQiTqp1FiKCgL7DI4/Tm62
23
+ CHNMvwIDAQABozkwNzAJBgNVHRMEAjAAMAsGA1UdDwQEAwIEsDAdBgNVHQ4EFgQU
24
+ DtwNA5H16pAiznZOti8bEjba8tUwDQYJKoZIhvcNAQEFBQADggEBALYguz5G0/OJ
25
+ xT+pCJlgQuU5XbKPx9dibev3ixqDaXz6F3rofNyskUGuCz80pIxwuVjsf7SC/l6x
26
+ iSqV4RZvqrQvgMa2VIQrbIfVya59CyFl+nlENev58nSZHo/3+AOK/rCLrvyRbv+y
27
+ NZocOuJdRiSWjnnRga8ccYA/Hu5OQsqUi3zWcZJx9Pf1yik/TGQBB5fVCg3wc/tT
28
+ 86mx1YMM5+6jp62bpABA/ztg5a1AwPjLztZO+kdsa5JPAe8kEORjgFUQd0bgoG1k
29
+ CGOLg0n36R4a1G+c6Meu9GeNGECbxY/1lzZOU9gfTqKd3DB+14BvAyvc5dTbR/RX
30
+ DrswbWvrKlA=
31
+ -----END CERTIFICATE-----
32
+
33
+ date: 2009-11-13 00:00:00 -08:00
34
+ default_executable:
35
+ dependencies:
36
+ - !ruby/object:Gem::Dependency
37
+ name: hoe
38
+ type: :development
39
+ version_requirement:
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ requirements:
42
+ - - ">="
43
+ - !ruby/object:Gem::Version
44
+ version: 2.3.3
45
+ version:
46
+ description: Easy coloring/markup for terminal output
47
+ email:
48
+ - nick@lemurheavy.com
49
+ executables: []
50
+
51
+ extensions: []
52
+
53
+ extra_rdoc_files:
54
+ - History.txt
55
+ - Manifest.txt
56
+ files:
57
+ - History.txt
58
+ - Manifest.txt
59
+ - README.rdoc
60
+ - Rakefile
61
+ - lib/terminal_markup.rb
62
+ - script/console
63
+ - script/destroy
64
+ - script/generate
65
+ - test/test_helper.rb
66
+ - test/test_terminal_markup.rb
67
+ has_rdoc: true
68
+ homepage: http://lemurheavy.com
69
+ licenses: []
70
+
71
+ post_install_message:
72
+ rdoc_options: []
73
+
74
+ require_paths:
75
+ - lib
76
+ required_ruby_version: !ruby/object:Gem::Requirement
77
+ requirements:
78
+ - - ">="
79
+ - !ruby/object:Gem::Version
80
+ version: "0"
81
+ version:
82
+ required_rubygems_version: !ruby/object:Gem::Requirement
83
+ requirements:
84
+ - - ">="
85
+ - !ruby/object:Gem::Version
86
+ version: "0"
87
+ version:
88
+ requirements: []
89
+
90
+ rubyforge_project: terminal_markup
91
+ rubygems_version: 1.3.5
92
+ signing_key:
93
+ specification_version: 3
94
+ summary: Easy coloring/markup for terminal output
95
+ test_files:
96
+ - test/test_helper.rb
97
+ - test/test_terminal_markup.rb
metadata.gz.sig ADDED
Binary file