vitals 0.0.2 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.gitignore +7 -0
- data/.travis.yml +15 -0
- data/Gemfile +4 -0
- data/Gemfile.lock +157 -0
- data/Guardfile +11 -0
- data/LICENSE.txt +21 -0
- data/README.md +135 -9
- data/Rakefile +17 -31
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/integration/multiverse/grape-on-rack/.gitignore +7 -0
- data/integration/multiverse/grape-on-rack/.rspec +2 -0
- data/integration/multiverse/grape-on-rack/.rubocop.yml +2 -0
- data/integration/multiverse/grape-on-rack/.rubocop_todo.yml +50 -0
- data/integration/multiverse/grape-on-rack/.travis.yml +12 -0
- data/integration/multiverse/grape-on-rack/Gemfile +28 -0
- data/integration/multiverse/grape-on-rack/Gemfile.lock +187 -0
- data/integration/multiverse/grape-on-rack/Guardfile +8 -0
- data/integration/multiverse/grape-on-rack/LICENSE +21 -0
- data/integration/multiverse/grape-on-rack/README.md +88 -0
- data/integration/multiverse/grape-on-rack/Rakefile +27 -0
- data/integration/multiverse/grape-on-rack/api/content_type.rb +18 -0
- data/integration/multiverse/grape-on-rack/api/entities.rb +28 -0
- data/integration/multiverse/grape-on-rack/api/get_json.rb +24 -0
- data/integration/multiverse/grape-on-rack/api/header_versioning.rb +9 -0
- data/integration/multiverse/grape-on-rack/api/path_versioning.rb +9 -0
- data/integration/multiverse/grape-on-rack/api/ping.rb +8 -0
- data/integration/multiverse/grape-on-rack/api/post_json.rb +11 -0
- data/integration/multiverse/grape-on-rack/api/post_put.rb +24 -0
- data/integration/multiverse/grape-on-rack/api/rescue_from.rb +11 -0
- data/integration/multiverse/grape-on-rack/api/upload_file.rb +22 -0
- data/integration/multiverse/grape-on-rack/api/wrap_response.rb +14 -0
- data/integration/multiverse/grape-on-rack/api/wrap_response_decorator.rb +15 -0
- data/integration/multiverse/grape-on-rack/app/acme_app.rb +49 -0
- data/integration/multiverse/grape-on-rack/app/api.rb +18 -0
- data/integration/multiverse/grape-on-rack/config/application.rb +23 -0
- data/integration/multiverse/grape-on-rack/config/boot.rb +2 -0
- data/integration/multiverse/grape-on-rack/config/environment.rb +3 -0
- data/integration/multiverse/grape-on-rack/config/newrelic.yml +255 -0
- data/integration/multiverse/grape-on-rack/config.ru +11 -0
- data/integration/multiverse/grape-on-rack/public/errors/404.html +15 -0
- data/integration/multiverse/grape-on-rack/public/errors/500.html +15 -0
- data/integration/multiverse/grape-on-rack/public/images/index.html +1 -0
- data/integration/multiverse/grape-on-rack/public/images/rack-logo.png +0 -0
- data/integration/multiverse/grape-on-rack/public/index.html +23 -0
- data/integration/multiverse/grape-on-rack/public/scripts/jquery-1.7.1.min.js +4 -0
- data/integration/multiverse/grape-on-rack/public/scripts/ring.js +17 -0
- data/integration/multiverse/grape-on-rack/spec/api/post_put_spec.rb +21 -0
- data/integration/multiverse/grape-on-rack/spec/fixtures/grape_logo.png +0 -0
- data/integration/multiverse/grape-on-rack/spec/spec_helper.rb +24 -0
- data/integration/multiverse/grape-on-rails/.gitignore +16 -0
- data/integration/multiverse/grape-on-rails/.rspec +2 -0
- data/integration/multiverse/grape-on-rails/.rubocop.yml +6 -0
- data/integration/multiverse/grape-on-rails/.rubocop_todo.yml +33 -0
- data/integration/multiverse/grape-on-rails/.travis.yml +17 -0
- data/integration/multiverse/grape-on-rails/Gemfile +22 -0
- data/integration/multiverse/grape-on-rails/Gemfile.lock +238 -0
- data/integration/multiverse/grape-on-rails/README.md +29 -0
- data/integration/multiverse/grape-on-rails/Rakefile +16 -0
- data/integration/multiverse/grape-on-rails/app/api/acme/ping.rb +8 -0
- data/integration/multiverse/grape-on-rails/app/api/acme/post.rb +10 -0
- data/integration/multiverse/grape-on-rails/app/api/acme/protected.rb +13 -0
- data/integration/multiverse/grape-on-rails/app/api/acme/raise.rb +8 -0
- data/integration/multiverse/grape-on-rails/app/api/api.rb +8 -0
- data/integration/multiverse/grape-on-rails/app/assets/images/rails.png +0 -0
- data/integration/multiverse/grape-on-rails/app/assets/javascripts/application.js +15 -0
- data/integration/multiverse/grape-on-rails/app/assets/javascripts/welcome.js.coffee +3 -0
- data/integration/multiverse/grape-on-rails/app/assets/stylesheets/application.css +13 -0
- data/integration/multiverse/grape-on-rails/app/assets/stylesheets/welcome.css.scss +3 -0
- data/{test/dummy → integration/multiverse/grape-on-rails}/app/controllers/application_controller.rb +0 -0
- data/integration/multiverse/grape-on-rails/app/controllers/welcome_controller.rb +4 -0
- data/{test/dummy → integration/multiverse/grape-on-rails}/app/helpers/application_helper.rb +0 -0
- data/integration/multiverse/grape-on-rails/app/helpers/welcome_helper.rb +2 -0
- data/{test/dummy/db/development.sqlite3 → integration/multiverse/grape-on-rails/app/mailers/.gitkeep} +0 -0
- data/{test/dummy/db/test.sqlite3 → integration/multiverse/grape-on-rails/app/models/.gitkeep} +0 -0
- data/{test/dummy → integration/multiverse/grape-on-rails}/app/views/layouts/application.html.erb +2 -2
- data/integration/multiverse/grape-on-rails/app/views/welcome/index.html.erb +6 -0
- data/integration/multiverse/grape-on-rails/bin/bundle +3 -0
- data/integration/multiverse/grape-on-rails/bin/rails +4 -0
- data/integration/multiverse/grape-on-rails/bin/rake +4 -0
- data/{test/dummy → integration/multiverse/grape-on-rails}/config/application.rb +26 -6
- data/integration/multiverse/grape-on-rails/config/boot.rb +6 -0
- data/integration/multiverse/grape-on-rails/config/database.travis.yml +4 -0
- data/integration/multiverse/grape-on-rails/config/database.yml +16 -0
- data/{test/dummy → integration/multiverse/grape-on-rails}/config/environment.rb +1 -1
- data/{test/dummy → integration/multiverse/grape-on-rails}/config/environments/development.rb +4 -5
- data/{test/dummy → integration/multiverse/grape-on-rails}/config/environments/production.rb +9 -4
- data/{test/dummy → integration/multiverse/grape-on-rails}/config/environments/test.rb +9 -18
- data/{test/dummy → integration/multiverse/grape-on-rails}/config/initializers/backtrace_silencers.rb +0 -0
- data/{test/dummy → integration/multiverse/grape-on-rails}/config/initializers/inflections.rb +5 -0
- data/{test/dummy → integration/multiverse/grape-on-rails}/config/initializers/mime_types.rb +0 -0
- data/integration/multiverse/grape-on-rails/config/initializers/reload_api.rb +13 -0
- data/integration/multiverse/grape-on-rails/config/initializers/secret_token.rb +1 -0
- data/{test/dummy → integration/multiverse/grape-on-rails}/config/initializers/session_store.rb +2 -2
- data/integration/multiverse/grape-on-rails/config/initializers/vitals.rb +8 -0
- data/{test/dummy → integration/multiverse/grape-on-rails}/config/initializers/wrap_parameters.rb +0 -0
- data/{test/dummy → integration/multiverse/grape-on-rails}/config/locales/en.yml +0 -0
- data/integration/multiverse/grape-on-rails/config/routes.rb +5 -0
- data/integration/multiverse/grape-on-rails/config.ru +4 -0
- data/integration/multiverse/grape-on-rails/db/schema.rb +16 -0
- data/integration/multiverse/grape-on-rails/db/seeds.rb +7 -0
- data/integration/multiverse/grape-on-rails/doc/README_FOR_APP +2 -0
- data/{test/dummy/log/test.log → integration/multiverse/grape-on-rails/lib/assets/.gitkeep} +0 -0
- data/{test/dummy/public/favicon.ico → integration/multiverse/grape-on-rails/lib/tasks/.gitkeep} +0 -0
- data/integration/multiverse/grape-on-rails/log/.gitkeep +0 -0
- data/{test/dummy → integration/multiverse/grape-on-rails}/public/404.html +0 -0
- data/{test/dummy → integration/multiverse/grape-on-rails}/public/422.html +0 -0
- data/{test/dummy → integration/multiverse/grape-on-rails}/public/500.html +0 -1
- data/integration/multiverse/grape-on-rails/public/favicon.ico +0 -0
- data/integration/multiverse/grape-on-rails/public/robots.txt +5 -0
- data/{test/dummy → integration/multiverse/grape-on-rails}/script/rails +2 -2
- data/integration/multiverse/grape-on-rails/spec/api/ping_spec.rb +15 -0
- data/integration/multiverse/grape-on-rails/spec/spec_helper.rb +15 -0
- data/integration/multiverse/rails42_app/.gitignore +18 -0
- data/integration/multiverse/rails42_app/Gemfile +49 -0
- data/integration/multiverse/rails42_app/Gemfile.lock +167 -0
- data/integration/multiverse/rails42_app/README.rdoc +28 -0
- data/{test/dummy → integration/multiverse/rails42_app}/Rakefile +1 -2
- data/integration/multiverse/rails42_app/app/assets/images/.keep +0 -0
- data/integration/multiverse/rails42_app/app/assets/javascripts/application.js +16 -0
- data/integration/multiverse/rails42_app/app/assets/javascripts/posts.coffee +3 -0
- data/integration/multiverse/rails42_app/app/assets/stylesheets/application.css +15 -0
- data/integration/multiverse/rails42_app/app/assets/stylesheets/posts.scss +3 -0
- data/integration/multiverse/rails42_app/app/assets/stylesheets/scaffolds.scss +73 -0
- data/integration/multiverse/rails42_app/app/controllers/application_controller.rb +5 -0
- data/integration/multiverse/rails42_app/app/controllers/concerns/.keep +0 -0
- data/integration/multiverse/rails42_app/app/controllers/posts_controller.rb +75 -0
- data/integration/multiverse/rails42_app/app/helpers/application_helper.rb +2 -0
- data/integration/multiverse/rails42_app/app/helpers/posts_helper.rb +2 -0
- data/integration/multiverse/rails42_app/app/jobs/foobar_cleanup_job.rb +7 -0
- data/integration/multiverse/rails42_app/app/mailers/.keep +0 -0
- data/integration/multiverse/rails42_app/app/models/.keep +0 -0
- data/integration/multiverse/rails42_app/app/models/concerns/.keep +0 -0
- data/integration/multiverse/rails42_app/app/models/post.rb +2 -0
- data/integration/multiverse/rails42_app/app/views/layouts/application.html.erb +14 -0
- data/integration/multiverse/rails42_app/app/views/posts/_form.html.erb +21 -0
- data/integration/multiverse/rails42_app/app/views/posts/edit.html.erb +6 -0
- data/integration/multiverse/rails42_app/app/views/posts/index.html.erb +27 -0
- data/integration/multiverse/rails42_app/app/views/posts/index.json.jbuilder +4 -0
- data/integration/multiverse/rails42_app/app/views/posts/new.html.erb +5 -0
- data/integration/multiverse/rails42_app/app/views/posts/show.html.erb +9 -0
- data/integration/multiverse/rails42_app/app/views/posts/show.json.jbuilder +1 -0
- data/integration/multiverse/rails42_app/bin/bundle +3 -0
- data/integration/multiverse/rails42_app/bin/rails +9 -0
- data/integration/multiverse/rails42_app/bin/rake +9 -0
- data/integration/multiverse/rails42_app/bin/setup +29 -0
- data/integration/multiverse/rails42_app/bin/spring +15 -0
- data/integration/multiverse/rails42_app/config/application.rb +26 -0
- data/integration/multiverse/rails42_app/config/boot.rb +3 -0
- data/{test/dummy → integration/multiverse/rails42_app}/config/database.yml +8 -8
- data/integration/multiverse/rails42_app/config/environment.rb +5 -0
- data/integration/multiverse/rails42_app/config/environments/development.rb +41 -0
- data/integration/multiverse/rails42_app/config/environments/production.rb +79 -0
- data/integration/multiverse/rails42_app/config/environments/test.rb +42 -0
- data/integration/multiverse/rails42_app/config/initializers/assets.rb +11 -0
- data/integration/multiverse/rails42_app/config/initializers/backtrace_silencers.rb +7 -0
- data/integration/multiverse/rails42_app/config/initializers/cookies_serializer.rb +3 -0
- data/integration/multiverse/rails42_app/config/initializers/filter_parameter_logging.rb +4 -0
- data/integration/multiverse/rails42_app/config/initializers/inflections.rb +16 -0
- data/integration/multiverse/rails42_app/config/initializers/mime_types.rb +4 -0
- data/integration/multiverse/rails42_app/config/initializers/session_store.rb +3 -0
- data/integration/multiverse/rails42_app/config/initializers/vitals.rb +12 -0
- data/integration/multiverse/rails42_app/config/initializers/wrap_parameters.rb +14 -0
- data/integration/multiverse/rails42_app/config/locales/en.yml +23 -0
- data/integration/multiverse/rails42_app/config/routes.rb +57 -0
- data/integration/multiverse/rails42_app/config/secrets.yml +22 -0
- data/integration/multiverse/rails42_app/config.ru +4 -0
- data/integration/multiverse/rails42_app/db/migrate/20160321140358_create_posts.rb +9 -0
- data/integration/multiverse/rails42_app/db/schema.rb +22 -0
- data/integration/multiverse/rails42_app/db/seeds.rb +7 -0
- data/integration/multiverse/rails42_app/lib/assets/.keep +0 -0
- data/integration/multiverse/rails42_app/lib/tasks/.keep +0 -0
- data/integration/multiverse/rails42_app/log/.keep +0 -0
- data/integration/multiverse/rails42_app/public/404.html +67 -0
- data/integration/multiverse/rails42_app/public/422.html +67 -0
- data/integration/multiverse/rails42_app/public/500.html +66 -0
- data/integration/multiverse/rails42_app/public/favicon.ico +0 -0
- data/integration/multiverse/rails42_app/public/robots.txt +5 -0
- data/integration/multiverse/rails42_app/test/controllers/.keep +0 -0
- data/integration/multiverse/rails42_app/test/controllers/posts_controller_test.rb +49 -0
- data/integration/multiverse/rails42_app/test/fixtures/.keep +0 -0
- data/integration/multiverse/rails42_app/test/fixtures/posts.yml +7 -0
- data/integration/multiverse/rails42_app/test/helpers/.keep +0 -0
- data/integration/multiverse/rails42_app/test/integration/.keep +0 -0
- data/integration/multiverse/rails42_app/test/integration/vitals_flow_test.rb +78 -0
- data/integration/multiverse/rails42_app/test/jobs/foobar_cleanup_job_test.rb +7 -0
- data/integration/multiverse/rails42_app/test/mailers/.keep +0 -0
- data/integration/multiverse/rails42_app/test/models/.keep +0 -0
- data/{test/dummy/test/unit/task_test.rb → integration/multiverse/rails42_app/test/models/post_test.rb} +1 -1
- data/integration/multiverse/rails42_app/test/test_helper.rb +11 -0
- data/integration/multiverse_helper.rb +16 -0
- data/integration/multiverse_spec.rb +40 -0
- data/lib/vitals/configuration.rb +35 -0
- data/lib/vitals/formats/host_last_format.rb +26 -0
- data/lib/vitals/formats/production_format.rb +21 -0
- data/lib/vitals/integrations/notifications/action_controller.rb +26 -0
- data/lib/vitals/integrations/notifications/active_job.rb +18 -0
- data/lib/vitals/integrations/notifications/base.rb +20 -0
- data/lib/vitals/integrations/notifications/grape.rb +30 -0
- data/lib/vitals/integrations/rack/requests.rb +23 -0
- data/lib/vitals/reporters/base_reporter.rb +9 -0
- data/lib/vitals/reporters/console_reporter.rb +23 -0
- data/lib/vitals/reporters/inmem_reporter.rb +31 -0
- data/lib/vitals/reporters/multi_reporter.rb +24 -0
- data/lib/vitals/reporters/statsd_reporter.rb +27 -0
- data/lib/vitals/utils.rb +15 -0
- data/lib/vitals/version.rb +1 -1
- data/lib/vitals.rb +46 -23
- data/vitals.gemspec +48 -0
- metadata +404 -147
- data/MIT-LICENSE +0 -20
- data/lib/generators/vitals/templates/vitals_initializer.rb +0 -7
- data/lib/generators/vitals/vitals_generator.rb +0 -12
- data/lib/tasks/vitals_tasks.rake +0 -4
- data/lib/vitals/reporter.rb +0 -23
- data/test/dummy/app/assets/javascripts/application.js +0 -9
- data/test/dummy/app/assets/javascripts/tasks.js +0 -2
- data/test/dummy/app/assets/stylesheets/application.css +0 -7
- data/test/dummy/app/assets/stylesheets/scaffold.css +0 -56
- data/test/dummy/app/assets/stylesheets/tasks.css +0 -4
- data/test/dummy/app/controllers/tasks_controller.rb +0 -83
- data/test/dummy/app/helpers/tasks_helper.rb +0 -2
- data/test/dummy/app/models/task.rb +0 -2
- data/test/dummy/app/views/tasks/_form.html.erb +0 -21
- data/test/dummy/app/views/tasks/edit.html.erb +0 -6
- data/test/dummy/app/views/tasks/index.html.erb +0 -23
- data/test/dummy/app/views/tasks/new.html.erb +0 -5
- data/test/dummy/app/views/tasks/show.html.erb +0 -10
- data/test/dummy/config/boot.rb +0 -10
- data/test/dummy/config/initializers/secret_token.rb +0 -7
- data/test/dummy/config/routes.rb +0 -60
- data/test/dummy/config.ru +0 -4
- data/test/dummy/db/migrate/20110917182114_create_tasks.rb +0 -9
- data/test/dummy/log/development.log +0 -55
- data/test/dummy/test/fixtures/tasks.yml +0 -7
- data/test/dummy/test/functional/tasks_controller_test.rb +0 -49
- data/test/dummy/test/unit/helpers/tasks_helper_test.rb +0 -4
- data/test/test_helper.rb +0 -10
- data/test/vitals_test.rb +0 -7
|
@@ -0,0 +1,187 @@
|
|
|
1
|
+
PATH
|
|
2
|
+
remote: ../../../
|
|
3
|
+
specs:
|
|
4
|
+
vitals (0.3.0)
|
|
5
|
+
statsd-ruby (~> 1.3.0)
|
|
6
|
+
|
|
7
|
+
GEM
|
|
8
|
+
remote: http://rubygems.org/
|
|
9
|
+
specs:
|
|
10
|
+
activesupport (4.2.5.1)
|
|
11
|
+
i18n (~> 0.7)
|
|
12
|
+
json (~> 1.7, >= 1.7.7)
|
|
13
|
+
minitest (~> 5.1)
|
|
14
|
+
thread_safe (~> 0.3, >= 0.3.4)
|
|
15
|
+
tzinfo (~> 1.1)
|
|
16
|
+
addressable (2.4.0)
|
|
17
|
+
ast (2.2.0)
|
|
18
|
+
axiom-types (0.1.1)
|
|
19
|
+
descendants_tracker (~> 0.0.4)
|
|
20
|
+
ice_nine (~> 0.11.0)
|
|
21
|
+
thread_safe (~> 0.3, >= 0.3.1)
|
|
22
|
+
builder (3.2.2)
|
|
23
|
+
capybara (2.6.2)
|
|
24
|
+
addressable
|
|
25
|
+
mime-types (>= 1.16)
|
|
26
|
+
nokogiri (>= 1.3.3)
|
|
27
|
+
rack (>= 1.0.0)
|
|
28
|
+
rack-test (>= 0.5.4)
|
|
29
|
+
xpath (~> 2.0)
|
|
30
|
+
childprocess (0.5.9)
|
|
31
|
+
ffi (~> 1.0, >= 1.0.11)
|
|
32
|
+
coderay (1.1.0)
|
|
33
|
+
coercible (1.0.0)
|
|
34
|
+
descendants_tracker (~> 0.0.1)
|
|
35
|
+
descendants_tracker (0.0.4)
|
|
36
|
+
thread_safe (~> 0.3, >= 0.3.1)
|
|
37
|
+
diff-lcs (1.2.5)
|
|
38
|
+
equalizer (0.0.11)
|
|
39
|
+
ffi (1.9.10)
|
|
40
|
+
formatador (0.2.5)
|
|
41
|
+
grape (0.14.0)
|
|
42
|
+
activesupport
|
|
43
|
+
builder
|
|
44
|
+
hashie (>= 2.1.0)
|
|
45
|
+
multi_json (>= 1.3.2)
|
|
46
|
+
multi_xml (>= 0.5.2)
|
|
47
|
+
rack (>= 1.3.0)
|
|
48
|
+
rack-accept
|
|
49
|
+
rack-mount
|
|
50
|
+
virtus (>= 1.0.0)
|
|
51
|
+
grape-entity (0.4.8)
|
|
52
|
+
activesupport
|
|
53
|
+
multi_json (>= 1.3.2)
|
|
54
|
+
grape-swagger (0.10.4)
|
|
55
|
+
grape (>= 0.8.0)
|
|
56
|
+
grape-entity (< 0.5.0)
|
|
57
|
+
guard (2.13.0)
|
|
58
|
+
formatador (>= 0.2.4)
|
|
59
|
+
listen (>= 2.7, <= 4.0)
|
|
60
|
+
lumberjack (~> 1.0)
|
|
61
|
+
nenv (~> 0.1)
|
|
62
|
+
notiffany (~> 0.0)
|
|
63
|
+
pry (>= 0.9.12)
|
|
64
|
+
shellany (~> 0.0)
|
|
65
|
+
thor (>= 0.18.1)
|
|
66
|
+
guard-bundler (2.1.0)
|
|
67
|
+
bundler (~> 1.0)
|
|
68
|
+
guard (~> 2.2)
|
|
69
|
+
guard-compat (~> 1.1)
|
|
70
|
+
guard-compat (1.2.1)
|
|
71
|
+
guard-rack (2.1.1)
|
|
72
|
+
ffi
|
|
73
|
+
guard (~> 2.3)
|
|
74
|
+
spoon
|
|
75
|
+
hashie (3.4.3)
|
|
76
|
+
i18n (0.7.0)
|
|
77
|
+
ice_nine (0.11.2)
|
|
78
|
+
json (1.8.3)
|
|
79
|
+
listen (3.0.5)
|
|
80
|
+
rb-fsevent (>= 0.9.3)
|
|
81
|
+
rb-inotify (>= 0.9)
|
|
82
|
+
lumberjack (1.0.10)
|
|
83
|
+
method_source (0.8.2)
|
|
84
|
+
mime-types (3.0)
|
|
85
|
+
mime-types-data (~> 3.2015)
|
|
86
|
+
mime-types-data (3.2015.1120)
|
|
87
|
+
mini_portile2 (2.0.0)
|
|
88
|
+
minitest (5.8.4)
|
|
89
|
+
multi_json (1.11.2)
|
|
90
|
+
multi_xml (0.5.5)
|
|
91
|
+
nenv (0.2.0)
|
|
92
|
+
newrelic_rpm (3.14.2.312)
|
|
93
|
+
nokogiri (1.6.7.2)
|
|
94
|
+
mini_portile2 (~> 2.0.0.rc2)
|
|
95
|
+
notiffany (0.0.8)
|
|
96
|
+
nenv (~> 0.1)
|
|
97
|
+
shellany (~> 0.0)
|
|
98
|
+
parser (2.3.0.2)
|
|
99
|
+
ast (~> 2.2)
|
|
100
|
+
powerpack (0.1.1)
|
|
101
|
+
pry (0.10.3)
|
|
102
|
+
coderay (~> 1.1.0)
|
|
103
|
+
method_source (~> 0.8.1)
|
|
104
|
+
slop (~> 3.4)
|
|
105
|
+
rack (1.6.4)
|
|
106
|
+
rack-accept (0.4.5)
|
|
107
|
+
rack (>= 0.4)
|
|
108
|
+
rack-cors (0.4.0)
|
|
109
|
+
rack-mount (0.8.3)
|
|
110
|
+
rack (>= 1.0.0)
|
|
111
|
+
rack-test (0.6.3)
|
|
112
|
+
rack (>= 1.0)
|
|
113
|
+
rainbow (2.1.0)
|
|
114
|
+
rake (10.5.0)
|
|
115
|
+
rb-fsevent (0.9.7)
|
|
116
|
+
rb-inotify (0.9.5)
|
|
117
|
+
ffi (>= 0.5.0)
|
|
118
|
+
rspec (3.4.0)
|
|
119
|
+
rspec-core (~> 3.4.0)
|
|
120
|
+
rspec-expectations (~> 3.4.0)
|
|
121
|
+
rspec-mocks (~> 3.4.0)
|
|
122
|
+
rspec-core (3.4.2)
|
|
123
|
+
rspec-support (~> 3.4.0)
|
|
124
|
+
rspec-expectations (3.4.0)
|
|
125
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
|
126
|
+
rspec-support (~> 3.4.0)
|
|
127
|
+
rspec-mocks (3.4.1)
|
|
128
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
|
129
|
+
rspec-support (~> 3.4.0)
|
|
130
|
+
rspec-support (3.4.1)
|
|
131
|
+
rubocop (0.37.0)
|
|
132
|
+
parser (>= 2.3.0.2, < 3.0)
|
|
133
|
+
powerpack (~> 0.1)
|
|
134
|
+
rainbow (>= 1.99.1, < 3.0)
|
|
135
|
+
ruby-progressbar (~> 1.7)
|
|
136
|
+
unicode-display_width (~> 0.3)
|
|
137
|
+
ruby-progressbar (1.7.5)
|
|
138
|
+
rubyzip (1.1.7)
|
|
139
|
+
selenium-webdriver (2.50.0)
|
|
140
|
+
childprocess (~> 0.5)
|
|
141
|
+
multi_json (~> 1.0)
|
|
142
|
+
rubyzip (~> 1.0)
|
|
143
|
+
websocket (~> 1.0)
|
|
144
|
+
shellany (0.0.1)
|
|
145
|
+
slop (3.6.0)
|
|
146
|
+
spoon (0.0.4)
|
|
147
|
+
ffi
|
|
148
|
+
statsd-ruby (1.3.0)
|
|
149
|
+
thor (0.19.1)
|
|
150
|
+
thread_safe (0.3.5)
|
|
151
|
+
tzinfo (1.2.2)
|
|
152
|
+
thread_safe (~> 0.1)
|
|
153
|
+
unicode-display_width (0.3.1)
|
|
154
|
+
virtus (1.0.5)
|
|
155
|
+
axiom-types (~> 0.1)
|
|
156
|
+
coercible (~> 1.0)
|
|
157
|
+
descendants_tracker (~> 0.0, >= 0.0.3)
|
|
158
|
+
equalizer (~> 0.0, >= 0.0.9)
|
|
159
|
+
websocket (1.2.2)
|
|
160
|
+
xpath (2.0.0)
|
|
161
|
+
nokogiri (~> 1.3)
|
|
162
|
+
|
|
163
|
+
PLATFORMS
|
|
164
|
+
ruby
|
|
165
|
+
|
|
166
|
+
DEPENDENCIES
|
|
167
|
+
capybara
|
|
168
|
+
grape
|
|
169
|
+
grape-entity
|
|
170
|
+
grape-swagger
|
|
171
|
+
guard
|
|
172
|
+
guard-bundler
|
|
173
|
+
guard-rack
|
|
174
|
+
json
|
|
175
|
+
mime-types
|
|
176
|
+
newrelic_rpm
|
|
177
|
+
nokogiri
|
|
178
|
+
rack-cors
|
|
179
|
+
rack-test
|
|
180
|
+
rake
|
|
181
|
+
rspec
|
|
182
|
+
rubocop
|
|
183
|
+
selenium-webdriver
|
|
184
|
+
vitals!
|
|
185
|
+
|
|
186
|
+
BUNDLED WITH
|
|
187
|
+
1.11.2
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
The MIT License (MIT)
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2014 Daniel Doubrovkine
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
Grape API on Rack
|
|
2
|
+
=================
|
|
3
|
+
|
|
4
|
+
[](https://travis-ci.org/ruby-grape/grape-on-rack)
|
|
5
|
+
[](https://gemnasium.com/ruby-grape/grape-on-rack)
|
|
6
|
+
[](https://codeclimate.com/github/ruby-grape/grape-on-rack)
|
|
7
|
+
|
|
8
|
+
A [Grape](http://github.com/ruby-grape/grape) API mounted on Rack.
|
|
9
|
+
|
|
10
|
+
* [ping](api/ping.rb): a hello world example that returns a JSON document
|
|
11
|
+
* [post_put](api/post_put.rb): a simple `POST` and `PUT` example
|
|
12
|
+
* [post_json](api/post_json.rb): an example that shows a `POST` of JSON data
|
|
13
|
+
* [get_json](api/get_json.rb): an example that pre-processes params sent as JSON data
|
|
14
|
+
* [rescue_from](api/rescue_from.rb): an example of `rescue_from` that wraps all exceptions in an HTTP error code 500
|
|
15
|
+
* [path_versioning](api/path_versioning.rb): an example that uses path-based versioning
|
|
16
|
+
* [header_versioning](api/header_versioning.rb): an example that uses vendor header-based versioning
|
|
17
|
+
* [wrap_response](api/wrap_response.rb): a middleware that wraps all responses and always returns HTTP code 200
|
|
18
|
+
* [content_type](api/content_type.rb): an example that overrides the default `Content-Type` or returns data in both JSON and XML formats
|
|
19
|
+
* [upload_file](api/upload_file.rb): an example that demonstrates a file upload and download
|
|
20
|
+
* [entites](api/entities.rb): an example of using [grape-entity](https://github.com/ruby-grape/grape-entity)
|
|
21
|
+
|
|
22
|
+
See
|
|
23
|
+
---
|
|
24
|
+
|
|
25
|
+
There's a deployed [grape-on-rack on Heroku](http://grape-on-rack.herokuapp.com/).
|
|
26
|
+
|
|
27
|
+
Run
|
|
28
|
+
---
|
|
29
|
+
|
|
30
|
+
```
|
|
31
|
+
$ bundle install
|
|
32
|
+
$ rackup
|
|
33
|
+
|
|
34
|
+
Loading NewRelic in developer mode ...
|
|
35
|
+
[2013-06-20 08:57:58] INFO WEBrick 1.3.1
|
|
36
|
+
[2013-06-20 08:57:58] INFO ruby 1.9.3 (2013-02-06) [x86_64-darwin11.4.2]
|
|
37
|
+
[2013-06-20 08:57:58] INFO WEBrick::HTTPServer#start: pid=247 port=9292
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
### Hello World
|
|
41
|
+
|
|
42
|
+
Navigate to http://localhost:9292/api/ping with a browser or use `curl`.
|
|
43
|
+
|
|
44
|
+
```
|
|
45
|
+
$ curl http://localhost:9292/api/ping
|
|
46
|
+
|
|
47
|
+
{"ping":"pong"}
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
### Get Plain Text
|
|
51
|
+
|
|
52
|
+
```
|
|
53
|
+
$ curl http://localhost:9292/api/plain_text
|
|
54
|
+
|
|
55
|
+
A red brown fox jumped over the road.
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
### Upload a File
|
|
59
|
+
|
|
60
|
+
```
|
|
61
|
+
$ curl -X POST -i -F image_file=@spec/fixtures/grape_logo.png http://localhost:9292/api/avatar
|
|
62
|
+
|
|
63
|
+
{"filename":"grape_logo.png","size":4272}
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
### Upload and Download a File
|
|
67
|
+
|
|
68
|
+
```
|
|
69
|
+
$ curl -X POST -i -F file=@spec/fixtures/grape_logo.png http://localhost:9292/api/download.png
|
|
70
|
+
$ curl -X POST -i -F file=@api/ping.rb http://localhost:9292/api/download.rb
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
List Routes
|
|
74
|
+
-----------
|
|
75
|
+
|
|
76
|
+
```
|
|
77
|
+
rake routes
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
Explore the API
|
|
81
|
+
---------------
|
|
82
|
+
|
|
83
|
+
Explore the API using [Swagger UI](http://petstore.swagger.io). Run the application and point the explorer to `http://localhost:9292/api/swagger_doc` or `http://grape-on-rack.herokuapp.com/api/swagger_doc`.
|
|
84
|
+
|
|
85
|
+
New Relic
|
|
86
|
+
---------
|
|
87
|
+
|
|
88
|
+
The application is setup with NewRelic w/ Developer Mode. Navigate to http://localhost:9292/newrelic after making some API calls.
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
require 'rubygems'
|
|
2
|
+
require 'bundler/setup'
|
|
3
|
+
|
|
4
|
+
require 'rake'
|
|
5
|
+
|
|
6
|
+
require 'rspec/core'
|
|
7
|
+
require 'rspec/core/rake_task'
|
|
8
|
+
|
|
9
|
+
RSpec::Core::RakeTask.new(:spec)
|
|
10
|
+
|
|
11
|
+
task :environment do
|
|
12
|
+
ENV['RACK_ENV'] ||= 'development'
|
|
13
|
+
require File.expand_path('../config/environment', __FILE__)
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
task routes: :environment do
|
|
17
|
+
Acme::API.routes.each do |route|
|
|
18
|
+
method = route.route_method.ljust(10)
|
|
19
|
+
path = route.route_path
|
|
20
|
+
puts " #{method} #{path}"
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
require 'rubocop/rake_task'
|
|
25
|
+
RuboCop::RakeTask.new(:rubocop)
|
|
26
|
+
|
|
27
|
+
task default: [:rubocop, :spec]
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
module Acme
|
|
2
|
+
class ContentType < Grape::API
|
|
3
|
+
format :json
|
|
4
|
+
content_type :txt, 'text/plain'
|
|
5
|
+
content_type :xml, 'application/xml'
|
|
6
|
+
|
|
7
|
+
desc 'Returns a plain text file.'
|
|
8
|
+
get 'plain_text' do
|
|
9
|
+
content_type 'text/plain'
|
|
10
|
+
'A red brown fox jumped over the road.'
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
desc 'Returns a response in either XML or JSON format.'
|
|
14
|
+
get 'mixed' do
|
|
15
|
+
{ data: 'A red brown fox jumped over the road.' }
|
|
16
|
+
end
|
|
17
|
+
end
|
|
18
|
+
end
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
module Acme
|
|
2
|
+
module Entities
|
|
3
|
+
class Tool < Grape::Entity
|
|
4
|
+
root 'tools', 'tool'
|
|
5
|
+
expose :id
|
|
6
|
+
expose :length, documentation: { type: :string, desc: 'length of the tool' }
|
|
7
|
+
expose :weight, documentation: { type: :string, desc: 'weight of the tool' }
|
|
8
|
+
expose :foo, documentation: { type: :string, desc: 'foo' }, if: ->(_tool, options) { options[:foo] } do |_tool, options|
|
|
9
|
+
options[:foo]
|
|
10
|
+
end
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
class API < Grape::API
|
|
14
|
+
format :json
|
|
15
|
+
content_type :xml, 'application/xml'
|
|
16
|
+
formatter :xml, proc { |object|
|
|
17
|
+
object[object.keys.first].to_xml root: object.keys.first
|
|
18
|
+
}
|
|
19
|
+
desc 'Exposes an entity'
|
|
20
|
+
namespace :entities do
|
|
21
|
+
desc 'Expose a tool', params: Acme::Entities::Tool.documentation
|
|
22
|
+
get ':id' do
|
|
23
|
+
present OpenStruct.new(id: params[:id], length: 10, weight: '20kg'), with: Acme::Entities::Tool, foo: params[:foo]
|
|
24
|
+
end
|
|
25
|
+
end
|
|
26
|
+
end
|
|
27
|
+
end
|
|
28
|
+
end
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
module Acme
|
|
2
|
+
class GetJson < Grape::API
|
|
3
|
+
format :json
|
|
4
|
+
desc 'Flips reticulated in a collection of splines passed as JSON in a query string.'
|
|
5
|
+
resource :reticulated_splines do
|
|
6
|
+
before do
|
|
7
|
+
params.each_pair do |k, v|
|
|
8
|
+
params[k] = JSON.parse(v) rescue v
|
|
9
|
+
end
|
|
10
|
+
end
|
|
11
|
+
params do
|
|
12
|
+
requires :splines, type: Array do
|
|
13
|
+
requires :id, type: Integer
|
|
14
|
+
requires :reticulated, type: Boolean
|
|
15
|
+
end
|
|
16
|
+
end
|
|
17
|
+
get do
|
|
18
|
+
params[:splines].map do |spline|
|
|
19
|
+
spline.merge(reticulated: !spline[:reticulated])
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
end
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
module Acme
|
|
2
|
+
class PostPut < Grape::API
|
|
3
|
+
cattr_accessor :rang
|
|
4
|
+
|
|
5
|
+
format :json
|
|
6
|
+
desc 'Returns pong.'
|
|
7
|
+
get :ring do
|
|
8
|
+
{ rang: PostPut.rang }
|
|
9
|
+
end
|
|
10
|
+
post :ring do
|
|
11
|
+
result = (PostPut.rang += 1)
|
|
12
|
+
{ rang: result }
|
|
13
|
+
end
|
|
14
|
+
params do
|
|
15
|
+
requires :count, type: Integer
|
|
16
|
+
end
|
|
17
|
+
put :ring do
|
|
18
|
+
result = (PostPut.rang += params[:count].to_i)
|
|
19
|
+
{ rang: result }
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
Acme::PostPut.rang = 0
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
module Acme
|
|
2
|
+
class UploadFile < Grape::API
|
|
3
|
+
format :json
|
|
4
|
+
|
|
5
|
+
desc 'Upload an image.'
|
|
6
|
+
post 'avatar' do
|
|
7
|
+
{
|
|
8
|
+
filename: params[:image_file][:filename],
|
|
9
|
+
size: params[:image_file][:tempfile].size
|
|
10
|
+
}
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
desc 'Upload and download a file of any format.'
|
|
14
|
+
post 'download' do
|
|
15
|
+
filename = params[:file][:filename]
|
|
16
|
+
content_type MIME::Types.type_for(filename)[0].to_s
|
|
17
|
+
env['api.format'] = :binary
|
|
18
|
+
header 'Content-Disposition', "attachment; filename*=UTF-8''#{URI.escape(filename)}"
|
|
19
|
+
params[:file][:tempfile].read
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
end
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
module Acme
|
|
2
|
+
class WrapResponseDecorator
|
|
3
|
+
def initialize(app)
|
|
4
|
+
@app = app
|
|
5
|
+
end
|
|
6
|
+
|
|
7
|
+
def call(env)
|
|
8
|
+
status, headers, body_proxy = @app.call(env)
|
|
9
|
+
bodies = body_proxy.body.map do |body|
|
|
10
|
+
{ body: JSON.parse(body), status: status }.to_json
|
|
11
|
+
end
|
|
12
|
+
[200, headers, bodies]
|
|
13
|
+
end
|
|
14
|
+
end
|
|
15
|
+
end
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
module Acme
|
|
2
|
+
class App
|
|
3
|
+
def initialize
|
|
4
|
+
@filenames = ['', '.html', 'index.html', '/index.html']
|
|
5
|
+
@rack_static = ::Rack::Static.new(
|
|
6
|
+
lambda { [404, {}, []] },
|
|
7
|
+
root: File.expand_path('../../public', __FILE__),
|
|
8
|
+
urls: ['/']
|
|
9
|
+
)
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
def self.instance
|
|
13
|
+
@instance ||= Rack::Builder.new do
|
|
14
|
+
use Rack::Cors do
|
|
15
|
+
allow do
|
|
16
|
+
origins '*'
|
|
17
|
+
resource '*', headers: :any, methods: :get
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
run Acme::App.new
|
|
22
|
+
end.to_app
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
def call(env)
|
|
26
|
+
# api
|
|
27
|
+
response = Acme::API.call(env)
|
|
28
|
+
|
|
29
|
+
# Check if the App wants us to pass the response along to others
|
|
30
|
+
if response[1]['X-Cascade'] == 'pass'
|
|
31
|
+
# static files
|
|
32
|
+
request_path = env['PATH_INFO']
|
|
33
|
+
@filenames.each do |path|
|
|
34
|
+
response = @rack_static.call(env.merge('PATH_INFO' => request_path + path))
|
|
35
|
+
return response if response[0] != 404
|
|
36
|
+
end
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
# Serve error pages or respond with API response
|
|
40
|
+
case response[0]
|
|
41
|
+
when 404, 500
|
|
42
|
+
content = @rack_static.call(env.merge('PATH_INFO' => "/errors/#{response[0]}.html"))
|
|
43
|
+
[response[0], content[1], content[2]]
|
|
44
|
+
else
|
|
45
|
+
response
|
|
46
|
+
end
|
|
47
|
+
end
|
|
48
|
+
end
|
|
49
|
+
end
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
module Acme
|
|
2
|
+
class API < Grape::API
|
|
3
|
+
prefix 'api'
|
|
4
|
+
format :json
|
|
5
|
+
mount ::Acme::Ping
|
|
6
|
+
mount ::Acme::RescueFrom
|
|
7
|
+
mount ::Acme::PathVersioning
|
|
8
|
+
mount ::Acme::HeaderVersioning
|
|
9
|
+
mount ::Acme::PostPut
|
|
10
|
+
mount ::Acme::WrapResponse
|
|
11
|
+
mount ::Acme::PostJson
|
|
12
|
+
mount ::Acme::GetJson
|
|
13
|
+
mount ::Acme::ContentType
|
|
14
|
+
mount ::Acme::UploadFile
|
|
15
|
+
mount ::Acme::Entities::API
|
|
16
|
+
add_swagger_documentation api_version: 'v1'
|
|
17
|
+
end
|
|
18
|
+
end
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'api'))
|
|
2
|
+
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'app'))
|
|
3
|
+
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
|
4
|
+
|
|
5
|
+
require 'boot'
|
|
6
|
+
|
|
7
|
+
Bundler.require :default, ENV['RACK_ENV']
|
|
8
|
+
|
|
9
|
+
Dir[File.expand_path('../../api/*.rb', __FILE__)].each do |f|
|
|
10
|
+
require f
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
require 'api'
|
|
14
|
+
require 'acme_app'
|
|
15
|
+
|
|
16
|
+
require 'vitals'
|
|
17
|
+
Vitals.configure! do |c|
|
|
18
|
+
c.facility = 'grape_app'
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
require 'vitals/integrations/notifications/grape'
|
|
22
|
+
Vitals::Integrations::Notifications::Grape.subscribe!
|
|
23
|
+
|