json-escape 1.0.0

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: 66a639aabf47b6809b62079868c2e6da28166e62
4
+ data.tar.gz: fc76d2e19adba2e1f8075ce3464d3d11085a5c83
5
+ SHA512:
6
+ metadata.gz: a11eddfd0a58afa8faaa5f27b1f778141dbe593418e8c38b82a050bc716cda970ae7bc8c56488927ad06a24c8654505516382bfa995f6af0d918c71bb8841ae4
7
+ data.tar.gz: 3918d8ddec5898bdcd99eb494cd3e070735ad50415a6b91fe3f3471f50d73c750732bb56142d70818b4011394ac33114caa86e21f0661e1fc3890fca1fe71fe5
data/.gems ADDED
@@ -0,0 +1 @@
1
+ cutest -v 1.2.2
data/LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2014-Present Harmoni LLC
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining a copy
4
+ of this software and associated documentation files (the "Software"), to deal
5
+ in the Software without restriction, including without limitation the rights
6
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7
+ copies of the Software, and to permit persons to whom the Software is
8
+ furnished to do so, subject to the following conditions:
9
+
10
+ The above copyright notice and this permission notice shall be included in
11
+ all copies or substantial portions of the Software.
12
+
13
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19
+ THE SOFTWARE.
20
+
@@ -0,0 +1,19 @@
1
+ # JSON Escape
2
+
3
+ Escapes JSON special characters: `&`, `<` and `>`.
4
+
5
+ ## Usage
6
+
7
+ ```ruby
8
+ require "json_escape"
9
+
10
+ JsonEscape.escape("&><") == '\u0026\u003e\u003c'
11
+ # => true
12
+ ```
13
+
14
+ ## Installation
15
+
16
+ ```bash
17
+ $ gem install json-escape
18
+ ```
19
+
@@ -0,0 +1,14 @@
1
+ Gem::Specification.new do |s|
2
+ s.name = "json-escape"
3
+ s.version = "1.0.0"
4
+ s.summary = "Escapes JSON special characters: &, <>"
5
+ s.description = s.summary
6
+ s.authors = ["Francesco Rodríguez", "Mayn Kjær"]
7
+ s.email = ["frodsan@me.com", "mayn.kjaer@gmail.com"]
8
+ s.homepage = "https://github.com/harmoni/json-escape"
9
+ s.license = "MIT"
10
+
11
+ s.files = `git ls-files`.split("\n")
12
+
13
+ s.add_development_dependency "cutest"
14
+ end
@@ -0,0 +1,13 @@
1
+ module JsonEscape
2
+ JSON_ESCAPE = {
3
+ "&" => '\u0026',
4
+ "<" => '\u003c',
5
+ ">" => '\u003e'
6
+ }
7
+
8
+ UNSAFE = /[&><]/
9
+
10
+ def self.escape(s)
11
+ s.to_str.gsub(UNSAFE, JSON_ESCAPE)
12
+ end
13
+ end
@@ -0,0 +1,7 @@
1
+ DEFAULT_GOAL := test
2
+ .PHONY: test
3
+ gem:
4
+ gem build *.gemspec
5
+ test:
6
+ cutest test/*.rb
7
+
@@ -0,0 +1,6 @@
1
+ require "cutest"
2
+ require_relative "../lib/json_escape"
3
+
4
+ test "escape unsafe characters" do
5
+ assert_equal('\u0026\u003e\u003c', JsonEscape.escape("&><"))
6
+ end
metadata ADDED
@@ -0,0 +1,67 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: json-escape
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ platform: ruby
6
+ authors:
7
+ - Francesco Rodríguez
8
+ - Mayn Kjær
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2015-02-10 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: cutest
16
+ requirement: !ruby/object:Gem::Requirement
17
+ requirements:
18
+ - - ">="
19
+ - !ruby/object:Gem::Version
20
+ version: '0'
21
+ type: :development
22
+ prerelease: false
23
+ version_requirements: !ruby/object:Gem::Requirement
24
+ requirements:
25
+ - - ">="
26
+ - !ruby/object:Gem::Version
27
+ version: '0'
28
+ description: 'Escapes JSON special characters: &, <>'
29
+ email:
30
+ - frodsan@me.com
31
+ - mayn.kjaer@gmail.com
32
+ executables: []
33
+ extensions: []
34
+ extra_rdoc_files: []
35
+ files:
36
+ - ".gems"
37
+ - LICENSE
38
+ - README.md
39
+ - json-escape.gemspec
40
+ - lib/json_escape.rb
41
+ - makefile
42
+ - test/json_escape.rb
43
+ homepage: https://github.com/harmoni/json-escape
44
+ licenses:
45
+ - MIT
46
+ metadata: {}
47
+ post_install_message:
48
+ rdoc_options: []
49
+ require_paths:
50
+ - lib
51
+ required_ruby_version: !ruby/object:Gem::Requirement
52
+ requirements:
53
+ - - ">="
54
+ - !ruby/object:Gem::Version
55
+ version: '0'
56
+ required_rubygems_version: !ruby/object:Gem::Requirement
57
+ requirements:
58
+ - - ">="
59
+ - !ruby/object:Gem::Version
60
+ version: '0'
61
+ requirements: []
62
+ rubyforge_project:
63
+ rubygems_version: 2.4.5
64
+ signing_key:
65
+ specification_version: 4
66
+ summary: 'Escapes JSON special characters: &, <>'
67
+ test_files: []