fmrest 0.3.2 → 0.3.3

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
  SHA256:
3
- metadata.gz: '0368b81402b25d33d32a77ce58c6d815ba4b40a61bc2a2b2da2f13fe6e90ba71'
4
- data.tar.gz: 18f5a9d7b338b818ddb90a0fff59aa0f95bdd472ad6dfb4568dcde0812de8a56
3
+ metadata.gz: f0334b98968b68371d61a1f46c010937feb87bb5137b6e688c0096daf73b168a
4
+ data.tar.gz: c6585502bbb1a8005ea0f8a618c47d53b40b9412778a51e8154ab79393814ce5
5
5
  SHA512:
6
- metadata.gz: 5714a35a16de760709a189b93c6258b8688315820bcf5d51902ca495a1d26f2fae0b15c80f476bc245b8a13a1d7fe4e3958d0b24f5808400cabba4dbfea0b5c9
7
- data.tar.gz: 34d059fc99d94a3496f2d8f2aaea549be22da05a3a47e6e928bb4910e1d9247ecb6358002d2826bc92fbd911f94b0c644c49c8bcbd876cc4324299ce29db2b4b
6
+ metadata.gz: 433e6b05959fd64afbffddd2065df862449b3a3dcebe13780182b28bd6847f6263d4b2faffa3cef7d0a0f7949005ec1a1b9e8f7825129868bf49bd3833784ab5
7
+ data.tar.gz: 542d824f1cbb3c87722105a24b6bf2fdecd0d522a1a6d796d660a4c806ec83b356c50f400c9d37ce472cd2c4781ea1a50ecc533c361c4d6c02e19d47d625fb47
@@ -1,5 +1,12 @@
1
1
  ## Changelog
2
2
 
3
+ ### 0.3.3
4
+
5
+ * Fix encoding of paths for layouts with brackets in them (e.g. `"\[Very Ugly\]
6
+ Layout"`)
7
+ * Raise an error if `"id"` is assigned as an attribute on a model, as it's
8
+ currently a reserved method name by Spyke
9
+
3
10
  ### 0.3.2
4
11
 
5
12
  * Fix support for ActiveSupport < 5.2
@@ -79,6 +79,8 @@ module FmRest
79
79
  end
80
80
 
81
81
  def _fmrest_define_attribute(from, to)
82
+ raise ArgumentError, "attribute name `id' is reserved for the recordId" if from.to_s == "id"
83
+
82
84
  # We use a setter here instead of injecting the hash key/value pair
83
85
  # directly with #[]= so that we don't change the mapped_attributes
84
86
  # hash on the parent class. The resulting hash is frozen for the
@@ -1,7 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require "uri"
4
-
5
3
  module FmRest
6
4
  module V1
7
5
  module Paths
@@ -12,25 +10,34 @@ module FmRest
12
10
  end
13
11
 
14
12
  def record_path(layout, id = nil)
15
- url = "layouts/#{URI.escape(layout.to_s)}/records"
13
+ url = "layouts/#{url_encode(layout)}/records"
16
14
  url += "/#{id}" if id
17
15
  url
18
16
  end
19
17
 
20
18
  def container_field_path(layout, id, field_name, field_repetition = 1)
21
19
  url = record_path(layout, id)
22
- url += "/containers/#{URI.escape(field_name.to_s)}"
20
+ url += "/containers/#{url_encode(field_name)}"
23
21
  url += "/#{field_repetition}" if field_repetition
24
22
  url
25
23
  end
26
24
 
27
25
  def find_path(layout)
28
- "layouts/#{URI.escape(layout.to_s)}/_find"
26
+ "layouts/#{url_encode(layout)}/_find"
29
27
  end
30
28
 
31
29
  def globals_path
32
30
  "globals"
33
31
  end
32
+
33
+ private
34
+
35
+ # Borrowed from ERB::Util
36
+ def url_encode(s)
37
+ s.to_s.b.gsub(/[^a-zA-Z0-9_\-.]/n) { |m|
38
+ sprintf("%%%02X", m.unpack("C")[0])
39
+ }
40
+ end
34
41
  end
35
42
  end
36
43
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module FmRest
4
- VERSION = "0.3.2"
4
+ VERSION = "0.3.3"
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fmrest
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.2
4
+ version: 0.3.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Pedro Carbajal
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2019-09-23 00:00:00.000000000 Z
11
+ date: 2019-10-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday