wanko 0.0.1
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 +13 -0
- data/.travis.yml +4 -0
- data/Gemfile +4 -0
- data/MIT-LICENSE +21 -0
- data/README.md +221 -0
- data/Rakefile +10 -0
- data/bin/console +14 -0
- data/bin/setup +7 -0
- data/gemfiles/Gemfile-rails.4.2.x +9 -0
- data/lib/generators/wanko/controller_generator.rb +27 -0
- data/lib/generators/wanko/extension_generator.rb +64 -0
- data/lib/generators/wanko/templates/controller.rb +15 -0
- data/lib/generators/wanko/templates/lib/%name%/engine.rb +9 -0
- data/lib/wanko.rb +12 -0
- data/lib/wanko/abstract_controller.rb +65 -0
- data/lib/wanko/action_view.rb +47 -0
- data/lib/wanko/engine.rb +26 -0
- data/lib/wanko/version.rb +3 -0
- data/wanko.gemspec +29 -0
- metadata +162 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 35f8261a71528c603e7515fe97107c697f2f4085
|
4
|
+
data.tar.gz: 336126eb4c5c6fa8a2b476e019dd0f95bdb90f47
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 737133a5a450221b492254ea0aba04b9e56844034e69e9fbb6af34e6733620900295534cec122b43ce71e139aafe5cc1ee4c9e6fcffde3e9e78b0d143f23d5e7
|
7
|
+
data.tar.gz: 2f94733f469498786a683df472458d02cf7cc4d1204ee51577b942e13d0f159c5285a2bdb753c3327b4bf2c034b24b09ef3957236f98f0e324cec8c4e6cfd638
|
data/.gitignore
ADDED
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/MIT-LICENSE
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2015 Akira Matsuda
|
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
|
13
|
+
all 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
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,221 @@
|
|
1
|
+
# Wanko
|
2
|
+
|
3
|
+
Wanko is a prototyping framework for Rails.
|
4
|
+
It's something akin to "feature toggle".
|
5
|
+
It can be used for "A/B testing" as well.
|
6
|
+
But essentially, the main purpose of this framework is to provide a way to rapidly and safely deliver new features to the production environment.
|
7
|
+
|
8
|
+
|
9
|
+
## Installation
|
10
|
+
|
11
|
+
Bundle into your Rails app.
|
12
|
+
|
13
|
+
|
14
|
+
## Features
|
15
|
+
|
16
|
+
### Isolated Engine
|
17
|
+
|
18
|
+
Wanko helps you mounting Isolated Engines called "extensions" onto the main Rails app.
|
19
|
+
An extension can contain whole MVC conponents, which means that you can encapsulate everything that are needed for your new feature under one single directory.
|
20
|
+
This helps your team creating multiple new features simultaneously without causing code conflict.
|
21
|
+
|
22
|
+
### Conditional Execution
|
23
|
+
Each Wanko extension can be configured to be enabled/disabled.
|
24
|
+
The condition is not just a flag but can be a Ruby Proc which will be dynamically evaluated on each request in the controller context.
|
25
|
+
|
26
|
+
### Error-proof
|
27
|
+
|
28
|
+
If any RuntimeError happens inside an extension, Wanko absorbs the error and executes the appropriate fallback code so that the end users would never even notice the occurrence of the error.
|
29
|
+
|
30
|
+
### Extending Action Methods in the Main App
|
31
|
+
|
32
|
+
Wanko provides an interface to override the main app's controller actions.
|
33
|
+
|
34
|
+
### Partially Extending Views in the Main App
|
35
|
+
|
36
|
+
Wanko provides a hook to partially overwrite any part of your existing view.
|
37
|
+
|
38
|
+
|
39
|
+
## Structure
|
40
|
+
|
41
|
+
main_app
|
42
|
+
├── Gemfile
|
43
|
+
├── Gemfile.lock
|
44
|
+
├── Rakefile
|
45
|
+
├── app
|
46
|
+
│ ├── assets
|
47
|
+
│ ├── controllers
|
48
|
+
│ ├── extensions
|
49
|
+
│ │ ├── my_awesome_new_feature
|
50
|
+
│ │ │ ├── app
|
51
|
+
│ │ │ │ ├── assets
|
52
|
+
│ │ │ │ ├── controllers
|
53
|
+
│ │ │ │ │ └── my_awesome_new_feature
|
54
|
+
│ │ │ │ │ └── welcome_controller.rb
|
55
|
+
│ │ │ │ ├── helpers
|
56
|
+
│ │ │ │ │ └── my_awesome_new_feature
|
57
|
+
│ │ │ │ │ └── welcome_helper.rb
|
58
|
+
│ │ │ │ ├── mailers
|
59
|
+
│ │ │ │ ├── models
|
60
|
+
│ │ │ │ └── views
|
61
|
+
│ │ │ │ ├── layouts
|
62
|
+
│ │ │ │ │ └── my_awesome_new_feature
|
63
|
+
│ │ │ │ │ └── application.html.erb
|
64
|
+
│ │ │ │ └── my_awesome_new_feature
|
65
|
+
│ │ │ │ └── welcome
|
66
|
+
│ │ │ ├── config
|
67
|
+
│ │ │ │ └── routes.rb
|
68
|
+
│ │ │ ├── lib
|
69
|
+
│ │ │ │ ├── my_awesome_new_feature
|
70
|
+
│ │ │ │ │ └── engine.rb
|
71
|
+
│ │ │ │ ├── my_awesome_new_feature.rb
|
72
|
+
│ │ │ │ └── tasks
|
73
|
+
│ │ │ ├── my_awesome_new_feature.gemspec
|
74
|
+
│ │ │ └── test
|
75
|
+
│ │ └── yet_another_new_feature
|
76
|
+
│ │ ├── app
|
77
|
+
│ │ ...
|
78
|
+
│ ├── helpers
|
79
|
+
│ ├── mailers
|
80
|
+
│ ├── models
|
81
|
+
│ └── views
|
82
|
+
├── bin
|
83
|
+
├── config
|
84
|
+
├── db
|
85
|
+
...
|
86
|
+
|
87
|
+
|
88
|
+
## Components
|
89
|
+
|
90
|
+
### lib/EXTENSION\_NAME/engine.rb
|
91
|
+
|
92
|
+
Put `active_if` directive inside the Engine class. The whole extension will only be executed if the block is evaluated to be truthy on runtime.
|
93
|
+
|
94
|
+
Example:
|
95
|
+
|
96
|
+
```ruby
|
97
|
+
# app/extensions/my_awesome_new_feature/config/routes.rb
|
98
|
+
module MyAwesomeNewFeature
|
99
|
+
class Engine < ::Rails::Engine
|
100
|
+
include Wanko::Engine
|
101
|
+
|
102
|
+
# this whole extension will be executed only when logged in as admin users
|
103
|
+
active_if { current_user.admin? }
|
104
|
+
end
|
105
|
+
end
|
106
|
+
```
|
107
|
+
|
108
|
+
### routes.rb
|
109
|
+
|
110
|
+
All routes in extensions' routes.rb will be automatically prepended to the main app's Routes.
|
111
|
+
|
112
|
+
|
113
|
+
### Controllers
|
114
|
+
|
115
|
+
Controllers can be a normal Engine controller.
|
116
|
+
Or, you can craft a controller class inheriting a controller that exists in the main app, and overriding some action methods.
|
117
|
+
From inside the actions in extensions, you can call the main app's action via `super`.
|
118
|
+
|
119
|
+
Example:
|
120
|
+
|
121
|
+
```ruby
|
122
|
+
# app/extensions/my_awesome_new_feature/app/controllers/my_awesome_new_feature/welcome_controller.rb
|
123
|
+
class MyAwesomeNewFeature::WelcomeController < ::WelcomeController
|
124
|
+
include Wanko::Controller
|
125
|
+
|
126
|
+
def index
|
127
|
+
# invoking the main app's action first
|
128
|
+
super
|
129
|
+
|
130
|
+
# adding some more business logic
|
131
|
+
@notificaations = Notification.for current_user
|
132
|
+
end
|
133
|
+
end
|
134
|
+
```
|
135
|
+
|
136
|
+
|
137
|
+
### Views
|
138
|
+
|
139
|
+
When an extension renders the views, it looks up app/views/EXTENSION\_NAME/ directory first, then the main app's view directory next. This way you can overwrite views per template/partial file.
|
140
|
+
Also, Wanko adds new `:extension` option to `render` method, which enables you to explicitly inject a piece of HTML from an extension into any place of the app.
|
141
|
+
`render :extension` takes an `EXTENSION_NAME/view_path' parameter
|
142
|
+
|
143
|
+
```haml
|
144
|
+
# app/extensions/my_awesome_new_feature/app/views/my_awesome_new_feature/welcome/_index.html.haml
|
145
|
+
.new_feature
|
146
|
+
Some contents for new feature
|
147
|
+
|
148
|
+
# app/views/welcome/index.html.haml
|
149
|
+
= render extension: 'my_awesome_new_feature/welcome/index' do
|
150
|
+
Some contents that will be shown by default
|
151
|
+
```
|
152
|
+
|
153
|
+
|
154
|
+
## Generators
|
155
|
+
|
156
|
+
Wanko provides some handy code generators.
|
157
|
+
|
158
|
+
### Generating an extension
|
159
|
+
|
160
|
+
```ruby
|
161
|
+
% rails g wanko:extension EXTENSION_NAME
|
162
|
+
```
|
163
|
+
|
164
|
+
Example:
|
165
|
+
|
166
|
+
```ruby
|
167
|
+
% rails g wanko:extension my_awesome_new_feature
|
168
|
+
```
|
169
|
+
|
170
|
+
This generates an extension Engine in
|
171
|
+
~/app/extensions/my\_awesome\_new\_feature/ directory.
|
172
|
+
|
173
|
+
### Generating a controller extention that extends an existing controller
|
174
|
+
|
175
|
+
```ruby
|
176
|
+
% rails g wanko:controller EXTENSION_NAME/CONTROLLER_NAME [action action] [options]
|
177
|
+
```
|
178
|
+
|
179
|
+
Example:
|
180
|
+
|
181
|
+
```ruby
|
182
|
+
% rails g wanko:controller my_awesome_new_feature/welcome index
|
183
|
+
```
|
184
|
+
|
185
|
+
This generates a controller that extends WelcomeController and implements index action inside ~/app/extensions/my\_awesome\_new\_feature/ directory.
|
186
|
+
|
187
|
+
### Generating an extension + controller
|
188
|
+
|
189
|
+
|
190
|
+
```ruby
|
191
|
+
% rails g wanko:extension EXTENSION_NAME CONTROLLER_NAME [action action] [options]
|
192
|
+
```
|
193
|
+
|
194
|
+
Example:
|
195
|
+
|
196
|
+
```ruby
|
197
|
+
% rails g wanko:extension my_awesome_new_feature welcome index
|
198
|
+
```
|
199
|
+
|
200
|
+
This generates an extension Engine in ~/app/extensions/my\_awesome\_new\_feature/ directory. Plus, a controller that extends WelcomeController and implements index action inside the Engine.
|
201
|
+
|
202
|
+
|
203
|
+
## Contributing
|
204
|
+
|
205
|
+
Pull requests are welcome on GitHub at https://github.com/amatsuda/wanko.
|
206
|
+
|
207
|
+
|
208
|
+
## Todo
|
209
|
+
|
210
|
+
* Better generator
|
211
|
+
|
212
|
+
* Better error handling
|
213
|
+
|
214
|
+
* Model extension
|
215
|
+
|
216
|
+
* Documentation
|
217
|
+
|
218
|
+
|
219
|
+
## License
|
220
|
+
|
221
|
+
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "wanko"
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
# require "pry"
|
11
|
+
# Pry.start
|
12
|
+
|
13
|
+
require "irb"
|
14
|
+
IRB.start
|
data/bin/setup
ADDED
@@ -0,0 +1,9 @@
|
|
1
|
+
source 'https://rubygems.org'
|
2
|
+
|
3
|
+
gemspec :path => '../'
|
4
|
+
|
5
|
+
gem 'rails', '~> 4.2.4'
|
6
|
+
gem 'controller_extension', path: '../test/dummy_app/app/extensions/controller_extension'
|
7
|
+
gem 'controller_fallback', path: '../test/dummy_app/app/extensions/controller_fallback'
|
8
|
+
gem 'view_render_fallback', path: '../test/dummy_app/app/extensions/view_render_fallback'
|
9
|
+
gem 'routes_fallback', path: '../test/dummy_app/app/extensions/routes_fallback'
|
@@ -0,0 +1,27 @@
|
|
1
|
+
require 'rails/generators/rails/controller/controller_generator'
|
2
|
+
|
3
|
+
module Wanko
|
4
|
+
module Generators
|
5
|
+
class ControllerGenerator < ::Rails::Generators::ControllerGenerator
|
6
|
+
source_root ::Rails::Generators::ControllerGenerator.source_root
|
7
|
+
|
8
|
+
class << self
|
9
|
+
def source_paths
|
10
|
+
[File.expand_path('../templates', __FILE__), *super]
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
# override
|
15
|
+
def create_controller_files
|
16
|
+
@destination_stack[@destination_stack.size - 1] = File.join @destination_stack.last, 'app/extensions', class_path
|
17
|
+
template 'controller.rb', File.join('app/controllers', class_path, "#{file_name}_controller.rb")
|
18
|
+
end
|
19
|
+
|
20
|
+
# override
|
21
|
+
private
|
22
|
+
def generate_routing_code(action)
|
23
|
+
"get '#{file_name}/#{action}'"
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,64 @@
|
|
1
|
+
require 'rails/generators/rails/plugin/plugin_generator'
|
2
|
+
|
3
|
+
module Wanko
|
4
|
+
class ExtensionBuilder < ::Rails::PluginBuilder
|
5
|
+
def readme() end
|
6
|
+
def rakefile() end
|
7
|
+
end
|
8
|
+
|
9
|
+
module Generators
|
10
|
+
class ExtensionGenerator < ::Rails::Generators::PluginGenerator
|
11
|
+
argument :base_controller, type: :string, optional: true, banner: 'base controller'
|
12
|
+
argument :actions, type: :array, default: [], banner: "action action"
|
13
|
+
source_root ::Rails::Generators::PluginGenerator.source_root
|
14
|
+
|
15
|
+
class << self
|
16
|
+
def source_paths
|
17
|
+
[File.expand_path('../templates', __FILE__), *super]
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
def initialize(*args)
|
22
|
+
options = args.extract_options!
|
23
|
+
options[:destination_root] = 'app/extensions'
|
24
|
+
super(*args, options)
|
25
|
+
options = @options.dup
|
26
|
+
options[:mountable] = options[:skip_bundle] = options[:skip_test_unit] = options[:skip_git] = options[:skip_gemfile] = true
|
27
|
+
@options = options.freeze
|
28
|
+
end
|
29
|
+
|
30
|
+
def get_builder_class
|
31
|
+
Wanko::ExtensionBuilder
|
32
|
+
end
|
33
|
+
|
34
|
+
# override
|
35
|
+
def create_bin_files
|
36
|
+
end
|
37
|
+
|
38
|
+
def put_litter_in_its_place
|
39
|
+
remove_file 'MIT-LICENSE'
|
40
|
+
remove_file "app/controllers/#{name}/application_controller.rb"
|
41
|
+
remove_file "lib/tasks/#{name}_tasks.rake"
|
42
|
+
end
|
43
|
+
|
44
|
+
def untodo_gemspec
|
45
|
+
gemspec = "#{name}.gemspec"
|
46
|
+
gsub_file gemspec, /"TODO.*?"/, '""'
|
47
|
+
end
|
48
|
+
|
49
|
+
def bundle_to_parent
|
50
|
+
gemfile = Rails.root + 'Gemfile'
|
51
|
+
append_to_file gemfile, "gem '#{name}', path: '#{destination_root}'\n" if gemfile.exist?
|
52
|
+
end
|
53
|
+
|
54
|
+
def generate_controller
|
55
|
+
if base_controller
|
56
|
+
Dir.chdir destination_root do
|
57
|
+
#FIXME call the controller generator directly
|
58
|
+
puts `rails g wanko:controller #{name}/#{base_controller} #{actions * ' '}`
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
<% if namespaced? -%>
|
2
|
+
require_dependency "<%= namespaced_path %>/application_controller"
|
3
|
+
|
4
|
+
<% end -%>
|
5
|
+
<% module_namespacing do -%>
|
6
|
+
class <%= class_name %>Controller < ::<%= file_name.camelize %>Controller
|
7
|
+
include Wanko::Controller
|
8
|
+
|
9
|
+
<% actions.each do |action| -%>
|
10
|
+
def <%= action %>
|
11
|
+
end
|
12
|
+
<%= "\n" unless action == actions.last -%>
|
13
|
+
<% end -%>
|
14
|
+
end
|
15
|
+
<% end -%>
|
data/lib/wanko.rb
ADDED
@@ -0,0 +1,65 @@
|
|
1
|
+
module Wanko
|
2
|
+
module Helpers
|
3
|
+
module UrlHelper
|
4
|
+
#FIXME there has to be a better way doing this...
|
5
|
+
def method_missing(meth, *args, &block)
|
6
|
+
if main_app.routes.url_helpers.instance_methods.include? meth
|
7
|
+
main_app.send meth, *args, &block
|
8
|
+
else
|
9
|
+
super
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
module Controller
|
16
|
+
extend ActiveSupport::Concern
|
17
|
+
|
18
|
+
included do
|
19
|
+
helper Wanko::Helpers::UrlHelper
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
module AbstractController
|
24
|
+
def send_action(method_name, *args)
|
25
|
+
if self.is_a?(Wanko::Controller)
|
26
|
+
begin
|
27
|
+
super
|
28
|
+
@_wanko_action_successfully_finished = true
|
29
|
+
rescue => e
|
30
|
+
#TODO error handling
|
31
|
+
p e
|
32
|
+
end
|
33
|
+
else
|
34
|
+
if env.key? 'wanko_render_result'
|
35
|
+
headers.delete 'X-Cascade'
|
36
|
+
ret = env.delete 'wanko_render_result'
|
37
|
+
self.response_body = ret
|
38
|
+
else
|
39
|
+
super
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
module ActionController
|
46
|
+
def process_action(*args)
|
47
|
+
if self.is_a?(Wanko::Controller)
|
48
|
+
headers['X-Cascade'] = 'pass'
|
49
|
+
if self.class.parent::Engine.active?(self)
|
50
|
+
super
|
51
|
+
end
|
52
|
+
else
|
53
|
+
super
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
def render_to_body(options = {})
|
58
|
+
return if (headers['X-Cascade'] == 'pass') && !defined?(@_wanko_action_successfully_finished)
|
59
|
+
env['wanko_render_result'] = super
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
AbstractController::Base.prepend Wanko::AbstractController
|
65
|
+
ActionController::Base.prepend Wanko::ActionController
|
@@ -0,0 +1,47 @@
|
|
1
|
+
module Wanko
|
2
|
+
module ActionView
|
3
|
+
module Helpers
|
4
|
+
module RenderingHelper
|
5
|
+
def render(options = {}, locals = {}, &block)
|
6
|
+
if (Hash === options) && options.key?(:extension)
|
7
|
+
ext_name = options[:extension][/[^\/]*/]
|
8
|
+
if ext_name.classify.constantize::Engine.active? controller
|
9
|
+
return view_renderer.render(self, options, &block)
|
10
|
+
else
|
11
|
+
return capture(&block)
|
12
|
+
end
|
13
|
+
end
|
14
|
+
super
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
module Renderer
|
20
|
+
def render(context, options)
|
21
|
+
if options.key? :extension
|
22
|
+
render_extension(context, options)
|
23
|
+
else
|
24
|
+
super
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
def render_extension(context, options, &block)
|
29
|
+
partial_name = options.delete :extension
|
30
|
+
Wanko::ExtensionRenderer.new(@lookup_context).render(context, options.merge(partial: partial_name), block)
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
class ExtensionRenderer < ::ActionView::PartialRenderer
|
36
|
+
def render(context, options, block)
|
37
|
+
super
|
38
|
+
rescue => e
|
39
|
+
#TODO error handling
|
40
|
+
p e
|
41
|
+
capture(&block)
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
ActionView::Base.prepend Wanko::ActionView::Helpers::RenderingHelper
|
47
|
+
ActionView::Renderer.prepend Wanko::ActionView::Renderer
|
data/lib/wanko/engine.rb
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
module Wanko
|
2
|
+
module Engine
|
3
|
+
extend ActiveSupport::Concern
|
4
|
+
|
5
|
+
module ClassMethods
|
6
|
+
def active_if(&block)
|
7
|
+
@active_if = block
|
8
|
+
end
|
9
|
+
|
10
|
+
def active?(controller)
|
11
|
+
controller.instance_eval(&@active_if)
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
included do
|
16
|
+
isolate_namespace self.parent
|
17
|
+
|
18
|
+
engine_kls = self
|
19
|
+
ActiveSupport.on_load :after_initialize do
|
20
|
+
Rails.application.routes.prepend do
|
21
|
+
mount engine_kls, :at => '/'
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
data/wanko.gemspec
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'wanko/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "wanko"
|
8
|
+
spec.version = Wanko::VERSION
|
9
|
+
spec.authors = ["Akira Matsuda"]
|
10
|
+
spec.email = ["ronnie@dio.jp"]
|
11
|
+
|
12
|
+
spec.summary = 'A safe and rapid prototyping framework for Rails'
|
13
|
+
spec.description = 'Wanko is a Rails Engine framework that can be used for rapid prototyping, feature toggle, or A/B testing'
|
14
|
+
spec.homepage = 'https://github.com/amatsuda/wanko'
|
15
|
+
spec.license = "MIT"
|
16
|
+
|
17
|
+
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
18
|
+
spec.bindir = "exe"
|
19
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
20
|
+
spec.require_paths = ["lib"]
|
21
|
+
|
22
|
+
spec.add_development_dependency "bundler", "~> 1.10"
|
23
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
24
|
+
spec.add_development_dependency "minitest"
|
25
|
+
spec.add_development_dependency 'rails'
|
26
|
+
spec.add_development_dependency 'sqlite3'
|
27
|
+
spec.add_development_dependency 'capybara'
|
28
|
+
spec.add_development_dependency 'byebug'
|
29
|
+
end
|
metadata
ADDED
@@ -0,0 +1,162 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: wanko
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Akira Matsuda
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2015-10-23 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.10'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.10'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '10.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '10.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: minitest
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rails
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: sqlite3
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: capybara
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ">="
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - ">="
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: byebug
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - ">="
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '0'
|
104
|
+
type: :development
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - ">="
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '0'
|
111
|
+
description: Wanko is a Rails Engine framework that can be used for rapid prototyping,
|
112
|
+
feature toggle, or A/B testing
|
113
|
+
email:
|
114
|
+
- ronnie@dio.jp
|
115
|
+
executables: []
|
116
|
+
extensions: []
|
117
|
+
extra_rdoc_files: []
|
118
|
+
files:
|
119
|
+
- ".gitignore"
|
120
|
+
- ".travis.yml"
|
121
|
+
- Gemfile
|
122
|
+
- MIT-LICENSE
|
123
|
+
- README.md
|
124
|
+
- Rakefile
|
125
|
+
- bin/console
|
126
|
+
- bin/setup
|
127
|
+
- gemfiles/Gemfile-rails.4.2.x
|
128
|
+
- lib/generators/wanko/controller_generator.rb
|
129
|
+
- lib/generators/wanko/extension_generator.rb
|
130
|
+
- lib/generators/wanko/templates/controller.rb
|
131
|
+
- lib/generators/wanko/templates/lib/%name%/engine.rb
|
132
|
+
- lib/wanko.rb
|
133
|
+
- lib/wanko/abstract_controller.rb
|
134
|
+
- lib/wanko/action_view.rb
|
135
|
+
- lib/wanko/engine.rb
|
136
|
+
- lib/wanko/version.rb
|
137
|
+
- wanko.gemspec
|
138
|
+
homepage: https://github.com/amatsuda/wanko
|
139
|
+
licenses:
|
140
|
+
- MIT
|
141
|
+
metadata: {}
|
142
|
+
post_install_message:
|
143
|
+
rdoc_options: []
|
144
|
+
require_paths:
|
145
|
+
- lib
|
146
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
147
|
+
requirements:
|
148
|
+
- - ">="
|
149
|
+
- !ruby/object:Gem::Version
|
150
|
+
version: '0'
|
151
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
152
|
+
requirements:
|
153
|
+
- - ">="
|
154
|
+
- !ruby/object:Gem::Version
|
155
|
+
version: '0'
|
156
|
+
requirements: []
|
157
|
+
rubyforge_project:
|
158
|
+
rubygems_version: 2.4.5.1
|
159
|
+
signing_key:
|
160
|
+
specification_version: 4
|
161
|
+
summary: A safe and rapid prototyping framework for Rails
|
162
|
+
test_files: []
|