Skip to content

Commit

Permalink
Merge c3b6030 into 71a9448
Browse files Browse the repository at this point in the history
  • Loading branch information
razum2um committed Feb 6, 2015
2 parents 71a9448 + c3b6030 commit 631ab40
Show file tree
Hide file tree
Showing 39 changed files with 351 additions and 188 deletions.
3 changes: 3 additions & 0 deletions .hound.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ AllCops:
- 'tmp/**/*'
- 'templates/rails32_http_patch_support.rb'

TrailingBlankLines:
Enabled: false

StringLiterals:
Enabled: false

Expand Down
20 changes: 14 additions & 6 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,20 @@
language: ruby
sudo: false
before_install: gem install bundler
gemfile:
- gemfiles/Gemfile32.ci
- gemfiles/Gemfile40.ci
- gemfiles/Gemfile41.ci
- gemfiles/Gemfile42.ci
install: bundle install -j4 --path vendor/bundle
- gemfiles/rails_32.gemfile
- gemfiles/rails_40.gemfile
- gemfiles/rails_41.gemfile
- gemfiles/rails_42.gemfile
rvm:
- 1.9.3
- 2.0.0
- 2.1.1
- 2.1.5
- 2.2.0
matrix:
exclude:
# NOTE : incompatible
- rvm: 2.2.0
gemfile: gemfiles/rails_32.gemfile
install: bundle install -j4 --path vendor/bundle

20 changes: 20 additions & 0 deletions Appraisals
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
appraise 'rails-32' do
gem 'rails', '~> 3.2.21'
eval ::File.read('Gemfile')
end

appraise 'rails-40' do
gem 'rails', '~> 4.0.13'
eval ::File.read('Gemfile')
end

appraise 'rails-41' do
gem 'rails', '~> 4.1.9'
eval ::File.read('Gemfile')
end

appraise 'rails-42' do
gem 'rails', '~> 4.2.0'
eval ::File.read('Gemfile')
end

16 changes: 10 additions & 6 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -1,22 +1,25 @@
source 'https://rubygems.org'
gemspec

# Add any gems and groups that you don't want to keep local
group :development do
# tools
gem 'pry-byebug'
gem 'pry-stack_explorer'
gem 'pry-session'
gem 'pry-byebug', platforms: [:mri_20, :mri_21, :mri_22]
gem 'pry-debugger', platforms: :mri_19
gem 'pry-stack_explorer', platform: :mri
gem 'pry-session', platform: :mri
# rspec --format fuubar
gem 'fuubar'
# cucumber --format fuubar
gem 'fuubar-cucumber', github: 'martinciu/fuubar-cucumber', branch: 'master'
gem 'fuubar-cucumber'
gem 'selenium-webdriver'

# deploy site
gem 'highline'
# gem 'coderay', path: '../coderay'

# multiple rails versions support
gem 'appraisal', github: 'razum2um/appraisal', branch: 'master'

# build template static
# run `rake assets:precompile`
# to get bundled application.(js|css)
Expand All @@ -27,5 +30,6 @@ group :development do
gem 'bootstrap-sass', '~> 3.1.1'
gem 'jquery-rails'
gem 'remotipart'
gem "launchy"
gem 'launchy'
end

54 changes: 40 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -88,9 +88,10 @@ and it fails if your code changes the api!

The generation of live-documentation is pretty simple:

bin/lurker convert # builds html under `Rails.root/html`
bin/lurker convert -o public/lurker # builds html under `Rails.root/public/lurker`
bin/lurker convert -f pdf -o html # builds `ServiceName.pdf` under `Rails.root/html`
bin/lurker convert # builds html under `Rails.root/public/lurker` to be served under `/lurker` url
bin/lurker convert -f pdf # builds `Rails.root/public/lurker/snake_cased_name.pdf`

For different document root or serving url prefix use `-o` and `-u` options accordingly.

Let's run your `rails s` and visit [http://localhost:3000/lurker/](http://localhost:3000/lurker/)
(or see [demo][demo_app2] for example)
Expand All @@ -99,8 +100,14 @@ Now, you can test your API on-line (for real)

## [Demo application][demo_app3]

You can clone the repo & run `rake build_example_docs && cd tmp/lurker_app && bin/rails s`
to get your running demo.
You can run this to get the demo running locally:

git clone https://github.com/razum2um/lurker.git
cd lurker
bundle exec appraisal rails-42 bundle install
bundle exec appraisal rails-42 rake build_example_docs
cd tmp/lurker_app_rails_42
bin/rails s

