dekiru 0.1.4 → 0.1.5

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
  SHA256:
3
- metadata.gz: fa88f3d2cf47df7ed8a071acc0dbb0b86fa20e42c5ad3e72b3f23fb8c6f593b5
4
- data.tar.gz: ddabf00fc5c3dfcfb8a22f9103f7a8d90ea5e92b6c158bd2b4ea1936d48ebc81
3
+ metadata.gz: 6b9158fca8d9cc40d5f155f79a890299816aa58d5b6c6d720fdfc3eab25e8e86
4
+ data.tar.gz: 8915f77d047f5badca79f90353a21d378e2e4edc2181c8af7a88319648242bb7
5
5
  SHA512:
6
- metadata.gz: 02ed8451df03137d882758e3adb2fb06f7d8aa3b9e240ec84cd0e59a3bf460945f18919717010c44f58f13abbd6f468d39a33d37a29c9ad809334385ecbd6adc
7
- data.tar.gz: be1798f99193883c7bb7978f52b9e52e40bcd2e01e1b041159f110c1be6517922b7a6067978a423e3c9315bf9a870bceb465fae1234b2929a318d191d486066c
6
+ metadata.gz: b739269eb0c4559f72eeff701a99b98b678f12f482e3f628d71bb260ba44ceab83b92ba97ff7cee966f9da0b3188b76e3e6a51a8a6851892f4b8a428b570908b
7
+ data.tar.gz: 0c10cc3b802a98e3de67daa937ac68898600fa4274951ac2f7ac9bbe158c395aa14bf02cbaac4cfef21b80c1d5318a3d12dbe0eec612bd5d59042e9e90a9f15b
@@ -1,7 +1,7 @@
1
1
  rvm:
2
- - 2.3.3
3
- - 2.4.4
4
- - 2.5.1
2
+ - 2.4.6
3
+ - 2.5.5
4
+ - 2.6.3
5
5
 
6
6
  # NOTE: https://github.com/travis-ci/travis-ci/issues/8978
7
7
  before_install:
data/README.md CHANGED
@@ -113,7 +113,7 @@ Rake::Task['db:migrate'].enhance(['db:migrate:check_conflict']) if Rails.env.dev
113
113
 
114
114
  以下の設定をすると、宛先を指定しないメールを配信しようとした時に`Dekiru::MailSecurityInterceptor::NoToAdreessError`例外を発生させる。
115
115
 
116
- ※ toに空文字や空配列を指定してメールを配信しようとすると、bcc内のアドレスがtoに転記されるといった問題がある。これを未然に防ぐことができる。
116
+ ※ to に空文字や空配列を指定してメールを配信しようとすると、bcc 内のアドレスが to に転記されるといった問題がある。これを未然に防ぐことができる。
117
117
 
118
118
  ```ruby
119
119
  # config/initializer/dekiru.rb
@@ -154,6 +154,20 @@ Finished successfully: Demo migration
154
154
  Total time: 6.35 sec
155
155
  ```
156
156
 
157
+ ## Refinements
158
+
159
+ ### Dekiru::CamelizeHash
160
+
161
+ ```ruby
162
+ using Dekiru::CamelizeHash
163
+
164
+ { dekiru_rails: true }.camelize_keys(:lower)
165
+ # => { dekiruRails: true }
166
+
167
+ { dekiru_rails: { dekiru_rails: true } }.deep_camelize_keys(:lower)
168
+ # => { dekiruRails: { dekiruRails: true } }
169
+ ```
170
+
157
171
  ## Contributing
158
172
 
159
173
  1. Fork it
@@ -15,6 +15,8 @@ Gem::Specification.new do |gem|
15
15
  gem.require_paths = ["lib"]
16
16
  gem.version = Dekiru::VERSION
17
17
 
18
+ gem.required_ruby_version = '>= 2.4.0'
19
+
18
20
  gem.add_dependency 'http_accept_language', [">= 2.0.0"]
19
21
  gem.add_dependency 'rails'
20
22
  gem.add_dependency 'ruby-progressbar'
@@ -5,6 +5,7 @@ require 'dekiru/controller_additions'
5
5
  require 'dekiru/validators/existence'
6
6
  require 'dekiru/data_migration_operator'
7
7
  require 'dekiru/mail_security_interceptor'
8
+ require 'dekiru/camelize_hash'
8
9
 
9
10
  require 'active_support'
10
11
  require 'active_support/all'
@@ -0,0 +1,25 @@
1
+ module Dekiru
2
+ module CamelizeHash
3
+ refine ::Hash do
4
+ def camelize_keys(first_letter = :upper)
5
+ transform_keys do |k|
6
+ if k.is_a?(Symbol)
7
+ k.to_s.camelize(first_letter).to_sym
8
+ else
9
+ k.camelize(first_letter)
10
+ end
11
+ end
12
+ end
13
+
14
+ def deep_camelize_keys(first_letter = :upper)
15
+ deep_transform_keys do |k|
16
+ if k.is_a?(Symbol)
17
+ k.to_s.camelize(first_letter).to_sym
18
+ else
19
+ k.camelize(first_letter)
20
+ end
21
+ end
22
+ end
23
+ end
24
+ end
25
+ end
@@ -20,7 +20,7 @@ module Dekiru
20
20
  def execute(&block)
