hache 1.1.0 → 1.1.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 0b9f5c147e9e42d09d6542a90d5078fda2dae3e6
4
- data.tar.gz: 0a40d7774cbd300f116e9ffc66124592833589dc
3
+ metadata.gz: 7dda5800d3b2cdb69cbceffaf5387a8bf47b2676
4
+ data.tar.gz: ffbccf68d39d5d1b0f1de3d2d6babb3c4b7b696a
5
5
  SHA512:
6
- metadata.gz: 9089048bab221a9b99ea953cf2955e19394c2ccbe07c422cb4780c392f330fed13f0a97245a7b094a078e03aa1ba51eb2f7009969ef4ba2eb6c14b6620218494
7
- data.tar.gz: 84bce11cf3bf4977504b05e0a726f9c93213cafc927d48d11a05ee40cf6bd137cd1ea952a207fc93de9c94582800df341bee30fc70a8c5cb3c1d5c7b6215358e
6
+ metadata.gz: 895d47f6f136787e20a9fb183d7e58638926fd55d681af21b01c3889c946ddd1ec90f9a7f35eabebe1838adb2d756c11cea68a25c94d4920240f81f8df407ae0
7
+ data.tar.gz: 19f650add5fd21a8f5678db99da6fed858f79a31410169aae9f555a5136fadc40711f21e01a84a82d9a9ceda231b53e870d897fdbe48a77af1380a84cfa35ce2
data/LICENSE CHANGED
@@ -1,4 +1,4 @@
1
- Copyright (c) 2014 Francesco Rodríguez
1
+ Copyright (c) 2014-2016 Francesco Rodríguez
2
2
 
3
3
  Permission is hereby granted, free of charge, to any person obtaining a copy
4
4
  of this software and associated documentation files (the "Software"), to deal
