doc_smoosher 0.0.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 +7 -0
- data/.document +5 -0
- data/.ruby-gemset +1 -0
- data/.ruby-version +1 -0
- data/.travis.yml +12 -0
- data/Gemfile +31 -0
- data/Gemfile.lock +148 -0
- data/LICENSE.txt +20 -0
- data/README.md +70 -0
- data/Rakefile +87 -0
- data/VERSION +1 -0
- data/bin/smoosher +18 -0
- data/lib/doc_smoosher.rb +146 -0
- data/lib/doc_smoosher/example.rb +5 -0
- data/lib/doc_smoosher/parameter.rb +5 -0
- data/lib/doc_smoosher/resource.rb +44 -0
- data/spec/lib/doc_smoosher_spec.rb +46 -0
- data/spec/spec_helper.rb +5 -0
- metadata +224 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 8f88819f03578660903966d440c44ed336af08ad
|
4
|
+
data.tar.gz: 64cae57da6df61b314a7b3f120c39e9850f53599
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: b33b606df65bdb52391cfb4d784c7b1fa7d9c66d5c1cef359abb79a2e5e06edce36a8fa3cecf60afa103a3ef7c1c4b348f70e4b4a9d928cf02a0679331a0dc0b
|
7
|
+
data.tar.gz: 43d2f407d9daa6c3fff0a05c3f7354936d54dd415d7e46fd132c613278a637e3ba3fe80f626ef6a971f90ad2d9e1055a61cba8edefbeefe9660ceba999954484
|
data/.document
ADDED
data/.ruby-gemset
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
docsmoosher
|
data/.ruby-version
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
ruby-2.1.0
|
data/.travis.yml
ADDED
@@ -0,0 +1,12 @@
|
|
1
|
+
language: ruby
|
2
|
+
rvm:
|
3
|
+
# - "1.8.7"
|
4
|
+
# - "1.9.2"
|
5
|
+
- "1.9.3"
|
6
|
+
- "2.0.0"
|
7
|
+
- "2.1.0"
|
8
|
+
# - jruby-18mode # JRuby in 1.8 mode
|
9
|
+
# - jruby-19mode # JRuby in 1.9 mode
|
10
|
+
- rbx
|
11
|
+
# uncomment this line if your project needs to run something other than `rake`:
|
12
|
+
# script: bundle exec rspec spec
|
data/Gemfile
ADDED
@@ -0,0 +1,31 @@
|
|
1
|
+
source "https://rubygems.org"
|
2
|
+
# Add dependencies required to use your gem here.
|
3
|
+
|
4
|
+
gem 'rake', "~> 0"
|
5
|
+
gem 'rest-client', "~> 0"
|
6
|
+
|
7
|
+
gem 'thor', "~> 0"
|
8
|
+
|
9
|
+
gem "activesupport"
|
10
|
+
|
11
|
+
|
12
|
+
# Add dependencies to develop your gem here.
|
13
|
+
# Include everything needed to run rake, tests, features, etc.
|
14
|
+
group :development do
|
15
|
+
gem "shoulda", ">= 0"
|
16
|
+
gem "rdoc", "~> 3.12"
|
17
|
+
gem "bundler", "~> 1.0"
|
18
|
+
gem "jeweler", "~> 2.0.1"
|
19
|
+
gem "simplecov", ">= 0"
|
20
|
+
|
21
|
+
gem 'terminal-notifier'
|
22
|
+
gem 'terminal-notifier-guard'
|
23
|
+
gem 'guard-rspec', require: false
|
24
|
+
gem 'guard'
|
25
|
+
|
26
|
+
gem 'doc_smoosher', :path => '/Users/joran/Documents/development/ruby/retechnica/doc_smoosher'
|
27
|
+
|
28
|
+
gem 'sinatra'
|
29
|
+
|
30
|
+
gem 'rspec'
|
31
|
+
end
|
data/Gemfile.lock
ADDED
@@ -0,0 +1,148 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
doc_smoosher (0.0.1)
|
5
|
+
active_support
|
6
|
+
i18n (~> 0)
|
7
|
+
rake (~> 0)
|
8
|
+
rest-client (~> 0)
|
9
|
+
thor (~> 0)
|
10
|
+
|
11
|
+
GEM
|
12
|
+
remote: https://rubygems.org/
|
13
|
+
specs:
|
14
|
+
active_support (3.0.0)
|
15
|
+
activesupport (= 3.0.0)
|
16
|
+
activesupport (3.0.0)
|
17
|
+
addressable (2.3.5)
|
18
|
+
builder (3.2.2)
|
19
|
+
celluloid (0.15.2)
|
20
|
+
timers (~> 1.1.0)
|
21
|
+
celluloid-io (0.15.0)
|
22
|
+
celluloid (>= 0.15.0)
|
23
|
+
nio4r (>= 0.5.0)
|
24
|
+
coderay (1.1.0)
|
25
|
+
descendants_tracker (0.0.3)
|
26
|
+
diff-lcs (1.2.5)
|
27
|
+
docile (1.1.3)
|
28
|
+
faraday (0.9.0)
|
29
|
+
multipart-post (>= 1.2, < 3)
|
30
|
+
ffi (1.9.3)
|
31
|
+
formatador (0.2.4)
|
32
|
+
git (1.2.6)
|
33
|
+
github_api (0.11.3)
|
34
|
+
addressable (~> 2.3)
|
35
|
+
descendants_tracker (~> 0.0.1)
|
36
|
+
faraday (~> 0.8, < 0.10)
|
37
|
+
hashie (>= 1.2)
|
38
|
+
multi_json (>= 1.7.5, < 2.0)
|
39
|
+
nokogiri (~> 1.6.0)
|
40
|
+
oauth2
|
41
|
+
guard (2.5.1)
|
42
|
+
formatador (>= 0.2.4)
|
43
|
+
listen (~> 2.6)
|
44
|
+
lumberjack (~> 1.0)
|
45
|
+
pry (>= 0.9.12)
|
46
|
+
thor (>= 0.18.1)
|
47
|
+
guard-rspec (4.2.7)
|
48
|
+
guard (~> 2.1)
|
49
|
+
rspec (>= 2.14, < 4.0)
|
50
|
+
hashie (2.0.5)
|
51
|
+
highline (1.6.20)
|
52
|
+
i18n (0.6.9)
|
53
|
+
jeweler (2.0.1)
|
54
|
+
builder
|
55
|
+
bundler (>= 1.0)
|
56
|
+
git (>= 1.2.5)
|
57
|
+
github_api
|
58
|
+
highline (>= 1.6.15)
|
59
|
+
nokogiri (>= 1.5.10)
|
60
|
+
rake
|
61
|
+
rdoc
|
62
|
+
json (1.8.1)
|
63
|
+
jwt (0.1.11)
|
64
|
+
multi_json (>= 1.5)
|
65
|
+
listen (2.6.0)
|
66
|
+
celluloid (>= 0.15.2)
|
67
|
+
celluloid-io (>= 0.15.0)
|
68
|
+
rb-fsevent (>= 0.9.3)
|
69
|
+
rb-inotify (>= 0.9)
|
70
|
+
lumberjack (1.0.4)
|
71
|
+
method_source (0.8.2)
|
72
|
+
mini_portile (0.5.2)
|
73
|
+
multi_json (1.8.4)
|
74
|
+
multi_xml (0.5.5)
|
75
|
+
multipart-post (2.0.0)
|
76
|
+
nio4r (1.0.0)
|
77
|
+
nokogiri (1.6.1)
|
78
|
+
mini_portile (~> 0.5.0)
|
79
|
+
oauth2 (0.9.3)
|
80
|
+
faraday (>= 0.8, < 0.10)
|
81
|
+
jwt (~> 0.1.8)
|
82
|
+
multi_json (~> 1.3)
|
83
|
+
multi_xml (~> 0.5)
|
84
|
+
rack (~> 1.2)
|
85
|
+
pry (0.9.12.6)
|
86
|
+
coderay (~> 1.0)
|
87
|
+
method_source (~> 0.8)
|
88
|
+
slop (~> 3.4)
|
89
|
+
rack (1.5.2)
|
90
|
+
rack-protection (1.5.2)
|
91
|
+
rack
|
92
|
+
rake (0.9.6)
|
93
|
+
rb-fsevent (0.9.4)
|
94
|
+
rb-inotify (0.9.3)
|
95
|
+
ffi (>= 0.5.0)
|
96
|
+
rdoc (3.12.2)
|
97
|
+
json (~> 1.4)
|
98
|
+
rest-client (0.9.2)
|
99
|
+
rspec (2.14.1)
|
100
|
+
rspec-core (~> 2.14.0)
|
101
|
+
rspec-expectations (~> 2.14.0)
|
102
|
+
rspec-mocks (~> 2.14.0)
|
103
|
+
rspec-core (2.14.7)
|
104
|
+
rspec-expectations (2.14.5)
|
105
|
+
diff-lcs (>= 1.1.3, < 2.0)
|
106
|
+
rspec-mocks (2.14.6)
|
107
|
+
shoulda (3.5.0)
|
108
|
+
shoulda-context (~> 1.0, >= 1.0.1)
|
109
|
+
shoulda-matchers (>= 1.4.1, < 3.0)
|
110
|
+
shoulda-context (1.1.6)
|
111
|
+
shoulda-matchers (2.5.0)
|
112
|
+
activesupport (>= 3.0.0)
|
113
|
+
simplecov (0.8.2)
|
114
|
+
docile (~> 1.1.0)
|
115
|
+
multi_json
|
116
|
+
simplecov-html (~> 0.8.0)
|
117
|
+
simplecov-html (0.8.0)
|
118
|
+
sinatra (1.4.4)
|
119
|
+
rack (~> 1.4)
|
120
|
+
rack-protection (~> 1.4)
|
121
|
+
tilt (~> 1.3, >= 1.3.4)
|
122
|
+
slop (3.4.7)
|
123
|
+
terminal-notifier (1.5.1)
|
124
|
+
terminal-notifier-guard (1.5.3)
|
125
|
+
thor (0.18.1)
|
126
|
+
tilt (1.4.1)
|
127
|
+
timers (1.1.0)
|
128
|
+
|
129
|
+
PLATFORMS
|
130
|
+
ruby
|
131
|
+
|
132
|
+
DEPENDENCIES
|
133
|
+
activesupport
|
134
|
+
bundler (~> 1.0)
|
135
|
+
doc_smoosher!
|
136
|
+
guard
|
137
|
+
guard-rspec
|
138
|
+
jeweler (~> 2.0.1)
|
139
|
+
rake (~> 0)
|
140
|
+
rdoc (~> 3.12)
|
141
|
+
rest-client (~> 0)
|
142
|
+
rspec
|
143
|
+
shoulda
|
144
|
+
simplecov
|
145
|
+
sinatra
|
146
|
+
terminal-notifier
|
147
|
+
terminal-notifier-guard
|
148
|
+
thor (~> 0)
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2014 Joran Kikke
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,70 @@
|
|
1
|
+
Doc Smoosher
|
2
|
+
===
|
3
|
+
[](https://travis-ci.org/dangerousbeans/doc_smoosher) <-- Yep, that's right.
|
4
|
+
|
5
|
+

|
6
|
+
|
7
|
+
###### A simple API documentation and test generator for the complicated world we live in
|
8
|
+
|
9
|
+
#### Turn this
|
10
|
+
define_api( name: 'Ingenia API' ) do |api|
|
11
|
+
api.description = 'Ingenia analyses your textual...'
|
12
|
+
api.endpoint = 'api.ingeniapi.com/v2/'
|
13
|
+
api.version = '2.0'
|
14
|
+
api.format = 'json'
|
15
|
+
|
16
|
+
api.resource name: 'items' do |r|
|
17
|
+
r.description = "Nuggets of textual content..."
|
18
|
+
|
19
|
+
r.request name: 'index' do |req|
|
20
|
+
req.description = 'An index of all your items'
|
21
|
+
req.call_type = :get
|
22
|
+
req.path = '/items'
|
23
|
+
|
24
|
+
req.parameter api_key
|
25
|
+
req.parameter limit
|
26
|
+
req.parameter full_text
|
27
|
+
req.parameter offset
|
28
|
+
end
|
29
|
+
|
30
|
+
|
31
|
+
# ....
|
32
|
+
|
33
|
+
|
34
|
+
r.request name: 'delete' do |req|
|
35
|
+
req.description = 'Delete an existing item'
|
36
|
+
req.call_type = :delete
|
37
|
+
req.path = '/items/:id'
|
38
|
+
|
39
|
+
req.parameter name: 'id' do |p|
|
40
|
+
p.description = 'The ID of the item you want to delete.'
|
41
|
+
p.type = :string
|
42
|
+
p.example = '3casjghd67'
|
43
|
+
p.required = true
|
44
|
+
end
|
45
|
+
req.parameter api_key
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
#### INTO THIS:
|
51
|
+

|
52
|
+
|
53
|
+
## DO IT
|
54
|
+
|
55
|
+
#### Install the stuff
|
56
|
+
|
57
|
+
gem install 'doc_smoosher'
|
58
|
+
|
59
|
+
#### Generate a new api scaffold
|
60
|
+
|
61
|
+
smoosher new example_api
|
62
|
+
|
63
|
+
#### Edit your API folder
|
64
|
+
|
65
|
+
#### Generate!
|
66
|
+
cd example_api
|
67
|
+
smoosher generate
|
68
|
+
|
69
|
+
#### Wow such docs
|
70
|
+
|
data/Rakefile
ADDED
@@ -0,0 +1,87 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require 'rubygems'
|
4
|
+
require 'bundler'
|
5
|
+
require 'rspec/core/rake_task'
|
6
|
+
|
7
|
+
begin
|
8
|
+
Bundler.setup(:default, :development)
|
9
|
+
rescue Bundler::BundlerError => e
|
10
|
+
$stderr.puts e.message
|
11
|
+
$stderr.puts "Run `bundle install` to install missing gems"
|
12
|
+
exit e.status_code
|
13
|
+
end
|
14
|
+
require 'rake'
|
15
|
+
|
16
|
+
require 'jeweler'
|
17
|
+
Jeweler::Tasks.new do |gem|
|
18
|
+
# gem is a Gem::Specification... see http://guides.rubygems.org/specification-reference/ for more options
|
19
|
+
gem.name = "doc_smoosher"
|
20
|
+
gem.homepage = "http://github.com/dangerousbeans/doc_smoosher"
|
21
|
+
gem.license = "MIT"
|
22
|
+
gem.summary = %Q{ A simple API documentation generator for the complicated world we live in }
|
23
|
+
gem.description = %Q{ A simple API documentation generator for the complicated world we live in }
|
24
|
+
gem.email = "joran.k@gmail.com"
|
25
|
+
gem.authors = ["Joran Kikke"]
|
26
|
+
# dependencies defined in Gemfile
|
27
|
+
end
|
28
|
+
Jeweler::RubygemsDotOrgTasks.new
|
29
|
+
|
30
|
+
|
31
|
+
desc "Code coverage detail"
|
32
|
+
task :simplecov do
|
33
|
+
ENV['COVERAGE'] = "true"
|
34
|
+
Rake::Task['test'].execute
|
35
|
+
end
|
36
|
+
|
37
|
+
RSpec::Core::RakeTask.new(:spec)
|
38
|
+
task :default => :spec
|
39
|
+
|
40
|
+
require 'rdoc/task'
|
41
|
+
Rake::RDocTask.new do |rdoc|
|
42
|
+
version = File.exist?('VERSION') ? File.read('VERSION') : ""
|
43
|
+
|
44
|
+
rdoc.rdoc_dir = 'rdoc'
|
45
|
+
rdoc.title = "doc_smoosher #{version}"
|
46
|
+
rdoc.rdoc_files.include('README*')
|
47
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
48
|
+
end
|
49
|
+
|
50
|
+
|
51
|
+
|
52
|
+
namespace :ds do
|
53
|
+
desc "Scan an API"
|
54
|
+
task :scan_url do
|
55
|
+
require 'rest-client'
|
56
|
+
|
57
|
+
puts 'missing URL' if ENV['URL'].nil?
|
58
|
+
puts 'missing API_KEY' if ENV['API_KEY'].nil?
|
59
|
+
|
60
|
+
end
|
61
|
+
|
62
|
+
desc "Generate from a directory"
|
63
|
+
task :generate do
|
64
|
+
require 'bundler/setup'
|
65
|
+
require_relative 'lib/doc_smoosher'
|
66
|
+
|
67
|
+
if ENV['DIR'].nil?
|
68
|
+
puts 'missing DIR'
|
69
|
+
next
|
70
|
+
end
|
71
|
+
|
72
|
+
dir = ENV['DIR']
|
73
|
+
|
74
|
+
api_name = File.split(dir).last
|
75
|
+
api_file_name = api_name + '.rb'
|
76
|
+
|
77
|
+
puts "Generating from: #{dir}"
|
78
|
+
puts "API Name: #{api_name}"
|
79
|
+
puts "Loading: #{api_file_name}"
|
80
|
+
|
81
|
+
require File.join(dir, api_file_name)
|
82
|
+
end
|
83
|
+
|
84
|
+
task :create, :project_name do |t, args|
|
85
|
+
puts args
|
86
|
+
end
|
87
|
+
end
|
data/VERSION
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
0.0.1
|
data/bin/smoosher
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
lib = File.expand_path(File.dirname(__FILE__) + '/../lib')
|
4
|
+
$LOAD_PATH.unshift(lib) if File.directory?(lib) && !$LOAD_PATH.include?(lib)
|
5
|
+
|
6
|
+
require 'rubygems'
|
7
|
+
require 'thor'
|
8
|
+
require 'thor/group'
|
9
|
+
require 'doc_smoosher'
|
10
|
+
|
11
|
+
module CLI
|
12
|
+
class Root < Thor
|
13
|
+
register DocSmoosher::Generators::Api, 'new', 'new <API Name>', 'Makes an new API scaffold folder structure ready for editing'
|
14
|
+
register DocSmoosher::Generators::Builder, 'generate', 'generate', 'Generate stuff based on your API definition '
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
CLI::Root.start
|
data/lib/doc_smoosher.rb
ADDED
@@ -0,0 +1,146 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'bundler/setup'
|
3
|
+
|
4
|
+
require 'thor/group'
|
5
|
+
require 'load_doc_smoosher'
|
6
|
+
|
7
|
+
|
8
|
+
module DocSmoosher
|
9
|
+
|
10
|
+
# DSL methods
|
11
|
+
module TopLevel
|
12
|
+
def define_api(params = {}, &block)
|
13
|
+
api = Api.new( params, &block )
|
14
|
+
|
15
|
+
@@api = api
|
16
|
+
end
|
17
|
+
|
18
|
+
def define_parameter(params = {}, &block)
|
19
|
+
parameter = Parameter.new( params, &block )
|
20
|
+
parameters << parameter unless parameters.include?(parameter)
|
21
|
+
parameter
|
22
|
+
end
|
23
|
+
|
24
|
+
def define_resource(params = {}, &block)
|
25
|
+
resource = Resource.new( params, &block )
|
26
|
+
resources << resource unless resources.include?(resource)
|
27
|
+
resource
|
28
|
+
end
|
29
|
+
|
30
|
+
def define_object(params = {}, &block)
|
31
|
+
object = ApiObject.new( params, &block )
|
32
|
+
objects << object unless resources.include?(object)
|
33
|
+
object
|
34
|
+
end
|
35
|
+
|
36
|
+
def api
|
37
|
+
@@api
|
38
|
+
end
|
39
|
+
|
40
|
+
def requests
|
41
|
+
@@requests ||= []
|
42
|
+
end
|
43
|
+
|
44
|
+
def resources
|
45
|
+
@@resources ||= []
|
46
|
+
end
|
47
|
+
|
48
|
+
def parameters
|
49
|
+
@@parameters ||= []
|
50
|
+
end
|
51
|
+
|
52
|
+
def objects
|
53
|
+
@@objects ||= []
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
|
58
|
+
TEMPLATES = "../templates"
|
59
|
+
|
60
|
+
# Scan files and folders inside a directory to define an API
|
61
|
+
def self.parse_dir directory
|
62
|
+
|
63
|
+
end
|
64
|
+
|
65
|
+
|
66
|
+
module Generators
|
67
|
+
require 'active_support/core_ext'
|
68
|
+
require 'active_support/inflector'
|
69
|
+
|
70
|
+
class Builder < Thor::Group
|
71
|
+
include Thor::Actions
|
72
|
+
|
73
|
+
OUTPUT = './output'
|
74
|
+
|
75
|
+
argument :api, required: false
|
76
|
+
argument :path, default: './'
|
77
|
+
|
78
|
+
|
79
|
+
def self.source_root
|
80
|
+
File.dirname(__FILE__)
|
81
|
+
end
|
82
|
+
|
83
|
+
# output directory
|
84
|
+
def output
|
85
|
+
empty_directory OUTPUT
|
86
|
+
end
|
87
|
+
|
88
|
+
def build_api_html
|
89
|
+
api_name = File.basename(Dir.getwd)
|
90
|
+
api_file = File.join(Dir.getwd, "#{api_name}.rb")
|
91
|
+
|
92
|
+
# load api_file
|
93
|
+
puts "opening: #{api_file}"
|
94
|
+
File.open(api_file) do |f|
|
95
|
+
instance_eval f.read
|
96
|
+
end
|
97
|
+
|
98
|
+
self.api = @api
|
99
|
+
copy_file(File.join(TEMPLATES, 'html', 'bootstrap.min.css'), "output/html/bootstrap.min.css")
|
100
|
+
copy_file(File.join(TEMPLATES, 'html', 'prettify.css'), "output/html/prettify.css")
|
101
|
+
copy_file(File.join(TEMPLATES, 'html', 'prettify.js'), "output/html/prettify.js")
|
102
|
+
copy_file(File.join(TEMPLATES, 'html', 'run_prettify.js'), "output/html/run_prettify.js")
|
103
|
+
|
104
|
+
template(File.join(TEMPLATES, 'html', 'api.html.erb'), "output/html/#{api_name}.html")
|
105
|
+
end
|
106
|
+
end
|
107
|
+
|
108
|
+
class Api < Thor::Group
|
109
|
+
include Thor::Actions
|
110
|
+
argument :name, :type => :string
|
111
|
+
argument :description, default: 'Example API'
|
112
|
+
# argument :requests, default: [DocSmoosher::Request.new(:name => 'item', :description => 'A unique identifier')]
|
113
|
+
# argument :fields, default: [DocSmoosher::Field.new(:name => 'id', :description => 'A unique identifier')]
|
114
|
+
|
115
|
+
class_option :test_framework, :default => :test_unit
|
116
|
+
|
117
|
+
def self.source_root
|
118
|
+
File.dirname(__FILE__)
|
119
|
+
end
|
120
|
+
|
121
|
+
def create_api
|
122
|
+
template(File.join(TEMPLATES, 'api.tt'), "#{name}/#{name}.rb")
|
123
|
+
copy_file(File.join(TEMPLATES, 'Readme.md'), "#{name}/Readme.md")
|
124
|
+
end
|
125
|
+
|
126
|
+
# %w( resource parameter request ).each do |thing_name|
|
127
|
+
# define_method "#{thing_name}_folder" do
|
128
|
+
# template(File.join(TEMPLATES, "#{thing_name}.tt"), "#{name}/#{thing_name.pluralize}/#{thing_name}_example.rb")
|
129
|
+
# end
|
130
|
+
# end
|
131
|
+
|
132
|
+
def done_message
|
133
|
+
message = <<MESSAGE
|
134
|
+
|
135
|
+
Scaffolding all built and ready!
|
136
|
+
|
137
|
+
You now need to edit the example files/folders to setup the shape of your API, so you can generate documentation around it magically.
|
138
|
+
|
139
|
+
Thanks for using doc_smoosher. Now smoosh them APIs gurd. - Joran Kikke - @donkeyscience
|
140
|
+
MESSAGE
|
141
|
+
|
142
|
+
puts message
|
143
|
+
end
|
144
|
+
end
|
145
|
+
end
|
146
|
+
end
|
@@ -0,0 +1,44 @@
|
|
1
|
+
module DocSmoosher
|
2
|
+
class Resource < ApiObject
|
3
|
+
attr_accessor :requests, :parameters
|
4
|
+
|
5
|
+
def initialize(params = {}, &block)
|
6
|
+
super(params)
|
7
|
+
end
|
8
|
+
|
9
|
+
def requests
|
10
|
+
@requests ||= []
|
11
|
+
end
|
12
|
+
|
13
|
+
def parameters
|
14
|
+
@parameters ||= []
|
15
|
+
end
|
16
|
+
|
17
|
+
def request( params = {}, &block )
|
18
|
+
r = Request.new( params, &block )
|
19
|
+
requests << r unless requests.include?(r)
|
20
|
+
r
|
21
|
+
end
|
22
|
+
|
23
|
+
|
24
|
+
def as_json(options={})
|
25
|
+
json = super
|
26
|
+
if self.requests.length > 0
|
27
|
+
json.merge(
|
28
|
+
{
|
29
|
+
:requests => self.requests.map(&:as_json)
|
30
|
+
}
|
31
|
+
)
|
32
|
+
end
|
33
|
+
if self.parameters.length > 0
|
34
|
+
json.merge(
|
35
|
+
{
|
36
|
+
:parameters => self.parameters.map(&:as_json)
|
37
|
+
}
|
38
|
+
)
|
39
|
+
end
|
40
|
+
json
|
41
|
+
end
|
42
|
+
|
43
|
+
end
|
44
|
+
end
|
@@ -0,0 +1,46 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
class TestSmoosher
|
4
|
+
extend DocSmoosher::TopLevel
|
5
|
+
end
|
6
|
+
|
7
|
+
describe DocSmoosher do
|
8
|
+
it 'loads' do
|
9
|
+
expect(DocSmoosher).not_to be_nil
|
10
|
+
end
|
11
|
+
|
12
|
+
|
13
|
+
describe 'top level methods' do
|
14
|
+
|
15
|
+
describe 'lets you define' do
|
16
|
+
it 'an Api' do
|
17
|
+
expect(TestSmoosher.define_api(name: 'test api'){}).to be_true
|
18
|
+
end
|
19
|
+
|
20
|
+
it 'a parameter' do
|
21
|
+
expect(TestSmoosher.define_parameter(name: 'test param'){}).to be_true
|
22
|
+
end
|
23
|
+
|
24
|
+
it 'keeps track of shared parameters' do
|
25
|
+
TestSmoosher.define_parameter(name: 'test param'){}
|
26
|
+
|
27
|
+
expect(TestSmoosher.parameters.first.name).to eql('test param')
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
describe 'DSL' do
|
33
|
+
describe '#define_api' do
|
34
|
+
it 'defines an api' do
|
35
|
+
TestSmoosher.define_api(name: 'test api') do |api|
|
36
|
+
api.description = "a test api example"
|
37
|
+
end
|
38
|
+
|
39
|
+
api = TestSmoosher.api
|
40
|
+
expect(api).not_to be_nil
|
41
|
+
expect(api.name).to eql('test api')
|
42
|
+
expect(api.description).to eql('a test api example')
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
data/spec/spec_helper.rb
ADDED
metadata
ADDED
@@ -0,0 +1,224 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: doc_smoosher
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.2
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Joran Kikke
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-02-24 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: rake
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: thor
|
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
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rest-client
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: active_support
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :runtime
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: i18n
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :runtime
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: shoulda
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - "~>"
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - "~>"
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: rdoc
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - "~>"
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '3.12'
|
104
|
+
type: :development
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - "~>"
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '3.12'
|
111
|
+
- !ruby/object:Gem::Dependency
|
112
|
+
name: bundler
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - "~>"
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '1.0'
|
118
|
+
type: :development
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - "~>"
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: '1.0'
|
125
|
+
- !ruby/object:Gem::Dependency
|
126
|
+
name: jeweler
|
127
|
+
requirement: !ruby/object:Gem::Requirement
|
128
|
+
requirements:
|
129
|
+
- - "~>"
|
130
|
+
- !ruby/object:Gem::Version
|
131
|
+
version: '2.0'
|
132
|
+
- - ">="
|
133
|
+
- !ruby/object:Gem::Version
|
134
|
+
version: 2.0.1
|
135
|
+
type: :development
|
136
|
+
prerelease: false
|
137
|
+
version_requirements: !ruby/object:Gem::Requirement
|
138
|
+
requirements:
|
139
|
+
- - "~>"
|
140
|
+
- !ruby/object:Gem::Version
|
141
|
+
version: '2.0'
|
142
|
+
- - ">="
|
143
|
+
- !ruby/object:Gem::Version
|
144
|
+
version: 2.0.1
|
145
|
+
- !ruby/object:Gem::Dependency
|
146
|
+
name: simplecov
|
147
|
+
requirement: !ruby/object:Gem::Requirement
|
148
|
+
requirements:
|
149
|
+
- - "~>"
|
150
|
+
- !ruby/object:Gem::Version
|
151
|
+
version: '0'
|
152
|
+
type: :development
|
153
|
+
prerelease: false
|
154
|
+
version_requirements: !ruby/object:Gem::Requirement
|
155
|
+
requirements:
|
156
|
+
- - "~>"
|
157
|
+
- !ruby/object:Gem::Version
|
158
|
+
version: '0'
|
159
|
+
- !ruby/object:Gem::Dependency
|
160
|
+
name: rspec
|
161
|
+
requirement: !ruby/object:Gem::Requirement
|
162
|
+
requirements:
|
163
|
+
- - "~>"
|
164
|
+
- !ruby/object:Gem::Version
|
165
|
+
version: '0'
|
166
|
+
type: :development
|
167
|
+
prerelease: false
|
168
|
+
version_requirements: !ruby/object:Gem::Requirement
|
169
|
+
requirements:
|
170
|
+
- - "~>"
|
171
|
+
- !ruby/object:Gem::Version
|
172
|
+
version: '0'
|
173
|
+
description: A simple API documentation generator for the complicated world we live
|
174
|
+
in.
|
175
|
+
email: joran.k@gmail.com
|
176
|
+
executables:
|
177
|
+
- smoosher
|
178
|
+
extensions: []
|
179
|
+
extra_rdoc_files:
|
180
|
+
- LICENSE.txt
|
181
|
+
- README.md
|
182
|
+
files:
|
183
|
+
- ".document"
|
184
|
+
- ".ruby-gemset"
|
185
|
+
- ".ruby-version"
|
186
|
+
- ".travis.yml"
|
187
|
+
- Gemfile
|
188
|
+
- Gemfile.lock
|
189
|
+
- LICENSE.txt
|
190
|
+
- README.md
|
191
|
+
- Rakefile
|
192
|
+
- VERSION
|
193
|
+
- bin/smoosher
|
194
|
+
- lib/doc_smoosher.rb
|
195
|
+
- lib/doc_smoosher/example.rb
|
196
|
+
- lib/doc_smoosher/parameter.rb
|
197
|
+
- lib/doc_smoosher/resource.rb
|
198
|
+
- spec/lib/doc_smoosher_spec.rb
|
199
|
+
- spec/spec_helper.rb
|
200
|
+
homepage: http://github.com/dangerousbeans/doc_smoosher
|
201
|
+
licenses:
|
202
|
+
- MIT
|
203
|
+
metadata: {}
|
204
|
+
post_install_message: DocSmoosher READY.
|
205
|
+
rdoc_options: []
|
206
|
+
require_paths:
|
207
|
+
- lib
|
208
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
209
|
+
requirements:
|
210
|
+
- - ">="
|
211
|
+
- !ruby/object:Gem::Version
|
212
|
+
version: '0'
|
213
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
214
|
+
requirements:
|
215
|
+
- - "~>"
|
216
|
+
- !ruby/object:Gem::Version
|
217
|
+
version: '0'
|
218
|
+
requirements: []
|
219
|
+
rubyforge_project:
|
220
|
+
rubygems_version: 2.2.2
|
221
|
+
signing_key:
|
222
|
+
specification_version: 4
|
223
|
+
summary: A simple API documentation generator for the complicated world we live in
|
224
|
+
test_files: []
|