vigia 0.2.1 → 0.2.2

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: a7222d06de2ca3a765f9e0e7a95d55dba86fcf2c
4
- data.tar.gz: 9682733199c872a48488ebff5bab234af8bc9602
3
+ metadata.gz: 839517ce635ec40f0392b395b499995141ce6f1e
4
+ data.tar.gz: ead01a03d5b47e234b89a3b05c0ab08d015a1258
5
5
  SHA512:
6
- metadata.gz: 2d7a990aa5867d01f729792a334cdcee1534340d7346fa26efc56b870477cdf98e749fb0e1d0b1da096aa81c241b3b3fcc52dabbde2855c68ee00cbe62ac34ac
7
- data.tar.gz: 91206c7fce603e5674dab0a8b5d6fa3f105a608876aaacc3c278bf8fb083037754fbe3a877be61050f6d467d2981d2c59fc641847aa6fa2b1210ea91d8facc77
6
+ metadata.gz: 480f72fca1b7d0fe762def39949a025fd0f6e85502b1d49981359556f6a94724bb1683d70be14b57a3feceff594bfaf612a0bb813913dbec153d85b8f016c4f2
7
+ data.tar.gz: 086906a7d54e9aab0cc1fd1b669ca822d00308bf7bb9daf143da07cd9bde54c929f2fd672e6db27021ecac84f69fd35a00e1390cc3cec3641395dd210622526e
@@ -85,7 +85,11 @@ module Vigia
85
85
 
86
86
  def format_parameters(raml_hash)
87
87
  raml_hash.values.each_with_object([]) do |parameter, array|
88
- array << { name: parameter.name, value: parameter.example, required: !parameter.optional }
88
+ array << {
89
+ name: name_to_rfc_3986(parameter.name),
90
+ value: parameter.example,
91
+ required: !parameter.optional
92
+ }
89
93
  end
90
94
  end
91
95
 
@@ -104,7 +108,31 @@ module Vigia
104
108
  def query_parameters(method)
105
109
  method.apply_traits if method.traits.any? # Does this belong here RAML?
106
110
  return '' if method.query_parameters.empty?
107
- "{?#{ method.query_parameters.keys.join(',') }}"
111
+
112
+ "{?#{ query_string(method) }}"
113
+ end
114
+
115
+ # RAML specification for query parameter name must comply with RFC 3986,
116
+ # However, Vigia uses `addressable` for query parameters expansion, which
117
+ # enforces RFC 6570. These two specification understand in different ways
118
+ # what it is consider to be an unreserved character. While RFC 3986 allows
119
+ # this set: `ALPHA / DIGIT / "-" / "." / "_" / "~"`, RFC 6570 only accepts
120
+ # `ALPHA / DIGIT / "_", and encoded characters in pct-encoded format `%*`
121
+ # Thus, the transformation:
122
+ def name_to_rfc_3986(string)
123
+ return if string.nil?
124
+
125
+ string.gsub(/[-.~]/,
126
+ '-' => '%2D',
127
+ '~' => '%7E',
128
+ '.' => '%2E'
129
+ )
130
+ end
131
+
132
+ def query_string(method)
133
+ method.query_parameters.keys.map do |key|
134
+ name_to_rfc_3986(key.to_s)
135
+ end.join(',')
108
136
  end
109
137
  end
110
138
  end
data/lib/vigia/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # encoding: utf-8
2
2
 
3
3
  module Vigia
4
- VERSION = "0.2.1"
4
+ VERSION = "0.2.2"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: vigia
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.2.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - David Tapiador
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2016-01-08 00:00:00.000000000 Z
12
+ date: 2016-02-16 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rake
@@ -246,7 +246,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
246
246
  version: '0'
247
247
  requirements: []
248
248
  rubyforge_project:
249
- rubygems_version: 2.4.5.1
249
+ rubygems_version: 2.2.2
250
250
  signing_key:
251
251
  specification_version: 4
252
252
  summary: Test your Apiary Blueprint specification on ruby