string-undump 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: a96a75247a20eaf38e57b3dbb246715b4d948471
4
+ data.tar.gz: c370d6a94ea1348901b2652f58848e5cde9a3472
5
+ SHA512:
6
+ metadata.gz: 5bee820d2b799c1d0b9d36cd58808d81c45a4018d9157d23727a3cc66e943ece4210cbe77461c359c40f86aa68956d4c40272197e254ef86d585f2adc587b15a
7
+ data.tar.gz: 17ec9c68f7949ef24a8aac3cb809410f328cb58d4eb05b8950864a7dc02f55f578162af08a9067f2d0c880465698896985e4ac88da2cb3361a119c04a1c030c3
@@ -0,0 +1 @@
1
+ /pkg/
data/BSDL ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (C) 2017- Tadashi Saito. All rights reserved.
2
+
3
+ Redistribution and use in source and binary forms, with or without
4
+ modification, are permitted provided that the following conditions
5
+ are met:
6
+ 1. Redistributions of source code must retain the above copyright
7
+ notice, this list of conditions and the following disclaimer.
8
+ 2. Redistributions in binary form must reproduce the above copyright
9
+ notice, this list of conditions and the following disclaimer in the
10
+ documentation and/or other materials provided with the distribution.
11
+
12
+ THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
13
+ ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
14
+ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
15
+ ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
16
+ FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
17
+ DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
18
+ OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
19
+ HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
20
+ LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
21
+ OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
22
+ SUCH DAMAGE.
data/COPYING ADDED
@@ -0,0 +1,56 @@
1
+ String#undump is copyrighted free software by Tadashi Saito <tad.a.digger@gmail.com>.
2
+ You can redistribute it and/or modify it under either the terms of the
3
+ 2-clause BSDL (see the file BSDL), or the conditions below:
4
+
5
+ 1. You may make and give away verbatim copies of the source form of the
6
+ software without restriction, provided that you duplicate all of the
7
+ original copyright notices and associated disclaimers.
8
+
9
+ 2. You may modify your copy of the software in any way, provided that
10
+ you do at least ONE of the following:
11
+
12
+ a) place your modifications in the Public Domain or otherwise
13
+ make them Freely Available, such as by posting said
14
+ modifications to Usenet or an equivalent medium, or by allowing
15
+ the author to include your modifications in the software.
16
+
17
+ b) use the modified software only within your corporation or
18
+ organization.
19
+
20
+ c) give non-standard binaries non-standard names, with
21
+ instructions on where to get the original software distribution.
22
+
23
+ d) make other distribution arrangements with the author.
24
+
25
+ 3. You may distribute the software in object code or binary form,
26
+ provided that you do at least ONE of the following:
27
+
28
+ a) distribute the binaries and library files of the software,
29
+ together with instructions (in the manual page or equivalent)
30
+ on where to get the original distribution.
31
+
32
+ b) accompany the distribution with the machine-readable source of
33
+ the software.
34
+
35
+ c) give non-standard binaries non-standard names, with
36
+ instructions on where to get the original software distribution.
37
+
38
+ d) make other distribution arrangements with the author.
39
+
40
+ 4. You may modify and include the part of the software into any other
41
+ software (possibly commercial). But some files in the distribution
42
+ are not written by the author, so that they are not under these terms.
43
+
44
+ For the list of those files and their copying conditions, see the
45
+ file LEGAL.
46
+
47
+ 5. The scripts and library files supplied as input to or produced as
48
+ output from the software do not automatically fall under the
49
+ copyright of the software, but belong to whomever generated them,
50
+ and may be sold commercially, and may be aggregated with this
51
+ software.
52
+
53
+ 6. THIS SOFTWARE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR
54
+ IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
55
+ WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
56
+ PURPOSE.
data/Gemfile ADDED
@@ -0,0 +1,3 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gemspec
@@ -0,0 +1,35 @@
1
+ # String#undump
2
+
3
+ Does inverse of String#dump. See [#12275](https://bugs.ruby-lang.org/issues/12275) for details.
4
+
5
+ ## Usage
6
+
7
+ ```ruby
8
+ require 'string-undump'
9
+
10
+ puts '\u3059\u3054\u30FC\u3044'.undump #=> すごーい
11
+ puts '\xE3\x81\x9F\xE3\x81\xAE\xE3\x81\x97\xE3\x83\xBC'.undump #=> たのしー
12
+ puts '\u{1F43E}'.undump #=> 🐾
13
+ ```
14
+
15
+ See [testcase](https://github.com/tadd/string-undump/blob/master/test/test_undump.rb) also.
16
+
17
+ ## Installation
18
+
19
+ Add this line to your application's Gemfile:
20
+
21
+ ```ruby
22
+ gem 'string-undump'
23
+ ```
24
+
25
+ And then execute:
26
+
27
+ $ bundle
28
+
29
+ Or install it yourself as:
30
+
31
+ $ gem install string-undump
32
+
33
+ ## Contributing
34
+
35
+ Bug reports and pull requests are welcome on GitHub at https://github.com/tadd/string-undump.
@@ -0,0 +1,6 @@
1
+ require "bundler/gem_tasks"
2
+ require 'rake/testtask'
3
+
4
+ Rake::TestTask.new {|t| t.libs << 'test' }
5
+
6
+ task :default => :test
@@ -0,0 +1,33 @@
1
+ class String
2
+ # todo: eval in '\#{some_code}' or '\#@var' or '\#$var' ???
3
+ def undump_badly
4
+ hex = /[0-9a-fA-F]/
5
+ esctable = {
6
+ '\n' => "\n",
7
+ '\r' => "\r",
8
+ '\t' => "\t",
9
+ '\f' => "\f",
10
+ '\v' => "\v",
11
+ '\b' => "\b",
12
+ '\a' => "\a",
13
+ '\e' => "\e",
14
+ }
15
+ e = self.encoding
16
+ s = if self[0] == '"' && self[-1] == '"'
17
+ self[1..-2]
18
+ else
19
+ self.dup
20
+ end
21
+ s.gsub!(/\\"/, '"')
22
+ s.gsub!(/\\\\/, '\\')
23
+ s.gsub!(/\\[nrtfvbae]/) {|m| esctable[m]}
24
+ s.gsub!(/\\u#{hex}{4}/) {|m| m[2..-1].hex.chr(e)}
25
+ s.gsub!(/\\[ux]{#{hex}+}/) {|m| m[3..-1].hex.chr(e)}
26
+ s.gsub!(/(?:\\x#{hex}{2})+/) {|m|
27
+ m.gsub(/\\x/, '').scan(/../).map(&:hex).pack("C*").force_encoding(e)
28
+ }
29
+ s
30
+ end
31
+
32
+ alias_method(:undump, :undump_badly) unless self.new.respond_to?(:undump)
33
+ end
@@ -0,0 +1,19 @@
1
+ Gem::Specification.new do |spec|
2
+ spec.name = "string-undump"
3
+ spec.version = '0.0.1'
4
+ spec.authors = ["Tadashi Saito"]
5
+ spec.email = ["tad.a.digger@gmail.com"]
6
+
7
+ spec.summary = 'String#undump'
8
+ spec.description = 'Does inverse of String#dump'
9
+ spec.homepage = 'https://github.com/tadd/string-undump'
10
+
11
+ spec.files = `git ls-files -z`.split("\x0").reject do |f|
12
+ f.match(%r{^(test|spec|features)/})
13
+ end
14
+ spec.require_paths = ["lib"]
15
+
16
+ spec.add_development_dependency "bundler"
17
+ spec.add_development_dependency "rake"
18
+ spec.add_development_dependency "test-unit"
19
+ end
metadata ADDED
@@ -0,0 +1,93 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: string-undump
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Tadashi Saito
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2017-04-12 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: test-unit
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ description: Does inverse of String#dump
56
+ email:
57
+ - tad.a.digger@gmail.com
58
+ executables: []
59
+ extensions: []
60
+ extra_rdoc_files: []
61
+ files:
62
+ - ".gitignore"
63
+ - BSDL
64
+ - COPYING
65
+ - Gemfile
66
+ - README.md
67
+ - Rakefile
68
+ - lib/string-undump.rb
69
+ - string-undump.gemspec
70
+ homepage: https://github.com/tadd/string-undump
71
+ licenses: []
72
+ metadata: {}
73
+ post_install_message:
74
+ rdoc_options: []
75
+ require_paths:
76
+ - lib
77
+ required_ruby_version: !ruby/object:Gem::Requirement
78
+ requirements:
79
+ - - ">="
80
+ - !ruby/object:Gem::Version
81
+ version: '0'
82
+ required_rubygems_version: !ruby/object:Gem::Requirement
83
+ requirements:
84
+ - - ">="
85
+ - !ruby/object:Gem::Version
86
+ version: '0'
87
+ requirements: []
88
+ rubyforge_project:
89
+ rubygems_version: 2.6.11
90
+ signing_key:
91
+ specification_version: 4
92
+ summary: String#undump
93
+ test_files: []