rack-usermanual 0.1.1 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +8 -8
- data/README.md +25 -20
- data/lib/rack/usermanual/app.rb +17 -11
- data/rack-usermanual.gemspec +1 -1
- data/spec/fixtures/layout.haml +2 -0
- data/spec/usermanual_spec.rb +1 -1
- metadata +3 -1
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
NmJlOWMwYzg4YzkwZjU2MmQwM2JjMTg1OGU1OTdmYjQyNGMyY2RiZg==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
Y2JjYWFjNzhmOGI2NjVhNmU4Mjg1N2Y0MTEwZDU5OTA5ODAwY2IyZQ==
|
7
7
|
!binary "U0hBNTEy":
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
ODQ5OWU2ZDEyZDI1YTcyYjhlZWYzZWVlYzM2NmJkZDYzY2Q2NTg2Zjk4MTM2
|
10
|
+
MDJhZGY4MmQ3ODY0YjJlZGNlY2M3YWMyNTE4ODI4YTEwYjRhMTJlZDRhMDBi
|
11
|
+
NWEyNzc5YTBiNGI2NDEyMDM4ZWVlNTQzNTg0YjYxMzVlOTE5NTc=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
NTljMDRmM2U5MTI0MzA3ZmUwMDY1NmJlNzU1MGQxZjFiNTIxOGY4MGFjOTlm
|
14
|
+
MDIwYTFiZjI0YzE0MmI0ZmNkNTI0N2QyNTcwNjdmZWY2M2NkZWYxYzE2YmMz
|
15
|
+
NzY1OTgxYzI2OWQxZWM4MWU3ZWI4NTE1Y2QwOWQyODRkMGNlOTA=
|
data/README.md
CHANGED
@@ -1,5 +1,4 @@
|
|
1
|
-
Rack Usermanual
|
2
|
-
================
|
1
|
+
# Rack Usermanual
|
3
2
|
|
4
3
|
![Build status](https://travis-ci.org/chrismdp/rack-usermanual.png) ![Code climate](https://codeclimate.com/github/chrismdp/rack-usermanual.png)
|
5
4
|
|
@@ -7,8 +6,7 @@ Want to embed your cucumber features directly into your project as a User manual
|
|
7
6
|
|
8
7
|
See an example here: [http://online.soltrader.net/help/game-manual/combat](http://online.soltrader.net/help/game-manual/combat)
|
9
8
|
|
10
|
-
Installation
|
11
|
-
------------
|
9
|
+
## Installation
|
12
10
|
|
13
11
|
```
|
14
12
|
gem install rack-usermanual
|
@@ -16,45 +14,52 @@ gem install rack-usermanual
|
|
16
14
|
|
17
15
|
(or add it to your bundle.)
|
18
16
|
|
19
|
-
Usage
|
20
|
-
-----
|
17
|
+
## Usage
|
21
18
|
|
22
|
-
|
19
|
+
|
20
|
+
### Rack
|
21
|
+
|
22
|
+
To use, add the following to your Rack::Builder instance:
|
23
23
|
|
24
24
|
```
|
25
25
|
# Choose whatever url endpoint you like.
|
26
26
|
map "/help" do
|
27
27
|
use Rack::Usermanual,
|
28
|
-
# `sections`: Sections of the manual: human readable name together
|
29
|
-
# with a path to a folder containing the features.
|
30
28
|
:sections => {
|
31
29
|
"Game manual" => 'features/docs/game-manual',
|
32
30
|
"API documentation" => 'features/docs/api-documentation'
|
33
31
|
},
|
34
|
-
|
35
|
-
:index => 'features/docs/README.md',
|
36
|
-
# `views`: Look in here for the layout: layout.erb, layout.haml etc.
|
37
|
-
:views => File.join(Dir.pwd, 'views')
|
32
|
+
:index => 'features/docs/README.md'
|
38
33
|
end
|
39
34
|
```
|
40
35
|
|
41
|
-
|
36
|
+
### Rails
|
37
|
+
|
38
|
+
Inside your `config/routes.rb`:
|
42
39
|
|
43
40
|
```
|
44
|
-
|
41
|
+
mount Rack::Usermanual.new(nil, :index => 'README.rdoc', :sections => ...), :at => '/help'
|
45
42
|
```
|
46
43
|
|
47
44
|
(I'm not quite sure about the best way to pass options with rails - clarifications welcome!)
|
48
45
|
|
49
46
|
Then start your app and point your browser to `/help` and your features should be displayed for you.
|
50
47
|
|
51
|
-
|
52
|
-
|
48
|
+
### Options
|
49
|
+
|
50
|
+
These are the options you can pass to the app:
|
51
|
+
|
52
|
+
* `sections`: Sections of the manual: human readable name together with a path to a folder containing the features.
|
53
|
+
* `index`: Markdown file to display on the index page of the help. Required.
|
54
|
+
* `layout`: the path from the root of your app to the layout you want to use. Uses `views/layout.haml` as the default.
|
55
|
+
|
56
|
+
## Caveats
|
57
|
+
|
58
|
+
The app will use the layout that you have given, but for Rails you might need to provide a custom layout as rails helpers such as `stylesheet_link_tag` currently don't work (Pull requests welcome!)
|
53
59
|
|
54
|
-
The
|
60
|
+
The CSS in the views is based on bootstrap: you might need to provide style your features slightly differently to get them to work in the way that you want. If you need more CSS classes, do submit pull requests to get them.
|
55
61
|
|
56
|
-
Contributing
|
57
|
-
------------
|
62
|
+
## Contributing
|
58
63
|
|
59
64
|
We work on pull requests. If you have an idea for something you'd like to contribute, here's how to do it:
|
60
65
|
|
data/lib/rack/usermanual/app.rb
CHANGED
@@ -4,27 +4,33 @@ require 'stringio'
|
|
4
4
|
require 'json'
|
5
5
|
require 'sinatra'
|
6
6
|
require 'kramdown'
|
7
|
+
require 'haml'
|
7
8
|
|
8
9
|
module Rack
|
9
10
|
class Usermanual < Sinatra::Base
|
10
11
|
VERSION = "0.1.0"
|
11
12
|
|
13
|
+
set :views, ::File.expand_path(::File.join(::File.dirname(__FILE__), '..', '..', '..', 'views'))
|
14
|
+
|
12
15
|
def initialize(app, options)
|
13
16
|
super(app)
|
14
17
|
@sections = options[:sections]
|
15
18
|
@index = options[:index]
|
16
|
-
|
19
|
+
|
20
|
+
layout = options[:layout] || 'views/layout.haml'
|
21
|
+
|
22
|
+
path = ::File.dirname(layout)
|
23
|
+
extension = ::File.extname(layout)
|
24
|
+
file = ::File.basename(layout, extension)
|
25
|
+
|
26
|
+
@render_options = {
|
27
|
+
:layout => file.to_sym,
|
28
|
+
:layout_options => { :views => path },
|
29
|
+
:layout_engine => extension[1..-1].to_sym
|
30
|
+
}
|
17
31
|
end
|
18
32
|
|
19
33
|
helpers do
|
20
|
-
def find_template(views, name, engine, &block)
|
21
|
-
new_views = [
|
22
|
-
::File.expand_path(::File.join(::File.dirname(__FILE__), '..', '..', '..', 'views')),
|
23
|
-
@main_views
|
24
|
-
].flatten.compact
|
25
|
-
Array(new_views).each { |v| super(v, name, engine, &block) }
|
26
|
-
end
|
27
|
-
|
28
34
|
def h(text)
|
29
35
|
Rack::Utils.escape_html(text)
|
30
36
|
end
|
@@ -46,7 +52,7 @@ module Rack
|
|
46
52
|
end
|
47
53
|
|
48
54
|
get '/?' do
|
49
|
-
haml :index
|
55
|
+
haml :index, @render_options
|
50
56
|
end
|
51
57
|
|
52
58
|
def get_feature(path, page)
|
@@ -73,7 +79,7 @@ module Rack
|
|
73
79
|
|
74
80
|
@raw, @json = get_feature(path, @page)
|
75
81
|
|
76
|
-
haml :page
|
82
|
+
haml :page, @render_options
|
77
83
|
end
|
78
84
|
end
|
79
85
|
end
|
data/rack-usermanual.gemspec
CHANGED
@@ -3,7 +3,7 @@ $:.push File.expand_path("../lib", __FILE__)
|
|
3
3
|
|
4
4
|
Gem::Specification.new do |s|
|
5
5
|
s.name = "rack-usermanual"
|
6
|
-
s.version = "0.
|
6
|
+
s.version = "0.2.0"
|
7
7
|
s.authors = ["Chris Parsons"]
|
8
8
|
s.email = ["chris.p@rsons.org"]
|
9
9
|
s.homepage = "http://github.com/chrismdp/rack-usermanual"
|
data/spec/usermanual_spec.rb
CHANGED
@@ -5,7 +5,7 @@ describe Rack::Usermanual do
|
|
5
5
|
include Rack::Test::Methods
|
6
6
|
|
7
7
|
def app
|
8
|
-
Rack::Usermanual.new(nil, :sections => {'My section' => 'spec/fixtures/features/my-section'})
|
8
|
+
Rack::Usermanual.new(nil, :layout => 'spec/fixtures/layout.haml', :sections => {'My section' => 'spec/fixtures/features/my-section'})
|
9
9
|
end
|
10
10
|
|
11
11
|
it "grabs a file from the features folder" do
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rack-usermanual
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Chris Parsons
|
@@ -126,6 +126,7 @@ files:
|
|
126
126
|
- lib/rack/usermanual/app.rb
|
127
127
|
- rack-usermanual.gemspec
|
128
128
|
- spec/fixtures/features/my-section/test.feature
|
129
|
+
- spec/fixtures/layout.haml
|
129
130
|
- spec/spec_helper.rb
|
130
131
|
- spec/usermanual_spec.rb
|
131
132
|
- views/_menu.haml
|
@@ -157,6 +158,7 @@ specification_version: 4
|
|
157
158
|
summary: Rack endpoint to serve your cucumber features as a user manual
|
158
159
|
test_files:
|
159
160
|
- spec/fixtures/features/my-section/test.feature
|
161
|
+
- spec/fixtures/layout.haml
|
160
162
|
- spec/spec_helper.rb
|
161
163
|
- spec/usermanual_spec.rb
|
162
164
|
has_rdoc:
|