michibiki 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/MIT-LICENSE +20 -0
- data/Rakefile +26 -0
- data/app/assets/javascripts/michibiki/application.js +13 -0
- data/app/assets/stylesheets/michibiki/application.css +15 -0
- data/app/controllers/michibiki/application_controller.rb +4 -0
- data/app/controllers/michibiki/skips_controller.rb +13 -0
- data/app/filters/michibiki/base.rb +50 -0
- data/app/helpers/michibiki/application_helper.rb +4 -0
- data/app/services/michibiki/skip_service.rb +19 -0
- data/app/views/layouts/michibiki/application.html.erb +14 -0
- data/config/locales/en.yml +4 -0
- data/config/routes.rb +3 -0
- data/lib/michibiki.rb +4 -0
- data/lib/michibiki/engine.rb +6 -0
- data/lib/michibiki/version.rb +3 -0
- data/lib/tasks/michibiki_tasks.rake +4 -0
- metadata +74 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 849fd4c7f4b28b8de4357e00da7828d002378d3c
|
4
|
+
data.tar.gz: fe407147b85f6cd39e261b84407e690b57549ae1
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 35e37413644ced59aaf6f25c37508ceff22e03f5ca03ad269c38d02008525c412c506418fb46cd8e2e856840159209cd9e69e99239c375039969955d8423a416
|
7
|
+
data.tar.gz: 8f16e5ea468af723a8f01b952334c90aae9ebb0d8b0e6d281404a360f06a6f9aef028d1f9ae3f2df645f94fe6d2be1a3bcb13d42f380fa3e6a6e19494eb12835
|
data/MIT-LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright 2015 koshikawa
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/Rakefile
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
begin
|
2
|
+
require 'bundler/setup'
|
3
|
+
rescue LoadError
|
4
|
+
puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
|
5
|
+
end
|
6
|
+
|
7
|
+
require 'rdoc/task'
|
8
|
+
|
9
|
+
RDoc::Task.new(:rdoc) do |rdoc|
|
10
|
+
rdoc.rdoc_dir = 'rdoc'
|
11
|
+
rdoc.title = 'Michibiki'
|
12
|
+
rdoc.options << '--line-numbers'
|
13
|
+
rdoc.rdoc_files.include('README.rdoc')
|
14
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
15
|
+
end
|
16
|
+
|
17
|
+
APP_RAKEFILE = File.expand_path("../spec/dummy/Rakefile", __FILE__)
|
18
|
+
load 'rails/tasks/engine.rake'
|
19
|
+
|
20
|
+
|
21
|
+
load 'rails/tasks/statistics.rake'
|
22
|
+
|
23
|
+
|
24
|
+
|
25
|
+
Bundler::GemHelper.install_tasks
|
26
|
+
|
@@ -0,0 +1,13 @@
|
|
1
|
+
// This is a manifest file that'll be compiled into application.js, which will include all the files
|
2
|
+
// listed below.
|
3
|
+
//
|
4
|
+
// Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
|
5
|
+
// or any plugin's vendor/assets/javascripts directory can be referenced here using a relative path.
|
6
|
+
//
|
7
|
+
// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
|
8
|
+
// compiled file.
|
9
|
+
//
|
10
|
+
// Read Sprockets README (https://github.com/sstephenson/sprockets#sprockets-directives) for details
|
11
|
+
// about supported directives.
|
12
|
+
//
|
13
|
+
//= require_tree .
|
@@ -0,0 +1,15 @@
|
|
1
|
+
/*
|
2
|
+
* This is a manifest file that'll be compiled into application.css, which will include all the files
|
3
|
+
* listed below.
|
4
|
+
*
|
5
|
+
* Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
|
6
|
+
* or any plugin's vendor/assets/stylesheets directory can be referenced here using a relative path.
|
7
|
+
*
|
8
|
+
* You're free to add application-wide styles to this file and they'll appear at the bottom of the
|
9
|
+
* compiled file so the styles you add here take precedence over styles defined in any styles
|
10
|
+
* defined in the other CSS/SCSS files in this directory. It is generally better to create a new
|
11
|
+
* file per style scope.
|
12
|
+
*
|
13
|
+
*= require_tree .
|
14
|
+
*= require_self
|
15
|
+
*/
|
@@ -0,0 +1,13 @@
|
|
1
|
+
module Michibiki
|
2
|
+
class SkipsController < ::ApplicationController
|
3
|
+
def update
|
4
|
+
skip_service = Michibiki::SkipService.new(skip_strategy: params[:skip_strategy])
|
5
|
+
if skip_service.valid?
|
6
|
+
session[skip_service.session_name] = Time.current
|
7
|
+
redirect_to '/'
|
8
|
+
else
|
9
|
+
head :not_found
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,50 @@
|
|
1
|
+
# ex.) before_action Michibiki::Strategies::ProfileSettingRedirector
|
2
|
+
module Michibiki
|
3
|
+
class Base
|
4
|
+
SKIP_SESSION_NAME_FORMAT = 'skip_%{underscored_class_name}_at'
|
5
|
+
attr_reader :controller
|
6
|
+
|
7
|
+
class << self
|
8
|
+
def before(c)
|
9
|
+
new(c)
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
def initialize(c)
|
14
|
+
@controller = c
|
15
|
+
controller.redirect_to(redirect_path, redirect_options) if trigger?
|
16
|
+
end
|
17
|
+
|
18
|
+
private
|
19
|
+
def trigger?
|
20
|
+
return false unless controller.request.get?
|
21
|
+
return false if controller.request.path == redirect_path
|
22
|
+
return false if skip?
|
23
|
+
trigger_conditions
|
24
|
+
end
|
25
|
+
|
26
|
+
def trigger_conditions
|
27
|
+
true
|
28
|
+
end
|
29
|
+
|
30
|
+
def redirect_path
|
31
|
+
'/'
|
32
|
+
end
|
33
|
+
|
34
|
+
def skip?
|
35
|
+
skip_session.present?
|
36
|
+
end
|
37
|
+
|
38
|
+
def skip_session
|
39
|
+
controller.session[skip_session_name]
|
40
|
+
end
|
41
|
+
|
42
|
+
def skip_session_name
|
43
|
+
format(SKIP_SESSION_NAME_FORMAT, underscored_class_name: self.class.name.demodulize.underscore)
|
44
|
+
end
|
45
|
+
|
46
|
+
def redirect_options
|
47
|
+
{}
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
class Michibiki::SkipService
|
2
|
+
include ActiveModel::Model
|
3
|
+
|
4
|
+
attr_accessor :skip_strategy
|
5
|
+
validate :check_strategy
|
6
|
+
|
7
|
+
def session_name
|
8
|
+
name_format = Michibiki::Base::SKIP_SESSION_NAME_FORMAT
|
9
|
+
format(name_format, underscored_class_name: skip_strategy)
|
10
|
+
end
|
11
|
+
|
12
|
+
private
|
13
|
+
|
14
|
+
def check_strategy
|
15
|
+
::Michibiki::Strategies.const_get(skip_strategy.classify)
|
16
|
+
rescue NameError
|
17
|
+
errors.add(:invalid_strategy, I18n.t('michibiki.skip_failure'))
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<title>Michibiki</title>
|
5
|
+
<%= stylesheet_link_tag "michibiki/application", media: "all" %>
|
6
|
+
<%= javascript_include_tag "michibiki/application" %>
|
7
|
+
<%= csrf_meta_tags %>
|
8
|
+
</head>
|
9
|
+
<body>
|
10
|
+
|
11
|
+
<%= yield %>
|
12
|
+
|
13
|
+
</body>
|
14
|
+
</html>
|
data/config/routes.rb
ADDED
data/lib/michibiki.rb
ADDED
metadata
ADDED
@@ -0,0 +1,74 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: michibiki
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- ppworks
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2015-03-16 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: rails
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 4.2.0
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 4.2.0
|
27
|
+
description: Michibiki is auto redirector if user's condition is match
|
28
|
+
email:
|
29
|
+
- koshikawa@ppworks.jp
|
30
|
+
executables: []
|
31
|
+
extensions: []
|
32
|
+
extra_rdoc_files: []
|
33
|
+
files:
|
34
|
+
- MIT-LICENSE
|
35
|
+
- Rakefile
|
36
|
+
- app/assets/javascripts/michibiki/application.js
|
37
|
+
- app/assets/stylesheets/michibiki/application.css
|
38
|
+
- app/controllers/michibiki/application_controller.rb
|
39
|
+
- app/controllers/michibiki/skips_controller.rb
|
40
|
+
- app/filters/michibiki/base.rb
|
41
|
+
- app/helpers/michibiki/application_helper.rb
|
42
|
+
- app/services/michibiki/skip_service.rb
|
43
|
+
- app/views/layouts/michibiki/application.html.erb
|
44
|
+
- config/locales/en.yml
|
45
|
+
- config/routes.rb
|
46
|
+
- lib/michibiki.rb
|
47
|
+
- lib/michibiki/engine.rb
|
48
|
+
- lib/michibiki/version.rb
|
49
|
+
- lib/tasks/michibiki_tasks.rake
|
50
|
+
homepage: https://github.com/ppworks/michibiki
|
51
|
+
licenses:
|
52
|
+
- MIT
|
53
|
+
metadata: {}
|
54
|
+
post_install_message:
|
55
|
+
rdoc_options: []
|
56
|
+
require_paths:
|
57
|
+
- lib
|
58
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
59
|
+
requirements:
|
60
|
+
- - ">="
|
61
|
+
- !ruby/object:Gem::Version
|
62
|
+
version: '0'
|
63
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
64
|
+
requirements:
|
65
|
+
- - ">="
|
66
|
+
- !ruby/object:Gem::Version
|
67
|
+
version: '0'
|
68
|
+
requirements: []
|
69
|
+
rubyforge_project:
|
70
|
+
rubygems_version: 2.4.5
|
71
|
+
signing_key:
|
72
|
+
specification_version: 4
|
73
|
+
summary: Auto redirector
|
74
|
+
test_files: []
|