judge 0.5.0 → 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (79) hide show
  1. data/.gitignore +8 -0
  2. data/.travis.yml +2 -1
  3. data/Gemfile +1 -10
  4. data/Rakefile +9 -44
  5. data/judge.gemspec +17 -164
  6. data/lib/generators/judge/templates/json2.js +46 -42
  7. data/lib/generators/judge/templates/judge.js +42 -41
  8. data/lib/generators/judge/templates/underscore.js +219 -97
  9. data/lib/judge.rb +6 -4
  10. data/lib/judge/form_builder.rb +75 -0
  11. data/lib/judge/{utils.rb → message_collection.rb} +45 -28
  12. data/lib/judge/validator.rb +21 -0
  13. data/lib/judge/validator_collection.rb +28 -0
  14. data/lib/judge/version.rb +3 -0
  15. data/spec/javascripts/JudgeSpec.js +25 -23
  16. data/test/expected_elements.rb +235 -0
  17. data/test/factories.rb +23 -0
  18. data/test/setup.rb +70 -0
  19. data/test/test_form_builder.rb +69 -0
  20. data/test/test_helper.rb +8 -20
  21. data/test/test_message_collection.rb +84 -0
  22. data/test/test_validator.rb +37 -0
  23. data/test/test_validator_collection.rb +19 -0
  24. metadata +46 -137
  25. data/.document +0 -5
  26. data/Gemfile.lock +0 -116
  27. data/VERSION +0 -1
  28. data/docs/docco.css +0 -196
  29. data/docs/judge.html +0 -280
  30. data/lib/judge/form.rb +0 -59
  31. data/test/dummy/Gemfile +0 -3
  32. data/test/dummy/Gemfile.lock +0 -75
  33. data/test/dummy/Rakefile +0 -7
  34. data/test/dummy/app/controllers/application_controller.rb +0 -3
  35. data/test/dummy/app/controllers/foos_controller.rb +0 -11
  36. data/test/dummy/app/helpers/application_helper.rb +0 -2
  37. data/test/dummy/app/models/city.rb +0 -5
  38. data/test/dummy/app/models/continent.rb +0 -4
  39. data/test/dummy/app/models/country.rb +0 -6
  40. data/test/dummy/app/models/fake.rb +0 -2
  41. data/test/dummy/app/models/foo.rb +0 -19
  42. data/test/dummy/app/views/foos/new.html.erb +0 -71
  43. data/test/dummy/app/views/layouts/application.html.erb +0 -14
  44. data/test/dummy/config.ru +0 -4
  45. data/test/dummy/config/application.rb +0 -45
  46. data/test/dummy/config/boot.rb +0 -10
  47. data/test/dummy/config/database.yml +0 -22
  48. data/test/dummy/config/environment.rb +0 -5
  49. data/test/dummy/config/environments/development.rb +0 -26
  50. data/test/dummy/config/environments/production.rb +0 -49
  51. data/test/dummy/config/environments/test.rb +0 -35
  52. data/test/dummy/config/initializers/backtrace_silencers.rb +0 -7
  53. data/test/dummy/config/initializers/inflections.rb +0 -10
  54. data/test/dummy/config/initializers/mime_types.rb +0 -5
  55. data/test/dummy/config/initializers/secret_token.rb +0 -7
  56. data/test/dummy/config/initializers/session_store.rb +0 -8
  57. data/test/dummy/config/locales/en.yml +0 -12
  58. data/test/dummy/config/routes.rb +0 -3
  59. data/test/dummy/db/development.sqlite3 +0 -0
  60. data/test/dummy/db/migrate/20110624115516_create_foos.rb +0 -26
  61. data/test/dummy/db/migrate/20110724201117_create_fake_collections.rb +0 -14
  62. data/test/dummy/db/migrate/20110724201548_rename_fake_collection_to_fake.rb +0 -9
  63. data/test/dummy/db/migrate/20110725082530_create_continent_country_and_city_tables.rb +0 -24
  64. data/test/dummy/db/schema.rb +0 -55
  65. data/test/dummy/db/test.sqlite3 +0 -0
  66. data/test/dummy/log/server.log +0 -0
  67. data/test/dummy/public/404.html +0 -26
  68. data/test/dummy/public/422.html +0 -26
  69. data/test/dummy/public/500.html +0 -26
  70. data/test/dummy/public/favicon.ico +0 -0
  71. data/test/dummy/public/javascripts/application.js +0 -2
  72. data/test/dummy/public/javascripts/controls.js +0 -965
  73. data/test/dummy/public/javascripts/dragdrop.js +0 -974
  74. data/test/dummy/public/javascripts/effects.js +0 -1123
  75. data/test/dummy/public/javascripts/prototype.js +0 -6001
  76. data/test/dummy/public/javascripts/rails.js +0 -175
  77. data/test/dummy/public/stylesheets/.gitkeep +0 -0
  78. data/test/dummy/script/rails +0 -6
  79. data/test/judge_test.rb +0 -186
