apipony 0.0.3 → 0.0.4

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: fba28b70c7a9ec44196e47c169e155354c568b6c
4
- data.tar.gz: b3a2c51b00dbff1967a9eda1912361782f63b32e
3
+ metadata.gz: 86b81077625eb78efec26c41c96c30e832ef5c02
4
+ data.tar.gz: d05befea092568084df3b920dfbc5ed4ea64f17d
5
5
  SHA512:
6
- metadata.gz: 8de377ae321a47d1bc86b5d952554ba17483b886e4ecdc59f239fefa76bc98ea30a9bbf9ee36dd816c662ed67b3554fed721029da5729e56bbaf104cd7831602
7
- data.tar.gz: 6ad91921dd5e5e85618d5fcbbdb30d557807ba2e5fae69e5413ad6ac2b5ff92b43afd04e628f7db18035e8316af795f9e694ead06a2c756bc223d6285200a4db
6
+ metadata.gz: 5fe9cdb7e1cfea04e9d4bac98aee904753b87750048da48fc4c37c826b9232bf709c17d1ed58f9c5c146b50f22915abc3cb91e054d85bd2c0c220d4c354c522c
7
+ data.tar.gz: 2b756e4a6ec30fe410c96d8fa6d609dac9d73284b8c7f7b3bb594427d178873c97c857ce60a6d022d5ed629d6bea18aba6527a03f37d7b379b1a5961e6fbc698
data/README.md CHANGED
@@ -28,9 +28,7 @@ Apipony::Documentation.define do
28
28
  e.description = 'Find ponies'
29
29
 
30
30
  request_with do
31
- set :params, {
32
- :name => :applejack
33
- }
31
+ param :name, example: 'applejack', required: true
34
32
  end
35
33
 
36
34
  response_with 200 do
@@ -1,6 +1,9 @@
1
1
  $dark_color: #111;
2
2
  $medium_color: #888;
3
3
  $light_color: #eee;
