dom 0.0.3 → 0.1.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/dom.rb +27 -27
  3. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: d5fa791a4e500fdbd727915ccd58b8762d070543
4
- data.tar.gz: 1906c21e96eed5e55d92bf54aa98b0cce3278759
3
+ metadata.gz: d502864cf12456b53f79f0810160b80a5dfce69b
4
+ data.tar.gz: 4ab11159c2b449d09d8edd5161588b21402cb782
5
5
  SHA512:
6
- metadata.gz: 57a57beacfe0992d5ca6f356aabe9c6aefa6efefac97ba858d3ae2c7be049081c5b11841c9ee3c8b1d02bfa5f40075092454333c77b4c46890afaef5d8db3a87
7
- data.tar.gz: 4ce4864868494e6831319b8cd489a7476127fce1f69c6655975a24282693232bd65502a2cd414c622e784a18b77b7d89f94e093f61df02f4b437c55acd9af06e
6
+ metadata.gz: d44c6cc9cffd641dc1712974fb31a9049db5caf5511d7d0d5535cbc41ae96b09d19841c30f01d455c3ec5cb8fd3ecbc84cc12dcb667ae0a20fcfb7a5a89217fe
7
+ data.tar.gz: 2f40d19e273402bf43da18d89c86ef0e0569ad947d79179f415ae1aed2f8af1627891ca1eeb6621f43cc3a4b3b0808e3b6031b85ecfc7f046739cf5be5b7c4ba
data/lib/dom.rb CHANGED
@@ -1,23 +1,23 @@
1
- require "cgi"
2
- require "stringio"
3
- require "strscan"
1
+ require "cgi".freeze
2
+ require "stringio".freeze
3
+ require "strscan".freeze
4
4
 
5
5
  module Dom
6
6
  def self.compact; singleton_class.class_eval{alias :join :join_compact} end
7
7
  def self.nested; singleton_class.class_eval{alias :join :join_nested} end
8
8
  def self.pre; singleton_class.class_eval{alias :join :join_pre} end
9
- def self.join_compact a, tag, s = ""
9
+ def self.join_compact a, tag, s = "".freeze
10
10
  a.map{|e| e.to_s.escape_html(tag)}.join(s)
11
11
  end
12
12
  def self.join_nested a, tag
13
- "#$/#{join_compact(a, tag, $/).gsub(/^/, " ")}#$/"
13
+ "#$/#{join_compact(a, tag, $/).gsub(/^/, " ".freeze)}#$/"
14
14
  end
15
15
  def self.join_pre a, tag
16
- "<!--#$/#{"-->#{join_compact(a, tag, "<!--#$/-->")}<!--".gsub(/^/, " ")}#$/-->"
16
+ "<!--#$/#{"-->#{join_compact(a, tag, "<!--#$/-->".freeze)}<!--".gsub(/^/, " ".freeze)}#$/-->"
17
17
  end
18
18
  def self.attr h; h.map{|k, v| " #{hyphenize(k)}=\"#{v}\""}.join end
19
19
  def self.json_attr h; Hash[h.map{|k, v| [hyphenize(k), v]}] end
20
- def self.hyphenize sym; sym.to_s.tr("_", "-") end
20
+ def self.hyphenize sym; sym.to_s.tr("_".freeze, "-".freeze) end
21
21
  end
22
22
 
23
23
  module Kernel
@@ -40,31 +40,31 @@ class String
40
40
  def escaped; DomString.new(self) end
41
41
  def jsonml tag, attr = nil; [Dom.hyphenize(tag), *([Dom.json_attr(attr)] if attr), self] end
42
42
  AnsiColor = {
43
- "1" => "bold",
44
- "4" => "underline",
45
- "30" => "black",
46
- "31" => "red",
47
- "32" => "green",
48
- "33" => "yellow",
49
- "34" => "blue",
50
- "35" => "magenta",
51
- "36" => "cyan",
52
- "37" => "white",
53
- "40" => "bg-black",
54
- "41" => "bg-red",
55
- "42" => "bg-green",
56
- "43" => "bg-yellow",
57
- "44" => "bg-blue",
58
- "45" => "bg-magenta",
59
- "46" => "bg-cyan",
60
- "47" => "bg-white",
43
+ "1".freeze => "bold".freeze,
44
+ "4".freeze => "underline".freeze,
45
+ "30".freeze => "black".freeze,
46
+ "31".freeze => "red".freeze,
47
+ "32".freeze => "green".freeze,
48
+ "33".freeze => "yellow".freeze,
49
+ "34".freeze => "blue".freeze,
50
+ "35".freeze => "magenta".freeze,
51
+ "36".freeze => "cyan".freeze,
52
+ "37".freeze => "white".freeze,
53
+ "40".freeze => "bg-black".freeze,
54
+ "41".freeze => "bg-red".freeze,
55
+ "42".freeze => "bg-green".freeze,
56
+ "43".freeze => "bg-yellow".freeze,
57
+ "44".freeze => "bg-blue".freeze,
58
+ "45".freeze => "bg-magenta".freeze,
59
+ "46".freeze => "bg-cyan".freeze,
60
+ "47".freeze => "bg-white".freeze,
61
61
  }
62
62
  def ansi2html
63
63
  ansi = StringScanner.new(self)
64
64
  html = StringIO.new
65
65
  until ansi.eos?
66
66
  if ansi.scan(/\e\[0?m/)
67
- html.print(%{</span>})
67
+ html.print(%{</span>}.freeze)
68
68
  elsif ansi.scan(/\e\[0?(\d+)m/)
69
69
  html.print(%{<span class="#{AnsiColor[ansi[1]]}">})
70
70
  else
@@ -80,7 +80,7 @@ class DomString < String
80
80
  def to_s; self end
81
81
  def escape_html tag; self end
82
82
  # Newline in Javascript terminates the command, causing `Unterminated string literal` error
83
- def escape_ajax; tr($/, "\\\n").to_json end
83
+ def escape_ajax; tr($/, "\\\n".freeze).to_json end
84
84
  end
85
85
 
86
86
  class Array
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dom
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - sawa
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-11-02 00:00:00.000000000 Z
11
+ date: 2013-12-10 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: ''
14
14
  email: []