sinatra-documentation 0.0.1
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.
- data/.gitignore +17 -0
- data/.rspec +2 -0
- data/Gemfile +4 -0
- data/LICENSE +22 -0
- data/README.md +29 -0
- data/Rakefile +2 -0
- data/examples/simple_api/app.rb +11 -0
- data/examples/simple_api/views/foo/:id.markdown +2 -0
- data/examples/simple_api/views/foo/bar.markdown +2 -0
- data/examples/simple_api/views/index.markdown +1 -0
- data/lib/sinatra/documentation.rb +55 -0
- data/lib/sinatra/version.rb +5 -0
- data/sinatra-documentation.gemspec +26 -0
- data/spec/documentation_spec.rb +14 -0
- data/spec/spec_helper.rb +16 -0
- metadata +145 -0
data/.gitignore
ADDED
data/.rspec
ADDED
data/Gemfile
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2012 Justin Smestad
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
# Self
|
2
|
+
|
3
|
+
TODO: Write a gem description
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
gem 'self'
|
10
|
+
|
11
|
+
And then execute:
|
12
|
+
|
13
|
+
$ bundle
|
14
|
+
|
15
|
+
Or install it yourself as:
|
16
|
+
|
17
|
+
$ gem install self
|
18
|
+
|
19
|
+
## Usage
|
20
|
+
|
21
|
+
TODO: Write usage instructions here
|
22
|
+
|
23
|
+
## Contributing
|
24
|
+
|
25
|
+
1. Fork it
|
26
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
27
|
+
3. Commit your changes (`git commit -am 'Added some feature'`)
|
28
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
29
|
+
5. Create new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
# Index Page
|
@@ -0,0 +1,55 @@
|
|
1
|
+
require 'redcarpet'
|
2
|
+
require 'sinatra/extension'
|
3
|
+
require 'tilt/markdown'
|
4
|
+
|
5
|
+
module Sinatra
|
6
|
+
module Documentation
|
7
|
+
extend Sinatra::Extension
|
8
|
+
|
9
|
+
mime_type :readme, 'text/html'
|
10
|
+
set :default_content, :html
|
11
|
+
|
12
|
+
before do
|
13
|
+
# Let through sinatra image urls in development
|
14
|
+
next if self.class.development? && request.path_info =~ %r{/__sinatra__/.*?.png}
|
15
|
+
unless settings.static? && settings.public_folder? && (request.get? || request.head?) && static_file?(request.path_info)
|
16
|
+
if request.params.has_key? 'format'
|
17
|
+
format params['format']
|
18
|
+
else
|
19
|
+
# Sinatra relies on a side-effect from path_info= to
|
20
|
+
# determine its routes. A direct string change (e.g., sub!)
|
21
|
+
# would bypass that -- and fail to have the effect we're looking
|
22
|
+
# for.
|
23
|
+
request.path_info = request.path_info.sub %r{\.([^\./]+)$}, ''
|
24
|
+
format $1 || (request.xhr? && settings.assume_xhr_is_js? ? :js : settings.default_content)
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
helpers do
|
30
|
+
def format(val=nil)
|
31
|
+
unless val.nil?
|
32
|
+
mime_type = ::Sinatra::Base.mime_type(val)
|
33
|
+
fail "Unknown media type #{val}\nTry registering the extension with a mime type" if mime_type.nil?
|
34
|
+
@_format = val.to_sym
|
35
|
+
response['Content-Type'] ? response['Content-Type'].sub!(/^[^;]+/, mime_type) : content_type(@_format)
|
36
|
+
end
|
37
|
+
@_format
|
38
|
+
end
|
39
|
+
|
40
|
+
# Patch the content_type function to remember the set type
|
41
|
+
# This helps cut down on time in the format helper so it
|
42
|
+
# doesn't have to do a reverse lookup on the header
|
43
|
+
def content_type(*args)
|
44
|
+
@_format = args.first.to_sym
|
45
|
+
super
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
get '/*' do
|
50
|
+
pass unless format == :readme
|
51
|
+
render(:markdown, :"#{request.path}")
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
@@ -0,0 +1,26 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
require File.expand_path('../lib/sinatra/version', __FILE__)
|
3
|
+
|
4
|
+
Gem::Specification.new do |gem|
|
5
|
+
gem.authors = ["Justin Smestad"]
|
6
|
+
gem.email = ["justin.smestad@gmail.com"]
|
7
|
+
gem.description = %q{Tools for creating a simple web API}
|
8
|
+
gem.summary = %q{Tools for creating a simple web API}
|
9
|
+
gem.homepage = "https://github.com/jsmestad/sinatra-documentation"
|
10
|
+
|
11
|
+
gem.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
12
|
+
gem.files = `git ls-files`.split("\n")
|
13
|
+
gem.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
14
|
+
gem.name = "sinatra-documentation"
|
15
|
+
gem.require_paths = ["lib"]
|
16
|
+
gem.version = Sinatra::Documentation::VERSION
|
17
|
+
|
18
|
+
gem.add_dependency 'redcarpet'
|
19
|
+
gem.add_dependency 'sinatra'
|
20
|
+
gem.add_dependency 'sinatra-contrib'
|
21
|
+
gem.add_dependency 'tilt'
|
22
|
+
|
23
|
+
gem.add_development_dependency 'bundler'
|
24
|
+
gem.add_development_dependency 'rspec'
|
25
|
+
gem.add_development_dependency 'shotgun'
|
26
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
require_relative 'spec_helper'
|
2
|
+
|
3
|
+
describe Sinatra::Documentation do
|
4
|
+
def respond_app(&block)
|
5
|
+
types = @provides
|
6
|
+
mock_app do
|
7
|
+
set :app_file, __FILE__
|
8
|
+
set :views, root + '/documentation'
|
9
|
+
register Sinatra::Documentation
|
10
|
+
respond_to(*types) if types
|
11
|
+
class_eval(&block)
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
require 'sinatra/contrib'
|
2
|
+
require 'sinatra/documentation'
|
3
|
+
|
4
|
+
# This file was generated by the `rspec --init` command. Conventionally, all
|
5
|
+
# specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
|
6
|
+
# Require this file using `require "spec_helper.rb"` to ensure that it is only
|
7
|
+
# loaded once.
|
8
|
+
#
|
9
|
+
# See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
|
10
|
+
RSpec.configure do |config|
|
11
|
+
config.treat_symbols_as_metadata_keys_with_true_values = true
|
12
|
+
config.run_all_when_everything_filtered = true
|
13
|
+
config.filter_run :focus
|
14
|
+
|
15
|
+
config.include Sinatra::TestHelpers
|
16
|
+
end
|
metadata
ADDED
@@ -0,0 +1,145 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: sinatra-documentation
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Justin Smestad
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2012-02-23 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: redcarpet
|
16
|
+
requirement: &70283592138200 !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '0'
|
22
|
+
type: :runtime
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: *70283592138200
|
25
|
+
- !ruby/object:Gem::Dependency
|
26
|
+
name: sinatra
|
27
|
+
requirement: &70283592137420 !ruby/object:Gem::Requirement
|
28
|
+
none: false
|
29
|
+
requirements:
|
30
|
+
- - ! '>='
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: '0'
|
33
|
+
type: :runtime
|
34
|
+
prerelease: false
|
35
|
+
version_requirements: *70283592137420
|
36
|
+
- !ruby/object:Gem::Dependency
|
37
|
+
name: sinatra-contrib
|
38
|
+
requirement: &70283592144640 !ruby/object:Gem::Requirement
|
39
|
+
none: false
|
40
|
+
requirements:
|
41
|
+
- - ! '>='
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
version: '0'
|
44
|
+
type: :runtime
|
45
|
+
prerelease: false
|
46
|
+
version_requirements: *70283592144640
|
47
|
+
- !ruby/object:Gem::Dependency
|
48
|
+
name: tilt
|
49
|
+
requirement: &70283592141860 !ruby/object:Gem::Requirement
|
50
|
+
none: false
|
51
|
+
requirements:
|
52
|
+
- - ! '>='
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
type: :runtime
|
56
|
+
prerelease: false
|
57
|
+
version_requirements: *70283592141860
|
58
|
+
- !ruby/object:Gem::Dependency
|
59
|
+
name: bundler
|
60
|
+
requirement: &70283592154540 !ruby/object:Gem::Requirement
|
61
|
+
none: false
|
62
|
+
requirements:
|
63
|
+
- - ! '>='
|
64
|
+
- !ruby/object:Gem::Version
|
65
|
+
version: '0'
|
66
|
+
type: :development
|
67
|
+
prerelease: false
|
68
|
+
version_requirements: *70283592154540
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: rspec
|
71
|
+
requirement: &70283592151600 !ruby/object:Gem::Requirement
|
72
|
+
none: false
|
73
|
+
requirements:
|
74
|
+
- - ! '>='
|
75
|
+
- !ruby/object:Gem::Version
|
76
|
+
version: '0'
|
77
|
+
type: :development
|
78
|
+
prerelease: false
|
79
|
+
version_requirements: *70283592151600
|
80
|
+
- !ruby/object:Gem::Dependency
|
81
|
+
name: shotgun
|
82
|
+
requirement: &70283592150720 !ruby/object:Gem::Requirement
|
83
|
+
none: false
|
84
|
+
requirements:
|
85
|
+
- - ! '>='
|
86
|
+
- !ruby/object:Gem::Version
|
87
|
+
version: '0'
|
88
|
+
type: :development
|
89
|
+
prerelease: false
|
90
|
+
version_requirements: *70283592150720
|
91
|
+
description: Tools for creating a simple web API
|
92
|
+
email:
|
93
|
+
- justin.smestad@gmail.com
|
94
|
+
executables: []
|
95
|
+
extensions: []
|
96
|
+
extra_rdoc_files: []
|
97
|
+
files:
|
98
|
+
- .gitignore
|
99
|
+
- .rspec
|
100
|
+
- Gemfile
|
101
|
+
- LICENSE
|
102
|
+
- README.md
|
103
|
+
- Rakefile
|
104
|
+
- examples/simple_api/app.rb
|
105
|
+
- examples/simple_api/views/foo/:id.markdown
|
106
|
+
- examples/simple_api/views/foo/bar.markdown
|
107
|
+
- examples/simple_api/views/index.markdown
|
108
|
+
- lib/sinatra/documentation.rb
|
109
|
+
- lib/sinatra/version.rb
|
110
|
+
- sinatra-documentation.gemspec
|
111
|
+
- spec/documentation_spec.rb
|
112
|
+
- spec/spec_helper.rb
|
113
|
+
homepage: https://github.com/jsmestad/sinatra-documentation
|
114
|
+
licenses: []
|
115
|
+
post_install_message:
|
116
|
+
rdoc_options: []
|
117
|
+
require_paths:
|
118
|
+
- lib
|
119
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
120
|
+
none: false
|
121
|
+
requirements:
|
122
|
+
- - ! '>='
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: '0'
|
125
|
+
segments:
|
126
|
+
- 0
|
127
|
+
hash: -511765631575549300
|
128
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
129
|
+
none: false
|
130
|
+
requirements:
|
131
|
+
- - ! '>='
|
132
|
+
- !ruby/object:Gem::Version
|
133
|
+
version: '0'
|
134
|
+
segments:
|
135
|
+
- 0
|
136
|
+
hash: -511765631575549300
|
137
|
+
requirements: []
|
138
|
+
rubyforge_project:
|
139
|
+
rubygems_version: 1.8.17
|
140
|
+
signing_key:
|
141
|
+
specification_version: 3
|
142
|
+
summary: Tools for creating a simple web API
|
143
|
+
test_files:
|
144
|
+
- spec/documentation_spec.rb
|
145
|
+
- spec/spec_helper.rb
|