hache 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (8) hide show
  1. checksums.yaml +7 -0
  2. data/.gems +1 -0
  3. data/LICENSE +19 -0
  4. data/README.md +21 -0
  5. data/hache.gemspec +14 -0
  6. data/lib/hache.rb +16 -0
  7. data/test/hache.rb +18 -0
  8. metadata +64 -0
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 798b7e68ce464d0abd7473ab0e74d03f1d2f534a
4
+ data.tar.gz: 7dea00c366e428e3006cb7542909c32e37cc0d03
5
+ SHA512:
6
+ metadata.gz: 02aba9da7b52e260723143789303478823df69f28ed0bc9babe173b1915802cc599ee762b1fa5dabf52c0732fd52011ec5406416b012a5c7d13fa07f74071815
7
+ data.tar.gz: 097dae04d84e9911c40f96b747ef764350fa7f170d786fe816c01c8f2721666bb854deed0e9882bd8ba31135d1110c0a5fc2839683a5783537faf09f178baa1f
data/.gems ADDED
@@ -0,0 +1 @@
1
+ cutest -v 1.2.1
data/LICENSE ADDED
@@ -0,0 +1,19 @@
1
+ Copyright (c) 2014 Francesco Rodríguez
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.
@@ -0,0 +1,21 @@
1
+ hache
2
+ =====
3
+
4
+ Escapes HTML tag characters: `&`, `<`, `>`, `"`, `'` and `/`.
5
+
6
+ Usage
7
+ -----
8
+
9
+ ```ruby
10
+ require "hache"
11
+
12
+ Hache.h(%q(<>&"'/)) == "&lt;&gt;&amp;&quot;&#x27;&#x2F;"
13
+ # => true
14
+ ```
15
+
16
+ Installation
17
+ ------------
18
+
19
+ ```bash
20
+ $ gem install hache
21
+ ```
@@ -0,0 +1,14 @@
1
+ Gem::Specification.new do |s|
2
+ s.name = "hache"
3
+ s.version = "1.0.0"
4
+ s.summary = %q(Escapes HTML tag characters: &, <>, ", ', /.)
5
+ s.description = s.summary
6
+ s.authors = ["Francesco Rodríguez"]
7
+ s.email = ["frodsan@me.com"]
8
+ s.homepage = "https://github.com/frodsan/hache"
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,16 @@
1
+ module Hache
2
+ HTML_ESCAPE = {
3
+ "&" => "&amp;",
4
+ ">" => "&gt;",
5
+ "<" => "&lt;",
6
+ '"' => "&quot;",
7
+ "'" => "&#x27;",
8
+ "/" => "&#x2F;"
9
+ }
10
+
11
+ UNSAFE = /[&"'><\/]/
12
+
13
+ def self.h(str)
14
+ str.to_s.gsub(UNSAFE, HTML_ESCAPE)
15
+ end
16
+ end
@@ -0,0 +1,18 @@
1
+ require "cutest"
2
+ require_relative "../lib/hache"
3
+
4
+ def h(str)
5
+ Hache.h(str)
6
+ end
7
+
8
+ test "not escapes safe string" do
9
+ assert_equal "hola", h("hola")
10
+ end
11
+
12
+ test "not raises an error with nil values" do
13
+ assert_equal "", h(nil)
14
+ end
15
+
16
+ test "escapes unsafe characters" do
17
+ assert_equal "&lt;&gt;&amp;&quot;&#x27;&#x2F;", h(%q(<>&"'/))
18
+ end
metadata ADDED
@@ -0,0 +1,64 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: hache
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ platform: ruby
6
+ authors:
7
+ - Francesco Rodríguez
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-03-28 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: cutest
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
+ description: 'Escapes HTML tag characters: &, <>, ", '', /.'
28
+ email:
29
+ - frodsan@me.com
30
+ executables: []
31
+ extensions: []
32
+ extra_rdoc_files: []
33
+ files:
34
+ - .gems
35
+ - LICENSE
36
+ - README.md
37
+ - hache.gemspec
38
+ - lib/hache.rb
39
+ - test/hache.rb
40
+ homepage: https://github.com/frodsan/hache
41
+ licenses:
42
+ - MIT
43
+ metadata: {}
44
+ post_install_message:
45
+ rdoc_options: []
46
+ require_paths:
47
+ - lib
48
+ required_ruby_version: !ruby/object:Gem::Requirement
49
+ requirements:
50
+ - - '>='
51
+ - !ruby/object:Gem::Version
52
+ version: '0'
53
+ required_rubygems_version: !ruby/object:Gem::Requirement
54
+ requirements:
55
+ - - '>='
56
+ - !ruby/object:Gem::Version
57
+ version: '0'
58
+ requirements: []
59
+ rubyforge_project:
60
+ rubygems_version: 2.0.14
61
+ signing_key:
62
+ specification_version: 4
63
+ summary: 'Escapes HTML tag characters: &, <>, ", '', /.'
64
+ test_files: []