the_garage 2.8.0 → 2.8.2

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
  SHA256:
3
- metadata.gz: db48e7a0d0aed64278d3ffa5864f19bd70782481411c1414583bd29b0067f006
4
- data.tar.gz: e20592e6c499284c41afc51ea27c3c8258d074eae85afc062a20f878945511fa
3
+ metadata.gz: 87e84567628627fee3bffdaeefd236ffdf56006ee409bab69113c119d839b552
4
+ data.tar.gz: f8ae0df461e8fd8fa757ca678a65e1d35ebe39e7c756177050c1c8583bc2cdb7
5
5
  SHA512:
6
- metadata.gz: ac22ddabbe44a7c762817f1a361248709348506c06a20f3028460467b5a650bc0fc3db77703f77b586f1783c4854221fc56972f284981c9f44f4571d18cff103
7
- data.tar.gz: 37cbe8ea4a2b3cea57eb5ce3ffb199652a35fb973e3e57a77134ca92857d088a8442369f52458d758d46417236ca9e62b19d26fcfdd2b5561b72ba4d6a4e2634
6
+ metadata.gz: a88ab893ae65a6ccbfaeba765f043543bcc7cca342c9809438b0a14c0f4b048383ebcee9d13f559814bacae2a1e91b72a687b8c94f29c6e13cc9b22da8462f16
7
+ data.tar.gz: bb5c3f9e6d070bd2eab8daa35c4b92809dcef6bfa21fc0c95cf0a1c698651b3d9eec72649d4f82c4c033bb67948d6adeae2b8453445a205b0f4474639bc40243
data/README.md CHANGED
@@ -113,13 +113,15 @@ In `config/initializers/garage.rb`:
113
113
  Garage.configure {}
114
114
 
115
115
  # Optional
116
- Garage::TokenScope.configure do
117
- register :public, desc: "accessing publicly available data" do
118
- access :read, Recipe
119
- end
120
-
121
- register :read_post, desc: "reading blog post" do
122
- access :read, Post
116
+ Rails.application.config.to_prepare do
117
+ Garage::TokenScope.configure do
118
+ register :public, desc: "accessing publicly available data" do
119
+ access :read, Recipe
120
+ end
121
+
122
+ register :read_post, desc: "reading blog post" do
123
+ access :read, Post
124
+ end
123
125
  end
124
126
  end
125
127
 