4
+ $brand_color: #5E147D;
5
+
6
+ @import url(https://fonts.googleapis.com/css?family=Cuprum&subset=latin,cyrillic);
4
7
 
5
8
  * {
6
9
  margin: 0;
@@ -66,7 +69,6 @@ ul {
66
69
  .container {
67
70
  width: 940px;
68
71
  margin: 0 auto;
69
- padding: 40px 0;
70
72
  position: relative;
71
73
  }
72
74
 
@@ -90,6 +92,39 @@ ul {
90
92
  }
91
93
  }
92
94
 
95
+ header {
96
+ background: $brand_color;
97
+ height: 60px;
98
+ line-height: 60px;
99
+ .title {
100
+ font-family: 'Cuprum';
101
+ font-weight: bold;
102
+ font-size: 20px;
103
+ color: #fff;
104
+ }
105
+ .back {
106
+ float: right;
107
+ color: #fff;
108
+ opacity: .7;
109
+ font-size: 12px;
110
+ }
111
+ }
112
+
113
+ main {
114
+ padding: 40px 0;
115
+ }
116
+
117
+ footer {
118
+ height: 60px;
119
+ line-height: 60px;
120
+ border-top: 1px solid $light_color;
121
+ text-align: right;
122
+ font-size: 12px;
123
+ a {
124
+ color: $medium_color;
125
+ }
126
+ }
127
+
93
128
  .section {
94
129
  &:not(:last-child) {
95
130
  padding-bottom: 40px;
@@ -152,3 +187,29 @@ ul {
152
187
  background: #C0392B;
153
188
  }
154
189
  }
190
+
191
+ .param {
192
+ .name {
193
+ color: $brand_color;
194
+ font-weight: bold;
195
+ }
196
+ .type {
197
+ color: $medium_color;
198
+ font-style: italic;
199
+ }
200
+ .required {
201
+ text-align: center;
202
+ .fa {
203
+ color: $medium_color;
204
+ }
205
+ }
206
+ }
207
+
208
+ .table {
209
+ padding: 8px 0;
210
+ tr {
211
+ td {
212
+ padding: 2px 10px;
213
+ }
214
+ }
215
+ }
@@ -1,50 +1,74 @@
1
- .row
2
- .col-3
3
- - @documentation.sections.each do |section|
4
- %h4= section.title
5
- %ul
6
- - section.endpoints.each do |endpoint|
7
- %li
8
- %h5
9
- = link_to root_path(:anchor => endpoint.id) do
10
- %span.method{ :class => endpoint.method }<
11
- = endpoint.method
12
- = endpoint.url
13
- .col-9
14
- %h1= @documentation.title
15
- - @documentation.sections.each do |section|
16
- .section
17
- %h2= section.title
18
- - section.endpoints.each do |endpoint|
19
- .endpoint{ :id => endpoint.id }
20
- %h3
21
- %span.method{ :class => endpoint.method }<
22
- = endpoint.method
23
- = endpoint.url
24
- - if endpoint.description
25
- .description= endpoint.description
26
- - if endpoint.request || endpoint.response
27
- - if endpoint.request
28
- .request
29
- %h4 Request:
30
- - if endpoint.request.params
31
- .panel
32
- .title Parameters
33
- %pre.code= JSON.pretty_generate(endpoint.request.params)
34
- - if endpoint.request.headers
35
- .panel
36
- .title Headers
37
- %pre.code= JSON.pretty_generate(endpoint.request.headers)
38
- - if endpoint.response
39
- .response
40
- %h4
41
- Response:
42
- = endpoint.response.status
43
- - if endpoint.response.body
44
- .panel
45
- .title Body
46
- %pre.code= JSON.pretty_generate(endpoint.response.body)
47
- - if endpoint.response.headers
48
- .panel
49
- .title Headers
50
- %pre.code= JSON.pretty_generate(endpoint.response.headers)
1
+ %header
2
+ .container
3
+ = link_to @documentation.title, root_path, class: 'title'
4
+ - if main_app.root_path
5
+ = link_to 'Back to site', main_app.root_path, class: 'back'
6
+ %main
7
+ .container
8
+ .row
9
+ .col-3
10
+ - @documentation.sections.each do |section|
11
+ %h4= section.title
12
+ %ul
13
+ - section.endpoints.each do |endpoint|
14
+ %li
15
+ %h5
16
+ = link_to root_path(:anchor => endpoint.id) do
17
+ %span.method{ :class => endpoint.method }<
18
+ = endpoint.method
19
+ = endpoint.url
20
+ .col-9
21
+ - @documentation.sections.each do |section|
22
+ .section
23
+ %h2= section.title
24
+ - section.endpoints.each do |endpoint|
25
+ .endpoint{ :id => endpoint.id }
26
+ %h3
27
+ %span.method{ :class => endpoint.method }<
28
+ = endpoint.method
29
+ = endpoint.url
30
+ - if endpoint.description
31
+ .description= endpoint.description
32
+ - if endpoint.request || endpoint.response
33
+ - if endpoint.request
34
+ .request
35
+ %h4 Request:
36
+ - if endpoint.request.params
37
+ .panel
38
+ .title Parameters
39
+ %table.table
40
+ - endpoint.request.params.each do |param|
41
+ %tr.param
42
+ %td.name
43
+ = param.name
44
+ %td.type
45
+ = param.type
46
+ %td.required
47
+ - if param.required
48
+ %i.fa.fa-check-square-o{ :title => 'Required' }
49
+ - else
50
+ %i.fa.fa-square-o{ :title => 'Optional' }
51
+ %td.example
52
+ = param.example
53
+ - if endpoint.request.headers
54
+ .panel
55
+ .title Headers
56
+ %pre.code= JSON.pretty_generate(endpoint.request.headers)
57
+ - if endpoint.response
58
+ .response
59
+ %h4
60
+ Response:
61
+ = endpoint.response.status
62
+ - if endpoint.response.body
63
+ .panel
64
+ .title Body
65
+ %pre.code= JSON.pretty_generate(endpoint.response.body)
66
+ - if endpoint.response.headers
67
+ .panel
68
+ .title Headers
69
+ %pre.code= JSON.pretty_generate(endpoint.response.headers)
70
+ %footer
71
+ .container
72
+ = link_to 'https://github.com/droptheplot/apipony' do
73
+ %i.fa.fa-github
74
+ Apipony
@@ -3,10 +3,10 @@
3
3
  %head
4
4
  %title Apipony
5
5
  %link{ :href => '//cdnjs.cloudflare.com/ajax/libs/highlight.js/8.9.1/styles/github.min.css', :rel => 'stylesheet' }/
6
+ %link{ :href => 'https://maxcdn.bootstrapcdn.com/font-awesome/4.5.0/css/font-awesome.min.css', :rel => 'stylesheet' }/
6
7
  = stylesheet_link_tag 'apipony/application', media: 'all'
7
8
  %script{ :src => '//cdnjs.cloudflare.com/ajax/libs/highlight.js/8.9.1/highlight.min.js' }
8
9
  = javascript_include_tag 'apipony/application'
9
10
  = csrf_meta_tags
10
11
  %body
11
- .container
12
- = yield
12
+ = yield
data/lib/apipony.rb CHANGED
@@ -6,6 +6,7 @@ require 'apipony/section'
6
6
  require 'apipony/endpoint'
7
7
  require 'apipony/response'
8
8
  require 'apipony/request'
9
+ require 'apipony/parameter'
9
10
 
10
11
  module Apipony
11
12
  end
@@ -0,0 +1,10 @@
1
+ class Apipony::Parameter < Apipony::Base
2
+ attr_accessor :name, :type, :example, :required
3
+
4
+ def initialize(name, example, type, required)
5
+ @name = name
6
+ @example = example
7
+ @type = type
8
+ @required = required
9
+ end
10
+ end
@@ -2,6 +2,12 @@ class Apipony::Request < Apipony::Base
2
2
  attr_accessor :params, :headers
3
3
 
4
4
  def initialize(&block)
5
+ @params = []
6
+
5
7
  instance_eval(&block)
6
8
  end
9
+
10
+ def param(name, example: '', type: :string, required: false)
11
+ @params << Apipony::Parameter.new(name, example, type, required)
12
+ end
7
13
  end
@@ -1,3 +1,3 @@
1
1
  module Apipony
2
- VERSION = '0.0.3'
2
+ VERSION = '0.0.4'
3
3
  end
@@ -9,9 +9,7 @@ Apipony::Documentation.define do
9
9
  e.description = 'Find ponies'
10
10
 
11
11
  request_with do
12
- set :params, {
13
- :name => :applejack
14
- }
12
+ param :name, example: :applejack, required: true
15
13
  end
16
14
 
17
15
  response_with 200 do
@@ -28,12 +26,10 @@ Apipony::Documentation.define do
28
26
  e.description = 'Create pony'
29
27
 
30
28
  request_with do
31
- set :params, {
32
- :name => :fluttershy,
33
- :kind => :pegasus,
34
- :sex => :female,
35
- :occupation => :caretaker
36
- }
29
+ param :name, example: :fluttershy
30
+ param :kind, example: :pegasus
31
+ param :sex, example: :female
32
+ param :occupation, example: :caretaker
37
33
  end
38
34
 
39
35
  response_with 200
@@ -43,12 +39,10 @@ Apipony::Documentation.define do
43
39
  e.description = 'Update pony id'
44
40
 
45
41
  request_with do
46
- set :params, {
47
- :name => :fluttershy,
48
- :kind => :pegasus,
49
- :sex => :female,
50
- :occupation => :singer
51
- }
42
+ param :name
43
+ param :kind
44
+ param :sex
45
+ param :occupation
52
46
  end
53
47
  end
54
48
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: apipony
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sergey Novikov
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-11-27 00:00:00.000000000 Z
11
+ date: 2015-11-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -184,6 +184,7 @@ files:
184
184
  - lib/apipony/documentation.rb
185
185
  - lib/apipony/endpoint.rb
186
186
  - lib/apipony/engine.rb
187
+ - lib/apipony/parameter.rb
187
188
  - lib/apipony/request.rb
188
189
  - lib/apipony/response.rb
189
190
  - lib/apipony/section.rb