dekiru 0.3.2 → 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/dekiru/data_migration_operator.rb +2 -2
- data/lib/dekiru/helper.rb +0 -74
- data/lib/dekiru/railtie.rb +0 -5
- data/lib/dekiru/validators/existence.rb +2 -0
- data/lib/dekiru/version.rb +1 -1
- data/lib/dekiru.rb +0 -1
- metadata +2 -7
- data/lib/dekiru/controller_additions.rb +0 -25
- data/lib/dekiru/smtp_check_mailer.rb +0 -20
- data/lib/dekiru/tasks/smtp_check.rake +0 -10
- data/spec/dekiru/helper_spec.rb +0 -49
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: dbfeff250b0e1ec21cc8ed1f4ccf284ac5430ad41be129f0f04a6fa73b6f36b7
|
4
|
+
data.tar.gz: dc7557d4f6a91491fad5cd70d938a0050e8b98405ded870825564ee037401156
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 447ab174db16c187dab03db7ecef25d217036ea688442c5594dd0d82382cde3bf2ce10e6e7fb27382b6f9702d4c7292fe01c583f7055cd365921f1bf97d4f1ed
|
7
|
+
data.tar.gz: 723725e05e52c1beef024d39787c2dd5c834b14e1c5c7d18374c0dea57c4bf6441c1e618d8287c5bb44210865ea9b7d63eb554486f5293fa19c78f9a7e280d92
|
@@ -12,7 +12,7 @@ module Dekiru
|
|
12
12
|
@title = title
|
13
13
|
@options = options
|
14
14
|
@stream = @options.fetch(:output, $stdout)
|
15
|
-
@without_transaction = @options.fetch(:without_transaction,
|
15
|
+
@without_transaction = @options.fetch(:without_transaction, false)
|
16
16
|
@side_effects = Hash.new do |hash, key|
|
17
17
|
hash[key] = Hash.new(0)
|
18
18
|
end
|
@@ -122,7 +122,7 @@ module Dekiru
|
|
122
122
|
end
|
123
123
|
|
124
124
|
def run(&block)
|
125
|
-
if @options
|
125
|
+
if @options.fetch(:warning_side_effects, true)
|
126
126
|
warning_side_effects(&block)
|
127
127
|
else
|
128
128
|
instance_eval(&block)
|
data/lib/dekiru/helper.rb
CHANGED
@@ -1,82 +1,8 @@
|
|
1
1
|
module Dekiru
|
2
2
|
module Helper
|
3
|
-
def menu_link_to(name = nil, options = nil, html_options = nil, &block)
|
4
|
-
ActiveSupport::Deprecation.warn('`menu_link_to` is deprecated and will be removed in v0.4.')
|
5
|
-
|
6
|
-
args = [name, options, html_options]
|
7
|
-
html_options, options, name = options, name, block if block_given?
|
8
|
-
|
9
|
-
classes = html_options.try(:delete, :li_class).try(:split, ' ') || []
|
10
|
-
classes << 'active' if current_page?(options)
|
11
|
-
|
12
|
-
obj = [options].flatten.last
|
13
|
-
if obj.is_a?(ActiveRecord::Base)
|
14
|
-
content_tag_for(:li, obj, :class => classes.join(' ')) do
|
15
|
-
link_to name, options, html_options, &block
|
16
|
-
end
|
17
|
-
else
|
18
|
-
content_tag(:li, :class => classes.join(' ')) do
|
19
|
-
link_to *args, &block
|
20
|
-
end
|
21
|
-
end
|
22
|
-
end
|
23
|
-
|
24
3
|
def null_check_localization(object, **options)
|
25
4
|
localize(object, **options) if object.present?
|
26
5
|
end
|
27
6
|
alias nl null_check_localization
|
28
|
-
|
29
|
-
def facebook_like(url = url_for(only_path: false), app_id = nil, width = 140)
|
30
|
-
ActiveSupport::Deprecation.warn('`facebook_like` is deprecated and will be removed in v0.4.')
|
31
|
-
|
32
|
-
facebook_app_id = app_id || ENV['FACEBOOK_APP_ID']
|
33
|
-
html = %Q(<iframe src="//www.facebook.com/plugins/like.php?href=#{u(url)}&send=false&layout=button_count&width=140&show_faces=false&action=like&colorscheme=light&font=arial&height=21&appId=#{facebook_app_id}" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:#{width}px; height:21px;" allowTransparency="true"></iframe>)
|
34
|
-
html.html_safe
|
35
|
-
end
|
36
|
-
|
37
|
-
def twitter_tweet
|
38
|
-
ActiveSupport::Deprecation.warn('`twitter_tweet` is deprecated and will be removed in v0.4.')
|
39
|
-
|
40
|
-
html = <<-EOF
|
41
|
-
<a href="https://twitter.com/share" class="twitter-share-button">Tweet</a>
|
42
|
-
<script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0],p=/^http:/.test(d.location)?'http':'https';if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src=p+'://platform.twitter.com/widgets.js';fjs.parentNode.insertBefore(js,fjs);}}(document, 'script', 'twitter-wjs');</script>
|
43
|
-
EOF
|
44
|
-
html.html_safe
|
45
|
-
end
|
46
|
-
|
47
|
-
def google_plus
|
48
|
-
ActiveSupport::Deprecation.warn('`google_plus` is deprecated and will be removed in v0.4.')
|
49
|
-
|
50
|
-
html = <<-EOF
|
51
|
-
<script type="text/javascript" src="https://apis.google.com/js/plusone.js"></script>
|
52
|
-
<g:plusone size="medium"></g:plusone>
|
53
|
-
EOF
|
54
|
-
html.html_safe
|
55
|
-
end
|
56
|
-
|
57
|
-
def google_analytics(code, options = {})
|
58
|
-
ActiveSupport::Deprecation.warn('`google_analytics` is deprecated and will be removed in v0.4.')
|
59
|
-
|
60
|
-
if code.present? && ::Rails.env == 'production'
|
61
|
-
multi_subdomain = if options[:domain]
|
62
|
-
"_gaq.push(['_setDomainName', '#{options[:domain]}']);"
|
63
|
-
end
|
64
|
-
|
65
|
-
html = <<-EOF
|
66
|
-
<script type="text/javascript">
|
67
|
-
var _gaq = _gaq || [];
|
68
|
-
_gaq.push(['_setAccount', '#{code}']);
|
69
|
-
#{multi_subdomain}
|
70
|
-
_gaq.push(['_trackPageview']);
|
71
|
-
(function() {
|
72
|
-
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
|
73
|
-
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
|
74
|
-
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
|
75
|
-
})();
|
76
|
-
</script>
|
77
|
-
EOF
|
78
|
-
html.html_safe
|
79
|
-
end
|
80
|
-
end
|
81
7
|
end
|
82
8
|
end
|
data/lib/dekiru/railtie.rb
CHANGED
@@ -4,10 +4,6 @@ module Dekiru
|
|
4
4
|
ActiveSupport.on_load(:action_view) do
|
5
5
|
::ActionView::Base.send :include, Dekiru::Helper
|
6
6
|
end
|
7
|
-
|
8
|
-
ActiveSupport.on_load(:action_controller) do
|
9
|
-
::ActionController::Base.send :include, Dekiru::ControllerAdditions
|
10
|
-
end
|
11
7
|
end
|
12
8
|
|
13
9
|
config.after_initialize do
|
@@ -19,7 +15,6 @@ module Dekiru
|
|
19
15
|
end
|
20
16
|
|
21
17
|
rake_tasks do
|
22
|
-
load 'dekiru/tasks/smtp_check.rake'
|
23
18
|
load 'dekiru/tasks/db.rake'
|
24
19
|
end
|
25
20
|
end
|
@@ -8,6 +8,8 @@ module ActiveModel
|
|
8
8
|
module Validations
|
9
9
|
class ExistenceValidator < EachValidator
|
10
10
|
def validate_each(record, attribute, value)
|
11
|
+
ActiveSupport::Deprecation.warn('`ExistenceValidator` is deprecated and will be removed in v0.5. Please use `inclusion: { in: xx }` instead.')
|
12
|
+
|
11
13
|
unless exists?(record, value)
|
12
14
|
record.errors.add(attribute, :existence, **options.except(:in).merge!(value: value))
|
13
15
|
end
|
data/lib/dekiru/version.rb
CHANGED
data/lib/dekiru.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dekiru
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Akihiro Matsumura
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-
|
11
|
+
date: 2022-09-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: http_accept_language
|
@@ -143,15 +143,12 @@ files:
|
|
143
143
|
- lib/dekiru/capybara/helpers/wait_for_position_stable.rb
|
144
144
|
- lib/dekiru/capybara/legacy_helpers.rb
|
145
145
|
- lib/dekiru/capybara/matchers.rb
|
146
|
-
- lib/dekiru/controller_additions.rb
|
147
146
|
- lib/dekiru/data_migration_operator.rb
|
148
147
|
- lib/dekiru/helper.rb
|
149
148
|
- lib/dekiru/mail_security_interceptor.rb
|
150
149
|
- lib/dekiru/railtie.rb
|
151
|
-
- lib/dekiru/smtp_check_mailer.rb
|
152
150
|
- lib/dekiru/task_with_logger.rb
|
153
151
|
- lib/dekiru/tasks/db.rake
|
154
|
-
- lib/dekiru/tasks/smtp_check.rake
|
155
152
|
- lib/dekiru/validators/existence.rb
|
156
153
|
- lib/dekiru/version.rb
|
157
154
|
- lib/generators/maintenance_script/USAGE
|
@@ -159,7 +156,6 @@ files:
|
|
159
156
|
- lib/generators/maintenance_script/templates/maintenance_script.rb.erb
|
160
157
|
- spec/dekiru/camelize_hash_spec.rb
|
161
158
|
- spec/dekiru/data_migration_operator_spec.rb
|
162
|
-
- spec/dekiru/helper_spec.rb
|
163
159
|
- spec/dekiru/mail_security_interceptor_spec.rb
|
164
160
|
- spec/dekiru/validators/existence_spec.rb
|
165
161
|
- spec/spec_helper.rb
|
@@ -190,7 +186,6 @@ summary: Usefull helper methods for Ruby on Rails
|
|
190
186
|
test_files:
|
191
187
|
- spec/dekiru/camelize_hash_spec.rb
|
192
188
|
- spec/dekiru/data_migration_operator_spec.rb
|
193
|
-
- spec/dekiru/helper_spec.rb
|
194
189
|
- spec/dekiru/mail_security_interceptor_spec.rb
|
195
190
|
- spec/dekiru/validators/existence_spec.rb
|
196
191
|
- spec/spec_helper.rb
|
@@ -1,25 +0,0 @@
|
|
1
|
-
require 'http_accept_language'
|
2
|
-
|
3
|
-
module Dekiru
|
4
|
-
module ControllerAdditions
|
5
|
-
def set_locale
|
6
|
-
ActiveSupport::Deprecation.warn('`set_locale` is deprecated and will be removed in v0.4.')
|
7
|
-
|
8
|
-
I18n.locale = locale_from_params || locale_from_header
|
9
|
-
logger.info "[locale] #{I18n.locale}"
|
10
|
-
end
|
11
|
-
|
12
|
-
def locale_from_params
|
13
|
-
ActiveSupport::Deprecation.warn('`locale_from_params` is deprecated and will be removed in v0.4.')
|
14
|
-
|
15
|
-
(I18n.available_locales & [params[:locale].try(:to_sym)]).first
|
16
|
-
end
|
17
|
-
|
18
|
-
def locale_from_header
|
19
|
-
ActiveSupport::Deprecation.warn('`locale_from_header` is deprecated and will be removed in v0.4.')
|
20
|
-
|
21
|
-
logger.debug "[debug] #{http_accept_language.user_preferred_languages}"
|
22
|
-
http_accept_language.compatible_language_from(I18n.available_locales)
|
23
|
-
end
|
24
|
-
end
|
25
|
-
end
|
@@ -1,20 +0,0 @@
|
|
1
|
-
module Dekiru
|
2
|
-
class SmtpCheckMailer < ActionMailer::Base
|
3
|
-
default from: 'smtp-checker@sonicgarden.jp'
|
4
|
-
|
5
|
-
def checkmail
|
6
|
-
app_key = ENV['SMTP_CHECKER_APP_KEY'] || Rails.application.class.parent_name.downcase
|
7
|
-
smtp_checker_to_addr = ENV['SMTP_CHECKER_TO_ADDR'] || 'smtp-alive@sg-ops-mail.sonicgarden.jp'
|
8
|
-
|
9
|
-
Rails.logger.error "ENV['SMTP_CHECKER_APP_KEY'] undefined!" if app_key.blank?
|
10
|
-
Rails.logger.error "ENV['SMTP_CHECKER_TO_ADDR'] undefined!" if smtp_checker_to_addr.blank?
|
11
|
-
|
12
|
-
Rails.logger.info "checkmail send start #{smtp_checker_to_addr} key:#{app_key}"
|
13
|
-
subject = '[SMTP Checker] SMTP Check Mail'
|
14
|
-
mail to: smtp_checker_to_addr, subject: subject do |format|
|
15
|
-
format.text { render plain: app_key }
|
16
|
-
end
|
17
|
-
Rails.logger.info "send to #{smtp_checker_to_addr} key:#{app_key}"
|
18
|
-
end
|
19
|
-
end
|
20
|
-
end
|
@@ -1,10 +0,0 @@
|
|
1
|
-
require "dekiru/smtp_check_mailer"
|
2
|
-
|
3
|
-
namespace :dekiru do
|
4
|
-
desc 'Ops check for smpt alival'
|
5
|
-
task smtp_check: :environment do
|
6
|
-
Rails.logger.info "[INFO] Start task dekiru:smtp_check env:#{Rails.env}"
|
7
|
-
Dekiru::SmtpCheckMailer.checkmail.deliver
|
8
|
-
Rails.logger.info "[INFO] End task dekiru:smtp_check env:#{Rails.env}"
|
9
|
-
end
|
10
|
-
end
|
data/spec/dekiru/helper_spec.rb
DELETED
@@ -1,49 +0,0 @@
|
|
1
|
-
require "spec_helper"
|
2
|
-
|
3
|
-
describe Dekiru::Helper do
|
4
|
-
let(:helper) do
|
5
|
-
class AClass
|
6
|
-
include Dekiru::Helper
|
7
|
-
include ActionView::Helpers::TagHelper
|
8
|
-
include ActionView::Context
|
9
|
-
include ActionView::Helpers::UrlHelper
|
10
|
-
end
|
11
|
-
a = AClass.new
|
12
|
-
end
|
13
|
-
describe "#menu_link_to" do
|
14
|
-
before do
|
15
|
-
allow(helper).to receive(:current_page?).and_return(true)
|
16
|
-
end
|
17
|
-
context "一番シンプルな呼び出し" do
|
18
|
-
it "動くこと" do
|
19
|
-
expect(helper.menu_link_to("テキスト", "/some_path")).to eq("<li class=\"active\"><a href=\"/some_path\">テキスト</a></li>")
|
20
|
-
end
|
21
|
-
end
|
22
|
-
context "blockなし" do
|
23
|
-
it "動くこと" do
|
24
|
-
expect(helper.menu_link_to("テキスト", "/some_path", class: "some_class")).to eq("<li class=\"active\"><a class=\"some_class\" href=\"/some_path\">テキスト</a></li>")
|
25
|
-
end
|
26
|
-
end
|
27
|
-
context "blockあり" do
|
28
|
-
it "動くこと" do
|
29
|
-
html = helper.menu_link_to("/some_path", class: "some_class") do
|
30
|
-
"テキスト"
|
31
|
-
end
|
32
|
-
expect(html).to eq("<li class=\"active\"><a class=\"some_class\" href=\"/some_path\">テキスト</a></li>")
|
33
|
-
end
|
34
|
-
end
|
35
|
-
context "今のページじゃない" do
|
36
|
-
before do
|
37
|
-
allow(helper).to receive(:current_page?).and_return(false)
|
38
|
-
end
|
39
|
-
it "動くこと" do
|
40
|
-
expect(helper.menu_link_to("テキスト", "/some_path", class: "some_class")).to eq("<li class=\"\"><a class=\"some_class\" href=\"/some_path\">テキスト</a></li>")
|
41
|
-
end
|
42
|
-
end
|
43
|
-
context "li_class指定あり" do
|
44
|
-
it "動くこと" do
|
45
|
-
expect(helper.menu_link_to("テキスト", "/some_path", class: "some_class", li_class: "li_class")).to eq("<li class=\"li_class active\"><a class=\"some_class\" href=\"/some_path\">テキスト</a></li>")
|
46
|
-
end
|
47
|
-
end
|
48
|
-
end
|
49
|
-
end
|