blue_print 0.0.1 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 71dac53d8435a095608cad84dd4db5b03e349e6b
4
- data.tar.gz: f4a443d5dd7123450ca46f413d00ce875097c3c4
3
+ metadata.gz: dbd7694883cacae9801cfc6fa826746829542562
4
+ data.tar.gz: 51575e4325de406fbf93d4b089c043e18b0ce74b
5
5
  SHA512:
6
- metadata.gz: a763f3cbd70716346034ab3e23676d12c0d6132540d680c551d3a349f8621823c64740625f065aec2ccc3d29f97e7281e7c248372427e39e6f573629fea50879
7
- data.tar.gz: 421a1e3f72aadc6bda1cec34b4ec9e1917f2c97c32c3b233da68567d74086f0651fed38b414f079ca2fa6203b76af2fbd9c9894baf145aab92b38355d87d4037
6
+ metadata.gz: 93b04df1d153d2af18d1853a2b3e0d7e21676caa36df2492647a0cfb44cbc9990da410645d42452e0bf949b6234ba169e8e4ae3b45ae747b08a9e08b2bd5f809
7
+ data.tar.gz: 83c97daa1ed5eff9dc535255f347a8c3f5bf8f517b945e85f53e4a9dbced1f2e87a049bd80bc9e3c819316a5d42b07d4796bbd419a69caad1d38ca7ec5d08ee7
data/blue_print.gemspec CHANGED
@@ -28,6 +28,8 @@ Gem::Specification.new do |spec|
28
28
  spec.add_development_dependency 'database_cleaner'
29
29
  spec.add_development_dependency 'generator_spec'
30
30
  spec.add_development_dependency 'coveralls'
31
+ spec.add_development_dependency 'draper'
32
+ spec.add_development_dependency 'grape'
31
33
 
32
34
  spec.add_dependency 'activesupport'
33
35
  spec.add_dependency 'hashie'
data/lib/blue_print.rb CHANGED
@@ -4,6 +4,7 @@ require 'blue_print/version'
4
4
  require 'blue_print/environment'
5
5
  require 'blue_print/context'
6
6
  require 'blue_print/helper'
7
+ require 'blue_print/integration'
7
8
  require 'blue_print/railtie' if defined?(Rails)
8
9
 
9
10
  module BluePrint
@@ -2,3 +2,15 @@ require 'blue_print'
2
2
 
3
3
  module BluePrint::Integration
4
4
  end
5
+
6
+ begin
7
+ require 'draper'
8
+ require 'blue_print/integration/draper'
9
+ rescue LoadError
10
+ end
11
+
12
+ begin
13
+ require 'grape'
14
+ require 'blue_print/integration/grape'
15
+ rescue LoadError
16
+ end
@@ -8,17 +8,10 @@ module BluePrint::Integration::ActionController
8
8
  include BluePrint::Helper
9
9
 
10
10
  included do
11
- if respond_to?(:before_action)
12
- before_action(:build_blue_print_environment)
13
- else
14
- before_filter(:build_blue_print_environment)
15
- end
16
-
17
- if respond_to?(:after_action)
18
- after_action(:clear_blue_print_environment)
19
- else
20
- after_filter(:clear_blue_print_environment)
21
- end
11
+ action_or_filter = respond_to?(:before_action) ? :action : :filter
12
+
13
+ send("before_#{action_or_filter}", :build_blue_print_environment)
14
+ send("after_#{action_or_filter}", :clear_blue_print_environment)
22
15
  end
23
16
 
24
17
  private
@@ -0,0 +1,8 @@
1
+ require 'blue_print/integration'
2
+ require 'blue_print/helper'
3
+
4
+ module BluePrint::Integration::Draper
5
+ include BluePrint::Helper
6
+ end
7
+
8
+ Draper::Decorator.send(:include, BluePrint::Integration::Draper)
@@ -0,0 +1,7 @@
1
+ require 'blue_print/integration'
2
+
3
+ module BluePrint::Integration::Grape
4
+ end
5
+
6
+ require 'blue_print/integration/grape/api'
7
+ require 'blue_print/integration/grape/middleware'
@@ -0,0 +1,13 @@
1
+ require 'grape/api'
2
+ require 'blue_print/integration/grape'
3
+ require 'blue_print/integration/grape/middleware'
4
+ require 'blue_print/integration/grape/helper'
5
+
6
+ class << Grape::API
7
+ def inherited_with_blue_print(klass)
8
+ inherited_without_blue_print(klass)
9
+ klass.use BluePrint::Integration::Grape::Middleware
10
+ klass.helpers BluePrint::Integration::Grape::Helper
11
+ end
12
+ alias_method_chain :inherited, :blue_print
13
+ end
@@ -0,0 +1,6 @@
1
+ require 'blue_print/integration/grape'
2
+ require 'blue_print/helper'
3
+
4
+ module BluePrint::Integration::Grape::Helper
5
+ include BluePrint::Helper
6
+ end
@@ -0,0 +1,12 @@
1
+ require 'grape/middleware/base'
2
+ require 'blue_print/integration/grape'
3
+
4
+ class BluePrint::Integration::Grape::Middleware < ::Grape::Middleware::Base
5
+ def before
6
+ BluePrint.env = BluePrint::Environment.new(env['api.endpoint'])
7
+ end
8
+
9
+ def after
10
+ BluePrint.clear!
11
+ end
12
+ end
@@ -1,3 +1,3 @@
1
1
  module BluePrint
