kakutani-yaml_waml 0.2.0 → 0.3.0
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/README.rdoc +6 -0
- data/lib/yaml_waml.rb +17 -16
- metadata +2 -2
data/README.rdoc
CHANGED
|
@@ -69,3 +69,9 @@ you must install the following gems:
|
|
|
69
69
|
Akira Ikeda(pinpon.ikeda at gmail.com), http://d.hatena.ne.jp/Rommy
|
|
70
70
|
|
|
71
71
|
Adapted by KAKUTANI Shintaro(shintaro at kakutani.com), http://kakutani.com
|
|
72
|
+
|
|
73
|
+
Thaks for pathes from followings:
|
|
74
|
+
|
|
75
|
+
* OHASHI Hideya (handling StringIO), http://github.com/ohac
|
|
76
|
+
* Nobuhiro IMAI (DRYied, handling IO), http://github.com/no6v
|
|
77
|
+
* Keiji Yoshimi (benchmark script and some advices), http://github.com/walf443
|
data/lib/yaml_waml.rb
CHANGED
|
@@ -6,26 +6,27 @@ class String
|
|
|
6
6
|
end
|
|
7
7
|
end
|
|
8
8
|
|
|
9
|
+
module YamlWaml
|
|
10
|
+
def decode(orig_yamled)
|
|
11
|
+
yamled_str = case orig_yamled
|
|
12
|
+
when String then orig_yamled
|
|
13
|
+
when StringIO then orig_yamled.string
|
|
14
|
+
else return orig_yamled
|
|
15
|
+
end
|
|
16
|
+
yamled_str.gsub!(/\\x(\w{2})/){[$1].pack("H2")}
|
|
17
|
+
return yamled_str
|
|
18
|
+
end
|
|
19
|
+
module_function :decode
|
|
20
|
+
end
|
|
21
|
+
|
|
9
22
|
ObjectSpace.each_object(Class) do |klass|
|
|
10
23
|
klass.class_eval do
|
|
11
24
|
if method_defined?(:to_yaml) && !method_defined?(:to_yaml_with_decode)
|
|
12
25
|
def to_yaml_with_decode(*args)
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
[Regexp.last_match.captures.first.to_i(16)].pack("C")}
|
|
18
|
-
elsif result.kind_of? StringIO
|
|
19
|
-
str = result.string
|
|
20
|
-
# decode to workaround
|
|
21
|
-
str.gsub!(/\\x(\w{2})/){
|
|
22
|
-
[Regexp.last_match.captures.first.to_i(16)].pack("C")}
|
|
23
|
-
result.rewind
|
|
24
|
-
result.write str
|
|
25
|
-
result
|
|
26
|
-
else
|
|
27
|
-
result
|
|
28
|
-
end
|
|
26
|
+
io = args.shift if IO === args.first
|
|
27
|
+
yamled_str = YamlWaml.decode(to_yaml_without_decode(*args))
|
|
28
|
+
io.write(yamled_str) if io
|
|
29
|
+
return yamled_str
|
|
29
30
|
end
|
|
30
31
|
alias_method :to_yaml_without_decode, :to_yaml
|
|
31
32
|
alias_method :to_yaml, :to_yaml_with_decode
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: kakutani-yaml_waml
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.3.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- KAKUTANI Shintaro
|
|
@@ -9,7 +9,7 @@ autorequire:
|
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
11
|
|
|
12
|
-
date: 2008-09-
|
|
12
|
+
date: 2008-09-03 20:00:00 -07:00
|
|
13
13
|
default_executable:
|
|
14
14
|
dependencies: []
|
|
15
15
|
|