form_stalker 1.0.4 → 1.0.5

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: f9b53d8d01b3c038a6691ea9d99be24f0053b575
4
- data.tar.gz: 5bce75bc933758fd2f8b807e019f5f66432ed246
3
+ metadata.gz: 0d96318616918fc4c3cf5c6760c6f57f51584dc0
4
+ data.tar.gz: 81404c17b4881c0febe23dbcca08eb6f93350021
5
5
  SHA512:
6
- metadata.gz: 681f0a9d056a3b80bfecce553e2b356005a7a6f945c3fd8291b381e0f9c989f84e2e22653546d18b414d669aaccaa02c4b09ef58ee3ac06c274b6eb8d9e6ead4
7
- data.tar.gz: 43813697816d2fd2ec4ac68d3473d3855613cd6af788070ad6b9e3b27d6f20910497d5c6a9e480efe8f786daa34d8f3326e7e7b421c4f497fd408d26b7c51c32
6
+ metadata.gz: 84e8abd04e8648bd8f03b054d4d84b925c060bdbfa28846976700699b9457086da41824e1300fbe62a0f4948057428829d765709402b008030cc679592af42ec
7
+ data.tar.gz: 807927350b715b584440ed5be4ace08943191195ee4a76e9fb8e8dc420a9febaa65d8b70ab827eceaacfe54c803b876734e24ce2f0cdfeafbaa3012c6788cef0
@@ -24,26 +24,23 @@ module FormStalker
24
24
  protected ####################### PROTECTED ##############################
25
25
 
26
26
  def js_to_json(js_object)
27
- split(js_object).map(&:strip).map do |js_string|
28
- escape_js_to_json(js_string)
29
- end.join(', ')
27
+ json_converted_keys = convert_keys(js_object)
28
+
29
+ convert_values(json_converted_keys)
30
30
  end
31
31
 
32
32
  private ######################### PRIVATE ################################
33
33
 
34
- def split(js_object)
35
- js_object
36
- .split(/(,)(?=(?:[^']|'[^']*')*$)/)
37
- .reject { |string| string == ',' }
34
+ def convert_keys(js_object)
35
+ js_object.gsub(/([a-zA-Z]+):/, '"\1":')
38
36
  end
39
37
 
40
- def escape_js_to_json(js_string)
41
- string = js_string.tr('"', '\"')
42
- .tr("'", '"')
43
- .gsub('{', '{"')
44
- .gsub(':', '":')
38
+ def convert_values(js_object)
39
+ js_object.gsub(/'(.*?(?<!\\))'/) do |match|
40
+ value = match.gsub(/^'/, '').gsub(/'$/, '')
45
41
 
46
- ['"', '{'].include?(string[0]) ? string : "\"#{string}"
42
+ "\"#{value}\""
43
+ end
47
44
  end
48
45
  end
49
46
  end
@@ -1,3 +1,3 @@
1
1
  module FormStalker
2
- VERSION = '1.0.4'.freeze
2
+ VERSION = '1.0.5'.freeze
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: form_stalker
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.4
4
+ version: 1.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - StreetBees Dev Team
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-09-19 00:00:00.000000000 Z
11
+ date: 2016-10-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: vcr