2
- VERSION = '0.0.1'
2
+ VERSION = '1.0.0'
3
3
  end
@@ -0,0 +1,10 @@
1
+ require 'spec_helper'
2
+
3
+ describe ApplicationApi do
4
+ describe 'GET /api/version' do
5
+ it 'returns blue print version' do
6
+ get '/api/version'
7
+ expect(response.body).to eq(BluePrint::VERSION)
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,5 @@
1
+ class ApplicationApi < Grape::API
2
+ get 'version' do
3
+ BluePrint::VERSION
4
+ end
5
+ end
@@ -0,0 +1,5 @@
1
+ class EchoController < ApplicationController
2
+ def show
3
+ render text: params[:text]
4
+ end
5
+ end
@@ -61,5 +61,7 @@ module Dummy
61
61
 
62
62
  # Version of your assets, change this if you want to expire all your assets
63
63
  config.assets.version = '1.0'
64
+
65
+ config.secret_key_base = 'secret key base'
64
66
  end
65
67
  end
@@ -1,58 +1,5 @@
1
1
  Dummy::Application.routes.draw do
2
- # The priority is based upon order of creation:
3
- # first created -> highest priority.
2
+ mount ApplicationApi => '/api'
4
3
 
5
- # Sample of regular route:
6
- # match 'products/:id' => 'catalog#view'
7
- # Keep in mind you can assign values other than :controller and :action
8
-
9
- # Sample of named route:
10
- # match 'products/:id/purchase' => 'catalog#purchase', :as => :purchase
11
- # This route can be invoked with purchase_url(:id => product.id)
12
-
13
- # Sample resource route (maps HTTP verbs to controller actions automatically):
14
- # resources :products
15
-
16
- # Sample resource route with options:
17
- # resources :products do
18
- # member do
19
- # get 'short'
20
- # post 'toggle'
21
- # end
22
- #
23
- # collection do
24
- # get 'sold'
25
- # end
26
- # end
27
-
28
- # Sample resource route with sub-resources:
29
- # resources :products do
30
- # resources :comments, :sales
31
- # resource :seller
32
- # end
33
-
34
- # Sample resource route with more complex sub-resources
35
- # resources :products do
36
- # resources :comments
37
- # resources :sales do
38
- # get 'recent', :on => :collection
39
- # end
40
- # end
41
-
42
- # Sample resource route within a namespace:
43
- # namespace :admin do
44
- # # Directs /admin/products/* to Admin::ProductsController
45
- # # (app/controllers/admin/products_controller.rb)
46
- # resources :products
47
- # end
48
-
49
- # You can have the root of your site routed with "root"
50
- # just remember to delete public/index.html.
51
- # root :to => 'welcome#index'
52
-
53
- # See how all your routes lay out with "rake routes"
54
-
55
- # This is a legacy wild controller route that's not recommended for RESTful applications.
56
- # Note: This route will make all actions in every controller accessible via GET requests.
57
- # match ':controller(/:action(/:id))(.:format)'
4
+ get 'echo/:text' => 'echo#show'
58
5
  end
@@ -0,0 +1,10 @@
1
+ require 'spec_helper'
2
+
3
+ describe EchoController do
4
+ describe 'GET /echo/text' do
5
+ it 'returns echo response' do
6
+ get '/echo/text'
7
+ expect(response.body).to eq('text')
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,5 @@
1
+ RSpec.configure do |config|
2
+ config.include RSpec::Rails::RequestExampleGroup, type: :request, example_group: {
3
+ file_path: /spec\/apis/
4
+ }
5
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: blue_print
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 1.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sho Kusano
@@ -164,6 +164,34 @@ dependencies:
164
164
  - - ">="
165
165
  - !ruby/object:Gem::Version
166
166
  version: '0'
