rack-usermanual 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- YTU5Mzg1NWM1NzFkMzA5Y2RiMDc2OWNhYjBlMzRjZjNjNmM1YzU0MQ==
4
+ YmFkZDVmY2I0MWNiNWYwNjEzMGI3NzNkYjFmNDQ0MmMwYmJlMGM4ZA==
5
5
  data.tar.gz: !binary |-
6
- MDE4NDA4NzI1MTcxNDM1Y2IxMTc0NmM2NTYwYjNkZjdkOTgyMTZhZA==
6
+ MGIyY2E5ODMyYzczNTQ4ZjAxNDZlOTJmMzkyNTI2NDAwYTUxNDNhNA==
7
7
  !binary "U0hBNTEy":
8
8
  metadata.gz: !binary |-
9
- MjVmNDQ2ZmJmNDFlMGQ4NmVlYmRiZWUwYWY5MzA0N2IyNzhkYmYwNzU2OGU4
10
- MTRhYzBlZDVlYTMwODIwMWUyYzVjYTBlMTBiNjBiYTY2YjYzMWJjOTQ1OWM0
11
- YTI3MDA3ZTc3MjAxYmU2OTkyY2VlYjZlM2ZiY2ZmMDRhYTExM2I=
9
+ MDZlZGJiNzAzMDc2NDk1YjlhM2Q0MTdmNDY0MGU4YWVhN2FhODc5ZWFkMTRh
10
+ ODE3NzY0YTkwOTdjM2ViZTZhMWQyMTMyZWY5ZmEzNTRiZmU5YzcxOTc2MzU4
11
+ ZDgwNTg4MjFjNDM4MjBiNDk5YTdjYTFhYTlhZjgyNDMyZWQyYzI=
12
12
  data.tar.gz: !binary |-
13
- ZWI2MTI3NDBhODVkM2FiY2E0YjAwMDBjYTU3MDJiYmYzZTU3MzA0OThlN2Iz
14
- Y2YyOTQ4ZWMxN2I5ZjliNDlkMzBhNmI0MDQ1YzlkYWE5YmNiNzkxYWNkNmEy
15
- OGYwZmFjZjdlOTc3MjBjNWRjYmViMzg5N2IxMWNhYTBhZmFkYWY=
13
+ ZmExMjNiZjFlNGY2MTcxNWVkZDk2OTZjZmNhNjQ0M2VmYzU5MTVmZjcwYTg4
14
+ N2FlYTA0NDA1ODQ2OWM4MDk0YmU1NzBiYzM4ZmJmMWZmNTEzZmNkMTA4OWZl
15
+ MzNlNzM2YmFjZTVhMWJhZmIxMTk0MGM4NWM4Y2RhNmZmMTAzMmQ=
data/.gitignore CHANGED
@@ -1 +1,2 @@
1
1
  Gemfile.lock
2
+ *.gem
data/.travis.yml ADDED
@@ -0,0 +1,5 @@
1
+ language: ruby
2
+ rvm:
3
+ - 1.9.3
4
+ - 2.0.0
5
+ script: bundle exec rspec
data/README.md CHANGED
@@ -1,7 +1,23 @@
1
- Rack::Usermanual
1
+ Rack Usermanual
2
2
  ================
3
3
 
