api_hammer 0.9.2 → 0.10.0

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: 25094fc3ff153feb9e2ac93c7c25a0e46d3143eb
4
- data.tar.gz: 42cbb9d5226111853163fd94043cd33ee16eee70
3
+ metadata.gz: 7fac5905a852166ba5ac4e8423ae29462b48bf94
4
+ data.tar.gz: 0e2e44ca6c35a242c77bd91a7e622f37fbeca59a
5
5
  SHA512:
6
- metadata.gz: f2b197a3c690c2e77a5cbebfcca7b6f98cbc1c4e5d7883a2cc1af545934be7433e58c5910eeffb77110e1da308a8753b993d5d2c683999192e18b178b4f26701
7
- data.tar.gz: 351a18b0ac2e23726b7614743f7097402a17330d80a30a81fa2cb418791bd8a598d682eba94947ce9529d92d1bcdc02b5f4f25d99bc43a60ab2b769c177211d7
6
+ metadata.gz: 2c5c51de80f7b2b5289bb147f22b1e5eecd63e9aed9edf08e81bd6401853a9289ac686b1b182aa563f6cb28791a722ff14456f7b823377e22f8f2f0cbfa6133c
7
+ data.tar.gz: 1b9005645b16b32ee67a313b6dc57e2704f9fac0e095027000cea06ab155049c976cb4765fc5158304ab6d7ee6e159b0a76c110a23c9357a26771435b7aa2a49
data/.travis.yml ADDED
@@ -0,0 +1,7 @@
1
+ # we don't actually use travis, just wwtd
2
+
3
+ gemfile:
4
+ - Gemfile_ar_3
5
+ - Gemfile_ar_40
6
+ - Gemfile_ar_41
7
+ script: rake test
data/CHANGELOG.md CHANGED
@@ -1,3 +1,6 @@
1
+ #v0.10.0
2
+ - JsonScriptEscapeHelper
3
+
1
4
  # v0.9.2
2
5
  - bugfix form encoded filtering
3
6
 
data/Gemfile ADDED
@@ -0,0 +1,7 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in api_hammer.gemspec
4
+ gemspec
5
+
6
+ gem 'byebug'
7
+ gem 'wwtd'
data/Gemfile_ar_3 ADDED
@@ -0,0 +1,8 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gemspec
4
+
5
+ gem 'byebug'
6
+ gem 'wwtd'
7
+
8
+ gem 'activerecord', '~> 3.0'
data/Gemfile_ar_40 ADDED
@@ -0,0 +1,8 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gemspec
4
+
5
+ gem 'byebug'
6
+ gem 'wwtd'
7
+
8
+ gem 'activerecord', '~> 4.0.0'
data/Gemfile_ar_41 ADDED
@@ -0,0 +1,8 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gemspec
4
+
5
+ gem 'byebug'
6
+ gem 'wwtd'
7
+
8
+ gem 'activerecord', '~> 4.1.0'
@@ -0,0 +1,39 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.any? { |lp| File.expand_path(lp) == File.expand_path(lib) }
4
+ require 'api_hammer/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = 'api_hammer'
8
+ spec.version = ApiHammer::VERSION
9
+ spec.authors = ['Ethan']
10
+ spec.email = ['ethan@unth']
11
+ spec.summary = 'an API tool'
12
+ spec.description = 'actually a set of small API-related tools. very much unlike a hammer at all, which ' +
13
+ 'is one large tool.'
14
+ spec.homepage = 'https://github.com/notEthan/api_hammer'
15
+ spec.license = 'MIT'
16
+
17
+ spec.files = `git ls-files -z`.split("\x0") - ['.gitignore']
18
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
19
+ spec.test_files = `git ls-files -z test`.split("\x0") + [
20
+ '.simplecov',
21
+ ]
22
+ spec.require_paths = ['lib']
23
+
24
+ spec.add_dependency 'rack'
25
+ spec.add_dependency 'faraday'
26
+ spec.add_dependency 'term-ansicolor'
27
+ spec.add_dependency 'json'
28
+ spec.add_dependency 'addressable'
29
+ spec.add_dependency 'coderay'
30
+ spec.add_development_dependency 'rake'
31
+ spec.add_development_dependency 'rack-test'
32
+ spec.add_development_dependency 'minitest'
33
+ spec.add_development_dependency 'minitest-reporters'
34
+ spec.add_development_dependency 'yard'
35
+ spec.add_development_dependency 'simplecov'
36
+ spec.add_development_dependency 'activesupport'
37
+ spec.add_development_dependency 'activerecord'
38
+ spec.add_development_dependency 'sqlite3'
39
+ end
@@ -0,0 +1,29 @@
1
+ require 'json'
2
+ module ApiHammer
3
+ module JsonScriptEscapeHelper
4
+ # takes an object which can be used to generate JSON, and formats it
5
+ # so that it may be safely be inserted inside a <script> tag.
6
+ #
7
+ # example: safely assigning the javascript variable foo to what's currently in the ruby variable foo.
8
+ #
9
+ # <script>
10
+ # foo = <%= json_script_escape(foo) %>;
11
+ # </script>
12
+ #
13
+ # the string is expressed as JSON, which applies proper escaping to any characters special to
14
+ # javascript, and then further escapes any <, >, and / characters which may otherwise introduce
15
+ # such things as </script> tags.
16
+ #
17
+ # this is aliased as #j, which replaces the j helper built into rails which requires quotes to
18
+ # be added around strings and does not support objects other than strings.
19
+ def json_script_escape(object)
20
+ encoded = JSON.generate(object, :quirks_mode => true)
21
+ escaped = encoded.gsub(%r([<>/])) { |x| x.codepoints.map { |p| "\\u%.4x" % p }.join }
22
+ escaped.respond_to?(:html_safe) ? escaped.html_safe : escaped
23
+ end
24
+ module_function :json_script_escape
25
+
26
+ alias j json_script_escape
27
+ module_function :j
28
+ end
29
+ end
@@ -1,3 +1,3 @@
1
1
  module ApiHammer
