static_docs 0.0.1 → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/app/assets/javascripts/static_docs/pages.js +2 -0
- data/app/assets/stylesheets/static_docs/pages.css +4 -0
- data/app/controllers/static_docs/application_controller.rb +1 -1
- data/app/controllers/static_docs/pages_controller.rb +9 -0
- data/app/helpers/static_docs/application_helper.rb +11 -0
- data/app/helpers/static_docs/pages_helper.rb +4 -0
- data/app/models/static_docs/page.rb +30 -0
- data/app/views/static_docs/pages/show.html.erb +3 -0
- data/config/routes.rb +4 -0
- data/db/migrate/20130502102206_create_static_docs_pages.rb +16 -0
- data/lib/static_docs/importer.rb +44 -0
- data/lib/static_docs/version.rb +1 -1
- data/lib/static_docs.rb +30 -0
- data/lib/tasks/static_docs_tasks.rake +11 -4
- data/test/dummy/app/helpers/application_helper.rb +3 -0
- data/test/dummy/config/environments/test.rb +1 -1
- data/test/dummy/config/initializers/static_docs.rb +13 -0
- data/test/dummy/config/routes.rb +1 -1
- data/test/dummy/db/development.sqlite3 +0 -0
- data/test/dummy/db/migrate/20130502133441_create_static_docs_pages.static_docs.rb +17 -0
- data/test/dummy/db/schema.rb +29 -0
- data/test/dummy/db/test.sqlite3 +0 -0
- data/test/dummy/log/development.log +56 -0
- data/test/dummy/log/production.log +0 -0
- data/test/dummy/log/test.log +8879 -0
- data/test/dummy/sources/namespace/home.html +1 -0
- data/test/dummy/sources/namespace/index.yml +9 -0
- data/test/dummy/sources/namespace/page.html +1 -0
- data/test/dummy/sources/root/getting_started.html +1 -0
- data/test/dummy/sources/root/home.html +1 -0
- data/test/dummy/sources/root/index.yml +13 -0
- data/test/dummy/sources/root/page.html +1 -0
- data/test/fixtures/static_docs/pages.yml +51 -0
- data/test/functional/static_docs/pages_controller_test.rb +9 -0
- data/test/integration/navigation_test.rb +22 -4
- data/test/static_docs_test.rb +7 -0
- data/test/test_helper.rb +0 -2
- data/test/unit/helpers/static_docs/pages_helper_test.rb +6 -0
- data/test/unit/static_docs/importer_test.rb +52 -0
- data/test/unit/static_docs/page_test.rb +46 -0
- metadata +52 -5
- data/app/views/layouts/static_docs/application.html.erb +0 -14
@@ -0,0 +1 @@
|
|
1
|
+
<p>Hello from namespace!</p>
|
@@ -0,0 +1 @@
|
|
1
|
+
<p>Hello, Namespace!</p>
|
@@ -0,0 +1 @@
|
|
1
|
+
<p>Welcome, Newbie!</p>
|
@@ -0,0 +1 @@
|
|
1
|
+
<p>Hello from homepage!</p>
|
@@ -0,0 +1 @@
|
|
1
|
+
<p>Hello, World!</p>
|
@@ -0,0 +1,51 @@
|
|
1
|
+
# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/Fixtures.html
|
2
|
+
|
3
|
+
home_page:
|
4
|
+
title: Main page
|
5
|
+
path: home
|
6
|
+
body: '<h3>This is home page</h3>'
|
7
|
+
extension: html
|
8
|
+
|
9
|
+
first_level_page:
|
10
|
+
title: First Level Page
|
11
|
+
path: 'page'
|
12
|
+
body: '<h3>This is first level page</h3>'
|
13
|
+
extension: html
|
14
|
+
|
15
|
+
deep_page:
|
16
|
+
title: First Level Page
|
17
|
+
path: 'path/to/page'
|
18
|
+
body: '<h3>This is third level page</h3>'
|
19
|
+
extension: html
|
20
|
+
|
21
|
+
namespaced_page:
|
22
|
+
title: Namespaced Page
|
23
|
+
path: 'page'
|
24
|
+
namespace: 'namespace'
|
25
|
+
body: '<h3>This is namespaced page</h3>'
|
26
|
+
extension: html
|
27
|
+
|
28
|
+
deep_page_like_namespaced:
|
29
|
+
title: Namespaced Page
|
30
|
+
path: 'namespace/page'
|
31
|
+
body: '<h3>This is not namespaced page</h3>'
|
32
|
+
extension: html
|
33
|
+
|
34
|
+
wrong_namespaced_page:
|
35
|
+
title: Wrong Namespaced Page
|
36
|
+
path: 'page'
|
37
|
+
namespace: 'wrong'
|
38
|
+
body: '<h3>This is wrong namespaced page</h3>'
|
39
|
+
extension: html
|
40
|
+
|
41
|
+
markdown_page:
|
42
|
+
title: Markdown Page
|
43
|
+
path: 'markdown'
|
44
|
+
body: '### This is markdown page'
|
45
|
+
extension: md
|
46
|
+
|
47
|
+
text_page:
|
48
|
+
title: Text Page
|
49
|
+
path: 'text'
|
50
|
+
body: 'some text'
|
51
|
+
extension: txt
|
@@ -3,8 +3,26 @@ require 'test_helper'
|
|
3
3
|
class NavigationTest < ActionDispatch::IntegrationTest
|
4
4
|
fixtures :all
|
5
5
|
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
6
|
+
test 'browse pages' do
|
7
|
+
get '/'
|
8
|
+
assert_response :success
|
9
|
+
assert_select 'title', {:text => 'Dummy'}, 'Page must be rendered within application layout'
|
10
|
+
assert_select 'h3', {:text => 'This is home page'}
|
11
|
+
|
12
|
+
get '/page'
|
13
|
+
assert_response :success
|
14
|
+
assert_select 'h3', {:text => 'This is first level page'}
|
15
|
+
assert_select 'body', /This is first level page/
|
16
|
+
|
17
|
+
get '/namespace/page'
|
18
|
+
assert_response :success
|
19
|
+
assert_select 'h3', {:text => 'This is namespaced page'}
|
10
20
|
|
21
|
+
get '/markdown'
|
22
|
+
assert_response :success
|
23
|
+
assert_select 'pre', {:text => '### This is markdown page'}
|
24
|
+
|
25
|
+
get '/wrong'
|
26
|
+
assert_response :not_found
|
27
|
+
end
|
28
|
+
end
|
data/test/static_docs_test.rb
CHANGED
@@ -4,4 +4,11 @@ class StaticDocsTest < ActiveSupport::TestCase
|
|
4
4
|
test "truth" do
|
5
5
|
assert_kind_of Module, StaticDocs
|
6
6
|
end
|
7
|
+
|
8
|
+
test 'setup' do
|
9
|
+
assert_equal StaticDocs.sources[nil], 'sources/root'
|
10
|
+
assert_equal StaticDocs.sources[:namespace], 'sources/namespace'
|
11
|
+
|
12
|
+
assert StaticDocs.renderers[:default].keys.include? 'md'
|
13
|
+
end
|
7
14
|
end
|
data/test/test_helper.rb
CHANGED
@@ -4,8 +4,6 @@ ENV["RAILS_ENV"] = "test"
|
|
4
4
|
require File.expand_path("../dummy/config/environment.rb", __FILE__)
|
5
5
|
require "rails/test_help"
|
6
6
|
|
7
|
-
Rails.backtrace_cleaner.remove_silencers!
|
8
|
-
|
9
7
|
# Load support files
|
10
8
|
Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each { |f| require f }
|
11
9
|
|
@@ -0,0 +1,52 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
require "static_docs/importer"
|
3
|
+
|
4
|
+
module StaticDocs
|
5
|
+
class ImporterTest < ActiveSupport::TestCase
|
6
|
+
fixtures 'static_docs/pages'
|
7
|
+
|
8
|
+
def setup
|
9
|
+
@importer = Importer.new(nil)
|
10
|
+
end
|
11
|
+
|
12
|
+
test 'source' do
|
13
|
+
src = File.expand_path("../../../dummy/sources/root", __FILE__)
|
14
|
+
assert_equal src, @importer.source.to_s
|
15
|
+
end
|
16
|
+
|
17
|
+
test 'config' do
|
18
|
+
assert @importer.config['special'].present?
|
19
|
+
assert @importer.config['pages'].present?
|
20
|
+
end
|
21
|
+
|
22
|
+
test 'cleanup' do
|
23
|
+
@importer.cleanup
|
24
|
+
assert_equal Page.find(static_docs_pages(:first_level_page).id), static_docs_pages(:first_level_page)
|
25
|
+
assert_raise(ActiveRecord::RecordNotFound){ Page.find(static_docs_pages(:deep_page).id) }
|
26
|
+
end
|
27
|
+
|
28
|
+
test 'import root' do
|
29
|
+
Importer.import(nil)
|
30
|
+
main = Page.matched('home')
|
31
|
+
assert_equal main.title, 'Main Page'
|
32
|
+
assert_equal main.extension, 'html'
|
33
|
+
assert_equal main.body, "<p>Hello from homepage!</p>\n"
|
34
|
+
assert_equal main.namespace, nil
|
35
|
+
|
36
|
+
assert_equal Page.matched('page').title, 'This is Just Page'
|
37
|
+
assert_equal Page.matched('getting-started').title, 'Getting Started'
|
38
|
+
end
|
39
|
+
|
40
|
+
test 'import namespaced' do
|
41
|
+
Importer.import('namespace')
|
42
|
+
main = Page.matched('namespace/home')
|
43
|
+
assert_equal main.title, 'Namespace Main Page'
|
44
|
+
assert_equal main.extension, 'html'
|
45
|
+
assert_equal main.body, "<p>Hello from namespace!</p>\n"
|
46
|
+
assert_equal main.namespace, 'namespace'
|
47
|
+
|
48
|
+
assert_equal Page.matched('namespace/page').title, 'This is Just Namespaced Page'
|
49
|
+
end
|
50
|
+
|
51
|
+
end
|
52
|
+
end
|
@@ -0,0 +1,46 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
module StaticDocs
|
4
|
+
class PageTest < ActiveSupport::TestCase
|
5
|
+
fixtures 'static_docs/pages'
|
6
|
+
|
7
|
+
setup do
|
8
|
+
@view_context = Object.new.extend ::ApplicationHelper
|
9
|
+
end
|
10
|
+
|
11
|
+
test "first-level search of matched page" do
|
12
|
+
assert_equal Page.matched('page'), static_docs_pages(:first_level_page)
|
13
|
+
end
|
14
|
+
|
15
|
+
test "deep search of matched page" do
|
16
|
+
assert_equal Page.matched('path/to/page'), static_docs_pages(:deep_page)
|
17
|
+
end
|
18
|
+
|
19
|
+
test "namespaced search of matched page" do
|
20
|
+
assert_equal Page.matched('namespace/page'), static_docs_pages(:namespaced_page)
|
21
|
+
end
|
22
|
+
|
23
|
+
test "search in unregistered namespace" do
|
24
|
+
assert_raise(ActiveRecord::RecordNotFound){ Page.matched('wrong/page') }
|
25
|
+
end
|
26
|
+
|
27
|
+
test "search of nonexistent page" do
|
28
|
+
assert_raise(ActiveRecord::RecordNotFound){ Page.matched('wrong') }
|
29
|
+
end
|
30
|
+
|
31
|
+
test 'simple renderer' do
|
32
|
+
assert_equal Page.matched('page').rendered_body(@view_context), '<h3>This is first level page</h3>'
|
33
|
+
end
|
34
|
+
|
35
|
+
test 'contextual renderer' do
|
36
|
+
str = "<h1>This is original markdown text</h1><pre>### This is markdown page</pre>"
|
37
|
+
assert_equal Page.matched('markdown').rendered_body(@view_context), str
|
38
|
+
end
|
39
|
+
|
40
|
+
test 'meta setting in renderer' do
|
41
|
+
page = Page.matched('text')
|
42
|
+
assert_equal page.rendered_body(@view_context), 'testtesttest'
|
43
|
+
assert_equal page.meta[:test], 'test'
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: static_docs
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 0.1.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-
|
12
|
+
date: 2013-05-03 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rails
|
@@ -53,12 +53,19 @@ extensions: []
|
|
53
53
|
extra_rdoc_files: []
|
54
54
|
files:
|
55
55
|
- app/assets/javascripts/static_docs/application.js
|
56
|
+
- app/assets/javascripts/static_docs/pages.js
|
56
57
|
- app/assets/stylesheets/static_docs/application.css
|
58
|
+
- app/assets/stylesheets/static_docs/pages.css
|
57
59
|
- app/controllers/static_docs/application_controller.rb
|
60
|
+
- app/controllers/static_docs/pages_controller.rb
|
58
61
|
- app/helpers/static_docs/application_helper.rb
|
59
|
-
- app/
|
62
|
+
- app/helpers/static_docs/pages_helper.rb
|
63
|
+
- app/models/static_docs/page.rb
|
64
|
+
- app/views/static_docs/pages/show.html.erb
|
60
65
|
- config/routes.rb
|
66
|
+
- db/migrate/20130502102206_create_static_docs_pages.rb
|
61
67
|
- lib/static_docs/engine.rb
|
68
|
+
- lib/static_docs/importer.rb
|
62
69
|
- lib/static_docs/version.rb
|
63
70
|
- lib/static_docs.rb
|
64
71
|
- lib/tasks/static_docs_tasks.rake
|
@@ -82,10 +89,18 @@ files:
|
|
82
89
|
- test/dummy/config/initializers/mime_types.rb
|
83
90
|
- test/dummy/config/initializers/secret_token.rb
|
84
91
|
- test/dummy/config/initializers/session_store.rb
|
92
|
+
- test/dummy/config/initializers/static_docs.rb
|
85
93
|
- test/dummy/config/initializers/wrap_parameters.rb
|
86
94
|
- test/dummy/config/locales/en.yml
|
87
95
|
- test/dummy/config/routes.rb
|
88
96
|
- test/dummy/config.ru
|
97
|
+
- test/dummy/db/development.sqlite3
|
98
|
+
- test/dummy/db/migrate/20130502133441_create_static_docs_pages.static_docs.rb
|
99
|
+
- test/dummy/db/schema.rb
|
100
|
+
- test/dummy/db/test.sqlite3
|
101
|
+
- test/dummy/log/development.log
|
102
|
+
- test/dummy/log/production.log
|
103
|
+
- test/dummy/log/test.log
|
89
104
|
- test/dummy/public/404.html
|
90
105
|
- test/dummy/public/422.html
|
91
106
|
- test/dummy/public/500.html
|
@@ -93,9 +108,21 @@ files:
|
|
93
108
|
- test/dummy/Rakefile
|
94
109
|
- test/dummy/README.rdoc
|
95
110
|
- test/dummy/script/rails
|
111
|
+
- test/dummy/sources/namespace/home.html
|
112
|
+
- test/dummy/sources/namespace/index.yml
|
113
|
+
- test/dummy/sources/namespace/page.html
|
114
|
+
- test/dummy/sources/root/getting_started.html
|
115
|
+
- test/dummy/sources/root/home.html
|
116
|
+
- test/dummy/sources/root/index.yml
|
117
|
+
- test/dummy/sources/root/page.html
|
118
|
+
- test/fixtures/static_docs/pages.yml
|
119
|
+
- test/functional/static_docs/pages_controller_test.rb
|
96
120
|
- test/integration/navigation_test.rb
|
97
121
|
- test/static_docs_test.rb
|
98
122
|
- test/test_helper.rb
|
123
|
+
- test/unit/helpers/static_docs/pages_helper_test.rb
|
124
|
+
- test/unit/static_docs/importer_test.rb
|
125
|
+
- test/unit/static_docs/page_test.rb
|
99
126
|
homepage: https://github.com/Mik-die/static_docs
|
100
127
|
licenses: []
|
101
128
|
post_install_message:
|
@@ -110,7 +137,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
110
137
|
version: '0'
|
111
138
|
segments:
|
112
139
|
- 0
|
113
|
-
hash:
|
140
|
+
hash: 1507088232620583790
|
114
141
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
115
142
|
none: false
|
116
143
|
requirements:
|
@@ -119,7 +146,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
119
146
|
version: '0'
|
120
147
|
segments:
|
121
148
|
- 0
|
122
|
-
hash:
|
149
|
+
hash: 1507088232620583790
|
123
150
|
requirements: []
|
124
151
|
rubyforge_project:
|
125
152
|
rubygems_version: 1.8.25
|
@@ -144,10 +171,18 @@ test_files:
|
|
144
171
|
- test/dummy/config/initializers/mime_types.rb
|
145
172
|
- test/dummy/config/initializers/secret_token.rb
|
146
173
|
- test/dummy/config/initializers/session_store.rb
|
174
|
+
- test/dummy/config/initializers/static_docs.rb
|
147
175
|
- test/dummy/config/initializers/wrap_parameters.rb
|
148
176
|
- test/dummy/config/locales/en.yml
|
149
177
|
- test/dummy/config/routes.rb
|
150
178
|
- test/dummy/config.ru
|
179
|
+
- test/dummy/db/development.sqlite3
|
180
|
+
- test/dummy/db/migrate/20130502133441_create_static_docs_pages.static_docs.rb
|
181
|
+
- test/dummy/db/schema.rb
|
182
|
+
- test/dummy/db/test.sqlite3
|
183
|
+
- test/dummy/log/development.log
|
184
|
+
- test/dummy/log/production.log
|
185
|
+
- test/dummy/log/test.log
|
151
186
|
- test/dummy/public/404.html
|
152
187
|
- test/dummy/public/422.html
|
153
188
|
- test/dummy/public/500.html
|
@@ -155,6 +190,18 @@ test_files:
|
|
155
190
|
- test/dummy/Rakefile
|
156
191
|
- test/dummy/README.rdoc
|
157
192
|
- test/dummy/script/rails
|
193
|
+
- test/dummy/sources/namespace/home.html
|
194
|
+
- test/dummy/sources/namespace/index.yml
|
195
|
+
- test/dummy/sources/namespace/page.html
|
196
|
+
- test/dummy/sources/root/getting_started.html
|
197
|
+
- test/dummy/sources/root/home.html
|
198
|
+
- test/dummy/sources/root/index.yml
|
199
|
+
- test/dummy/sources/root/page.html
|
200
|
+
- test/fixtures/static_docs/pages.yml
|
201
|
+
- test/functional/static_docs/pages_controller_test.rb
|
158
202
|
- test/integration/navigation_test.rb
|
159
203
|
- test/static_docs_test.rb
|
160
204
|
- test/test_helper.rb
|
205
|
+
- test/unit/helpers/static_docs/pages_helper_test.rb
|
206
|
+
- test/unit/static_docs/importer_test.rb
|
207
|
+
- test/unit/static_docs/page_test.rb
|
@@ -1,14 +0,0 @@
|
|
1
|
-
<!DOCTYPE html>
|
2
|
-
<html>
|
3
|
-
<head>
|
4
|
-
<title>StaticDocs</title>
|
5
|
-
<%= stylesheet_link_tag "static_docs/application", :media => "all" %>
|
6
|
-
<%= javascript_include_tag "static_docs/application" %>
|
7
|
-
<%= csrf_meta_tags %>
|
8
|
-
</head>
|
9
|
-
<body>
|
10
|
-
|
11
|
-
<%= yield %>
|
12
|
-
|
13
|
-
</body>
|
14
|
-
</html>
|