4
- This little piece of middleware helps you expose your cucumber features in a readable 'manual-like' style for your users to consume.
4
+ ![Build status](https://travis-ci.org/chrismdp/rack-usermanual.png)   ![Code climate](https://codeclimate.com/github/chrismdp/rack-usermanual.png)
5
+
6
+ Want to embed your cucumber features directly into your project as a User manual? Here's a gem to do it.
7
+
8
+ See an example here: [http://online.soltrader.net/help/game-manual/combat](http://online.soltrader.net/help/game-manual/combat)
9
+
10
+ Installation
11
+ ------------
12
+
13
+ ```
14
+ gem install rack-usermanual
15
+ ```
16
+
17
+ (or add it to your bundle.)
18
+
19
+ Usage
20
+ -----
5
21
 
6
22
  To use, add the following to your Rack app:
7
23
 
@@ -22,11 +38,23 @@ map "/help" do
22
38
  end
23
39
  ```
24
40
 
25
- Then start your app and point your browser to `/help` and your features should be displayed for you!
41
+ Or with Rails, you can do something like this in `config/routes.rb`:
42
+
43
+ ```
44
+ match "/help" => Rack::Usermanual.new(self, :sections => ... }
45
+ ```
46
+
47
+ (I'm not quite sure about the best way to pass options with rails - clarifications welcome!)
48
+
49
+ Then start your app and point your browser to `/help` and your features should be displayed for you.
50
+
51
+ Caveats
52
+ -------
26
53
 
27
54
  The app will use the layout that you have in layout.{erb,haml} in whichever folder you specify. The CSS in the views is based on bootstrap: you might need to style your features slightly differently to get them to work in the way that you want. In the future it may be possible to completely override the views with your own.
28
55
 
29
- ## Contributing
56
+ Contributing
57
+ ------------
30
58
 
31
59
  We work on pull requests. If you have an idea for something you'd like to contribute, here's how to do it:
32
60
 
@@ -29,6 +29,10 @@ module Rack
29
29
  Rack::Utils.escape_html(text)
30
30
  end
31
31
 
32
+ def humanize(word)
33
+ word.capitalize.gsub(/[-_]/, ' ')
34
+ end
35
+
32
36
  def replace_start(sentence)
33
37
  {
34
38
  /^given / => 'Assume ',
@@ -49,7 +53,9 @@ module Rack
49
53
  sio = StringIO.new
50
54
  json_formatter = Gherkin::Formatter::JSONFormatter.new(sio)
51
55
  parser = Gherkin::Parser::Parser.new(json_formatter)
52
- raw = ::File.read("#{path}/#{page}.feature")
56
+ filepath = "#{path}/#{page}.feature"
57
+ halt 404 unless ::File.exist?(filepath)
58
+ raw = ::File.read(filepath)
53
59
  parser.parse(raw, uri, 0)
54
60
  json_formatter.done
55
61
  [raw, JSON.parse(sio.string)]
@@ -1,10 +1,9 @@
1
1
  # -*- encoding: utf-8 -*-
2
2
  $:.push File.expand_path("../lib", __FILE__)
3
- require "rack/usermanual"
4
3
 
5
4
  Gem::Specification.new do |s|
6
5
  s.name = "rack-usermanual"
7
- s.version = Rack::Usermanual::VERSION
6
+ s.version = "0.1.1"
8
7
  s.authors = ["Chris Parsons"]
9
8
  s.email = ["chris.p@rsons.org"]
10
9
  s.homepage = "http://github.com/chrismdp/rack-usermanual"
data/views/_menu.haml CHANGED
@@ -7,4 +7,4 @@
7
7
  - features.each do |fn|
8
8
  - name = ::File.basename(fn, '.feature')
9
9
  %li
10
- %a{:href => "/help/#{::File.basename(path)}/#{name}"}= name.capitalize.gsub(/[-_]/, ' ')
10
+ %a{:href => "/help/#{::File.basename(path)}/#{name}"}= humanize(name)
data/views/page.haml CHANGED
@@ -1,6 +1,6 @@
1
1
  %h4.page-header
2
2
  %a{:href => '/help'} Help & support
3
- == » #{@human_name} » #{@page.capitalize}
3
+ == » #{@human_name} » #{humanize(@page)}
4
4
 
5
5
  .container
6
6
  .row
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.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Chris Parsons
@@ -117,6 +117,7 @@ extra_rdoc_files: []
117
117
  files:
118
118
  - .gitignore
119
119
  - .rspec
120
+ - .travis.yml
120
121
  - Gemfile
121
122
  - LICENSE
122
123
  - README.md