dekiru 0.3.3 → 0.4.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 +4 -4
- data/.github/labels.yml +18 -0
- data/.github/release.yml +23 -0
- data/.github/workflows/github-label-sync.yml +16 -0
- data/lib/dekiru/data_migration_operator.rb +9 -1
- 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
- data/spec/dekiru/data_migration_operator_spec.rb +13 -1
- metadata +5 -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: 883e443347e743adfd76dd7c0a7932d04227241c542bd69bd4c99db26dd41b56
|
4
|
+
data.tar.gz: b841f7ceda476d786b00453a95747d9049d72c94e477d0666780bac57ec0e696
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 86df3c5e61c8bf2a34aaf0fe2c27dc1aeae509ba39aea50559fd7ab7685878fd610b3d45b4a9b2c443c5039703450b87d9da6787c3ad21fa77a9cf81a621118f
|
7
|
+
data.tar.gz: 31d047b646605752a5e9b7025e2275d7163d5b846d824a358aa2e9edf332e7f777d2b306abd821d8f933fbb6fc4dfef2e7648fc6cc256258362b7ddee1051ee6
|
data/.github/labels.yml
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
- name: add
|
2
|
+
description: Add new features.
|
3
|
+
color: "0e8a16"
|
4
|
+
- name: change
|
5
|
+
description: Change existing functionality.
|
6
|
+
color: "fbca04"
|
7
|
+
- name: deprecate
|
8
|
+
description: Mark as soon-to-be removed features.
|
9
|
+
color: "d93f0b"
|
10
|
+
- name: remove
|
11
|
+
description: Remove features.
|
12
|
+
color: "b60205"
|
13
|
+
- name: fix
|
14
|
+
description: Fix bug.
|
15
|
+
color: "5319e7"
|
16
|
+
- name: security
|
17
|
+
description: In case of vulnerabilities.
|
18
|
+
color: "0052cc"
|
data/.github/release.yml
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
changelog:
|
2
|
+
categories:
|
3
|
+
- title: Added
|
4
|
+
labels:
|
5
|
+
- add
|
6
|
+
- title: Changed
|
7
|
+
labels:
|
8
|
+
- change
|
9
|
+
- title: Deprecated
|
10
|
+
labels:
|
11
|
+
- deprecate
|
12
|
+
- title: Fixed
|
13
|
+
labels:
|
14
|
+
- fix
|
15
|
+
- title: Removed
|
16
|
+
labels:
|
17
|
+
- remove
|
18
|
+
- title: Security
|
19
|
+
labels:
|
20
|
+
- security
|
21
|
+
- title: Others
|
22
|
+
labels:
|
23
|
+
- "*"
|
@@ -0,0 +1,16 @@
|
|
1
|
+
name: github-label-sync
|
2
|
+
|
3
|
+
on:
|
4
|
+
push:
|
5
|
+
branches:
|
6
|
+
- master
|
7
|
+
paths:
|
8
|
+
- .github/labels.yml
|
9
|
+
- .github/workflows/github-label-sync.yml
|
10
|
+
workflow_dispatch:
|
11
|
+
|
12
|
+
jobs:
|
13
|
+
build:
|
14
|
+
runs-on: ubuntu-latest
|
15
|
+
steps:
|
16
|
+
- uses: r7kamura/github-label-sync-action@v0
|
@@ -2,6 +2,8 @@ require 'ruby-progressbar'
|
|
2
2
|
|
3
3
|
module Dekiru
|
4
4
|
class DataMigrationOperator
|
5
|
+
class NestedTransactionError < StandardError ; end
|
6
|
+
|
5
7
|
attr_reader :title, :stream, :result, :canceled, :started_at, :ended_at, :error
|
6
8
|
|
7
9
|
def self.execute(title, options = {}, &block)
|
@@ -25,7 +27,9 @@ module Dekiru
|
|
25
27
|
run(&block)
|
26
28
|
@result = true
|
27
29
|
else
|
28
|
-
|
30
|
+
raise NestedTransactionError if current_transaction_open?
|
31
|
+
|
32
|
+
@result = ActiveRecord::Base.transaction do
|
29
33
|
run(&block)
|
30
34
|
confirm?("\nAre you sure to commit?")
|
31
35
|
end
|
@@ -65,6 +69,10 @@ module Dekiru
|
|
65
69
|
|
66
70
|
private
|
67
71
|
|
72
|
+
def current_transaction_open?
|
73
|
+
ActiveRecord::Base.connection.current_transaction.open?
|
74
|
+
end
|
75
|
+
|
68
76
|
def log(message)
|
69
77
|
stream.puts(message)
|
70
78
|
end
|
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
@@ -27,7 +27,11 @@ describe Dekiru::DataMigrationOperator do
|
|
27
27
|
Dekiru::DummyStream.new
|
28
28
|
end
|
29
29
|
let(:without_transaction) { false }
|
30
|
-
let(:operator)
|
30
|
+
let(:operator) do
|
31
|
+
op = Dekiru::DataMigrationOperator.new('dummy', output: dummy_stream, without_transaction: without_transaction)
|
32
|
+
allow(op).to receive(:current_transaction_open?) { false }
|
33
|
+
op
|
34
|
+
end
|
31
35
|
|
32
36
|
describe '#execute' do
|
33
37
|
it 'confirm で yes' do
|
@@ -76,6 +80,14 @@ describe Dekiru::DataMigrationOperator do
|
|
76
80
|
expect(operator.stream.out).to include('Total time:')
|
77
81
|
end
|
78
82
|
|
83
|
+
context 'トランザクション内で呼び出された場合' do
|
84
|
+
before { allow(operator).to receive(:current_transaction_open?) { true } }
|
85
|
+
|
86
|
+
it '例外が発生すること' do
|
87
|
+
expect { operator.execute { log 'processing'; sleep 1.0 } }.to raise_error(Dekiru::DataMigrationOperator::NestedTransactionError)
|
88
|
+
end
|
89
|
+
end
|
90
|
+
|
79
91
|
context 'without_transaction: true のとき' do
|
80
92
|
let(:without_transaction) { true }
|
81
93
|
|
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.1
|
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-10-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: http_accept_language
|
@@ -129,6 +129,9 @@ executables: []
|
|
129
129
|
extensions: []
|
130
130
|
extra_rdoc_files: []
|
131
131
|
files:
|
132
|
+
- ".github/labels.yml"
|
133
|
+
- ".github/release.yml"
|
134
|
+
- ".github/workflows/github-label-sync.yml"
|
132
135
|
- ".github/workflows/rspec.yml"
|
133
136
|
- ".gitignore"
|
134
137
|
- ".ruby-version"
|
@@ -143,15 +146,12 @@ files:
|
|
143
146
|
- lib/dekiru/capybara/helpers/wait_for_position_stable.rb
|
144
147
|
- lib/dekiru/capybara/legacy_helpers.rb
|
145
148
|
- lib/dekiru/capybara/matchers.rb
|
146
|
-
- lib/dekiru/controller_additions.rb
|
147
149
|
- lib/dekiru/data_migration_operator.rb
|
148
150
|
- lib/dekiru/helper.rb
|
149
151
|
- lib/dekiru/mail_security_interceptor.rb
|
150
152
|
- lib/dekiru/railtie.rb
|
151
|
-
- lib/dekiru/smtp_check_mailer.rb
|
152
153
|
- lib/dekiru/task_with_logger.rb
|
153
154
|
- lib/dekiru/tasks/db.rake
|
154
|
-
- lib/dekiru/tasks/smtp_check.rake
|
155
155
|
- lib/dekiru/validators/existence.rb
|
156
156
|
- lib/dekiru/version.rb
|
157
157
|
- lib/generators/maintenance_script/USAGE
|
@@ -159,7 +159,6 @@ files:
|
|
159
159
|
- lib/generators/maintenance_script/templates/maintenance_script.rb.erb
|
160
160
|
- spec/dekiru/camelize_hash_spec.rb
|
161
161
|
- spec/dekiru/data_migration_operator_spec.rb
|
162
|
-
- spec/dekiru/helper_spec.rb
|
163
162
|
- spec/dekiru/mail_security_interceptor_spec.rb
|
164
163
|
- spec/dekiru/validators/existence_spec.rb
|
165
164
|
- spec/spec_helper.rb
|
@@ -190,7 +189,6 @@ summary: Usefull helper methods for Ruby on Rails
|
|
190
189
|
test_files:
|
191
190
|
- spec/dekiru/camelize_hash_spec.rb
|
192
191
|
- spec/dekiru/data_migration_operator_spec.rb
|
193
|
-
- spec/dekiru/helper_spec.rb
|
194
192
|
- spec/dekiru/mail_security_interceptor_spec.rb
|
195
193
|
- spec/dekiru/validators/existence_spec.rb
|
196
194
|
- 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
|