kanpachi 0.0.2 → 0.0.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
  SHA1:
3
- metadata.gz: 6b32fca8beebd8f5825ae812e10da8afcc954e1e
4
- data.tar.gz: e9b1afcb5063c31d7a34a00df982df90b2018444
3
+ metadata.gz: 8e5b6e4840bc2626d0f535c41b4b1616c68ed104
4
+ data.tar.gz: 6a8a37c95c72696c02a1d16584f86a2e7a52da83
5
5
  SHA512:
6
- metadata.gz: 13b00d7801dcaa54c0a1ecb266cbfce68ee90f453b72c4d4fc502eb65ad4e701436906ea1e5e8dd773c14095798732484b749968aaef02b7c333d9b8052c902b
7
- data.tar.gz: c522f30028ccaf62e7161b622090fb318d3df0ae86a9ae6a2c0623f44ab8558722b1e00dbca5466a7263c512f37910f2bba3b0825911f91edb4fff63499315a9
6
+ metadata.gz: a3b3203cf7f46001360c790ebe6737221121a43e9be71d4ea9df159c2090c60c7e22bb776f25eb497128a6dc72836a16c1684d54ab4711b044f311441114367c
7
+ data.tar.gz: a23863a0ce77e9774db497c11c683dc350d91adc7db3011d0c490f15313c941ce545bc46befd62a6987110467f22b0249c08f9b6a6e10763d745c001add80099
data/CHANGELOG.md CHANGED
@@ -1,5 +1,10 @@
1
1
  # Kanpachi Changelog
2
2
 
3
+ ## 0.0.3
4
+ * Wrap documentation footer in a container class to pad copyright
5
+ * Switch response roar representer to decorator. Prefer decorating objects
6
+ rather than mutating them with `#extend`.
7
+
3
8
  ## 0.0.2
4
9
 
5
10
  * Add error codes and responses documentation page.
data/README.md CHANGED
@@ -23,12 +23,14 @@ Below is an example of one of Twitter's API endpoints partially described in Kan
23
23
  api 'Twitter' do
24
24
  # API meta data
25
25
  title 'REST API v1.1 Resources'
26
- description 'This describes the resources that make up the official Twitter API v1.1'
26
+ description 'This describes the resources that make up the official Twitter
27
+ API v1.1'
27
28
  host 'api.twitter.com'
28
29
 
29
30
  # Define global error responses
30
31
  error :malformed_params do
31
- description 'Sending invalid JSON will result in a 400 Bad Request response.'
32
+ description 'Sending invalid JSON will result in a 400 Bad Request
33
+ response.'
32
34
 
33
35
  response do
34
36
  status 400
@@ -40,35 +42,56 @@ api 'Twitter' do
40
42
  end
41
43
 
42
44
  section 'Timelines' do
43
- description 'Timelines are collections of Tweets, ordered with the most recent first.'
44
-
45
45
  resource :get, '/statuses/mentions_timeline' do
46
46
  name 'Mentions timeline'
