string-undump 0.0.1 → 0.0.2

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: a96a75247a20eaf38e57b3dbb246715b4d948471
4
- data.tar.gz: c370d6a94ea1348901b2652f58848e5cde9a3472
3
+ metadata.gz: 72bd5bdb5c55d015ba3aa28c6ee478d2938c960b
4
+ data.tar.gz: b234a9651491a276593523e3179a86639d93ba0f
5
5
  SHA512:
6
- metadata.gz: 5bee820d2b799c1d0b9d36cd58808d81c45a4018d9157d23727a3cc66e943ece4210cbe77461c359c40f86aa68956d4c40272197e254ef86d585f2adc587b15a
7
- data.tar.gz: 17ec9c68f7949ef24a8aac3cb809410f328cb58d4eb05b8950864a7dc02f55f578162af08a9067f2d0c880465698896985e4ac88da2cb3361a119c04a1c030c3
6
+ metadata.gz: 64f95dbd47160cf23c17a73ab4877a3987bc963212462f9c40b934e7cb1712c25b59517cde2e0c8f6aa18ae670b46b527706efaf2c7aa757da096d11800053dd
7
+ data.tar.gz: e0c46d40310507fef76470f62ba25f208dd410e10d1d6462b96a50b4d1ceddea2b1168d3a505608bb941e52f550077c9291caf1dd0ebbb846e4385d1ff3c651c
data/README.md CHANGED
@@ -1,6 +1,7 @@
1
1
  # String#undump
2
2
 
3
- Does inverse of String#dump. See [#12275](https://bugs.ruby-lang.org/issues/12275) for details.
3
+ Unofficial implementation of String#undump, does inverse of String#dump.
4
+ See [Feature #12275](https://bugs.ruby-lang.org/issues/12275) for details.
4
5
 
5
6
  ## Usage
6
7
 
@@ -33,3 +34,7 @@ Or install it yourself as:
33
34
  ## Contributing
34
35
 
35
36
  Bug reports and pull requests are welcome on GitHub at https://github.com/tadd/string-undump.
37
+
38
+ ## License
39
+
40
+ Ruby's. See [COPYING](COPYING).
data/lib/string-undump.rb CHANGED
@@ -1,5 +1,4 @@
1
1
  class String
2
- # todo: eval in '\#{some_code}' or '\#@var' or '\#$var' ???
3
2
  def undump_badly
4
3
  hex = /[0-9a-fA-F]/
5
4
  esctable = {
@@ -18,6 +17,9 @@ class String
18
17
  else
19
18
  self.dup
20
19
  end
20
+ s.gsub!(/\\\#\$/, '#$')
21
+ s.gsub!(/\\\#@/, '#@')
22
+ s.gsub!(/\\\#{/, '#{')
21
23
  s.gsub!(/\\"/, '"')
22
24
  s.gsub!(/\\\\/, '\\')
23
25
  s.gsub!(/\\[nrtfvbae]/) {|m| esctable[m]}
@@ -1,16 +1,17 @@
1
1
  Gem::Specification.new do |spec|
2
2
  spec.name = "string-undump"
3
- spec.version = '0.0.1'
3
+ spec.version = '0.0.2'
4
4
  spec.authors = ["Tadashi Saito"]
5
5
  spec.email = ["tad.a.digger@gmail.com"]
6
6
 
7
7
  spec.summary = 'String#undump'
8
- spec.description = 'Does inverse of String#dump'
8
+ spec.description = 'Unofficial implementation of String#undump, does inverse of String#dump'
9
9
  spec.homepage = 'https://github.com/tadd/string-undump'
10
+ spec.license = "Ruby's"
10
11
 
11
- spec.files = `git ls-files -z`.split("\x0").reject do |f|
12
- f.match(%r{^(test|spec|features)/})
13
- end
12
+ files = `git ls-files -z`.split("\x0")
13
+ spec.files = files.reject {|f| f.match(%r{^(test|spec|features)/})}
14
+ spec.test_files = files.grep(%r{^(test|spec|features)/})
14
15
  spec.require_paths = ["lib"]
15
16
 
16
17
  spec.add_development_dependency "bundler"
@@ -0,0 +1,21 @@
1
+ require 'test-unit'
2
+
3
+ require_relative '../lib/string-undump'
4
+
5
+ class TestUndump < Test::Unit::TestCase
6
+ def test_undump_badly
7
+ assert_equal('foo', '"foo"'.undump_badly)
8
+ assert_equal('foo#$bar#@baz#{quxx}', 'foo\#$bar\#@baz\#{quxx}'.undump_badly)
9
+ assert_equal(%(\\"\n), '\\\\\\"\n'.undump_badly)
10
+ assert_equal('すごーい', '\u3059\u3054\u30FC\u3044'.undump_badly)
11
+ assert_equal('たのしー', '\xE3\x81\x9F\xE3\x81\xAE\xE3\x81\x97\xE3\x83\xBC'.undump_badly)
12
+ assert_equal('🐾', '\u{1F43E}'.undump_badly)
13
+ assert_equal(%(すごーい\\🐾たのしー\n\#{foo}),
14
+ ('"\u3059\u3054\u30FC\u3044\\\\\u{1F43E}' +
15
+ '\xE3\x81\x9F\xE3\x81\xAE\xE3\x81\x97\xE3\x83\xBC\\n\#{foo}"').undump_badly)
16
+ end
17
+
18
+ def test_undump
19
+ assert_includes(String.instance_methods, :undump)
20
+ end
21
+ end
@@ -0,0 +1,11 @@
1
+ # encoding: euc-jp
2
+ require 'test-unit'
3
+
4
+ require_relative '../lib/string-undump'
5
+
6
+ class TestUndumpEucJp < Test::Unit::TestCase
7
+ def test_undump_badly
8
+ assert_equal('��������', '\xA4\xB9\xA4\xB4\xA1\xBC\xA4\xA4'.undump_badly)
9
+ assert_equal('������', '\x{A4BF}\x{A4CE}\x{A4B7}\x{A1BC}'.undump_badly)
10
+ end
11
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: string-undump
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tadashi Saito
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-04-12 00:00:00.000000000 Z
11
+ date: 2017-04-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -52,7 +52,7 @@ dependencies:
52
52
  - - ">="
53
53
  - !ruby/object:Gem::Version
54
54
  version: '0'
55
- description: Does inverse of String#dump
55
+ description: Unofficial implementation of String#undump, does inverse of String#dump
56
56
  email:
57
57
  - tad.a.digger@gmail.com
58
58
  executables: []
@@ -67,8 +67,11 @@ files:
67
67
  - Rakefile
68
68
  - lib/string-undump.rb
69
69
  - string-undump.gemspec
70
+ - test/test_undump.rb
71
+ - test/test_undump_euc-jp.rb
70
72
  homepage: https://github.com/tadd/string-undump
71
- licenses: []
73
+ licenses:
74
+ - Ruby's
72
75
  metadata: {}
73
76
  post_install_message:
74
77
  rdoc_options: []
@@ -90,4 +93,6 @@ rubygems_version: 2.6.11
90
93
  signing_key:
91
94
  specification_version: 4
92
95
  summary: String#undump
93
- test_files: []
96
+ test_files:
97
+ - test/test_undump.rb
98
+ - test/test_undump_euc-jp.rb