@@ -0,0 +1,103 @@
1
+ jQuery(function(){
2
+ $(".get-oauth-token").colorbox({
3
+ transition: "none",
4
+ href: "#oauth-dialog",
5
+ inline: true
6
+ });
7
+
8
+ $(".modal-close").click(function(ev) {
9
+ $.colorbox.close();
10
+ ev.preventDefault();
11
+ });
12
+
13
+ var addNewParamField = function(container) {
14
+ const nextId = "parameter-" + $('.parameter', container).length;
15
+ const copy = $('.template .parameter').clone().attr('id', nextId);
16
+ $('.close-field', copy).click(ev => $('#' + nextId).detach());
17
+ $('.add-field', copy).click(ev => addNewParamField(container));
18
+ copy.show().appendTo(container);
19
+ };
20
+
21
+ const buildData = function(container) {
22
+ const data = {};
23
+ $('.parameter', container).each(function(index) {
24
+ const name = $('.name', this).val();
25
+ const value = $('.value', this).val();
26
+ return data[name] = value;
27
+ });
28
+ return data;
29
+ };
30
+
31
+ $('.console #method').change(function(ev) {
32
+ if (($(this).val() === 'POST') || ($(this).val() === 'PUT')) {
33
+ if ($('.parameters .parameter').length === 0) {
34
+ addNewParamField($('.parameters'));
35
+ }
36
+ } else {
37
+ $('.parameters').empty();
38
+ }
39
+ });
40
+
41
+ const buildHyperlinks = function(json) {
42
+ const html = $('<div/>').text(json).html().replace(/"href": "(\/.*?)"/g, "\"href\": \"<a>$1</a>\"");
43
+ const dom = $(`<div>${html}</div>`);
44
+ $('a', dom).each(function(i) {
45
+ return $(this).attr('href', `${location.pathname}?location=${encodeURIComponent($(this).text())}&method=GET`);
46
+ });
47
+ return dom.html();
48
+ };
49
+
50
+ $('.console .send-request').click(function(ev) {
51
+ $('#api-headers').text('');
52
+ $('#api-response').text('');
53
+
54
+ console.log(buildData($('.parameters')));
55
+ $.ajax({
56
+ type: $('#method').val(),
57
+ url: $('#base').val() + $('#location').val(),
58
+ headers: {'Authorization': 'Bearer ' + $('#access_token').val()},
59
+ cache: false,
60
+ data: buildData($('.parameters')),
61
+ dataType: 'json',
62
+ complete() {
63
+ const queryString = $.param({'location': $('#location').val(), 'method': $('#method').val()});
64
+ const newFullpath = `${location.pathname}?${queryString}`;
65
+ history.pushState('', '', newFullpath);
66
+ $("#oauth-dialog #return_to").val(newFullpath);
67
+ },
68
+ success(data, textStatus, xhr) {
69
+ $('#api-headers').text(`${xhr.status} ${xhr.statusText}\n` + xhr.getAllResponseHeaders());
70
+ $('#api-response').html(buildHyperlinks(JSON.stringify(data, undefined, 2)));
71
+ },
72
+ error(xhr, textStatus, error) {
73
+ $('#api-headers').text(`${xhr.status} ${xhr.statusText}\n` + xhr.getAllResponseHeaders());
74
+ $('#api-response').text(xhr.responseText);
75
+ }
76
+ });
77
+ ev.preventDefault();
78
+ });
79
+
80
+ if (($('.console #token').val() !== '') && ($('.console #location').val() !== '') && ($('.console #method').val() === 'GET')) {
81
+ $('.send-request').click();
82
+ }
83
+
84
+ if ($('.oauth-callback-redirect').size() > 0) {
85
+ const token = window.location.hash.match(/\#access_token=(\w+)/)[1];
86
+ if (token) {
87
+ $('#access_token').val(token);
88
+ $('form.oauth-callback-redirect').submit();
89
+ }
90
+ }
91
+
92
+ $('#oauth-dialog .token-scope-check-all').click(function(ev) {
93
+ $('.token-scope-checkbox').prop('checked', this.checked);
94
+ });
95
+
96
+ return $('#oauth-dialog .token-scope-checkbox').click(function(ev) {
97
+ if ($('.token-scope-checkbox:not(:checked)').length === 0) {
98
+ $('.token-scope-check-all').prop('checked', true);
99
+ } else if (!this.checked) {
100
+ $('.token-scope-check-all').prop('checked', false);
101
+ }
102
+ });
103
+ });
@@ -48,15 +48,11 @@
48
48
  background: #000;
49
49
  }
50
50
 
51
- @mixin border-radius($size) {
52
- -moz-border-radius: $size;
53
- -webkit-border-radius: $size;
54
- -o-border-radius: $size;
55
- border-radius: $size;
56
- }
57
-
58
51
  #cboxLoadedContent {
59
- @include border-radius(10px);
52
+ -moz-border-radius: 10px;
53
+ -webkit-border-radius: 10px;
54
+ -o-border-radius: 10px;
55
+ border-radius: 10px;
60
56
  border: 10px solid #fff;
61
57
  background: #fff;
62
58
  }
@@ -0,0 +1,51 @@
1
+ body {
2
+ padding-bottom: 100px;
3
+ }
4
+
5
+ .resources_controller.index_action h2,
6
+ .resources_controller.index_action h3,
7
+ .resources_controller.index_action h4 {
8
+ margin-top: 1.5em;
9
+ }
10
+
11
+ .resources_controller.show_action h2 {
12
+ font-size: 20px;
13
+ }
14
+
15
+ .resources_controller.show_action h3 {
16
+ font-size: 16px;
17
+ }
18
+
19
+ .resources_controller.show_action .document h2 {
20
+ margin-top: 4em;
21
+ padding-bottom: .5em;
22
+ border-bottom: solid 1px #eee;
23
+ }
24
+
25
+ .resources_controller.show_action .toc ul ul {
26
+ display: none;
27
+ }
28
+
29
+ .resources_controller.show_action .main h1 {
30
+ padding-bottom: .5em;
31
+ border-bottom: solid 1px #eee;
32
+ }
33
+
34
+ .resources_controller.console_action .main #oauth-dialog {
35
+ display: none;
36
+ }
37
+
38
+ .resources_controller.console_action .response {
39
+ margin-top: 4em;
40
+ }
41
+
42
+ .resources_controller .sidebar-nav > .nav > li > a {
43
+ padding-top: 2px;
44
+ padding-bottom: 2px;
45
+ }
46
+
47
+ .resources_controller code {
48
+ overflow: auto;
49
+ white-space: pre-wrap;
50
+ word-wrap: break-word;
51
+ }
@@ -1,7 +1,5 @@
1
1
  require "rails"
2
2
  require "haml"