47
- description <<-TEXT
48
- Returns the 20 most recent mentions (tweets containing a users's @screen_name) for the authenticating user.
47
+ description <<-END
48
+ Returns the 20 most recent mentions (tweets containing a users's @screen_name)
49
+ for the authenticating user.
49
50
 
50
- The timeline returned is the equivalent of the one seen when you view [your mentions](https://twitter.com/mentions) on twitter.com.
51
+ The timeline returned is the equivalent of the one seen when you view
52
+ [your mentions](https://twitter.com/mentions) on twitter.com.
51
53
 
52
54
  This method can only return up to 800 tweets.
53
55
 
54
- See [__Working with Timelines__](https://dev.twitter.com/docs/working-with-timelines) for instructions on traversing timelines.
55
- TEXT
56
+ See [__Working with Timelines__](https://dev.twitter.com/docs/working-with-timelines)
57
+ for instructions on traversing timelines.
58
+ END
56
59
  versions '1.1'
57
60
  ssl true
58
61
  formats :json
59
62
 
60
- # Params are a subclass of Mutations::Command
61
63
  params do
62
- required do
63
- end
64
-
65
64
  optional do
66
- integer :count, doc: 'Specifies the number of tweets to try and retrieve, up to a maximum of 200. The value of count is best thought of as a limit to the number of tweets to return because suspended or deleted content is removed after the count has been applied. We include retweets in the count, even if `include_rts` is not supplied. It is recommended you always send `include_rts=1` when using this API method.'
67
- integer :since_id, doc: 'Returns results with an ID greater than (that is, more recent than) the specified ID. There are limits to the number of Tweets which can be accessed through the API. If the limit of Tweets has occured since the since_id, the since_id will be forced to the oldest ID available.', example: 12345
68
- integer :max_id, doc: 'Returns results with an ID less than (that is, older than) or equal to the specified ID.', example: 54321
69
- boolean :trim_user, doc: 'When set to either true, t or 1, each tweet returned in a timeline will include a user object including only the status authors numerical ID. Omit this parameter to receive the complete user object.', example: true
70
- boolean :contributor_details, doc: 'This parameter enhances the contributors element of the status response to include the screen_name of the contributor. By default only the user_id of the contributor is included.', example: true
71
- boolean :include_entities, doc: 'The `entities` node will be disincluded when set to false.', example: false
65
+ integer :count,
66
+ doc: 'Specifies the number of tweets to try and retrieve, up to a
67
+ maximum of 200. The value of count is best thought of as a limit to the number
68
+ of tweets to return because suspended or deleted content is removed after the
69
+ count has been applied. We include retweets in the count, even if `include_rts`
70
+ is not supplied. It is recommended you always send `include_rts=1` when using
71
+ this API method.'
72
+ integer :since_id,
73
+ doc: 'Returns results with an ID greater than (that is, more recent
74
+ than) the specified ID. There are limits to the number of Tweets which can be
75
+ accessed through the API. If the limit of Tweets has occured since the since_id,
76
+ the since_id will be forced to the oldest ID available.',
77
+ example: 12345
78
+ integer :max_id,
79
+ doc: 'Returns results with an ID less than (that is, older than) or
80
+ equal to the specified ID.',
81
+ example: 54321
82
+ boolean :trim_user,
83
+ doc: 'When set to either true, t or 1, each tweet returned in a
84
+ timeline will include a user object including only the status authors numerical
85
+ ID. Omit this parameter to receive the complete user object.',
86
+ example: true
87
+ boolean :contributor_details,
88
+ doc: 'This parameter enhances the contributors element of the status
89
+ response to include the screen_name of the contributor. By default only the
90
+ user_id of the contributor is included.',
91
+ example: true
92
+ boolean :include_entities,
93
+ doc: 'The `entities` node will be disincluded when set to false.',
94
+ example: false
72
95
  end
73
96
  end
74
97
 
@@ -80,8 +103,14 @@ TEXT
80
103
  # Response representations include Roar::Representer
81
104
  representation do
82
105
  include ::Representable::JSON::Collection
83
- property :title, type: String, doc: "it's the title", example: 'The Title'
84
- collection :coordinates, doc: "it's the coordinates", example: [100.4, 45.1]
106
+
107
+ property :title,
108
+ type: String,
109
+ doc: 'The title',
110
+ example: 'The Title'
111
+ collection :coordinates,
112
+ doc: 'The coordinates',
113
+ example: [100.4, 45.1]
85
114
  end
86
115
  end
87
116
  end
data/kanpachi.gemspec CHANGED
@@ -19,24 +19,23 @@ Gem::Specification.new do |spec|
19
19
  spec.require_paths = ["lib"]
20
20
 
21
21
  spec.add_dependency 'thor'
22
- spec.add_dependency 'slim'
23
22
  spec.add_dependency 'roar'
24
23
  spec.add_dependency 'representable'
25
24
  spec.add_dependency 'mutations'
26
- spec.add_dependency 'virtus', '>= 1.0.0.beta7'
25
+ spec.add_dependency 'virtus', '~> 1.0.0rc2'
27
26
  spec.add_dependency 'coercible'
28
27
  spec.add_dependency 'kramdown'
29
28
  spec.add_dependency 'inflecto'
30
- spec.add_dependency 'middleman', '>= 3.1.5'
31
- spec.add_dependency 'slim', '>= 1.3.6'
29
+ spec.add_dependency 'middleman', '~> 3.1.5'
30
+ spec.add_dependency 'slim', '~> 1.3.9'
32
31
 
33
32
  # Live-reloading plugin
34
- spec.add_dependency 'middleman-livereload', '>= 3.1.0'
33
+ spec.add_dependency 'middleman-livereload', '~> 3.1.0'
35
34
 
36
35
  spec.add_development_dependency 'bundler'
37
36
  spec.add_development_dependency 'rake'
38
- spec.add_development_dependency 'minitest'
39
- spec.add_development_dependency 'guard', '>= 2.0.0.beta.3'
37
+ spec.add_development_dependency 'minitest', '~> 5.0.0'
38
+ spec.add_development_dependency 'guard'
40
39
  spec.add_development_dependency 'guard-minitest'
41
40
 
42
41
  # For faster file watcher updates on Windows:
@@ -10,7 +10,7 @@ module Kanpachi
10
10
  class_option :test_framework, default: :minitest
11
11
 
12
12
  def self.source_root
13
- File.expand_path(File.join('..', 'templates'), File.dirname(__FILE__))
13
+ File.expand_path(File.join('..', '..', '..', 'templates'), File.dirname(__FILE__))
14
14
  end
15
15
 
16
16
  def create_app
@@ -47,7 +47,8 @@ html
47
47
  = yield
48
48
  hr
49
49
  footer
50
- | &copy; #{Time.now.year}
50
+ .container
51
+ | &copy; #{Time.now.year}
51
52
 
52
53
  /! /container
53
54
  /!
@@ -1,5 +1,5 @@
1
- require 'roar/representer'
2
- require 'roar/representer/feature/hypermedia'
1
+ require 'roar/representer/json'
2
+ require 'roar/decorator'
3
3
  require 'representable/json/collection'
4
4
  require 'representable/json/hash'
5
5
 
@@ -14,14 +14,14 @@ module Kanpachi
14
14
  @name = name
15
15
  @status = 200
16
16
  @headers = {}
17
- @representation = Module.new { include Representation }
17
+ @representation = Class.new(Roar::Decorator) { include Representation }
18
18
  end
19
19
 
20
20
  module Representation
21
21
  def self.included(base)
22
22
  base.class_eval do
23
- include Roar::Representer
24
- include Roar::Representer::Feature::Hypermedia
23
+ include Roar::Representer::JSON
24
+ include Roar::Decorator::HypermediaConsumer
25
25
 
26
26
  def self.example
27
27
  example = Hash.new
@@ -1,3 +1,3 @@
1
1
  module Kanpachi
2
- VERSION = '0.0.2'
2
+ VERSION = '0.0.3'
3
3
  end
@@ -108,12 +108,12 @@ describe 'Integration Spec' do
108
108
  u = user.new
109
109
  u.first_name = "Jack"
110
110
  u.last_name = "Chu"
111
- rep = repo.new.extend(r.responses.all.first.representation)
111
+ rep = repo.new
112
112
  rep.title = "Hi"
113
113
  rep.id = ""
114
114
  rep.users = []
115
115
  rep.users << u
116
- puts rep.to_json
116
+ puts r.responses.all.first.representation.new(rep).to_json
117
117
 
118
118
  puts rep
119
119
  puts r.url
@@ -27,9 +27,10 @@ describe Kanpachi::Response do
27
27
  subject.representation.must_equal representation
28
28
  end
29
29
 
30
- it 'representation is a Roar representer' do
31
- subject.representation.ancestors.must_include Roar::Representer
32
- subject.representation.ancestors.must_include Roar::Representer::Feature::Hypermedia
30
+ it 'representation is a Roar decorator' do
31
+ subject.representation.superclass.must_equal Roar::Decorator
32
+ subject.representation.ancestors.must_include Roar::Representer::JSON
33
+ subject.representation.ancestors.must_include Roar::Decorator::HypermediaConsumer
33
34
  end
34
35
 
35
36
  it 'representation returns properties' do
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: kanpachi
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jack Chu
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-10-03 00:00:00.000000000 Z
11
+ date: 2013-10-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: thor
@@ -24,20 +24,6 @@ dependencies:
24
24
  - - ">="
25
25
  - !ruby/object:Gem::Version
26
26
  version: '0'
27
- - !ruby/object:Gem::Dependency
28
- name: slim
29
- requirement: !ruby/object:Gem::Requirement
30
- requirements:
31
- - - ">="
32
- - !ruby/object:Gem::Version
33
- version: '0'
34
- type: :runtime
35
- prerelease: false
36
- version_requirements: !ruby/object:Gem::Requirement
37
- requirements:
38
- - - ">="
39
- - !ruby/object:Gem::Version
40
- version: '0'
41
27
  - !ruby/object:Gem::Dependency
42
28
  name: roar
43
29
  requirement: !ruby/object:Gem::Requirement
@@ -84,16 +70,16 @@ dependencies:
84
70
  name: virtus
85
71
  requirement: !ruby/object:Gem::Requirement
86
72
  requirements:
87
- - - ">="
73
+ - - "~>"
88
74
  - !ruby/object:Gem::Version
89
- version: 1.0.0.beta7
75
+ version: 1.0.0rc2
90
76
  type: :runtime
91
77
  prerelease: false
92
78
  version_requirements: !ruby/object:Gem::Requirement
93
79
  requirements:
94
- - - ">="
80
+ - - "~>"
95
81
  - !ruby/object:Gem::Version
96
- version: 1.0.0.beta7
82
+ version: 1.0.0rc2
97
83
  - !ruby/object:Gem::Dependency
98
84
  name: coercible
99
85
  requirement: !ruby/object:Gem::Requirement
@@ -140,42 +126,42 @@ dependencies:
140
126
  name: middleman
141
127
  requirement: !ruby/object:Gem::Requirement
142
128
  requirements:
143
- - - ">="
129
+ - - "~>"
144
130
  - !ruby/object:Gem::Version
145
131
  version: 3.1.5
146
132
  type: :runtime
147
133
  prerelease: false
148
134
  version_requirements: !ruby/object:Gem::Requirement
149
135
  requirements:
150
- - - ">="
136
+ - - "~>"
151
137
  - !ruby/object:Gem::Version
152
138
  version: 3.1.5
153
139
  - !ruby/object:Gem::Dependency
154
140
  name: slim
155
141
  requirement: !ruby/object:Gem::Requirement
156
142
  requirements:
157
- - - ">="
143
+ - - "~>"
158
144
  - !ruby/object:Gem::Version
159
- version: 1.3.6
145
+ version: 1.3.9
160
146
  type: :runtime
161
147
  prerelease: false
162
148
  version_requirements: !ruby/object:Gem::Requirement
163
149
  requirements:
164
- - - ">="
150
+ - - "~>"
165
151
  - !ruby/object:Gem::Version
166
- version: 1.3.6
152
+ version: 1.3.9
167
153
  - !ruby/object:Gem::Dependency
168
154
  name: middleman-livereload
169
155
  requirement: !ruby/object:Gem::Requirement
170
156
  requirements:
171
- - - ">="
157
+ - - "~>"
172
158
  - !ruby/object:Gem::Version
173
159
  version: 3.1.0
174
160
  type: :runtime
175
161
  prerelease: false
176
162
  version_requirements: !ruby/object:Gem::Requirement
177
163
  requirements:
178
- - - ">="
164
+ - - "~>"
179
165
  - !ruby/object:Gem::Version
180
166
  version: 3.1.0
181
167
  - !ruby/object:Gem::Dependency
@@ -210,30 +196,30 @@ dependencies:
210
196
  name: minitest
211
197
  requirement: !ruby/object:Gem::Requirement
212
198
  requirements:
213
- - - ">="
199
+ - - "~>"
214
200
  - !ruby/object:Gem::Version
215
- version: '0'
201
+ version: 5.0.0
216
202
  type: :development
217
203
  prerelease: false
218
204
  version_requirements: !ruby/object:Gem::Requirement
219
205
  requirements:
220
- - - ">="
206
+ - - "~>"
221
207
  - !ruby/object:Gem::Version
222
- version: '0'
208
+ version: 5.0.0
223
209
  - !ruby/object:Gem::Dependency
224
210
  name: guard
225
211
  requirement: !ruby/object:Gem::Requirement
226
212
  requirements:
227
213
  - - ">="
228
214
  - !ruby/object:Gem::Version
229
- version: 2.0.0.beta.3
215
+ version: '0'
230
216
  type: :development
231
217
  prerelease: false
232
218
  version_requirements: !ruby/object:Gem::Requirement
233
219
  requirements:
234
220
  - - ">="
235
221
  - !ruby/object:Gem::Version
236
- version: 2.0.0.beta.3
222
+ version: '0'
237
223
  - !ruby/object:Gem::Dependency
238
224
  name: guard-minitest
239
225
  requirement: !ruby/object:Gem::Requirement
@@ -272,7 +258,6 @@ files:
272
258
  - lib/kanpachi/api.rb
273
259
  - lib/kanpachi/api_list.rb
274
260
  - lib/kanpachi/cli.rb
275
- - lib/kanpachi/cli/doc.rb
276
261
  - lib/kanpachi/commands/new.rb
277
262
  - lib/kanpachi/documentation/config.rb
278
263
  - lib/kanpachi/documentation/source/errors/index.html.slim
@@ -312,13 +297,6 @@ files:
312
297
  - lib/kanpachi/response_list.rb
313
298
  - lib/kanpachi/section.rb
314
299
  - lib/kanpachi/section_list.rb
315
- - lib/kanpachi/templates/.gitignore
316
- - lib/kanpachi/templates/Gemfile
317
- - lib/kanpachi/templates/api/api.rb
318
- - lib/kanpachi/templates/api/errors.rb
319
- - lib/kanpachi/templates/api/posts.rb
320
- - lib/kanpachi/templates/api/users.rb
321
- - lib/kanpachi/templates/documentation/config.rb
322
300
  - lib/kanpachi/version.rb
323
301
  - spec/api_list_spec.rb
324
302
  - spec/api_spec.rb
@@ -339,6 +317,13 @@ files:
339
317
  - spec/section_list_spec.rb
340
318
  - spec/section_spec.rb
341
319
  - spec/spec_helper.rb
320
+ - templates/.gitignore
321
+ - templates/Gemfile
322
+ - templates/api/api.rb
323
+ - templates/api/errors.rb
324
+ - templates/api/posts.rb
325
+ - templates/api/users.rb
326
+ - templates/documentation/config.rb
342
327
  homepage: https://github.com/kamui/kanpachi
343
328
  licenses:
344
329
  - MIT
@@ -359,7 +344,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
359
344
  version: '0'
360
345
  requirements: []
361
346
  rubyforge_project:
362
- rubygems_version: 2.1.4
347
+ rubygems_version: 2.1.7
363
348
  signing_key:
364
349
  specification_version: 4
365
350
  summary: DSL for describing Web APIs
@@ -1,62 +0,0 @@
1
- ENV['MM_ROOT'] = '/Users/jack/Development/kanpachi/lib/kanpachi/doc'
2
-
3
- module Kanpachi
4
- module SubCommand
5
- # class CLI < Thor
6
- class Doc < Thor
7
- namespace :doc
8
-
9
- desc "doc:generate_doc API_NAME, SOURCE_PATH DESTINATION_PATH", "Generate HTML documentation for Kanpachi web services"
10
- def generate_doc(api_name, source_path, destination_path="doc")
11
- puts "Starting"
12
- api_files = Dir.glob(File.join(destination_root, source_path, "**", "*.rb"))
13
- if api_files.empty?
14
- puts "No ruby files in source_path: #{File.join(destination_root, source_path)}"
15
- return
16
- end
17
- api_files.each do |file|
18
- require file
19
- end
20
-
21
- api = APIList.find(api_name)
22
-
23
- require 'fileutils'
24
- destination = File.join(destination_root, destination_path)
25
- FileUtils.mkdir_p(destination) unless File.exist?(destination)
26
- File.open("#{destination}/index.html", "w"){|f| f << doc_template.result(binding)}
27
- puts "Documentation available there: #{destination}/index.html"
28
- `open #{destination}/index.html` if RUBY_PLATFORM =~ /darwin/ && !ENV['DONT_OPEN']
29
- end
30
-
31
- private
32
-
33
- def response_html(attrs)
34
- response_template.result(binding)
35
- end
36
-
37
- def input_params_html(required, optional)
38
- input_params_template.result(binding)
39
- end
40
-
41
- def input_params_template
42
- file = resources.join '_input_params.erb'
43
- ERB.new File.read(file)
44
- end
45
-
46
- def response_template
47
- file = resources.join '_response.erb'
48
- ERB.new File.read(file)
49
- end
50
-
51
- def doc_template
52
- file = resources.join 'template.erb'
53
- ERB.new File.read(file)
54
- end
55
-
56
- def resources
57
- require 'pathname'
58
- @resources ||= Pathname.new(File.join(File.dirname(__FILE__), 'doc_generator'))
59
- end
60
- end
61
- end
62
- end