data/.gitignore ADDED
@@ -0,0 +1,8 @@
1
+ *.gem
2
+ .bundle
3
+ Gemfile.lock
4
+ pkg/*
5
+ docs
6
+ doc
7
+ rdoc
8
+ gem_graph.png
data/.travis.yml CHANGED
@@ -1,7 +1,8 @@
1
1
  rvm:
2
2
  - 1.9.2
3
+ - 1.9.3
3
4
 
4
- script: "bundle exec rake test:form"
5
+ script: "bundle exec rake test:ruby"
5
6
 
6
7
  notifications:
7
8
  recipients:
data/Gemfile CHANGED
@@ -1,12 +1,3 @@
1
1
  source "http://rubygems.org"
2
2
 
3
- group :development do
4
- gem "bundler", "~> 1.0.18"
5
- gem "jeweler", "~> 1.5.2"
6
- gem "jasmine", "~> 1.0.2"
7
- gem "rails", "~> 3.0.10"
8
- gem "shoulda", "~> 2.11.3"
9
- gem "sqlite3-ruby", "~> 1.3.2"
10
- gem "nokogiri", "~> 1.4.7"
11
- gem "json", "~> 1.6.0"
12
- end
3
+ gemspec
data/Rakefile CHANGED
@@ -1,52 +1,17 @@
1
- require 'rubygems'
2
- require 'bundler'
3
- require 'rake'
4
- require 'jeweler'
5
- require 'rdoc/task'
6
- require 'jasmine'
7
- require 'rake/testtask'
1
+ require "bundler/gem_tasks"
2
+ require "jasmine"
3
+ require "rake/testtask"
8
4
 
9
- load 'jasmine/tasks/jasmine.rake'
10
- load 'lib/tasks/js_tests.rake'
11
-
12
- begin
13
- Bundler.setup(:default, :development)
14
- rescue Bundler::BundlerError => e
15
- $stderr.puts e.message
16
- $stderr.puts "Run `bundle install` to install missing gems"
17
- exit e.status_code
18
- end
19
-
20
- Jeweler::Tasks.new do |gem|
21
- gem.name = "judge"
22
- gem.homepage = "http://github.com/joecorcoran/judge"
23
- gem.license = "MIT"
24
- gem.summary = %Q{Simple client-side ActiveModel::Validators}
25
- gem.description = %Q{Validate forms in-place using your model validations}
26
- gem.email = "joe@tribesports.com"
27
- gem.authors = ["Joe Corcoran"]
28
- end
29
- Jeweler::RubygemsDotOrgTasks.new
30
-
31
- RDoc::Task.new do |rdoc|
32
- version = File.exist?('VERSION') ? File.read('VERSION') : ""
33
-
34
- rdoc.rdoc_dir = 'rdoc'
35
- rdoc.title = "judge #{version}"
36
- rdoc.rdoc_files.include('README*')
37
- rdoc.rdoc_files.include('lib/**/*.rb')
38
- end
5
+ load "jasmine/tasks/jasmine.rake"
6
+ load "lib/tasks/js_tests.rake"
39
7
 