data/README.md CHANGED
@@ -1,8 +1,29 @@
1
- hache
1
+ Hache [![Build Status](https://gitlab.com/frodsan/hache/badges/master/build.svg)](https://gitlab.com/frodsan/hache/builds)
2
2
  =====
3
3
 
4
4
  Escapes HTML tag characters: `&`, `<`, `>`, `"`, `'` and `/`.
5
5
 
6
+ Installation
7
+ ------------
8
+
9
+ Add this line to your application's Gemfile:
10
+
11
+ ```ruby
12
+ gem "hache"
13
+ ```
14
+
15
+ And then execute:
16
+
17
+ ```
18
+ $ bundle
19
+ ```
20
+
21
+ Or install it yourself as:
22
+
23
+ ```
24
+ $ gem install hache
25
+ ```
26
+
6
27
  Usage
7
28
  -----
8
29
 
@@ -13,9 +34,33 @@ Hache.h(%q(<>&"'/)) == "&lt;&gt;&amp;&quot;&#x27;&#x2F;"
13
34
  # => true
14
35
  ```
15
36
 
16
- Installation
37
+ Contributing
17
38
  ------------
18
39
 
19
- ```bash
20
- $ gem install hache
40
+ Fork the project with:
41
+
42
+ ```
43
+ $ git clone git@gitlab.com:frodsan/hache.git
44
+ ```
45
+
46
+ To install dependencies, use:
47
+
48
+ ```
49
+ $ bundle install
21
50
  ```
51
+
52
+ To run the test suite, do:
53
+
54
+ ```
55
+ $ rake test
56
+ ```
57
+
58
+ For bug reports and pull requests use [GitLab][issues].
59
+
60
+ License
61
+ -------
62
+
63
+ Hache is released under the [MIT License][mit].
64
+
65
+ [mit]: http://www.opensource.org/licenses/MIT
66
+ [issues]: https://gitlab.com/frodsan/hache/issues
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Hache
2
4
  HTML_ESCAPE = {
3
5
  "&" => "&amp;",
@@ -6,7 +8,7 @@ module Hache
6
8
  '"' => "&quot;",
7
9
  "'" => "&#x27;",
8
10
  "/" => "&#x2F;"
9
- }
11
+ }.freeze
10
12
 
11
13
  UNSAFE = /[&"'><\/]/
12
14
 
@@ -0,0 +1,17 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "bundler/setup"
4
+ require "minitest/autorun"
5
+ require "minitest/pride"
6
+ require "minitest/sugar"
7
+ require_relative "../lib/hache"
8
+
9
+ class HacheTest < Minitest::Test
10
+ test "not escapes safe string" do
11
+ assert_equal "hola", Hache.h("hola")
12
+ end
13
+
14
+ test "escapes unsafe characters" do
15
+ assert_equal "&lt;&gt;&amp;&quot;&#x27;&#x2F;", Hache.h(%q(<>&"'/))
16
+ end
17
+ end
metadata CHANGED
@@ -1,44 +1,82 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hache
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.0
4
+ version: 1.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Francesco Rodríguez
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-03-31 00:00:00.000000000 Z
11
+ date: 2016-04-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
- name: cutest
14
+ name: minitest
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - '>='
17
+ - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '0'
19
+ version: '5.8'
20
20
  type: :development
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - '>='
24
+ - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: '0'
26
+ version: '5.8'
27
+ - !ruby/object:Gem::Dependency
28
+ name: minitest-sugar
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '2.1'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '2.1'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rake
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '10.0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '10.0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rubocop
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '0.39'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '0.39'
27
69
  description: 'Escapes HTML tag characters: &, <>, ", '', /.'
28
- email:
29
- - frodsan@me.com
70
+ email: hello@frodsan.com
30
71
  executables: []
31
72
  extensions: []
32
73
  extra_rdoc_files: []
33
74
  files:
34
- - .gems
35
75
  - LICENSE
36
76
  - README.md
37
- - benchmarks/escaping.rb
38
- - hache.gemspec
39
77
  - lib/hache.rb
40
- - test/hache.rb
41
- homepage: https://github.com/frodsan/hache
78
+ - test/hache_test.rb
79
+ homepage: https://gitlab.com/frodsan/hache
42
80
  licenses:
43
81
  - MIT
44
82
  metadata: {}
@@ -48,18 +86,19 @@ require_paths:
48
86
  - lib
49
87
  required_ruby_version: !ruby/object:Gem::Requirement
50
88
  requirements:
51
- - - '>='
89
+ - - ">="
52
90
  - !ruby/object:Gem::Version
53
91
  version: '0'
54
92
  required_rubygems_version: !ruby/object:Gem::Requirement
55
93
  requirements:
56
- - - '>='
94
+ - - ">="
57
95
  - !ruby/object:Gem::Version
58
96
  version: '0'
59
97
  requirements: []
60
98
  rubyforge_project:
61
- rubygems_version: 2.0.14
99
+ rubygems_version: 2.5.1
62
100
  signing_key:
63
101
  specification_version: 4
64
102
  summary: 'Escapes HTML tag characters: &, <>, ", '', /.'
65
- test_files: []
103
+ test_files:
104
+ - test/hache_test.rb
data/.gems DELETED
@@ -1 +0,0 @@
1
- cutest -v 1.2.1
@@ -1,20 +0,0 @@
1
- require "benchmark/ips"
2
- require "rack/utils"
3
- require_relative "../lib/hache"
4
-
5
- text = %q(some < text > inside & these " escapable' characters/1234)
6
-
7
- Benchmark.ips do |x|
8
- x.report("encode") { text.encode(xml: :text) } # encode doesn't escape `'`, `"` and `/`.
9
- x.report("rack") { Rack::Utils.escape_html(text) }
10
- x.report("hache") { Hache.h(text) }
11
- end
12
-
13
- # Calculating -------------------------------------
14
- # encode 16385 i/100ms
15
- # rack 9626 i/100ms
16
- # hache 10211 i/100ms
17
- # -------------------------------------------------
18
- # encode 241085.8 (±11.8%) i/s - 1163335 in 5.004123s
19
- # rack 127905.8 (±4.5%) i/s - 644942 in 5.053418s
20
- # hache 153666.9 (±11.5%) i/s - 745403 in 5.056082s
@@ -1,14 +0,0 @@
1
- Gem::Specification.new do |s|
2
- s.name = "hache"
3
- s.version = "1.1.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
@@ -1,10 +0,0 @@
1
- require "cutest"
2
- require_relative "../lib/hache"
3
-
4
- test "not escapes safe string" do
5
- assert_equal "hola", Hache.h("hola")
6
- end
7
-
8
- test "escapes unsafe characters" do
9
- assert_equal "&lt;&gt;&amp;&quot;&#x27;&#x2F;", Hache.h(%q(<>&"'/))
10
- end