try_api 0.0.17 → 0.0.18

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: c32074ebd9d31c8c9b026592f11a07272f11398f
4
- data.tar.gz: 2c7987599b29f291c9778f32e703c007b2362287
3
+ metadata.gz: c2ecbc0b9fe2f833f16c373593fd4b7d3082d30e
4
+ data.tar.gz: ae4f6997359ec3c60ffbdb2f4dc882ae8452a567
5
5
  SHA512:
6
- metadata.gz: 265fec214f540c1685c8bdfe4220673563b3f54f46fcb2e2f4f27a58878e9723bdec8f88ca32ed3777cb6c790878c515865a85806c08d7e453e38956c46c8407
7
- data.tar.gz: 921d2c59c66956e30bdcd21a03070a24834b2079099e3ba669951e7b15fe33ca39a12fd8e8c6116b92d9f50b14d5ba521ffbc64c660eeac826acb61a58454977
6
+ metadata.gz: 4673b1f0d0df87785799af919b2a7982038b6313ec6489096992e6bb426408c2b18285d57ceda82c34d355cd4051ca29e36a050a33529c8c760d6f97ec88ef91
7
+ data.tar.gz: 282f6fdbdcefcdb69b3ef7eaec7ce7649bb247f517b5376771e3a0c1b2f3542c4b07a90051328f14c029c5301c14e1e3207e448cfffea8ef06a05e50783fc847
@@ -9,6 +9,7 @@
9
9
  #= require try_api/param.directive
10
10
  #= require try_api/paramsarray.directive
11
11
  #= require try_api/image.directive
12
+ #= require try_api/url.directive
12
13
 
13
14
  $ ->
14
15
  $('pre code').each (i, block) ->
@@ -34,11 +35,8 @@ $ ->
34
35
  TryApiApp = angular.module('TryApiApp', [
35
36
  'ui.bootstrap'
36
37
  'ngAnimate'
37
- 'formInput.image'
38
+ 'TryApi'
38
39
  'angular-ladda'
39
- 'param'
40
- 'params'
41
- 'paramsarray'
42
40
  'hljs'
43
41
  ])