40
8
  namespace :test do
41
- Rake::TestTask.new(:form) do |test|
42
- test.libs << 'lib' << 'test'
43
- test.pattern = 'test/**/*_test.rb'
9
+ Rake::TestTask.new(:ruby) do |test|
10
+ test.libs << "lib" << "test"
11
+ test.pattern = "test/**/test_*.rb"
44
12
  test.verbose = true
45
13
  end
46
-
47
- desc "Run javascript tests"
48
- task :js => ["jasmine:phantom"]
49
14
  end
50
15
 
51
16
  desc "Run all tests"
52
- task :test => ["test:form", "test:js"]
17
+ task :test => ["test:ruby", "jasmine:phantom"]
data/judge.gemspec CHANGED
@@ -1,171 +1,24 @@
1
- # Generated by jeweler
2
- # DO NOT EDIT THIS FILE DIRECTLY
3
- # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
4
1
  # -*- encoding: utf-8 -*-
2
+ $:.push File.expand_path("../lib", __FILE__)
3
+ require "judge/version"
5
4
 
6
5
  Gem::Specification.new do |s|
7
- s.name = %q{judge}
8
- s.version = "0.5.0"
9
-
10
- s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
6
+ s.name = "judge"
7
+ s.version = Judge::VERSION
8
+ s.homepage = "http://github.com/joecorcoran/judge"
9
+ s.license = "MIT"
10
+ s.summary = %Q{Simple client side ActiveModel::Validators}
11
+ s.description = %Q{Validate forms on the client side, cleanly}
12
+ s.email = "joe@tribesports.com"
11
13
  s.authors = ["Joe Corcoran"]
