form_stalker 1.0.2 → 1.0.3

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 7c6c157ea0f59610e9e34e86d1ab5dcdb2ca941a
4
- data.tar.gz: 8e36059c4113539ac839eab25bede83732c53f11
3
+ metadata.gz: 71c9e6082066146895626125b4282d9bb90aaa21
4
+ data.tar.gz: bfe54fbab6ef59301179bfd73c3729173302b468
5
5
  SHA512:
6
- metadata.gz: f98838ba9b8f8e36b04b708477a2881dd01bbc82557a844922084aca8a5ade15fdc1b56bb7b0d2a0c5c0a84caad842a92a90b529816f7b48a1e17407198e5171
7
- data.tar.gz: e3a8ab3349d4c499864846bb57354a64b235a3847134adce93be26eaebe1cd7d73c672d14f6db0f6d5d27f6af035f37ef59ab4d3f1a7609f94f48063cf50acd9
6
+ metadata.gz: 8fef77d58422c9853be86d8498a535e649ef8875a3ee957e20bbe62410251a3e24bb4d9f3c92731c0133123f23c97f2ee69ad1cddb371c33d374110dbfd3464c
7
+ data.tar.gz: 0c882abd9a2e6f5ee9527c84bdb361f9fdbf5229928da050e5e7bbf2ded9afe7676f8f5761777bd11c3bac19fbb11a7ae409348cc4b4172284fedd819737b48f
data/README.md CHANGED
@@ -20,16 +20,81 @@ Make requests to FormStack and receive a sanitized response
20
20
  ```ruby
21
21
  response = FormStalker.form(1)
22
22
 
23
- # don't trust (response.status == :ok) because Formstack API does not respect the HTTP error status
23
+ # don't trust (response.status == :ok) because Formstack API does not respect the HTTP status codes
24
24
  if response.ok?
25
- form_data = response.data
25
+ form_data = response.data # returns a FormStalker::Data::Form instance
26
26
  else
27
- response.status # will return a symbol representing FormStack's HTTP status
28
- response.error # will return a message string explaining the error
27
+ response.status # returns a symbol representing FormStack's HTTP status
28
+ response.error # returns a message string explaining the error
29
29
  end
30
30
  ```
31
31
 
32
- ## 2) Instalation
32
+ ## 2) FormStalker.form
33
+ ```ruby
34
+ response = FormStalker.form(1)
35
+
36
+ raise response.error unless response.ok?
37
+
38
+ form_data = response.data
39
+
40
+ form_data.id # returns an integer
41
+ form_data.created # returns a date
42
+ form_data.deleted # returns a boolean
43
+ form_data.fields # returns an array of FormStalker::Data::FormField instances
44
+ # etc.
45
+ form_data.attributes # returns a Hash with all of its data
46
+
47
+ # and the one your are probably looking for
48
+ form_data.logic # returns an instance of FormStalker::Data::FormFieldsLogic
49
+
50
+ form_data.logic.logic_field_ids # returns an array of field ids that have logic
51
+ form_data.logic.calc_field_ids # returns an array of field ids
52
+
53
+ form_data.logic.checks # returns an array of Hashes with the actual logic
54
+
55
+ # Example of what can be inside the #checks
56
+ [
57
+ {
58
+ target: 37314714,
59
+ action: 'Show',
60
+ bool: 'AND',
61
+ fields: [41111633],
62
+ checks: [{ field: 41111633, condition: '==', option: 'Option1' }]
63
+ },
64
+ {
65
+ target: 40952921,
66
+ action: 'Show',
67
+ bool: 'AND',
68
+ fields: [37314736],
69
+ checks: [{ field: 37314736, condition: '!=', option: 'Option1' }]
70
+ }
71
+ {
72
+ target: 37314784,
73
+ action: 'Show',
74
+ bool: 'AND',
75
+ fields: [37314745],
76
+ checks: [{ field: 37314745, condition: '==', option: '0' }]
77
+ }
78
+ ]
79
+ ```
80
+
81
+ ## 2) FormStalker.form_fields
82
+ ```ruby
83
+ response = FormStalker.form_fields(1)
84
+
85
+ raise response.error unless response.ok?
86
+
87
+ form_fields = response.data # returns an array of FormStalker::Data::FormField instances
88
+
89
+ form_fields.each do |form_fields_data|
90
+ form_fields_data.id # returns an integer
91
+ form_fields_data.required # returns an boolean
92
+ # etc.
93
+ form_fields_data.attributes # returns a Hash with all of its data
94
+ end
95
+ ```
96
+
97
+ ## 4) Instalation
33
98
 
34
99
  Add this to your Gemfile:
35
100
  ```
@@ -37,7 +37,7 @@ module FormStalker
37
37
  .gsub('{', '{"')
38
38
  .gsub(':', '":')
39
39
 
40
- "\"#{string}"
40
+ ['"', '{'].include?(string[0]) ? string : "\"#{string}"
41
41
  end
42
42
  end
43
43
  end
@@ -1,3 +1,3 @@
1
1
  module FormStalker
2
- VERSION = '1.0.2'.freeze
2
+ VERSION = '1.0.3'.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.2
4
+ version: 1.0.3
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-08-02 00:00:00.000000000 Z
11
+ date: 2016-08-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: vcr