21
21
  @started_at = Time.current
22
22
  log "Start: #{title} at #{started_at}\n\n"
23
- @result = ActiveRecord::Base.transaction(requires_new: true) do
23
+ @result = ActiveRecord::Base.transaction(requires_new: true, joinable: false) do
24
24
  instance_eval(&block)
25
25
  confirm?("\nAre you sure to commit?")
26
26
  end
@@ -1,3 +1,3 @@
1
1
  module Dekiru
2
- VERSION = '0.1.4'
2
+ VERSION = '0.1.5'
3
3
  end
@@ -0,0 +1,64 @@
1
+ require "spec_helper"
2
+
3
+ describe Dekiru::CamelizeHash do
4
+ using Dekiru::CamelizeHash
5
+
6
+ let(:hash) do
7
+ hash = {
8
+ dekiru_rails: {
9
+ dekiru_rails: 'dekiru'
10
+ },
11
+ 'dekiru_ruby' => {
12
+ 'dekiru_ruby' => 'dekiru'
13
+ }
14
+ }
15
+ end
16
+
17
+ describe '#camelize_keys' do
18
+ it '一階層目のキーがキャメルケースに変換される' do
19
+ expect(hash.camelize_keys(:lower)).to match({
20
+ dekiruRails: {
21
+ dekiru_rails: 'dekiru'
22
+ },
23
+ 'dekiruRuby' => {
24
+ 'dekiru_ruby' => 'dekiru'
25
+ }
26
+ })
27
+ end
28
+
29
+ it '一階層目のキーがアッパーキャメルケースに変換される' do
30
+ expect(hash.camelize_keys).to match({
31
+ DekiruRails: {
32
+ dekiru_rails: 'dekiru'
33
+ },
34
+ 'DekiruRuby' => {
35
+ 'dekiru_ruby' => 'dekiru'
36
+ }
37
+ })
38
+ end
39
+ end
40
+
41
+ describe '#deep_camelize_keys' do
42
+ it '2階層目以降のキーもキャメルケースに変換される' do
43
+ expect(hash.deep_camelize_keys(:lower)).to match({
44
+ dekiruRails: {
45
+ dekiruRails: 'dekiru'
46
+ },
47
+ 'dekiruRuby' => {
48
+ 'dekiruRuby' => 'dekiru'
49
+ }
50
+ })
51
+ end
52
+
53
+ it '2階層目以降のキーもアッパーキャメルケースに変換される' do
54
+ expect(hash.deep_camelize_keys).to match({
55
+ DekiruRails: {
56
+ DekiruRails: 'dekiru'
57
+ },
58
+ 'DekiruRuby' => {
59
+ 'DekiruRuby' => 'dekiru'
60
+ }
61
+ })
62
+ end
63
+ end
64
+ end
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.1.4
4
+ version: 0.1.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Akihiro Matsumura
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-06-01 00:00:00.000000000 Z
11
+ date: 2019-06-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: http_accept_language
@@ -124,6 +124,7 @@ files:
124
124
  - Rakefile
125
125
  - dekiru.gemspec
126
126
  - lib/dekiru.rb
127
+ - lib/dekiru/camelize_hash.rb
127
128
  - lib/dekiru/capybara/helpers.rb
128
129
  - lib/dekiru/capybara/matchers.rb
129
130
  - lib/dekiru/controller_additions.rb
@@ -137,6 +138,7 @@ files:
137
138
  - lib/dekiru/tasks/smtp_check.rake
138
139
  - lib/dekiru/validators/existence.rb
139
140
  - lib/dekiru/version.rb
141
+ - spec/dekiru/camelize_hash_spec.rb
140
142
  - spec/dekiru/data_migration_operator_spec.rb
141
143
  - spec/dekiru/helper_spec.rb
142
144
  - spec/dekiru/mail_security_interceptor_spec.rb
@@ -155,7 +157,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
155
157
  requirements:
156
158
  - - ">="
157
159
  - !ruby/object:Gem::Version
158
- version: '0'
160
+ version: 2.4.0
159
161
  required_rubygems_version: !ruby/object:Gem::Requirement
160
162
  requirements:
161
163
  - - ">="
@@ -168,6 +170,7 @@ signing_key:
168
170
  specification_version: 4
169
171
  summary: Usefull helper methods for Ruby on Rails
170
172
  test_files:
173
+ - spec/dekiru/camelize_hash_spec.rb
171
174
  - spec/dekiru/data_migration_operator_spec.rb
172
175
  - spec/dekiru/helper_spec.rb
173
176
  - spec/dekiru/mail_security_interceptor_spec.rb