12
- s.date = %q{2011-11-13}
13
- s.description = %q{Validate forms in-place using your model validations}
14
- s.email = %q{joe@tribesports.com}
15
- s.extra_rdoc_files = [
16
- "LICENSE.txt",
17
- "README.md"
18
- ]
19
- s.files = [
20
- ".document",
21
- ".travis.yml",
22
- "Gemfile",
23
- "Gemfile.lock",
24
- "LICENSE.txt",
25
- "README.md",
26
- "Rakefile",
27
- "VERSION",
28
- "docs/docco.css",
29
- "docs/judge.html",
30
- "judge.gemspec",
31
- "lib/generators/judge/judge_generator.rb",
32
- "lib/generators/judge/templates/json2.js",
33
- "lib/generators/judge/templates/judge.js",
34
- "lib/generators/judge/templates/underscore.js",
35
- "lib/judge.rb",
36
- "lib/judge/form.rb",
37
- "lib/judge/utils.rb",
38
- "lib/tasks/js_tests.rake",
39
- "spec/javascripts/JudgeSpec.js",
40
- "spec/javascripts/fixtures/form.html",
41
- "spec/javascripts/helpers/customMatchers.js",
42
- "spec/javascripts/helpers/jasmine-jquery.js",
43
- "spec/javascripts/helpers/jquery-1.5.1.min.js",
44
- "spec/javascripts/helpers/json2.js",
45
- "spec/javascripts/helpers/underscore.js",
46
- "spec/javascripts/support/jasmine.yml",
47
- "spec/javascripts/support/jasmine_config.rb",
48
- "spec/javascripts/support/jasmine_runner.rb",
49
- "spec/javascripts/support/phantomRunner.js",
50
- "test/dummy/Gemfile",
51
- "test/dummy/Gemfile.lock",
52
- "test/dummy/Rakefile",
53
- "test/dummy/app/controllers/application_controller.rb",
54
- "test/dummy/app/controllers/foos_controller.rb",
55
- "test/dummy/app/helpers/application_helper.rb",
56
- "test/dummy/app/models/city.rb",
57
- "test/dummy/app/models/continent.rb",
58
- "test/dummy/app/models/country.rb",
59
- "test/dummy/app/models/fake.rb",
60
- "test/dummy/app/models/foo.rb",
61
- "test/dummy/app/views/foos/new.html.erb",
62
- "test/dummy/app/views/layouts/application.html.erb",
63
- "test/dummy/config.ru",
64
- "test/dummy/config/application.rb",
65
- "test/dummy/config/boot.rb",
66
- "test/dummy/config/database.yml",
67
- "test/dummy/config/environment.rb",
68
- "test/dummy/config/environments/development.rb",
69
- "test/dummy/config/environments/production.rb",
70
- "test/dummy/config/environments/test.rb",
71
- "test/dummy/config/initializers/backtrace_silencers.rb",
72
- "test/dummy/config/initializers/inflections.rb",
73
- "test/dummy/config/initializers/mime_types.rb",
74
- "test/dummy/config/initializers/secret_token.rb",
75
- "test/dummy/config/initializers/session_store.rb",
76
- "test/dummy/config/locales/en.yml",
77
- "test/dummy/config/routes.rb",
78
- "test/dummy/db/development.sqlite3",
79
- "test/dummy/db/migrate/20110624115516_create_foos.rb",
80
- "test/dummy/db/migrate/20110724201117_create_fake_collections.rb",
81
- "test/dummy/db/migrate/20110724201548_rename_fake_collection_to_fake.rb",
82
- "test/dummy/db/migrate/20110725082530_create_continent_country_and_city_tables.rb",
83
- "test/dummy/db/schema.rb",
84
- "test/dummy/db/test.sqlite3",
85
- "test/dummy/log/server.log",
86
- "test/dummy/public/404.html",
87
- "test/dummy/public/422.html",
88
- "test/dummy/public/500.html",
89
- "test/dummy/public/favicon.ico",
90
- "test/dummy/public/javascripts/application.js",
91
- "test/dummy/public/javascripts/controls.js",
92
- "test/dummy/public/javascripts/dragdrop.js",
93
- "test/dummy/public/javascripts/effects.js",
94
- "test/dummy/public/javascripts/prototype.js",
95
- "test/dummy/public/javascripts/rails.js",
96
- "test/dummy/public/stylesheets/.gitkeep",
97
- "test/dummy/script/rails",
98
- "test/judge_test.rb",
99
- "test/test_helper.rb"
100
- ]
101
- s.homepage = %q{http://github.com/joecorcoran/judge}
102
- s.licenses = ["MIT"]
103
- s.require_paths = ["lib"]
104
- s.rubygems_version = %q{1.6.2}
105
- s.summary = %q{Simple client-side ActiveModel::Validators}
106
- s.test_files = [
107
- "spec/javascripts/support/jasmine_config.rb",
108
- "spec/javascripts/support/jasmine_runner.rb",
109
- "test/dummy/app/controllers/application_controller.rb",
110
- "test/dummy/app/controllers/foos_controller.rb",
111
- "test/dummy/app/helpers/application_helper.rb",
112
- "test/dummy/app/models/city.rb",
113
- "test/dummy/app/models/continent.rb",
114
- "test/dummy/app/models/country.rb",
115
- "test/dummy/app/models/fake.rb",
116
- "test/dummy/app/models/foo.rb",
117
- "test/dummy/config/application.rb",
118
- "test/dummy/config/boot.rb",
119
- "test/dummy/config/environment.rb",
120
- "test/dummy/config/environments/development.rb",
121
- "test/dummy/config/environments/production.rb",
122
- "test/dummy/config/environments/test.rb",
123
- "test/dummy/config/initializers/backtrace_silencers.rb",
124
- "test/dummy/config/initializers/inflections.rb",
125
- "test/dummy/config/initializers/mime_types.rb",
126
- "test/dummy/config/initializers/secret_token.rb",
127
- "test/dummy/config/initializers/session_store.rb",
128
- "test/dummy/config/routes.rb",
129
- "test/dummy/db/migrate/20110624115516_create_foos.rb",
130
- "test/dummy/db/migrate/20110724201117_create_fake_collections.rb",
131
- "test/dummy/db/migrate/20110724201548_rename_fake_collection_to_fake.rb",
132
- "test/dummy/db/migrate/20110725082530_create_continent_country_and_city_tables.rb",
133
- "test/dummy/db/schema.rb",
134
- "test/judge_test.rb",
135
- "test/test_helper.rb"
136
- ]
137
14
 
138
- if s.respond_to? :specification_version then
139
- s.specification_version = 3
15
+ s.files = `git ls-files`.split("\n")
16
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
17
+ s.require_paths = ["lib"]
140
18
 
141
- if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
142
- s.add_development_dependency(%q<bundler>, ["~> 1.0.18"])
143
- s.add_development_dependency(%q<jeweler>, ["~> 1.5.2"])
144
- s.add_development_dependency(%q<jasmine>, ["~> 1.0.2"])
145
- s.add_development_dependency(%q<rails>, ["~> 3.0.10"])
146
- s.add_development_dependency(%q<shoulda>, ["~> 2.11.3"])
147
- s.add_development_dependency(%q<sqlite3-ruby>, ["~> 1.3.2"])
148
- s.add_development_dependency(%q<nokogiri>, ["~> 1.4.7"])
149
- s.add_development_dependency(%q<json>, ["~> 1.6.0"])
150
- else
151
- s.add_dependency(%q<bundler>, ["~> 1.0.18"])
152
- s.add_dependency(%q<jeweler>, ["~> 1.5.2"])
153
- s.add_dependency(%q<jasmine>, ["~> 1.0.2"])
154
- s.add_dependency(%q<rails>, ["~> 3.0.10"])
155
- s.add_dependency(%q<shoulda>, ["~> 2.11.3"])
156
- s.add_dependency(%q<sqlite3-ruby>, ["~> 1.3.2"])
157
- s.add_dependency(%q<nokogiri>, ["~> 1.4.7"])
158
- s.add_dependency(%q<json>, ["~> 1.6.0"])
159
- end
160
- else
161
- s.add_dependency(%q<bundler>, ["~> 1.0.18"])
162
- s.add_dependency(%q<jeweler>, ["~> 1.5.2"])
163
- s.add_dependency(%q<jasmine>, ["~> 1.0.2"])
164
- s.add_dependency(%q<rails>, ["~> 3.0.10"])
165
- s.add_dependency(%q<shoulda>, ["~> 2.11.3"])
166
- s.add_dependency(%q<sqlite3-ruby>, ["~> 1.3.2"])
167
- s.add_dependency(%q<nokogiri>, ["~> 1.4.7"])
168
- s.add_dependency(%q<json>, ["~> 1.6.0"])
169
- end
19
+ s.add_development_dependency "jasmine", "~> 1.0.2"
20
+ s.add_development_dependency "rails", "~> 3.0.10"
21
+ s.add_development_dependency "shoulda", "~> 2.11.3"
22
+ s.add_development_dependency "sqlite3-ruby", "~> 1.3.2"
23
+ s.add_development_dependency "factory_girl", "~> 2.2.0"
170
24
  end
171
-
@@ -1,6 +1,6 @@
1
1
  /*
2
2
  http://www.JSON.org/json2.js
3
- 2010-08-25
3
+ 2011-10-19
4
4
 
5
5
  Public Domain.
6
6
 
@@ -146,7 +146,7 @@
146
146
  redistribute.
147
147
  */
148
148
 
149
- /*jslint evil: true, strict: false */
149
+ /*jslint evil: true, regexp: true */
150
150
 
151
151
  /*members "", "\b", "\t", "\n", "\f", "\r", "\"", JSON, "\\", apply,
152
152
  call, charCodeAt, getUTCDate, getUTCFullYear, getUTCHours,
@@ -159,11 +159,13 @@
159
159
  // Create a JSON object only if one does not already exist. We create the
160
160
  // methods in a closure to avoid creating global variables.
161
161
 
162
- if (!this.JSON) {
163
- this.JSON = {};
162
+ var JSON;
163
+ if (!JSON) {
164
+ JSON = {};
164
165
  }
165
166
 
166
167
  (function () {
168
+ 'use strict';
167
169
 
168
170
  function f(n) {
169
171
  // Format integers to have at least two digits.
@@ -174,20 +176,21 @@ if (!this.JSON) {
174
176
 
175
177
  Date.prototype.toJSON = function (key) {
176
178
 
177
- return isFinite(this.valueOf()) ?
178
- this.getUTCFullYear() + '-' +
179
- f(this.getUTCMonth() + 1) + '-' +
180
- f(this.getUTCDate()) + 'T' +
181
- f(this.getUTCHours()) + ':' +
182
- f(this.getUTCMinutes()) + ':' +
183
- f(this.getUTCSeconds()) + 'Z' : null;
179
+ return isFinite(this.valueOf())
180
+ ? this.getUTCFullYear() + '-' +
181
+ f(this.getUTCMonth() + 1) + '-' +
182
+ f(this.getUTCDate()) + 'T' +
183
+ f(this.getUTCHours()) + ':' +
184
+ f(this.getUTCMinutes()) + ':' +
185
+ f(this.getUTCSeconds()) + 'Z'
186
+ : null;
184
187
  };
185
188
 
186
- String.prototype.toJSON =
187
- Number.prototype.toJSON =
188
- Boolean.prototype.toJSON = function (key) {
189
- return this.valueOf();
190
- };
189
+ String.prototype.toJSON =
190
+ Number.prototype.toJSON =
191
+ Boolean.prototype.toJSON = function (key) {
192
+ return this.valueOf();
193
+ };
191
194
  }
192
195
 
193
196
  var cx = /[\u0000\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,
@@ -214,13 +217,12 @@ if (!this.JSON) {
214
217
  // sequences.
215
218
 
216
219
  escapable.lastIndex = 0;
217
- return escapable.test(string) ?
218
- '"' + string.replace(escapable, function (a) {
219
- var c = meta[a];
220
- return typeof c === 'string' ? c :
221
- '\\u' + ('0000' + a.charCodeAt(0).toString(16)).slice(-4);
222
- }) + '"' :
223
- '"' + string + '"';
220
+ return escapable.test(string) ? '"' + string.replace(escapable, function (a) {
221
+ var c = meta[a];
222
+ return typeof c === 'string'
223
+ ? c
224
+ : '\\u' + ('0000' + a.charCodeAt(0).toString(16)).slice(-4);
225
+ }) + '"' : '"' + string + '"';
224
226
  }
225
227
 
226
228
 
@@ -303,11 +305,11 @@ if (!this.JSON) {
303
305
  // Join all of the elements together, separated with commas, and wrap them in
304
306
  // brackets.
305
307
 
306
- v = partial.length === 0 ? '[]' :
307
- gap ? '[\n' + gap +
308
- partial.join(',\n' + gap) + '\n' +
309
- mind + ']' :
310
- '[' + partial.join(',') + ']';
308
+ v = partial.length === 0
309
+ ? '[]'
310
+ : gap
311
+ ? '[\n' + gap + partial.join(',\n' + gap) + '\n' + mind + ']'
312
+ : '[' + partial.join(',') + ']';
311
313
  gap = mind;
312
314
  return v;
313
315
  }
@@ -317,8 +319,8 @@ if (!this.JSON) {
317
319
  if (rep && typeof rep === 'object') {
318
320
  length = rep.length;
319
321
  for (i = 0; i < length; i += 1) {
320
- k = rep[i];
321
- if (typeof k === 'string') {
322
+ if (typeof rep[i] === 'string') {
323
+ k = rep[i];
322
324
  v = str(k, value);
323
325
  if (v) {
324
326
  partial.push(quote(k) + (gap ? ': ' : ':') + v);
@@ -330,7 +332,7 @@ if (!this.JSON) {
330
332
  // Otherwise, iterate through all of the keys in the object.
331
333
 
332
334
  for (k in value) {
333
- if (Object.hasOwnProperty.call(value, k)) {
335
+ if (Object.prototype.hasOwnProperty.call(value, k)) {
334
336
  v = str(k, value);
335
337
  if (v) {
336
338
  partial.push(quote(k) + (gap ? ': ' : ':') + v);
@@ -342,9 +344,11 @@ if (!this.JSON) {
342
344
  // Join all of the member texts together, separated with commas,
343
345
  // and wrap them in braces.
344
346
 
345
- v = partial.length === 0 ? '{}' :
346
- gap ? '{\n' + gap + partial.join(',\n' + gap) + '\n' +
347
- mind + '}' : '{' + partial.join(',') + '}';
347
+ v = partial.length === 0
348
+ ? '{}'
349
+ : gap
350
+ ? '{\n' + gap + partial.join(',\n' + gap) + '\n' + mind + '}'
351
+ : '{' + partial.join(',') + '}';
348
352
  gap = mind;
349
353
  return v;
350
354
  }
@@ -385,7 +389,7 @@ if (!this.JSON) {
385
389
  rep = replacer;
386
390
  if (replacer && typeof replacer !== 'function' &&
387
391
  (typeof replacer !== 'object' ||
388
- typeof replacer.length !== 'number')) {
392
+ typeof replacer.length !== 'number')) {
389
393
  throw new Error('JSON.stringify');
390
394
  }
391
395
 
@@ -415,7 +419,7 @@ if (!this.JSON) {
415
419
  var k, v, value = holder[key];
416
420
  if (value && typeof value === 'object') {
417
421
  for (k in value) {
418
- if (Object.hasOwnProperty.call(value, k)) {
422
+ if (Object.prototype.hasOwnProperty.call(value, k)) {
419
423
  v = walk(value, k);
420
424
  if (v !== undefined) {
421
425
  value[k] = v;
@@ -456,9 +460,9 @@ if (!this.JSON) {
456
460
  // ',' or ':' or '{' or '}'. If that is so, then the text is safe for eval.
457
461
 
458
462
  if (/^[\],:{}\s]*$/
459
- .test(text.replace(/\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g, '@')
460
- .replace(/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g, ']')
461
- .replace(/(?:^|:|,)(?:\s*\[)+/g, ''))) {
463
+ .test(text.replace(/\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g, '@')
464
+ .replace(/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g, ']')
465
+ .replace(/(?:^|:|,)(?:\s*\[)+/g, ''))) {
462
466
 
463
467
  // In the third stage we use the eval function to compile the text into a
464
468
  // JavaScript structure. The '{' operator is subject to a syntactic ambiguity
@@ -470,8 +474,9 @@ if (!this.JSON) {
470
474
  // In the optional fourth stage, we recursively walk the new structure, passing
471
475
  // each name/value pair to a reviver function for possible transformation.
472
476
 
473
- return typeof reviver === 'function' ?
474
- walk({'': j}, '') : j;
477
+ return typeof reviver === 'function'
478
+ ? walk({'': j}, '')
479
+ : j;
475
480
  }
476
481
 
477
482
  // If the text is not JSON parseable, then a SyntaxError is thrown.
@@ -480,4 +485,3 @@ if (!this.JSON) {
480
485
  };
481
486
  }
482
487
  }());
483
-