lurker 0.0.1 → 0.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- checksums.yaml.gz.asc +8 -8
- data.tar.gz.asc +8 -8
- data/.gitignore +4 -0
- data/.gitmodules +3 -0
- data/.rspec +2 -0
- data/.travis.yml +7 -0
- data/Gemfile.local +28 -0
- data/README.md +128 -13
- data/Rakefile +179 -0
- data/bin/lurker +14 -0
- data/cucumber.yml +2 -0
- data/features/README.md +22 -0
- data/features/controller_specs/nested_schema_scaffolding.feature +81 -0
- data/features/controller_specs/readme.md +4 -0
- data/features/controller_specs/schema_scaffolding.feature +61 -0
- data/features/controller_specs/test_endpoint.feature +119 -0
- data/features/docs_generation/html_generation.feature +75 -0
- data/features/docs_generation/multidomain_support.feature +82 -0
- data/features/docs_generation/readme.md +2 -0
- data/features/request_specs/nested_schema_scaffolding.feature +65 -0
- data/features/request_specs/readme.md +4 -0
- data/features/request_specs/schema_scaffolding.feature +71 -0
- data/features/step_definitions/additional_cli_steps.rb +63 -0
- data/features/support/env.rb +46 -0
- data/lib/endpoint-schema.yaml +30 -0
- data/lib/lurker.rb +57 -2
- data/lib/lurker/capistrano.rb +1 -0
- data/lib/lurker/cli.rb +202 -0
- data/lib/lurker/controller_spec_watcher.rb +61 -0
- data/lib/lurker/endpoint.rb +180 -0
- data/lib/lurker/endpoint_scaffold.rb +133 -0
- data/lib/lurker/engine.rb +11 -0
- data/lib/lurker/erb_schema_context.rb +9 -0
- data/lib/lurker/form_builder.rb +64 -0
- data/lib/lurker/jaml_descriptor.rb +14 -0
- data/lib/lurker/meta_service.rb +46 -0
- data/lib/lurker/presenters/base_presenter.rb +91 -0
- data/lib/lurker/presenters/endpoint_presenter.rb +207 -0
- data/lib/lurker/presenters/json_presenter.rb +31 -0
- data/lib/lurker/presenters/meta_service_presenter.rb +85 -0
- data/lib/lurker/presenters/response_code_presenter.rb +41 -0
- data/lib/lurker/presenters/schema_presenter.rb +200 -0
- data/lib/lurker/presenters/service_presenter.rb +103 -0
- data/lib/lurker/ref_object.rb +22 -0
- data/lib/lurker/rendering_controller.rb +61 -0
- data/lib/lurker/request_spec_watcher.rb +69 -0
- data/lib/lurker/sandbox.rb +24 -0
- data/lib/lurker/schema.rb +81 -0
- data/lib/lurker/server.rb +46 -0
- data/lib/lurker/service.rb +118 -0
- data/lib/lurker/spec_watcher.rb +124 -0
- data/lib/lurker/tasks/capistrano.rake +14 -0
- data/lib/lurker/templates/endpoint.html.erb +62 -0
- data/lib/lurker/templates/endpoint.md.erb +40 -0
- data/lib/lurker/templates/fonts/FontAwesome.otf +0 -0
- data/lib/lurker/templates/fonts/fontawesome-webfont.eot +0 -0
- data/lib/lurker/templates/fonts/fontawesome-webfont.svg +414 -0
- data/lib/lurker/templates/fonts/fontawesome-webfont.ttf +0 -0
- data/lib/lurker/templates/fonts/fontawesome-webfont.woff +0 -0
- data/lib/lurker/templates/fonts/glyphicons-halflings-regular.eot +0 -0
- data/lib/lurker/templates/fonts/glyphicons-halflings-regular.svg +229 -0
- data/lib/lurker/templates/fonts/glyphicons-halflings-regular.ttf +0 -0
- data/lib/lurker/templates/fonts/glyphicons-halflings-regular.woff +0 -0
- data/lib/lurker/templates/javascripts/application.js +17 -0
- data/lib/lurker/templates/javascripts/demo/dashboard-demo.js +117 -0
- data/lib/lurker/templates/javascripts/demo/flot-demo.js +1242 -0
- data/lib/lurker/templates/javascripts/demo/morris-demo.js +155 -0
- data/lib/lurker/templates/javascripts/lurker.js +147 -0
- data/lib/lurker/templates/javascripts/plugins/dataTables/dataTables.bootstrap.js +245 -0
- data/lib/lurker/templates/javascripts/plugins/dataTables/jquery.dataTables.js +14013 -0
- data/lib/lurker/templates/javascripts/plugins/flot/excanvas.min.js +1 -0
- data/lib/lurker/templates/javascripts/plugins/flot/jquery.flot.js +2599 -0
- data/lib/lurker/templates/javascripts/plugins/flot/jquery.flot.pie.js +750 -0
- data/lib/lurker/templates/javascripts/plugins/flot/jquery.flot.resize.js +60 -0
- data/lib/lurker/templates/javascripts/plugins/flot/jquery.flot.tooltip.min.js +12 -0
- data/lib/lurker/templates/javascripts/plugins/metisMenu/jquery.metisMenu.js +45 -0
- data/lib/lurker/templates/javascripts/plugins/morris/morris.js +1888 -0
- data/lib/lurker/templates/javascripts/plugins/morris/raphael-2.1.0.min.js +10 -0
- data/lib/lurker/templates/javascripts/prettify.js +28 -0
- data/lib/lurker/templates/javascripts/sb-admin.js +18 -0
- data/lib/lurker/templates/layouts/_navbar_right.html.erb +13 -0
- data/lib/lurker/templates/layouts/_sidemenu.html.erb +16 -0
- data/lib/lurker/templates/layouts/_sidesearch.html.erb +12 -0
- data/lib/lurker/templates/layouts/application.html.erb +67 -0
- data/lib/lurker/templates/lurker/rendering/_breadcrumb.html.erb +9 -0
- data/lib/lurker/templates/lurker/rendering/_endpoint.html.erb +65 -0
- data/lib/lurker/templates/lurker/rendering/_information_warning_li.html.erb +8 -0
- data/lib/lurker/templates/lurker/rendering/_left_menu.html.erb +38 -0
- data/lib/lurker/templates/lurker/rendering/_param_form_element.html.erb +10 -0
- data/lib/lurker/templates/lurker/rendering/_param_form_legend.html.erb +1 -0
- data/lib/lurker/templates/lurker/rendering/_route_definitions.html.erb +7 -0
- data/lib/lurker/templates/lurker/rendering/_undefined_route.html.erb +6 -0
- data/lib/lurker/templates/lurker/rendering/index.html.erb +6 -0
- data/lib/lurker/templates/lurker/rendering/show.html.erb +102 -0
- data/lib/lurker/templates/meta_service.html.erb +54 -0
- data/lib/lurker/templates/meta_service.md.erb +20 -0
- data/lib/lurker/templates/public/application.css +7684 -0
- data/lib/lurker/templates/public/application.js +15171 -0
- data/lib/lurker/templates/public/fonts/FontAwesome.otf +0 -0
- data/lib/lurker/templates/public/fonts/fontawesome-webfont.eot +0 -0
- data/lib/lurker/templates/public/fonts/fontawesome-webfont.svg +414 -0
- data/lib/lurker/templates/public/fonts/fontawesome-webfont.ttf +0 -0
- data/lib/lurker/templates/public/fonts/fontawesome-webfont.woff +0 -0
- data/lib/lurker/templates/public/fonts/glyphicons-halflings-regular.eot +0 -0
- data/lib/lurker/templates/public/fonts/glyphicons-halflings-regular.svg +229 -0
- data/lib/lurker/templates/public/fonts/glyphicons-halflings-regular.ttf +0 -0
- data/lib/lurker/templates/public/fonts/glyphicons-halflings-regular.woff +0 -0
- data/lib/lurker/templates/service.html.erb +50 -0
- data/lib/lurker/templates/service.md.erb +18 -0
- data/lib/lurker/templates/shared/endpoint_name.html.erb +8 -0
- data/lib/lurker/templates/shared/endpoint_name.md.erb +1 -0
- data/lib/lurker/templates/styles.css +75 -0
- data/lib/lurker/templates/stylesheets/application.css +22 -0
- data/lib/lurker/templates/stylesheets/bootstrap.css +5831 -0
- data/lib/lurker/templates/stylesheets/font-awesome/css/font-awesome.css +1331 -0
- data/lib/lurker/templates/stylesheets/plugins/dataTables/dataTables.bootstrap.css +233 -0
- data/lib/lurker/templates/stylesheets/plugins/morris/morris-0.4.3.min.css +2 -0
- data/lib/lurker/templates/stylesheets/plugins/social-buttons/social-buttons.css +68 -0
- data/lib/lurker/templates/stylesheets/plugins/timeline/timeline.css +144 -0
- data/lib/lurker/templates/stylesheets/prettify-desert.css +34 -0
- data/lib/lurker/templates/stylesheets/prettify.css +1 -0
- data/lib/lurker/templates/stylesheets/sb-admin.css +315 -0
- data/lib/lurker/validation_error.rb +4 -0
- data/lib/lurker/validator.rb +10 -0
- data/lib/lurker/version.rb +1 -1
- data/lurker.gemspec +26 -3
- data/spec/lurker/endpoint_spec.rb +6 -0
- data/spec/spec_helper.rb +12 -0
- data/templates/generate_stuff.rb +241 -0
- data/templates/lurker_app.rb +24 -0
- metadata +384 -8
- metadata.gz.asc +8 -8
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7e601ce25f19a4934646ebdf2ae0444a4ba5d723
|
4
|
+
data.tar.gz: b7618552c90b8a5722c285b159135ac118c38c14
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0426b14b4b0193db2834219cfc944257c2694c49d86f844fa12778dfc83bb24c78f7f806f0d1df252d24640223062d835e3a62f5b9bd4f953ce5f7ef0104de81
|
7
|
+
data.tar.gz: 69b8ded078f03ccc034797e9602e5fdbe90535e7a98316ea0cdebbf5bd619fb7580786b400cad04329fda9c8537e83977e4e1f3b8bf353c4bfc5453477518626
|
checksums.yaml.gz.asc
CHANGED
@@ -1,12 +1,12 @@
|
|
1
1
|
-----BEGIN PGP SIGNATURE-----
|
2
|
-
Version: GnuPG
|
2
|
+
Version: GnuPG v1
|
3
3
|
Comment: GPGTools - http://gpgtools.org
|
4
4
|
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
=
|
5
|
+
iQEcBAABCgAGBQJTUFPHAAoJENcoxKfNVdjbOiYH/imY5zbQeBr6hrWkjRXz89Ef
|
6
|
+
2+ARZFzUvk5WZ+iejtnx5EczeU2R7spkJ+YK5o/+vUCT8yoIvZTdCZggTVEcQElq
|
7
|
+
ee5x3jj5SW4NkvfDfgdgBqyZPKZF/EiOBrsEyR/LS+bacUh5yKD4BOQxwxeMQ7Dh
|
8
|
+
jGnyQdpJ4MPxRx2eyuYwi5kVC45sXdmFeYXYW8lyslMbGLzDIrQzzTcyxosRgsze
|
9
|
+
Dy9u1wL4SE0y7wm4zpm6DiYaOgi/GRlp223z/SfsGq3bNg8d1deuI3vDKiPTDGus
|
10
|
+
2P9W1wtB3xVbL7TYyF/t6T47lGe4jpY30FKtjDHpAPYxKywCCHdRa7A8IePbIIs=
|
11
|
+
=p3AX
|
12
12
|
-----END PGP SIGNATURE-----
|
data.tar.gz.asc
CHANGED
@@ -1,12 +1,12 @@
|
|
1
1
|
-----BEGIN PGP SIGNATURE-----
|
2
|
-
Version: GnuPG
|
2
|
+
Version: GnuPG v1
|
3
3
|
Comment: GPGTools - http://gpgtools.org
|
4
4
|
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
5
|
+
iQEcBAABCgAGBQJTUFO8AAoJENcoxKfNVdjbGzcH/jTfrX9MDTo8BtyuvAHbNDoC
|
6
|
+
EZycU+mf2Ukm1pdQfDKZxyPcn7OEwxaMikwm3FMGLqo+/plx59mS49wPX46Hjjlj
|
7
|
+
yZ7+C1YZTpSUxE+fOn1/afd6alzZ7CTHHprQFOZmPvuq02ewO8OK04iOlQYVVIG/
|
8
|
+
yjRQo9nweWGJpz7QtlP9Q5YxUduJwEk5fb2nmZG7c2JeQ7TmezpvO5qI5rrQmzv8
|
9
|
+
DqrUGamq4OgtGBU0Z8n7E2mdhTcujhk9ZNEGhfL3C9Wm97ehQkfI/8mRKwQEGD4V
|
10
|
+
OuQjzyb9d9CPfrpjbbZMjQLC+U+th91tzUCi2q/oh4C3gBWad2u+771joRspC38=
|
11
|
+
=qyaU
|
12
12
|
-----END PGP SIGNATURE-----
|
data/.gitignore
CHANGED
data/.gitmodules
ADDED
data/.rspec
ADDED
data/.travis.yml
ADDED
data/Gemfile.local
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
# There is no need for these gems on travis and it's up to you whenever you use them
|
2
|
+
# See: https://github.com/gerrywastaken/Gemfile.local
|
3
|
+
# and GH's issue for bundler: https://github.com/bundler/bundler/issues/183
|
4
|
+
eval File.read('Gemfile')
|
5
|
+
|
6
|
+
# Add any gems and groups that you don't want to keep local
|
7
|
+
group :development do
|
8
|
+
# tools
|
9
|
+
gem 'pry-debugger'
|
10
|
+
gem 'pry-stack_explorer'
|
11
|
+
# rspec --format fuubar
|
12
|
+
gem 'fuubar'
|
13
|
+
# cucumber --format fuubar
|
14
|
+
gem 'fuubar-cucumber', github: 'martinciu/fuubar-cucumber', branch: 'master'
|
15
|
+
gem 'selenium-webdriver'
|
16
|
+
|
17
|
+
# deploy site
|
18
|
+
gem 'highline'
|
19
|
+
|
20
|
+
# build template static
|
21
|
+
# run `rake assets:precompile`
|
22
|
+
# to get bundled application.(js|css)
|
23
|
+
gem 'sprockets'
|
24
|
+
gem 'sass-rails'
|
25
|
+
gem 'bootstrap-sass', '~> 3.1.1'
|
26
|
+
gem 'jquery-rails'
|
27
|
+
gem 'remotipart'
|
28
|
+
end
|
data/README.md
CHANGED
@@ -1,6 +1,15 @@
|
|
1
1
|
# Lurker
|
2
2
|
|
3
|
-
|
3
|
+
The new de-facto for API testing your Rails application (Rails 3 & 4 both compatible)
|
4
|
+
|
5
|
+
[![Gem Version][GV img]][Gem Version]
|
6
|
+
[![Build Status][BS img]][Build Status]
|
7
|
+
[![Dependency Status][DS img]][Dependency Status]
|
8
|
+
[![Code Climate][CC img]][Code Climate]
|
9
|
+
[![Coverage Status][CS img]][Coverage Status]
|
10
|
+
[![Inline docs](http://inch-pages.github.io/github/razum2um/lurker.png)](http://inch-pages.github.io/github/razum2um/lurker)
|
11
|
+
[![githalytics.com alpha](https://cruel-carlota.pagodabox.com/87ced56265849ad6386c2ba0a78f8038 "githalytics.com")](http://githalytics.com/razum2um/lurker)
|
12
|
+
|
4
13
|
|
5
14
|
## Installation
|
6
15
|
|
@@ -8,22 +17,128 @@ Add this line to your application's Gemfile:
|
|
8
17
|
|
9
18
|
gem 'lurker'
|
10
19
|
|
11
|
-
|
20
|
+
## Usage
|
12
21
|
|
13
|
-
|
22
|
+
Write your [RSpec][rspec] [controller][rspec_controller_spec] or [request][rspec_request_spec] specs as usual,
|
23
|
+
but add `:lurker` mark (like documented [controller example][controler_spec_example] or [request spec example][request_spec_example]).
|
14
24
|
|
15
|
-
|
25
|
+
describe Api::V1::UsersController, :lurker do
|
26
|
+
...
|
16
27
|
|
17
|
-
|
28
|
+
And run the specs. That's all, easy!
|
18
29
|
|
19
|
-
|
30
|
+
Please, commit your files under `Rails.root/lurker` directory.
|
31
|
+
Feel free to edit them according to [json-schema][json_schema] standart.
|
32
|
+
It can be very strict and flexible if you wish: see [example][json_schema_example],
|
33
|
+
but scaffolded schemas are pretty good by default.
|
34
|
+
|
35
|
+
A lurker/ExampleApp.service.yml
|
36
|
+
A lurker/api/v1/users-GET.json.yml
|
37
|
+
A lurker/api/v1/users/__user_id/repos-GET.json.yml
|
38
|
+
|
39
|
+
## Profit!
|
40
|
+
|
41
|
+
Now, every test run lurker will look into your requests and [vaditate them][failed_spec_example]
|
42
|
+
and it fails if your code changes the api!
|
43
|
+
|
44
|
+
Failure/Error: post :create [...]
|
45
|
+
Lurker::ValidationError:
|
46
|
+
Request
|
47
|
+
- The property '#/' contains additional properties ["social_network"] outside of the schema
|
48
|
+
when none are allowed in schema file:///.../lurker/api/v1/users-POST.json.yml#
|
49
|
+
Response
|
50
|
+
- The property '#/user/last_sign_in_at' of type String did not match the following type:
|
51
|
+
null in schema file:///.../lurker/api/v1/users-POST.json.yml#
|
52
|
+
|
53
|
+
Let's run your `rails s` and visit [http://localhost:3000/lurker/](http://localhost:3000/lurker/) (or see [demo][demo_app])
|
54
|
+
|
55
|
+
Now, you can test your API on-line (for real)
|
56
|
+
|
57
|
+
## Features
|
58
|
+
|
59
|
+
- [Autoscaffolding for non-covered API endpoints][controler_spec_example]
|
60
|
+
- [Autotesting for covered endpoint once written][failed_spec_example] (both request & response!)
|
61
|
+
- [Pretty HTML documentation based on your schemas][html_generation_example]
|
62
|
+
- [Pretty submit form to test API endpoints (live) based on schemas][demo_live] (enter a name & press "Submit")
|
63
|
+
- [Handling URLs with dynamic segments][nested_controller_spec_example] (such as `api/v1/:user_id/repos`)
|
64
|
+
- Multiple docs for many test cases
|
65
|
+
- JSON-Schema partials (inline reference to other schemas)
|
66
|
+
- ERB support inside `.json.yml.erb`
|
67
|
+
- HTTP-Auth authorization for your online docs
|
68
|
+
- Separate API-services generated within one test suite
|
69
|
+
- Capistrano integration
|
70
|
+
- JSON-Schema draft-v4 support
|
71
|
+
- Static site deploy and milti-domain support
|
72
|
+
|
73
|
+
|
74
|
+
## Sandbox mode for Live API testing
|
75
|
+
|
76
|
+
# make sure it's not production!
|
77
|
+
# e.g. config/environtents/staging.rb
|
78
|
+
config.middleware.use Lurker::Sandbox
|
79
|
+
|
80
|
+
## Demo application
|
81
|
+
|
82
|
+
You can clone the repo & run `rake build_example_docs`.
|
83
|
+
It will generate testing rails application under `tmp/lurker_app`.
|
84
|
+
Currently it is deployed [here][demo_app].
|
85
|
+
|
86
|
+
## Contributions
|
87
|
+
|
88
|
+
To get new version of bundled `bootstrap` or to use debugger in specs run:
|
89
|
+
|
90
|
+
bundle --gemfile Gemfile.local
|
91
|
+
export BUNDLE_GEMFILE=$PWD/Gemfile.local
|
92
|
+
|
93
|
+
rake assets:precompile # to build assets
|
94
|
+
cucumber some/feature # to use pry-debugger
|
95
|
+
|
96
|
+
## Todo
|
97
|
+
|
98
|
+
- More tests
|
99
|
+
- More docs
|
100
|
+
- Production middleware to validate real input/output
|
101
|
+
- Render lurker-app to gh-pages with arbitrary endpoint (my & heroku)
|
102
|
+
- Render dosc like these: [gh_api][gh_api]
|
103
|
+
- Auto extraction for models into json-schema partials (in responses at least)
|
104
|
+
- Auto marking of attributes as required if `strong_params` are used
|
105
|
+
- Sinatra support
|
106
|
+
- Better Diff expected-schema vs recorded schema
|
107
|
+
- XML api testing via .xsd
|
108
|
+
|
109
|
+
## Acknoledgements
|
110
|
+
|
111
|
+
Sponsored by [Evil Martians][evil_martians], thanks!
|
112
|
+
|
113
|
+
This gem is quite opinionated and relies on rails & rspec - if you're
|
114
|
+
interested in anything else, please take a look at [api_taster][api_taster] or [fdoc][fdoc],
|
115
|
+
This gem is heavily inspirated by them. Thanks, @square & @fredwu
|
20
116
|
|
21
|
-
|
117
|
+
[gh_api]: https://developer.github.com/v3/meta/
|
118
|
+
[rspec]: https://github.com/rspec/rspec-rails
|
119
|
+
[api_taster]: https://github.com/fredwu/api_taster
|
120
|
+
[fdoc]: https://github.com/square/fdoc
|
121
|
+
[rspec_controller_spec]: https://www.relishapp.com/rspec/rspec-rails/docs/controller-specs
|
122
|
+
[rspec_request_spec]: https://www.relishapp.com/rspec/rspec-rails/docs/request-specs/request-spec
|
123
|
+
[json_schema]: http://json-schema.org/
|
124
|
+
[json_schema_example]: http://json-schema.org/example2.html
|
125
|
+
[failed_spec_example]: https://www.relishapp.com/razum2um/lurker/docs/controller-specs/test-endpoint
|
126
|
+
[controler_spec_example]: https://www.relishapp.com/razum2um/lurker/docs/controller-specs/schema-scaffolding
|
127
|
+
[nested_controller_spec_example]: https://www.relishapp.com/razum2um/lurker/docs/controller-specs/nested-schema-scaffolding
|
128
|
+
[request_spec_example]: https://www.relishapp.com/razum2um/lurker/docs/request-specs/schema-scaffolding
|
129
|
+
[html_generation_example]: https://www.relishapp.com/razum2um/lurker/docs/docs-generation/html-generation
|
130
|
+
[evil_martians]: http://evilmartians.com/
|
131
|
+
[demo_app]: http://lurker-app.herokuapp.com/lurker/
|
132
|
+
[demo_live]: http://lurker-app.herokuapp.com/lurker/api/v1/users-POST.html
|
22
133
|
|
23
|
-
|
134
|
+
[Gem Version]: https://rubygems.org/gems/lurker
|
135
|
+
[Build Status]: https://travis-ci.org/razum2um/lurker
|
136
|
+
[Dependency Status]: https://gemnasium.com/razum2um/lurker
|
137
|
+
[Code Climate]: https://codeclimate.com/github/razum2um/lurker
|
138
|
+
[Coverage Status]: https://coveralls.io/r/razum2um/lurker
|
24
139
|
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
140
|
+
[GV img]: https://badge.fury.io/rb/lurker.png
|
141
|
+
[BS img]: https://travis-ci.org/razum2um/lurker.png
|
142
|
+
[DS img]: https://gemnasium.com/razum2um/lurker.png
|
143
|
+
[CC img]: https://codeclimate.com/github/razum2um/lurker.png
|
144
|
+
[CS img]: https://coveralls.io/repos/razum2um/lurker/badge.png?branch=master
|
data/Rakefile
CHANGED
@@ -1 +1,180 @@
|
|
1
1
|
require "bundler/gem_tasks"
|
2
|
+
require 'bundler/setup'
|
3
|
+
require 'rspec/core/rake_task'
|
4
|
+
require 'cucumber/rake/task'
|
5
|
+
require 'coveralls/rake/task'
|
6
|
+
|
7
|
+
desc 'pry console for gem'
|
8
|
+
task :c do
|
9
|
+
require 'pry'
|
10
|
+
require 'lurker'
|
11
|
+
ARGV.clear
|
12
|
+
Pry.start
|
13
|
+
end
|
14
|
+
|
15
|
+
namespace :assets do
|
16
|
+
desc 'compiles static css & js for web'
|
17
|
+
task :precompile do
|
18
|
+
require 'pathname'
|
19
|
+
require 'logger'
|
20
|
+
require 'fileutils'
|
21
|
+
|
22
|
+
require 'lurker/cli'
|
23
|
+
|
24
|
+
require_with_help 'sprockets'
|
25
|
+
require_with_help 'sass'
|
26
|
+
|
27
|
+
ROOT = Pathname(File.dirname(__FILE__))
|
28
|
+
LOGGER = Logger.new(STDOUT)
|
29
|
+
BUNDLES = %w( application.css application.js )
|
30
|
+
BUILD_DIR = Pathname.new Lurker::Cli.precompiled_static_root
|
31
|
+
SOURCE_DIR = Pathname.new Lurker::Cli.source_root
|
32
|
+
|
33
|
+
FileUtils.rm_rf(BUILD_DIR)
|
34
|
+
FileUtils.mkdir_p(BUILD_DIR)
|
35
|
+
|
36
|
+
# raw copy
|
37
|
+
%w[fonts].each do |subdir|
|
38
|
+
FileUtils.cp_r(SOURCE_DIR.join(subdir), BUILD_DIR.join(subdir))
|
39
|
+
end
|
40
|
+
|
41
|
+
sprockets = Sprockets::Environment.new(ROOT) do |env|
|
42
|
+
env.logger = LOGGER
|
43
|
+
end
|
44
|
+
|
45
|
+
sprockets.context_class.class_eval do
|
46
|
+
def asset_path(path, options = {})
|
47
|
+
'/'
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
sprockets.append_path(SOURCE_DIR.join('javascripts').to_s)
|
52
|
+
sprockets.append_path(SOURCE_DIR.join('stylesheets').to_s)
|
53
|
+
|
54
|
+
%w[jquery-rails bootstrap-sass remotipart].each do |gem|
|
55
|
+
gem_path = Pathname.new(Bundler.rubygems.find_name(gem).first.full_gem_path)
|
56
|
+
%w[javascripts stylesheets].each do |prefix|
|
57
|
+
sprockets.append_path(gem_path.join('vendor', 'assets', prefix).to_s)
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
BUNDLES.each do |bundle|
|
62
|
+
assets = sprockets.find_asset(bundle)
|
63
|
+
realname = (assets.pathname.basename.to_s.split(".").take_while { |s| !s.match /^(js|css)$/ } + [$~.to_s]).join(".")
|
64
|
+
assets.write_to(BUILD_DIR.join(realname))
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
# testing
|
70
|
+
|
71
|
+
Coveralls::RakeTask.new
|
72
|
+
|
73
|
+
RSpec::Core::RakeTask.new(:spec) do |t|
|
74
|
+
t.rspec_opts = "--format progress"
|
75
|
+
end
|
76
|
+
|
77
|
+
Cucumber::Rake::Task.new(:cucumber) do |t|
|
78
|
+
t.cucumber_opts = "features --format progress --tags ~@wip"
|
79
|
+
end
|
80
|
+
|
81
|
+
EXAMPLE_APP = 'tmp/lurker_app'
|
82
|
+
EXAMPLE_PATH = File.expand_path("../#{EXAMPLE_APP}", __FILE__)
|
83
|
+
|
84
|
+
namespace :clobber do
|
85
|
+
desc "clobber coverage"
|
86
|
+
task :coverage do
|
87
|
+
rm_rf File.expand_path('../coverage', __FILE__)
|
88
|
+
end
|
89
|
+
|
90
|
+
desc "clobber the generated app"
|
91
|
+
task :app do
|
92
|
+
FileUtils.mkdir_p EXAMPLE_PATH
|
93
|
+
in_lurker_app "bin/spring stop" if File.exist?("#{EXAMPLE_PATH}/bin/spring")
|
94
|
+
Dir.chdir EXAMPLE_PATH do
|
95
|
+
Dir.glob("*", File::FNM_DOTMATCH).each do |fname|
|
96
|
+
next if fname == '.' || fname == '..' || fname == '.git'
|
97
|
+
FileUtils.rm_rf fname
|
98
|
+
end
|
99
|
+
end
|
100
|
+
end
|
101
|
+
end
|
102
|
+
|
103
|
+
namespace :generate do
|
104
|
+
desc "generate a fresh app with rspec installed"
|
105
|
+
task :app do |t|
|
106
|
+
if needs_generation?
|
107
|
+
sh "bundle exec rails new #{EXAMPLE_APP} -d postgresql -m #{File.expand_path '../templates/lurker_app.rb', __FILE__} --skip-javascript --skip-sprockets --skip-git --skip-test-unit --skip-keeps --quiet"
|
108
|
+
end
|
109
|
+
end
|
110
|
+
|
111
|
+
desc "generate a bunch of stuff with generators"
|
112
|
+
task :stuff do
|
113
|
+
in_lurker_app "LOCATION='../../templates/generate_stuff.rb' bin/rake rails:template --quiet --silent"
|
114
|
+
end
|
115
|
+
end
|
116
|
+
|
117
|
+
def in_lurker_app(command)
|
118
|
+
Dir.chdir(EXAMPLE_PATH) do
|
119
|
+
Bundler.with_clean_env do
|
120
|
+
sh command
|
121
|
+
end
|
122
|
+
end
|
123
|
+
end
|
124
|
+
|
125
|
+
def needs_generation?
|
126
|
+
!File.exists?("#{EXAMPLE_PATH}/Gemfile")
|
127
|
+
end
|
128
|
+
|
129
|
+
def require_with_help(name)
|
130
|
+
begin
|
131
|
+
require name
|
132
|
+
rescue LoadError
|
133
|
+
puts "Incorrect Gemfile, run: `bundle --gemfile Gemfile.local` and"
|
134
|
+
puts "BUNDLE_GEMFILE=$PWD/Gemfile.local #{$0}"
|
135
|
+
raise
|
136
|
+
end
|
137
|
+
end
|
138
|
+
|
139
|
+
desc 'destroys & recreates new test app'
|
140
|
+
task :regenerate => ["clobber:coverage", "clobber:app", "generate:app", "generate:stuff"]
|
141
|
+
|
142
|
+
desc 'run cucumber in a fresh env'
|
143
|
+
task :features => [:regenerate, :cucumber]
|
144
|
+
|
145
|
+
desc 'convert docs for example app'
|
146
|
+
task :build_example_docs => :features do
|
147
|
+
in_lurker_app "bin/lurker convert"
|
148
|
+
end
|
149
|
+
|
150
|
+
namespace :heroku do
|
151
|
+
desc 'pushes example lurker_app to heroku'
|
152
|
+
task :push do
|
153
|
+
require_with_help 'highline/import'
|
154
|
+
in_lurker_app "echo 'bin/lurker' > .gitignore"
|
155
|
+
in_lurker_app "echo 'log' >> .gitignore"
|
156
|
+
# commit migration and deploy by hand first time
|
157
|
+
in_lurker_app "echo 'db/*' >> .gitignore"
|
158
|
+
in_lurker_app "echo 'tmp/*' >> .gitignore"
|
159
|
+
|
160
|
+
|
161
|
+
in_lurker_app "git add -A"
|
162
|
+
in_lurker_app "git status"
|
163
|
+
choose do |menu|
|
164
|
+
menu.prompt = 'Commit & push & deploy?'
|
165
|
+
menu.choice(:yes) {
|
166
|
+
in_lurker_app "git commit -a -m 'auto commit: #{`git log --oneline -n 1`.strip}'"
|
167
|
+
in_lurker_app "git push origin master"
|
168
|
+
in_lurker_app "heroku run rake db:import --app lurker-app"
|
169
|
+
}
|
170
|
+
menu.choice(:no) { say("Exit") }
|
171
|
+
end
|
172
|
+
end
|
173
|
+
|
174
|
+
desc 'rebuilds & pushes app to heroku'
|
175
|
+
task :deploy => [:build_example_docs, 'heroku:push'] do
|
176
|
+
end
|
177
|
+
end
|
178
|
+
|
179
|
+
task :default => [:spec, :regenerate, :cucumber, 'coveralls:push']
|
180
|
+
|