Lurker supports multiple domains (usually `staging` and `production`) and can be deployed
statically everywhere as well as be served by current `Rails` instance.
Expand All @@ -119,12 +126,11 @@ For example:
- [Pretty submit form to test API endpoints (live) based on schemas][demo_live] (enter a name & press "Submit")
- [Handling URLs with dynamic segments][nested_controller_spec_example] (such as `api/v1/:user_id/repos`)
- [JSON-Schema partials][partial_example], also in YAML format ([demo][partial_example_demo])
- [Generation PDF documentation][pdf_example] (add `gem 'pdfkit'` to Gemfile)
- [Generation PDF documentation][pdf_example] (*NOTE*: add `gem 'pdfkit'` to Gemfile)
- [Multiple docs for many usecases][suffixes_example] (e.g `:lurker => '...'`)
- ERB support inside `.json.yml.erb`
- Insert custom content in Markdown into `index.html` (add `gem 'kramdown'` to Gemfile)
- Insert custom content in Markdown into `index.html` (*NOTE*: add `gem 'kramdown'` to Gemfile)
- Syntax highlighting for sample response (add `gem 'execjs'` to Gemfile)
- HTTP-Auth authorization for docs (`mount Lurker::Server.to_rack username: '...', password: '...'`)
- Separate API-services generated within one test suite
- Capistrano integration
- JSON-Schema draft-v4 support
Expand Down Expand Up @@ -166,21 +172,41 @@ I try to use [Waffle][waffle] to develop this gem, if you want to help:
don't touch files under `lib/lurker/templates/public` - they are autogenerated
and copied to static generated site while `bin/lurker convert`

rake assets:precompile # to build them
bundle exec appraisal rails-42 rake assets:precompile # to build them

Don't commit `lib/lurker/templates/public/**/*` to avoid conflicts.

**NOTE:** if you write features keep in mind to generate different files with aruba,
because they are kept in `lurker_app` directory to be deployed as a demo. Please, write
features in a way to generate **new** relevant `lurker/**/*.json.yml` files

To run cucumber in a clean `lurker` & `html` directories run:

CLEAN=1 cucumber features

**NOTE:** template partial `submit_form.html.erb` and it's partials is a big `jsx` script for `React`
so there are `<label htmlFor` instead of `<label for>` and `<div className` instead of `<div class`

### Different Rails versions