3
- require "sassc-rails"
4
- require "coffee-rails"
5
3
  require "redcarpet"
6
4
 
7
5
  require "garage/docs/anchor_building"
data/lib/garage/tracer.rb CHANGED
@@ -16,7 +16,7 @@ module Garage
16
16
  # Any tracers must have `.start` to start tracing context and:
17
17
  # - `#inject_trace_context` to add tracing context to the given request header.
18
18
  # - `#record_http_request` to record http request in tracer.
19
- # - `#record_http_response` to recrod http response in tracer.
19
+ # - `#record_http_response` to record http response in tracer.
20
20
  class NullTracer
21
21
  def self.start(&block)
22
22
  yield new
data/lib/garage/utils.rb CHANGED
@@ -16,7 +16,7 @@ module Garage
16
16
  end
17
17
 
18
18
  def fuzzy_parse(date)
19
- if date.is_a?(Numeric) || /^\d+$/ === date
19
+ if date.is_a?(Numeric) || /\A\d+\z/ === date
20
20
  Time.zone.at(date.to_i)
21
21
  else
22
22
  Time.zone.parse(date)
@@ -1,3 +1,3 @@
1
1
  module Garage
2
- VERSION = '2.8.0'
2
+ VERSION = '2.8.2'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: the_garage
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.8.0
4
+ version: 2.8.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tatsuhiko Miyagawa
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-01-11 00:00:00.000000000 Z
11
+ date: 2022-11-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -122,34 +122,6 @@ dependencies:
122
122
  - - ">="
123
123
  - !ruby/object:Gem::Version
124
124
  version: '0'
125
- - !ruby/object:Gem::Dependency
126
- name: sassc-rails
127
- requirement: !ruby/object:Gem::Requirement
128
- requirements:
129
- - - ">="
130
- - !ruby/object:Gem::Version
131
- version: '0'
132
- type: :runtime
133
- prerelease: false
134
- version_requirements: !ruby/object:Gem::Requirement
135
- requirements:
136
- - - ">="
137
- - !ruby/object:Gem::Version
138
- version: '0'
139
- - !ruby/object:Gem::Dependency
140
- name: coffee-rails
141
- requirement: !ruby/object:Gem::Requirement
142
- requirements:
143
- - - ">="
144
- - !ruby/object:Gem::Version
145
- version: '0'
146
- type: :runtime
147
- prerelease: false
148
- version_requirements: !ruby/object:Gem::Requirement
149
- requirements:
150
- - - ">="
151
- - !ruby/object:Gem::Version
152
- version: '0'
153
125
  - !ruby/object:Gem::Dependency
154
126
  name: http_accept_language
155
127
  requirement: !ruby/object:Gem::Requirement
@@ -175,11 +147,11 @@ files:
175
147
  - README.md
176
148
  - Rakefile
177
149
  - app/assets/javascripts/garage/application.js
178
- - app/assets/javascripts/garage/docs/console.js.coffee
150
+ - app/assets/javascripts/garage/docs/console.js
179
151
  - app/assets/javascripts/garage/docs/jquery.colorbox.js
180
152
  - app/assets/stylesheets/garage/application.css
181
- - app/assets/stylesheets/garage/colorbox.scss
182
- - app/assets/stylesheets/garage/style.scss
153
+ - app/assets/stylesheets/garage/colorbox.css
154
+ - app/assets/stylesheets/garage/style.css
183
155
  - app/assets/stylesheets/vendor/bootstrap.min.css
184
156
  - app/controllers/garage/application_controller.rb
185
157
  - app/controllers/garage/docs/resources_controller.rb
@@ -256,7 +228,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
256
228
  - !ruby/object:Gem::Version
257
229
  version: '0'
258
230
  requirements: []
259
- rubygems_version: 3.1.4
231
+ rubygems_version: 3.3.7
260
232
  signing_key:
261
233
  specification_version: 4
262
234
  summary: Garage Platform Engine
