term-colorizer 0.1.1 → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- Y2JiMWVhMjllYmIzYzM3NjdiMmQ1M2VhNTdlMjQ1OGQwYjY4ZDZiYw==
4
+ YmIyYTkwODI1YTNhZWQ5ZmZmYTNiYzU1YWJjZDY0N2ExYWQxNDdjZg==
5
5
  data.tar.gz: !binary |-
6
- MTZlYTYzMTcxZDZmOWM3MmIzY2RlOGZlNGUyNGY2ZDQyZWY3YjA5Mg==
6
+ NWFjN2JjNjRhZGViOTczYjRjNDdlMGVmOGNiNTMwZjNhNzg3ZjZlMw==
7
7
  !binary "U0hBNTEy":
8
8
  metadata.gz: !binary |-
9
- ZWQxYmIyYjBmYzBlZTQ1MDMwYzk2YjI5NGE3NDZjMDllZTY3MTU1MmE5NTY2
10
- YmFiZTQ4ZDNiZTdiZWRjNjc2OWVkYjQxNzBlMGEzMDI1NmVmOWM1MjQzNTRk
11
- YTY1ODkyOWNhMTNkOWJkM2IwNmIxOTIyYjU5MTQ1Y2I5YmViZjc=
9
+ ZjE0MGY3MjQzNjdiODI0NTZmOWQ0N2U4ZTZlMmU3M2M5MDY3NmIwNzNhMzQ1
10
+ NjMyMzEyNDI5NzE4OTk2YmM3YmUwMjdlZGI5NDgwMThjOTFmODM2YjljYTMz
11
+ NDcyZTAzZDYwNzA4ODIyNTBiYThmZjE4MTFjM2E5MmE4NDIxNzY=
12
12
  data.tar.gz: !binary |-
13
- YWE5MmJhYmFkOTlmMTE1MjYxODY4Yzc2NTZiMWQzMTlhMDEzZDMyZDc4Mjlj
14
- OGZlZDc2ZjY4N2FkZDhkOGY2OThiZDQ4ZDkyNTYwYzdiZDg3NmJiYjI4YWZh
15
- YzAwM2RlYTI0Y2E2NDdkNWRkYmQ0MTdmY2UzMGJlZDY3NjEwYmI=
13
+ NWI4MzU3M2M3NDk3MTNmYjUyODIxMzg5OGFmYTk0M2ViZThkNWEwMDI5YmJh
14
+ ODg5YzUxYjg2ODk3ODMwYmZiNDkyZDEyOWY2N2QxMGUxNTI2MWM3OTJkNTY2
15
+ MGNiMjAzOTAzMjY4ZTBhOGEzNTA5MGFhZDIwYWI3YjQ4NTBiYTU=
data/CHANGELOG.md CHANGED
@@ -1,7 +1,11 @@
1
- ### 0.1.2 (Next Release)
1
+ ### 0.1.3 (Next Release)
2
2
 
3
3
  * Your contribution here.
4
4
 
5
+ ### 0.1.2 (7/22/2013)
6
+
7
+ * Created a hash for terminal color, and used it inside method_missing to define color methods on the fly when called. - [@vishaltelangre](https://github.com/vishaltelangre).
8
+
5
9
  ### 0.1.1 (7/13/2013)
6
10
 
7
11
  * Logic changed to dynamically define and call the color methods on strings - [@vishaltelangre](https://github.com/vishaltelangre).
@@ -1,33 +1,28 @@
1
1
  module Term
2
2
  module Colorizer
3
- TERM_COLORS = %w{
4
- black red green yellow blue magenta cyan white bright_black
5
- bright_red bright_green bright_yellow bright_blue bright_magenta
6
- bright_cyan bright_white
7
- }
3
+ TERM_COLORS = {
4
+ :black => "\e[30mSTR\e[0m",
5
+ :red => "\e[31mSTR\e[0m",
6
+ :green => "\e[32mSTR\e[0m",
7
+ :yellow => "\e[33mSTR\e[0m",
8
+ :blue => "\e[34mSTR\e[0m",
9
+ :magenta => "\e[35mSTR\e[0m",
10
+ :cyan => "\e[36mSTR\e[0m",
11
+ :white => "\e[37mSTR\e[0m",
12
+ :bright_black => "\e[1m\e[30mSTR\e[0m",
13
+ :bright_red => "\e[1m\e[31mSTR\e[0m",
14
+ :bright_green => "\e[1m\e[32mSTR\e[0m",
15
+ :bright_yellow => "\e[1m\e[33mSTR\e[0m",
16
+ :bright_blue => "\e[1m\e[34mSTR\e[0m",
17
+ :bright_magenta => "\e[1m\e[35mSTR\e[0m",
18
+ :bright_cyan => "\e[1m\e[36mSTR\e[0m",
19
+ :bright_white => "\e[1m\e[37mSTR\e[0m"
20
+ }
8
21
 
9
- def method_missing(sym, *args, &block)
10
- method = sym.to_s
11
- super unless TERM_COLORS.include? method
22
+ def method_missing(method, *args, &block)
23
+ super unless TERM_COLORS.keys.include? method
12
24
  self.class.send(:define_method, method) do
13
- case method
14
- when "black" then "\e[30m" + self.to_s + "\e[0m"
15
- when "red" then "\e[31m" + self.to_s + "\e[0m"
16
- when "green" then "\e[32m" + self.to_s + "\e[0m"
17
- when "yellow" then "\e[33m" + self.to_s + "\e[0m"
18
- when "blue" then "\e[34m" + self.to_s + "\e[0m"
19
- when "magenta" then "\e[35m" + self.to_s + "\e[0m"
20
- when "cyan" then "\e[36m" + self.to_s + "\e[0m"
21
- when "white" then "\e[37m" + self.to_s + "\e[0m"
22
- when "bright_black" then "\e[1m\e[30m" + self.to_s + "\e[0m"
23
- when "bright_red" then "\e[1m\e[31m" + self.to_s + "\e[0m"
24
- when "bright_green" then "\e[1m\e[32m" + self.to_s + "\e[0m"
25
- when "bright_yellow" then "\e[1m\e[33m" + self.to_s + "\e[0m"
26
- when "bright_blue" then "\e[1m\e[34m" + self.to_s + "\e[0m"
27
- when "bright_magenta" then "\e[1m\e[35m" + self.to_s + "\e[0m"
28
- when "bright_cyan" then "\e[1m\e[36m" + self.to_s + "\e[0m"
29
- when "bright_white" then "\e[1m\e[37m" + self.to_s + "\e[0m"
30
- end
25
+ TERM_COLORS[method].sub(/STR/, self.to_s)
31
26
  end and self.send(method, *args)
32
27
  end
33
28
  end
@@ -1,5 +1,5 @@
1
1
  module Term
2
2
  module Colorizer
3
- VERSION = '0.1.1'
3
+ VERSION = '0.1.2'
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: term-colorizer
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Vishal Telangre
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-07-13 00:00:00.000000000 Z
11
+ date: 2013-07-22 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description:
14
14
  email: the@vishaltelangre.com