We use [`appraisal`](https://github.com/thoughtbot/appraisal) to test the lib with different Rails versions (from 3.2 up to 4.2):

# run this to install all gems for all the supported rails versions:
bundle exec appraisal install

# then prefix any rake command with `bundle exec appraisal` and rails version
bundle exec appraisal rails-42 rake build_example_docs

Test apps are getting generated into their's own directory under `tmp/lurker_app...` prefix. They also use
separate databases for each rails version both for dev & test env - all prefixed with `lurker_app`

### Demo app == Testing app

Currently testing application is using postgresql, because **the same** testing app is deployed to serve demo purposes.

This is also the reason not to delete anything under `lurker` directory between feature tests
and using **different** API endpoints of the testing app. To run cucumber with clean `lurker` & `html` directories run:

CLEAN=1 bundle exec appraisal rails-42 cucumber features

Beware while writing your feature tests for PRs.

## Acknoledgements

[![Sponsored by Evil Martians](https://evilmartians.com/badges/sponsored-by-evil-martians.svg)](http://evilmartians.com/)
Expand Down Expand Up @@ -223,7 +249,7 @@ Also thanks to
[demo_app2]: http://lurker.razum2um.me
[demo_app3]: http://razum2um.github.io/lurker/
[demo_live]: http://lurker.razum2um.me/lurker/api/v1/users-POST.html
[pdf_example]: http://razum2um.github.io/lurker/Lurker%20Demo%20Application.pdf
[pdf_example]: http://razum2um.github.io/lurker/lurker_demo_application.pdf
[partial_example_demo]: http://razum2um.github.io/lurker/api/v1/users/__user_id/repos-POST.html

[Gem Version]: https://rubygems.org/gems/lurker
Expand Down
5 changes: 3 additions & 2 deletions features/atom_persistent_within_the_same_type.feature
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,9 @@ Feature: atom persistent within test suite
method: PATCH
path_info: "/api/v2/users/100"
path_params:
id: '100'
controller: api/v2/users
action: update
id: '100'
"""

Scenario: json schema tests response parameters and keep atom unchanged using "users/update"
Expand Down Expand Up @@ -129,8 +129,9 @@ Feature: atom persistent within test suite
method: PATCH
path_info: "/api/v2/users/100"
path_params:
id: '100'
controller: api/v2/users
action: update
id: '100'
"""

3 changes: 2 additions & 1 deletion features/controller_nested_schema_scaffolding.feature
Original file line number Diff line number Diff line change
Expand Up @@ -71,10 +71,11 @@ Feature: controller nested schema scaffolding
method: GET
path_info: "/api/v1/users/1/repos.json"
path_params:
user_id: '1'
controller: api/v1/repos
action: index
user_id: '1'
query_params:
limit: 1
"""

3 changes: 2 additions & 1 deletion features/controller_schema_scaffolding.feature
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,9 @@ Feature: controller schema scaffolding
method: GET
path_info: "/api/v1/users/1.json"
path_params:
id: '1'
controller: api/v1/users
action: show
id: '1'
"""

3 changes: 2 additions & 1 deletion features/dereferencing_through_inlining.feature
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@ Feature: $ref defererencing through inlining
method: PATCH
path_info: "/api/v3/users/1"
path_params:
id: '1'
controller: api/v3/users
action: update
id: '1'
"""
And a file named "lurker/definitions/user_request_parameters.json" with:
Expand Down Expand Up @@ -100,3 +100,4 @@ Feature: $ref defererencing through inlining
]
}
"""

9 changes: 5 additions & 4 deletions features/html_generation.feature
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ Feature: html generation

@javascript
Scenario: json schema gets generated into html preview using "users/create"
Given an empty directory named "html"
Given an empty directory named "public/lurker"
And a file named "lurker/api/v1/users-POST.json.yml" with:
"""yml
---
Expand Down Expand Up @@ -38,8 +38,8 @@ Feature: html generation
method: POST
path_info: "/api/v1/users.json"
path_params:
action: create
controller: api/v1/users
action: create
"""

When I successfully run `bin/lurker convert`
Expand All @@ -48,8 +48,8 @@ Feature: html generation
Converting lurker to html
using lurker
create index.html
create api/v1/users-POST.html
create public/lurker/index.html
create public/lurker/api/v1/users-POST.html
"""

When I go to "/lurker"
Expand All @@ -73,3 +73,4 @@ Feature: html generation
And I submit it

Then I should see JSON response with "can't be blank"

5 changes: 3 additions & 2 deletions features/minitest.feature
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,8 @@ Feature: minitest
method: DELETE
path_info: "/api/v1/users/1/repos/1.json"
path_params:
action: destroy
controller: api/v1/repos
action: destroy
user_id: '1'
id: '1'
Expand Down Expand Up @@ -100,8 +100,8 @@ Feature: minitest
path_info: "/api/v1/users/1"
method: PATCH
path_params:
action: update
controller: api/v1/users
action: update
id: 1
"""

Expand Down Expand Up @@ -136,3 +136,4 @@ Feature: minitest
"""
1 (runs|tests), 1 assertions, 0 failures, 1 errors, 0 skips
"""

10 changes: 5 additions & 5 deletions features/multidomain_support.feature
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ Feature: mutidomain support

@javascript
Scenario: json schema gets generated into html preview using "users/destroy"
Given an empty directory named "html"
And a file named "lurker/LurkerApp.service.yml" with:
Given an empty directory named "public/lurker"
And a service file with:
"""yml
---
basePath: ''
Expand Down Expand Up @@ -47,8 +47,8 @@ Feature: mutidomain support
method: DELETE
path_info: "/api/v1/users/1.json"
path_params:
action: destroy
controller: api/v1/users
action: destroy
id: 1
"""

Expand All @@ -58,8 +58,8 @@ Feature: mutidomain support
Converting lurker to html
using lurker
create index.html
create api/v1/users/__id-DELETE.html
create public/lurker/index.html
create public/lurker/api/v1/users/__id-DELETE.html
"""

When I go to "/lurker/api/v1/users/__id-DELETE.html"
Expand Down
5 changes: 3 additions & 2 deletions features/multitype_request_support.feature
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,9 @@ Feature: multitype request support
method: PATCH
path_info: "/api/v2/users/1"
path_params:
id: '1'
controller: api/v2/users
action: update
id: '1'
"""

Scenario: json schema tests response parameters and update request parameters using "users/update"
Expand Down Expand Up @@ -130,8 +130,9 @@ Feature: multitype request support
method: PATCH
path_info: "/api/v2/users/1"
path_params:
id: '1'
controller: api/v2/users
action: update
id: '1'
"""

0 comments on commit 631ab40

Please sign in to comment.