@@ -1,84 +0,0 @@
1
- jQuery ()->
2
- $(".get-oauth-token").colorbox(
3
- transition: "none"
4
- href: "#oauth-dialog"
5
- inline: true
6
- )
7
-
8
- $(".modal-close").click (ev) ->
9
- $.colorbox.close()
10
- ev.preventDefault()
11
-
12
- addNewParamField = (container) ->
13
- nextId = "parameter-" + $('.parameter', container).length
14
- copy = $('.template .parameter').clone().attr('id', nextId)
15
- $('.close-field', copy).click (ev) ->
16
- $('#' + nextId).detach()
17
- $('.add-field', copy).click (ev) ->
18
- addNewParamField(container)
19
- copy.show().appendTo(container)
20
-
21
- buildData = (container) ->
22
- data = {}
23
- $('.parameter', container).each (index) ->
24
- name = $('.name', this).val()
25
- value = $('.value', this).val()
26
- data[name] = value
27
- data
28
-
29
- $('.console #method').change (ev) ->
30
- if $(this).val() == 'POST' or $(this).val() == 'PUT'
31
- if $('.parameters .parameter').length == 0
32
- addNewParamField($('.parameters'))
33
- else
34
- $('.parameters').empty()
35
-
36
- buildHyperlinks = (json) ->
37
- html = $('<div/>').text(json).html().replace /"href": "(\/.*?)"/g, "\"href\": \"<a>$1</a>\""
38
- dom = $("<div>#{html}</div>")
39
- $('a', dom).each (i) ->
40
- $(this).attr('href', "#{location.pathname}?location=#{encodeURIComponent($(this).text())}&method=GET")
41
- dom.html()
42
-
43
- $('.console .send-request').click (ev) ->
44
- $('#api-headers').text ''
45
- $('#api-response').text ''
46
-
47
- console.log buildData($('.parameters'))
48
- $.ajax
49
- type: $('#method').val(),
50
- url: $('#base').val() + $('#location').val(),
51
- headers: {'Authorization': 'Bearer ' + $('#access_token').val()},
52
- cache: false,
53
- data: buildData($('.parameters')),
54
- dataType: 'json',
55
- complete: ->
56
- queryString = $.param({'location': $('#location').val(), 'method': $('#method').val()})
57
- newFullpath = "#{location.pathname}?#{queryString}"
58
- history.pushState('', '', newFullpath)
59
- $("#oauth-dialog #return_to").val(newFullpath)
60
- success: (data, textStatus, xhr) ->
61
- $('#api-headers').text("#{xhr.status} #{xhr.statusText}\n" + xhr.getAllResponseHeaders())
62
- $('#api-response').html buildHyperlinks(JSON.stringify(data, undefined, 2))
63
- error: (xhr, textStatus, error) ->
64
- $('#api-headers').text("#{xhr.status} #{xhr.statusText}\n" + xhr.getAllResponseHeaders())
65
- $('#api-response').text xhr.responseText
66
- ev.preventDefault()
67
-
68
- if $('.console #token').val() != '' && $('.console #location').val() != '' && $('.console #method').val() == 'GET'
69
- $('.send-request').click()
70
-
71
- if $('.oauth-callback-redirect').size() > 0
72
- token = window.location.hash.match(/\#access_token=(\w+)/)[1]
73
- if token
74
- $('#access_token').val(token)
75
- $('form.oauth-callback-redirect').submit()
76
-
77
- $('#oauth-dialog .token-scope-check-all').click (ev) ->
78
- $('.token-scope-checkbox').prop('checked', this.checked)
79
-
80
- $('#oauth-dialog .token-scope-checkbox').click (ev) ->
81
- if $('.token-scope-checkbox:not(:checked)').length == 0
82
- $('.token-scope-check-all').prop('checked', true)
83
- else if not this.checked
84
- $('.token-scope-check-all').prop('checked', false)
@@ -1,59 +0,0 @@
1
- body {
2
- padding-bottom: 100px;
3
- }
4
-
5
- .resources_controller.index_action {
6
- h2,
7
- h3,
8
- h4 {
9
- margin-top: 1.5em;
10
- }
11
- }
12
-
13
- .resources_controller.show_action {
14
- h2 {
15
- font-size: 20px;
16
- }
17
-
18
- h3 {
19
- font-size: 16px;
20
- }
21
-
22
- .document h2 {
23
- margin-top: 4em;
24
- padding-bottom: .5em;
25
- border-bottom: solid 1px #eee;
26
- }
27
-
28
- .toc ul ul {
29
- display: none;
30
- }
31
-
32
- .main h1 {
33
- padding-bottom: .5em;
34
- border-bottom: solid 1px #eee;
35
- }
36
- }
37
-
38
- .resources_controller.console_action {
39
- .main #oauth-dialog {
40
- display: none;
41
- }
42
-
43
- .response {
44
- margin-top: 4em;
45
- }
46
- }
47
-
48
- .resources_controller {
49
- .sidebar-nav > .nav > li > a {
50
- padding-top: 2px;
51
- padding-bottom: 2px;
52
- }
53
-
54
- code {
55
- overflow: auto;
56
- white-space: pre-wrap;
57
- word-wrap: break-word;
58
- }
59
- }