167
+ - !ruby/object:Gem::Dependency
168
+ name: draper
169
+ requirement: !ruby/object:Gem::Requirement
170
+ requirements:
171
+ - - ">="
172
+ - !ruby/object:Gem::Version
173
+ version: '0'
174
+ type: :development
175
+ prerelease: false
176
+ version_requirements: !ruby/object:Gem::Requirement
177
+ requirements:
178
+ - - ">="
179
+ - !ruby/object:Gem::Version
180
+ version: '0'
181
+ - !ruby/object:Gem::Dependency
182
+ name: grape
183
+ requirement: !ruby/object:Gem::Requirement
184
+ requirements:
185
+ - - ">="
186
+ - !ruby/object:Gem::Version
187
+ version: '0'
188
+ type: :development
189
+ prerelease: false
190
+ version_requirements: !ruby/object:Gem::Requirement
191
+ requirements:
192
+ - - ">="
193
+ - !ruby/object:Gem::Version
194
+ version: '0'
167
195
  - !ruby/object:Gem::Dependency
168
196
  name: activesupport
169
197
  requirement: !ruby/object:Gem::Requirement
@@ -232,6 +260,11 @@ files:
232
260
  - lib/blue_print/helper.rb
233
261
  - lib/blue_print/integration.rb
234
262
  - lib/blue_print/integration/action_controller.rb
263
+ - lib/blue_print/integration/draper.rb
264
+ - lib/blue_print/integration/grape.rb
265
+ - lib/blue_print/integration/grape/api.rb
266
+ - lib/blue_print/integration/grape/helper.rb
267
+ - lib/blue_print/integration/grape/middleware.rb
235
268
  - lib/blue_print/railtie.rb
236
269
  - lib/blue_print/railtie/action_controller.rb
237
270
  - lib/blue_print/railtie/action_view.rb
@@ -244,14 +277,17 @@ files:
244
277
  - lib/generators/rspec/blue_print_generator.rb
245
278
  - lib/generators/rspec/templates/context_spec.rb
246
279
  - lib/generators/rspec/templates/role_spec.rb
280
+ - spec/apis/application_api_spec.rb
247
281
  - spec/dummy/.gitignore
248
282
  - spec/dummy/Gemfile
249
283
  - spec/dummy/README.rdoc
250
284
  - spec/dummy/Rakefile
285
+ - spec/dummy/app/apis/application_api.rb
251
286
  - spec/dummy/app/assets/images/rails.png
252
287
  - spec/dummy/app/assets/javascripts/application.js
253
288
  - spec/dummy/app/assets/stylesheets/application.css
254
289
  - spec/dummy/app/controllers/application_controller.rb
290
+ - spec/dummy/app/controllers/echo_controller.rb
255
291
  - spec/dummy/app/helpers/application_helper.rb
256
292
  - spec/dummy/app/mailers/.gitkeep
257
293
  - spec/dummy/app/models/.gitkeep
@@ -294,7 +330,9 @@ files:
294
330
  - spec/lib/blue_print_spec.rb
295
331
  - spec/lib/generators/rails/blue_print_generator_spec.rb
296
332
  - spec/lib/generators/rspec/blue_print_generator_spec.rb
333
+ - spec/requests/echo_spec.rb
297
334
  - spec/spec_helper.rb
335
+ - spec/support/api_testing.rb
298
336
  - spec/support/database_cleaner.rb
299
337
  - spec/support/generator_spec.rb
300
338
  homepage: http://magnet-inc.github.io/blue_print
@@ -322,14 +360,17 @@ signing_key:
322
360
  specification_version: 4
323
361
  summary: The behavior switching framework for Rails
324
362
  test_files:
363
+ - spec/apis/application_api_spec.rb
325
364
  - spec/dummy/.gitignore
326
365
  - spec/dummy/Gemfile
327
366
  - spec/dummy/README.rdoc
328
367
  - spec/dummy/Rakefile
368
+ - spec/dummy/app/apis/application_api.rb
329
369
  - spec/dummy/app/assets/images/rails.png
330
370
  - spec/dummy/app/assets/javascripts/application.js
331
371
  - spec/dummy/app/assets/stylesheets/application.css
332
372
  - spec/dummy/app/controllers/application_controller.rb
373
+ - spec/dummy/app/controllers/echo_controller.rb
333
374
  - spec/dummy/app/helpers/application_helper.rb
334
375
  - spec/dummy/app/mailers/.gitkeep
335
376
  - spec/dummy/app/models/.gitkeep
@@ -372,6 +413,8 @@ test_files:
372
413
  - spec/lib/blue_print_spec.rb
373
414
  - spec/lib/generators/rails/blue_print_generator_spec.rb
374
415
  - spec/lib/generators/rspec/blue_print_generator_spec.rb
416
+ - spec/requests/echo_spec.rb
375
417
  - spec/spec_helper.rb
418
+ - spec/support/api_testing.rb
376
419
  - spec/support/database_cleaner.rb
377
420
  - spec/support/generator_spec.rb