2
- VERSION = "0.9.2"
2
+ VERSION = "0.10.0"
3
3
  end
data/lib/api_hammer.rb CHANGED
@@ -1,3 +1,5 @@
1
+ proc { |p| $:.unshift(p) unless $:.any? { |lp| File.expand_path(lp) == p } }.call(File.expand_path(File.dirname(__FILE__)))
2
+
1
3
  require 'api_hammer/version'
2
4
 
3
5
  module ApiHammer
@@ -12,6 +14,7 @@ module ApiHammer
12
14
  autoload :FaradayCurlVOutputter, 'api_hammer/faraday/outputter'
13
15
  autoload :ParsedBody, 'api_hammer/parsed_body'
14
16
  autoload :ContentTypeAttrs, 'api_hammer/content_type_attrs'
17
+ autoload :JsonScriptEscapeHelper, 'api_hammer/json_script_escape_helper'
15
18
  module Faraday
16
19
  autoload :RequestLogger, 'api_hammer/faraday/request_logger'
17
20
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: api_hammer
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.2
4
+ version: 0.10.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ethan
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-01-08 00:00:00.000000000 Z
11
+ date: 2015-02-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rack
@@ -230,11 +230,17 @@ extensions: []
230
230
  extra_rdoc_files: []
231
231
  files:
232
232
  - .simplecov
233
+ - .travis.yml
233
234
  - .yardopts
234
235
  - CHANGELOG.md
236
+ - Gemfile
237
+ - Gemfile_ar_3
238
+ - Gemfile_ar_40
239
+ - Gemfile_ar_41
235
240
  - LICENSE.txt
236
241
  - README.md
237
242
  - Rakefile.rb
243
+ - api_hammer.gemspec
238
244
  - bin/hc
239
245
  - lib/api_hammer.rb
240
246
  - lib/api_hammer/active_record_cache_find_by.rb
@@ -245,6 +251,7 @@ files:
245
251
  - lib/api_hammer/filtration/form_encoded.rb
246
252
  - lib/api_hammer/filtration/json.rb
247
253
  - lib/api_hammer/halt.rb
254
+ - lib/api_hammer/json_script_escape_helper.rb
248
255
  - lib/api_hammer/parsed_body.rb
249
256
  - lib/api_hammer/public_instance_exec.rb
250
257
  - lib/api_hammer/rails.rb