44
42
  TryApiApp.config [
@@ -128,7 +126,6 @@ TryApiApp.controller 'HomeController', [
128
126
  method.submit = ->
129
127
  method.pending = true
130
128
  headers = {'Content-Type': undefined}
131
- path = data.project.api_prefix + method.path
132
129
 
133
130
  $.each method.headers, (i)->
134
131
  header = this
@@ -141,13 +138,13 @@ TryApiApp.controller 'HomeController', [
141
138
  $.each method.parameters, (i) ->
142
139
  $scope.addParameterToForm fd, this
143
140
 
144
- $http.post path, fd,
141
+ $http.post method.submit_path, fd,
145
142
  transformRequest: angular.identity
146
143
  headers: headers
147
144
  .success method.response_handler
148
145
  .error method.response_handler
149
146
  when 'delete'
150
- $http.delete path,
147
+ $http.delete method.submit_path,
151
148
  transformRequest: angular.identity
152
149
  headers: headers
153
150
  .success method.response_handler
@@ -159,7 +156,7 @@ TryApiApp.controller 'HomeController', [
159
156
  parameter = this
160
157
  fd = fd + parameter.name + '=' + (parameter.value || '') + '&'
161
158
 
162
- $http.get path + '?' + fd,
159
+ $http.get method.submit_path + '?' + fd,
163
160
  transformRequest: angular.identity
164
161
  headers: headers
165
162
  .success method.response_handler
@@ -170,7 +167,7 @@ TryApiApp.controller 'HomeController', [
170
167
  $.each method.parameters, (i) ->
171
168
  $scope.addParameterToForm fd, this
172
169
 
173
- $http.put path, fd,
170
+ $http.put method.submit_path, fd,
174
171
  transformRequest: angular.identity
175
172
  headers: headers
176
173
  .success method.response_handler
@@ -1,8 +1,6 @@
1
1
  'use strict';
2
2
 
3
- angular.module('formInput.image', []);
4
-
5
- angular.module('formInput.image').directive('image', ['$filter', function($filter) {
3
+ angular.module('TryApi').directive('image', ['$filter', function($filter) {
6
4
 
7
5
  function link(scope, element, attributes, ctrl) {
8
6
 
@@ -1,5 +1,4 @@
1
- angular.module 'param', []
2
- angular.module('param').directive 'param', [
1
+ angular.module('TryApi').directive 'param', [
3
2
  '$filter',
4
3
  '$sce'
5
4
  ($filter, $sce) ->
@@ -1,5 +1,5 @@
1
- angular.module 'params', []
2
- angular.module('params').directive 'params', [
1
+ angular.module 'TryApi', []
2
+ angular.module('TryApi').directive 'params', [
3
3
  () ->
4
4
 
5
5
  link = (scope, element, attrs, ctrl) ->
@@ -1,5 +1,4 @@
1
- angular.module 'paramsarray', []
2
- angular.module('paramsarray').directive 'paramsarray', [
1
+ angular.module('TryApi').directive 'paramsarray', [
3
2
  '$filter'
4
3
  ($filter) ->
5
4
 
@@ -0,0 +1,40 @@
1
+ angular.module('TryApi').directive 'url', [
2
+ '$filter',
3
+ '$sce'
4
+ ($filter, $sce) ->
5
+
6
+ link = (scope, element, attrs, ctrl) ->
7
+
8
+ scope.isParameter = (value) ->
9
+ if value
10
+ return value.indexOf(':') != -1
11
+ else
12
+ return false
13
+
14
+ scope.parts = scope.pattern.split('/').filter(Boolean).map (i)->
15
+ value = if scope.isParameter(i) then '' else i
16
+ {
17
+ value: value,
18
+ placeholder: i
19
+ }
20
+
21
+ scope.$watch 'parts', ->
22
+ scope.url = scope.parts.map((i)->
23
+ i.value
24
+ ).join('/')
25
+ , true
26
+
27
+ return {
28
+ link: link
29
+ restrict: 'A'
30
+ require: 'ngModel'
31
+ scope:
32
+ url: '=ngModel'
33
+ pattern: '=pattern'
34
+ template: '<span ng-repeat="part in parts track by $index">' +
35
+ '/' +
36
+ '<span ng-if="!isParameter(part.placeholder)">{{ part.value }}</span>' +
37
+ '<input ng-if="isParameter(part.placeholder)" ng-model="part.value" placeholder="{{ part.placeholder }}"/>' +
38
+ '</span>'
39
+ }
40
+ ]
@@ -40,10 +40,13 @@ module TryApi
40
40
  result.with_indifferent_access
41
41
  end
42
42
 
43
- @@instance_count = 0
43
+ @@instances_count = 0
44
44
 
45
- def id
46
- @id ||= @@instance_count += 1
45
+ attr_accessor :id
46
+
47
+ def initialize()
48
+ super
49
+ self.id = @@instances_count += 1
47
50
  end
48
51
  end
49
52
  end
@@ -36,7 +36,7 @@
36
36
  <div class="col-md-6 method-try"><h4>{{ method.title }}</h4>
37
37
  <h4>
38
38
  <div class="label label-info">{{ method.method }}</div>
39
- {{ method.local_path }}
39
+ <span url=true ng-model="method.submit_path" pattern="method.local_path"></span>
40
40
  </h4>
41
41
  <div ng-if="method.headers.length &gt; 0"><label>Headers:</label>
42
42
  <div class="row parameter" ng-repeat="header in method.headers">
@@ -65,7 +65,7 @@
65
65
  </div>
66
66
  <br/>
67
67
  <div class="label">Data:</div>
68
- <div hljs="" hljs-language="json" hljs-source="method.response.data"></div>
68
+ <div hljs="" hljs-language="" hljs-source="method.response.data"></div>
69
69
  <br/>
70
70
  <div class="label">Headers:</div>
71
71
  <div hljs="" hljs-language="json" hljs-source="method.response.headers"></div>
@@ -1,3 +1,3 @@
1
1
  module TryApi
2
- VERSION = "0.0.17"
2
+ VERSION = "0.0.18"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: try_api
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.17
4
+ version: 0.0.18
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mykhaylo Skubenych
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-09-05 00:00:00.000000000 Z
11
+ date: 2016-09-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -253,6 +253,7 @@ files:
253
253
  - app/assets/javascripts/try_api/param.directive.js.coffee
254
254
  - app/assets/javascripts/try_api/params.directive.js.coffee
255
255
  - app/assets/javascripts/try_api/paramsarray.directive.js.coffee
256
+ - app/assets/javascripts/try_api/url.directive.js.coffee
256
257
  - app/assets/stylesheets/try_api/application.css.sass
257
258
  - app/controllers/try_api/application_controller.rb
258
259
  - app/controllers/try_api/pages_controller.rb