gyomu_ruby 0.0.4 → 0.0.6
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/.travis.yml +11 -0
- data/Gemfile +1 -1
- data/HISTORY.md +8 -0
- data/README.md +2 -0
- data/gyomu_ruby.gemspec +9 -10
- data/lib/gyomu_ruby/address_formatter.rb +39 -0
- data/lib/gyomu_ruby/all_your_site_are_belong_to_ssl.rb +21 -0
- data/lib/gyomu_ruby/core_ext/numeric/round.rb +15 -0
- data/lib/gyomu_ruby/core_ext/numeric.rb +6 -0
- data/lib/gyomu_ruby/core_ext/time/biz_year.rb +2 -2
- data/lib/gyomu_ruby/core_ext/time.rb +1 -1
- data/lib/gyomu_ruby/deprecation.rb +32 -0
- data/lib/gyomu_ruby/helper_utility.rb +30 -0
- data/lib/gyomu_ruby/master_data/form_builder_helper.rb +15 -0
- data/lib/gyomu_ruby/master_data/form_helper.rb +18 -0
- data/lib/gyomu_ruby/master_data.rb +63 -0
- data/lib/gyomu_ruby/{ordinary_system_development/translated_from.rb → translated_from.rb} +2 -1
- data/lib/gyomu_ruby/validators/hankaku_validator.rb +14 -0
- data/lib/gyomu_ruby/version.rb +1 -1
- data/lib/gyomu_ruby/word_normalizer.rb +63 -0
- data/lib/gyomu_ruby.rb +17 -2
- data/spec/core_ext/numeric_spec.rb +18 -0
- data/spec/core_ext/time_spec.rb +9 -9
- data/spec/fixtures/images/esm-gravater.png +0 -0
- data/spec/gyomu_ruby/address_formatter_spec.rb +105 -0
- data/spec/gyomu_ruby/master_data/form_builder_helper_spec.rb +23 -0
- data/spec/gyomu_ruby/master_data_spec.rb +31 -0
- data/spec/spec_helper.rb +2 -0
- metadata +53 -43
- data/lib/gyomu_ruby/amazon_web_service/file_bucket.rb +0 -74
- data/lib/gyomu_ruby/core_ext/integer/round.rb +0 -9
- data/lib/gyomu_ruby/core_ext/integer.rb +0 -1
- data/lib/gyomu_ruby/ordinary_system_development/address_formatter.rb +0 -36
- data/lib/gyomu_ruby/ordinary_system_development/all_your_site_are_belong_to_ssl.rb +0 -22
- data/lib/gyomu_ruby/ordinary_system_development.rb +0 -10
- data/masters/prefectures.csv +0 -47
- data/spec/core_ext/integer_spec.rb +0 -18
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: f6cf4eeaf98d3ccfd9f8f468e27d1159c01399bbc4f148ea7466892e5e12b7e7
|
4
|
+
data.tar.gz: 2ff6f528d51c25c6632f9a33494c5b8266df59fb9f298c420ed9c1175da38227
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 5331ccae7df722d2fada5278145346f44dfd016672fb652811b23ff2ff5c03b60119e506d28d7fb68992773de95bc76719437acf389b36e316682e0e68795c11
|
7
|
+
data.tar.gz: ee1d39fbec589cd7e88c6aec069e2be6761433b5e66f26b25edd6f459552cbe8f337714caa0400957427828968252189eaacd97993db6955151034c592196c1e
|
data/.travis.yml
ADDED
data/Gemfile
CHANGED
data/HISTORY.md
CHANGED
@@ -1,3 +1,11 @@
|
|
1
|
+
# Version 0.0.6
|
2
|
+
|
3
|
+
Remove GyomuRuby::AWS::FileBucket use fog (or so) directly
|
4
|
+
|
5
|
+
# Version 0.0.5
|
6
|
+
|
7
|
+
* rename Integer#ceil(offset), Integer#floor(offset) to Numeric#roundup(offset), Numeric#rounddown(offset)
|
8
|
+
|
1
9
|
# Version 0.0.4
|
2
10
|
|
3
11
|
* added Integer#ceil(offset), Integer#floor(offset)
|
data/README.md
CHANGED
data/gyomu_ruby.gemspec
CHANGED
@@ -1,24 +1,23 @@
|
|
1
1
|
# -*- encoding: utf-8 -*-
|
2
|
-
$:.push File.expand_path(
|
3
|
-
require
|
2
|
+
$:.push File.expand_path('../lib', __FILE__)
|
3
|
+
require 'gyomu_ruby/version'
|
4
4
|
|
5
5
|
Gem::Specification.new do |s|
|
6
|
-
s.name =
|
6
|
+
s.name = 'gyomu_ruby'
|
7
7
|
s.version = GyomuRuby::VERSION
|
8
8
|
s.platform = Gem::Platform::RUBY
|
9
|
-
s.authors = [
|
10
|
-
s.
|
11
|
-
s.homepage = "http://www.esm.co.jp/"
|
9
|
+
s.authors = ['ESM, Inc.']
|
10
|
+
s.homepage = 'https://agile.esm.co.jp/'
|
12
11
|
s.summary = %q{GyomuRuby}
|
13
12
|
s.description = %q{GyomuRuby}
|
14
13
|
|
15
14
|
s.files = `git ls-files`.split("\n")
|
16
15
|
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
17
16
|
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
18
|
-
s.require_paths = [
|
17
|
+
s.require_paths = ['lib']
|
19
18
|
|
20
|
-
s.add_dependency
|
21
|
-
s.add_dependency
|
19
|
+
s.add_dependency 'activesupport', ['>= 3.0']
|
20
|
+
s.add_dependency 'moji'
|
22
21
|
|
23
|
-
s.add_development_dependency
|
22
|
+
s.add_development_dependency 'rspec', ['>= 3.0.0']
|
24
23
|
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
|
3
|
+
require 'active_support'
|
4
|
+
require 'moji'
|
5
|
+
|
6
|
+
module GyomuRuby
|
7
|
+
module AddressFormatter
|
8
|
+
ext_tel_numbers = File.read(
|
9
|
+
File.expand_path('../../masters/ext_tel_numbers.csv', File.dirname(__FILE__))
|
10
|
+
).lines.map{|n| "0#{n.strip}" }
|
11
|
+
|
12
|
+
EXT_TEL_NUMBERS = (ext_tel_numbers + %w[050 070 080 090 0120]).sort.reverse.freeze
|
13
|
+
EXT_TEL_NUMBERS_RE = /\A(#{EXT_TEL_NUMBERS.sort.reverse.join('|')})/uo
|
14
|
+
|
15
|
+
module_function
|
16
|
+
|
17
|
+
def format_zipcode(zipcode_string, blank = '')
|
18
|
+
return blank if zipcode_string.blank?
|
19
|
+
zipcode = Moji.zen_to_han(zipcode_string, Moji::NUMBER | Moji::SYMBOL)
|
20
|
+
digits_only = zipcode.scan(/\d/)
|
21
|
+
[digits_only[0..2], '-', digits_only[3..6]].flatten.join
|
22
|
+
end
|
23
|
+
|
24
|
+
def format_tel_no(telno_numeric_string, blank = '')
|
25
|
+
return blank if telno_numeric_string.blank?
|
26
|
+
telno_numeric_string.to_s.
|
27
|
+
sub(EXT_TEL_NUMBERS_RE){ "#{$1}-" }.
|
28
|
+
sub(/(\d{4})\Z/) { "-#{$1}" }
|
29
|
+
end
|
30
|
+
|
31
|
+
def prefecture_name(prefecture_code, blank = '')
|
32
|
+
GyomuRuby::Deprecation.deprecated_method_warning(:prefecture_name, "use GyomuRuby::MasterData.prefecture_name instead")
|
33
|
+
|
34
|
+
return blank if prefecture_code.blank?
|
35
|
+
|
36
|
+
MasterData.prefecture_name(prefecture_code)
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
# coding:us-ascii
|
2
|
+
|
3
|
+
require 'rack'
|
4
|
+
|
5
|
+
module GyomuRuby
|
6
|
+
class AllYourSiteAreBelongToSsl
|
7
|
+
def initialize(app)
|
8
|
+
@app = app
|
9
|
+
end
|
10
|
+
|
11
|
+
def call(env)
|
12
|
+
if env['HTTPS'] == 'on' || env['HTTP_X_FORWARDED_PROTO'] == 'https'
|
13
|
+
@app.call(env)
|
14
|
+
else
|
15
|
+
url = Rack::Request.new(env).url.sub(/^http:/, 'https:')
|
16
|
+
body = "<html><body>You are being <a href=\"#{url}\">redirected</a>.</body></html>"
|
17
|
+
[301, {'Location' => url, 'Content-Type' => 'text/html'}, [body]]
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
module GyomuRuby
|
2
|
+
module CoreExt
|
3
|
+
module Numeric
|
4
|
+
module Round
|
5
|
+
def round_up(unit) # nodoc
|
6
|
+
((self + unit) * Rational(1, unit)).ceil * unit - unit
|
7
|
+
end
|
8
|
+
|
9
|
+
def round_down(unit) # nodoc
|
10
|
+
(self * Rational(1, unit)).floor * unit
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
module GyomuRuby
|
2
|
+
module Deprecation
|
3
|
+
module_function
|
4
|
+
|
5
|
+
def deprecated_method_warning(method_name, message)
|
6
|
+
warning = "DEPRECATIOPN WARNING:"
|
7
|
+
warning = "#{warning} #{method_name} is deprecated and will be removed in the near future"
|
8
|
+
warning = "#{warning} (#{message})"
|
9
|
+
STDERR.puts(warning)
|
10
|
+
end
|
11
|
+
|
12
|
+
module DeprecatedConstant
|
13
|
+
private
|
14
|
+
|
15
|
+
def self.extended(constant)
|
16
|
+
constant.instance_variable_set :@__new_constants, {}
|
17
|
+
end
|
18
|
+
|
19
|
+
def const_missing(name)
|
20
|
+
return super unless constant = @__new_constants[name]
|
21
|
+
|
22
|
+
STDERR.puts "DEPRECATIOPN WARNING: #{self.name}::#{name} is deprecated and will be removed in the near future(use #{constant.name} instead)"
|
23
|
+
|
24
|
+
constant
|
25
|
+
end
|
26
|
+
|
27
|
+
def deprecated(name, new_constant)
|
28
|
+
@__new_constants.update name => new_constant
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
module GyomuRuby::HelperUtility
|
2
|
+
|
3
|
+
def human(klass, attribute = nil)
|
4
|
+
if attribute
|
5
|
+
klass.human_attribute_name(attribute)
|
6
|
+
else
|
7
|
+
klass.model_name.human
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
def routed_to?(*signatures)
|
12
|
+
[controller_name, action_name].join('#').in?(Array(signatures))
|
13
|
+
end
|
14
|
+
|
15
|
+
def nice_datetime_duration(from, to, join_word = ' - ')
|
16
|
+
from, to = [from, to].map(&:localtime)
|
17
|
+
|
18
|
+
if from.localtime.to_date == to.localtime.to_date
|
19
|
+
[l(from), to.strftime("%H:%M")]
|
20
|
+
else
|
21
|
+
[l(from), l(to)]
|
22
|
+
end.join(join_word)
|
23
|
+
end
|
24
|
+
|
25
|
+
def with_paging(objects, opts = {}, &block)
|
26
|
+
inner = capture { block.call(objects) }
|
27
|
+
render partial: 'shared/paging', locals: {objects: objects, inner: inner, opts: opts}
|
28
|
+
end
|
29
|
+
|
30
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
|
3
|
+
module GyomuRuby
|
4
|
+
module MasterData
|
5
|
+
module FormBuilderHelper
|
6
|
+
[:prefecture, :currency].each do |master|
|
7
|
+
define_method %(#{master}_select) do |attribute, options = {}, html_options = {}, &block|
|
8
|
+
choices = FormHelper.__send__("options_for_#{master}_select")
|
9
|
+
|
10
|
+
select(attribute, choices, options, html_options, &block)
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
|
3
|
+
require 'active_support/core_ext/string'
|
4
|
+
|
5
|
+
module GyomuRuby
|
6
|
+
module MasterData
|
7
|
+
module FormHelper
|
8
|
+
%w(prefecture currency).each do |master|
|
9
|
+
method_name = %(options_for_#{master}_select)
|
10
|
+
|
11
|
+
define_method method_name do
|
12
|
+
MasterData.data[master.pluralize.intern].invert.to_a
|
13
|
+
end
|
14
|
+
module_function method_name
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,63 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
|
3
|
+
require 'active_support/deprecation'
|
4
|
+
require 'active_support/core_ext/module'
|
5
|
+
|
6
|
+
module GyomuRuby
|
7
|
+
module MasterData
|
8
|
+
autoload :FormHelper, 'gyomu_ruby/master_data/form_helper'
|
9
|
+
autoload :FormBuilderHelper, 'gyomu_ruby/master_data/form_builder_helper'
|
10
|
+
|
11
|
+
# ISO-4217 に従い、必要になるたびに足しています
|
12
|
+
currencies = {
|
13
|
+
'JPY' => '円',
|
14
|
+
'USD' => '米ドル',
|
15
|
+
'EUR' => 'ユーロ'
|
16
|
+
}
|
17
|
+
|
18
|
+
# JIS X 0401に定められた都道府県コードを定義
|
19
|
+
# 東北、関東、、などの地域の括りは https://www.lasdec.or.jp/cms/1,0,14.html のものを参照している
|
20
|
+
prefectures, areas = {}, {}
|
21
|
+
{
|
22
|
+
'北海道' => %w(北海道),
|
23
|
+
'東北' => %w(青森県 岩手県 宮城県 秋田県 山形県 福島県),
|
24
|
+
'関東' => %w(茨城県 栃木県 群馬県 埼玉県 千葉県 東京都 神奈川県),
|
25
|
+
'中部' => %w(新潟県 富山県 石川県 福井県 山梨県 長野県 岐阜県 静岡県 愛知県),
|
26
|
+
'近畿' => %w(三重県 滋賀県 京都府 大阪府 兵庫県 奈良県 和歌山県),
|
27
|
+
'中国' => %w(鳥取県 島根県 岡山県 広島県 山口県),
|
28
|
+
'四国' => %w(徳島県 香川県 愛媛県 高知県),
|
29
|
+
'九州' => %w(福岡県 佐賀県 長崎県 熊本県 大分県 宮崎県 鹿児島県 沖縄県)
|
30
|
+
}.each do |area_name, prefecture_names|
|
31
|
+
areas[area_name] ||= []
|
32
|
+
|
33
|
+
prefecture_names.each.with_index(prefectures.length) do |prefecture_name, index|
|
34
|
+
code = '%02d' % index.next
|
35
|
+
|
36
|
+
prefectures[code] = prefecture_name
|
37
|
+
areas[area_name] << code
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
mattr_accessor :data
|
42
|
+
|
43
|
+
self.data = {currencies: currencies, prefectures: prefectures, areas: areas}
|
44
|
+
|
45
|
+
module_function
|
46
|
+
|
47
|
+
def currency_name(code)
|
48
|
+
lookup(:currencies, code.to_s.upcase)
|
49
|
+
end
|
50
|
+
|
51
|
+
def prefecture_name(code)
|
52
|
+
lookup(:prefectures, "%02d" % code.to_i)
|
53
|
+
end
|
54
|
+
|
55
|
+
def prefecture_codes_by_area(name)
|
56
|
+
lookup(:areas, name)
|
57
|
+
end
|
58
|
+
|
59
|
+
def lookup(type, val)
|
60
|
+
MasterData.data[type.intern][val]
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
#coding: utf-8
|
2
|
+
require 'moji'
|
3
|
+
|
4
|
+
module GyomuRuby::Validators
|
5
|
+
class HankakuValidator < ActiveModel::EachValidator
|
6
|
+
def validate_each(record, attribute, str)
|
7
|
+
record.errors[attribute] << "は、半角文字で入力してください" unless hankaku?(str)
|
8
|
+
end
|
9
|
+
|
10
|
+
def hankaku?(str)
|
11
|
+
str.blank? || str =~ /\A#{Moji.han}+\Z/
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
data/lib/gyomu_ruby/version.rb
CHANGED
@@ -0,0 +1,63 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
|
3
|
+
require 'moji'
|
4
|
+
|
5
|
+
module GyomuRuby
|
6
|
+
module WordNormalizer
|
7
|
+
extend self
|
8
|
+
def to_doublewidth_hiragana(word)
|
9
|
+
normalize_symbol_unicode(Moji.kata_to_hira(Moji.han_to_zen(word || '', Moji::KANA)))
|
10
|
+
end
|
11
|
+
alias to_kana to_doublewidth_hiragana
|
12
|
+
|
13
|
+
def normalize_unconversion_symbol_unicode(word)
|
14
|
+
word.tap do |w|
|
15
|
+
w.gsub!(/\u2212|\u2012|\u2013|\u2014/){ "\u30fc" }
|
16
|
+
w.gsub!(/\u301c/){ "\uff5e" }
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
def normalize_symbol_unicode(word)
|
21
|
+
normalize_unconversion_symbol_unicode(word).tap do |w|
|
22
|
+
w.gsub!(/\u002d|\uff0d|\u2015|\u2500/){ "\u30fc" }
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
def to_time(word)
|
27
|
+
if word.acts_like?(:time) && word.acts_like_time?
|
28
|
+
word
|
29
|
+
else
|
30
|
+
Time.parse(word.to_s) rescue nil
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
def to_date(word)
|
35
|
+
if word.acts_like?(:date) && word.acts_like_date?
|
36
|
+
word
|
37
|
+
elsif word.respond_to?(:to_date)
|
38
|
+
word.to_date
|
39
|
+
else
|
40
|
+
Date.parse(word.to_s) rescue nil
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
def to_array(words)
|
45
|
+
if words.is_a?(Hash)
|
46
|
+
words.inject([]){|memo, (k,v)| v.blank? ? memo : memo << k.to_s }
|
47
|
+
else
|
48
|
+
Array(words)
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
# XXX 0x20が壊れる詳細を追いかける
|
53
|
+
def to_hankaku(word)
|
54
|
+
return '' if word.blank?
|
55
|
+
Moji.zen_to_han(Moji.han_to_zen(normalize_symbol_unicode(word), Moji::SYMBOL)).gsub(/\uff70/){ "\u002d" }
|
56
|
+
end
|
57
|
+
|
58
|
+
def to_numeric(word)
|
59
|
+
return word.to_s if word.is_a?(Numeric)
|
60
|
+
to_hankaku(word || '').scan(/\d/).join
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
data/lib/gyomu_ruby.rb
CHANGED
@@ -1,4 +1,19 @@
|
|
1
1
|
# coding: utf-8
|
2
2
|
require 'gyomu_ruby/core_ext/time'
|
3
|
-
require 'gyomu_ruby/
|
4
|
-
require 'gyomu_ruby/
|
3
|
+
require 'gyomu_ruby/core_ext/numeric'
|
4
|
+
require 'gyomu_ruby/deprecation'
|
5
|
+
|
6
|
+
module GyomuRuby
|
7
|
+
autoload :AmazonWebService, 'gyomu_ruby/amazon_web_service'
|
8
|
+
autoload :MasterData, 'gyomu_ruby/master_data'
|
9
|
+
autoload :AddressFormatter, 'gyomu_ruby/address_formatter'
|
10
|
+
autoload :AllYourSiteAreBelongToSsl, 'gyomu_ruby/all_your_site_are_belong_to_ssl'
|
11
|
+
autoload :Translation, 'gyomu_ruby/translated_from'
|
12
|
+
autoload :WordNormalizer, 'gyomu_ruby/word_normalizer'
|
13
|
+
autoload :AddressFormatter, 'gyomu_ruby/address_formatter'
|
14
|
+
|
15
|
+
extend GyomuRuby::Deprecation::DeprecatedConstant
|
16
|
+
|
17
|
+
deprecated :OrdinarySystemDevelopment, GyomuRuby
|
18
|
+
deprecated :OSD, GyomuRuby
|
19
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'gyomu_ruby/core_ext/numeric'
|
3
|
+
|
4
|
+
describe Numeric, 'gyomu_ruby extentions' do
|
5
|
+
describe '#round_up' do
|
6
|
+
it { expect(101.round_up(50)).to eq(150) }
|
7
|
+
it { expect(151.round_up(50)).to eq(200) }
|
8
|
+
it { expect(123.round_up(3)).to eq(123) }
|
9
|
+
it { expect(10.1.round_up(2)).to eq(12) }
|
10
|
+
end
|
11
|
+
|
12
|
+
describe '#round_down' do
|
13
|
+
it { expect(101.round_down(50)).to eq(100) }
|
14
|
+
it { expect(151.round_down(50)).to eq(150) }
|
15
|
+
it { expect(123.round_down(3)).to eq(123) }
|
16
|
+
it { expect(10.1.round_down(2)).to eq(10) }
|
17
|
+
end
|
18
|
+
end
|
data/spec/core_ext/time_spec.rb
CHANGED
@@ -4,21 +4,21 @@ require 'gyomu_ruby/core_ext/time'
|
|
4
4
|
describe Time, 'gyomu_ruby extentions' do
|
5
5
|
describe '#biz_year' do
|
6
6
|
context 'default boundary' do
|
7
|
-
specify { Time.local(2011, 4, 1).biz_year.
|
8
|
-
specify { Time.local(2011,12,31).biz_year.
|
9
|
-
specify { Time.local(2012, 1, 1).biz_year.
|
10
|
-
specify { Time.local(2012, 3,31).biz_year.
|
7
|
+
specify { expect(Time.local(2011, 4, 1).biz_year).to eq(2011) }
|
8
|
+
specify { expect(Time.local(2011,12,31).biz_year).to eq(2011) }
|
9
|
+
specify { expect(Time.local(2012, 1, 1).biz_year).to eq(2011) }
|
10
|
+
specify { expect(Time.local(2012, 3,31).biz_year).to eq(2011) }
|
11
11
|
end
|
12
12
|
|
13
13
|
context 'custom boundary at 4/2' do
|
14
|
-
specify { Time.local(2011, 4, 1).biz_year(4, 2).
|
15
|
-
specify { Time.local(2011, 4, 2).biz_year(4, 2).
|
14
|
+
specify { expect(Time.local(2011, 4, 1).biz_year(4, 2)).to eq(2010) }
|
15
|
+
specify { expect(Time.local(2011, 4, 2).biz_year(4, 2)).to eq(2011) }
|
16
16
|
end
|
17
17
|
|
18
18
|
context 'custom boundary at 3/31' do
|
19
|
-
specify { Time.local(2011, 3,30).biz_year(3, 31).
|
20
|
-
specify { Time.local(2011, 3,31).biz_year(3, 31).
|
21
|
-
specify { Time.local(2011, 4, 1).biz_year(3, 31).
|
19
|
+
specify { expect(Time.local(2011, 3,30).biz_year(3, 31)).to eq(2010) }
|
20
|
+
specify { expect(Time.local(2011, 3,31).biz_year(3, 31)).to eq(2011) }
|
21
|
+
specify { expect(Time.local(2011, 4, 1).biz_year(3, 31)).to eq(2011) }
|
22
22
|
end
|
23
23
|
end
|
24
24
|
end
|
Binary file
|
@@ -0,0 +1,105 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
require 'spec_helper'
|
3
|
+
|
4
|
+
module GyomuRuby
|
5
|
+
describe AddressFormatter do
|
6
|
+
let(:described_module) { described_class }
|
7
|
+
|
8
|
+
describe '.format_zipcode' do
|
9
|
+
context 'when 7 digit number' do
|
10
|
+
subject { described_module.format_zipcode('1234567') }
|
11
|
+
it { is_expected.to eq('123-4567') }
|
12
|
+
end
|
13
|
+
|
14
|
+
context 'when 3 digit and 4 digit number separated by hyphen' do
|
15
|
+
subject { described_module.format_zipcode('234-5678') }
|
16
|
+
it { is_expected.to eq('234-5678') }
|
17
|
+
end
|
18
|
+
|
19
|
+
context 'when 7 digit number in Zenkaku' do
|
20
|
+
subject { described_module.format_zipcode('3456789') }
|
21
|
+
it { is_expected.to eq('345-6789') }
|
22
|
+
end
|
23
|
+
|
24
|
+
context 'when 3 digit and 4 digit number separated by hyphen in Zenkaku' do
|
25
|
+
subject { described_module.format_zipcode('456−7890') }
|
26
|
+
it { is_expected.to eq('456-7890') }
|
27
|
+
end
|
28
|
+
|
29
|
+
context 'when passed blank' do
|
30
|
+
context 'with empty string' do
|
31
|
+
subject { described_module.format_zipcode('') }
|
32
|
+
it { is_expected.to eq('') }
|
33
|
+
end
|
34
|
+
|
35
|
+
context 'with nil' do
|
36
|
+
subject { described_module.format_zipcode(nil) }
|
37
|
+
it { is_expected.to eq('') }
|
38
|
+
end
|
39
|
+
|
40
|
+
context 'with whitespace' do
|
41
|
+
subject { described_module.format_zipcode(' ') }
|
42
|
+
it { is_expected.to eq('') }
|
43
|
+
end
|
44
|
+
|
45
|
+
context 'with whitespaces' do
|
46
|
+
subject { described_module.format_zipcode(' ' * 4) }
|
47
|
+
it { is_expected.to eq('') }
|
48
|
+
end
|
49
|
+
|
50
|
+
context 'specified blank character' do
|
51
|
+
subject { described_module.format_zipcode('', '***') }
|
52
|
+
it { is_expected.to eq('***')}
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
describe '.format_tel_no' do
|
58
|
+
let(:telno_numeric_string) { '03123456' }
|
59
|
+
|
60
|
+
subject { described_module.format_tel_no(telno_numeric_string) }
|
61
|
+
|
62
|
+
context 'when passed blank' do
|
63
|
+
before do
|
64
|
+
allow(telno_numeric_string).to receive(:blank?).and_return(true)
|
65
|
+
end
|
66
|
+
|
67
|
+
it { is_expected.to eq '' }
|
68
|
+
end
|
69
|
+
|
70
|
+
context 'when valid area code' do
|
71
|
+
context 'when more than 4 digit number after area code' do
|
72
|
+
let(:telno_numeric_string) { '03123456' }
|
73
|
+
it { is_expected.to eq '03-12-3456' }
|
74
|
+
end
|
75
|
+
|
76
|
+
context 'when 4 digit number after area code' do
|
77
|
+
let(:telno_numeric_string) { '031234' }
|
78
|
+
it { is_expected.to eq '03--1234' }
|
79
|
+
end
|
80
|
+
|
81
|
+
context 'when less than or equal to 4 digit number after area code' do
|
82
|
+
let(:telno_numeric_string) { '03123' }
|
83
|
+
it { is_expected.to eq '03-123' }
|
84
|
+
end
|
85
|
+
end
|
86
|
+
|
87
|
+
context 'when invalid area code' do
|
88
|
+
context 'when more than 4 digit number' do
|
89
|
+
let(:telno_numeric_string) { '00000' }
|
90
|
+
it { is_expected.to eq '0-0000' }
|
91
|
+
end
|
92
|
+
|
93
|
+
context 'when 4 digit number' do
|
94
|
+
let(:telno_numeric_string) { '0000' }
|
95
|
+
it { is_expected.to eq '-0000' }
|
96
|
+
end
|
97
|
+
|
98
|
+
context 'when less than 4 digit number' do
|
99
|
+
let(:telno_numeric_string) { '000' }
|
100
|
+
it { is_expected.to eq '000' }
|
101
|
+
end
|
102
|
+
end
|
103
|
+
end
|
104
|
+
end
|
105
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe GyomuRuby::MasterData::FormBuilderHelper do
|
4
|
+
include GyomuRuby::MasterData::FormHelper
|
5
|
+
|
6
|
+
let(:fake_builder) { Object.new.extend(GyomuRuby::MasterData::FormBuilderHelper) }
|
7
|
+
|
8
|
+
describe '#prefecture_select' do
|
9
|
+
it 'calls :select with choices for prefectures' do
|
10
|
+
expect(fake_builder).to receive(:select).with(:attr_name, options_for_prefecture_select, {}, {}).and_return(true)
|
11
|
+
|
12
|
+
fake_builder.prefecture_select(:attr_name)
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
describe '#currency_select' do
|
17
|
+
it 'calls :select with choices for currencies' do
|
18
|
+
expect(fake_builder).to receive(:select).with(:attr_name, options_for_currency_select, {}, {}).and_return(true)
|
19
|
+
|
20
|
+
fake_builder.currency_select(:attr_name)
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
|
3
|
+
require 'spec_helper'
|
4
|
+
|
5
|
+
describe GyomuRuby::MasterData do
|
6
|
+
describe '.prefecture_name' do
|
7
|
+
context 'code in String' do
|
8
|
+
subject { GyomuRuby::MasterData.prefecture_name('01') }
|
9
|
+
|
10
|
+
it { is_expected.to eq('北海道') }
|
11
|
+
end
|
12
|
+
|
13
|
+
context 'code in Fixnum' do
|
14
|
+
subject { GyomuRuby::MasterData.prefecture_name(1) }
|
15
|
+
|
16
|
+
it { is_expected.to eq('北海道') }
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
describe '.prefecture_codes_by_area' do
|
21
|
+
subject { GyomuRuby::MasterData.prefecture_codes_by_area('関東') }
|
22
|
+
|
23
|
+
it { is_expected.to eq(%w(08 09 10 11 12 13 14)) }
|
24
|
+
end
|
25
|
+
|
26
|
+
describe '.currency_name' do
|
27
|
+
subject { GyomuRuby::MasterData.currency_name('USD') }
|
28
|
+
|
29
|
+
it { is_expected.to eq('米ドル') }
|
30
|
+
end
|
31
|
+
end
|
data/spec/spec_helper.rb
CHANGED
metadata
CHANGED
@@ -1,108 +1,118 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: gyomu_ruby
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
5
|
-
prerelease:
|
4
|
+
version: 0.0.6
|
6
5
|
platform: ruby
|
7
6
|
authors:
|
8
|
-
-
|
7
|
+
- ESM, Inc.
|
9
8
|
autorequire:
|
10
9
|
bindir: bin
|
11
10
|
cert_chain: []
|
12
|
-
date:
|
11
|
+
date: 2024-01-17 00:00:00.000000000 Z
|
13
12
|
dependencies:
|
14
13
|
- !ruby/object:Gem::Dependency
|
15
14
|
name: activesupport
|
16
|
-
requirement:
|
17
|
-
none: false
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
18
16
|
requirements:
|
19
|
-
- -
|
17
|
+
- - ">="
|
20
18
|
- !ruby/object:Gem::Version
|
21
19
|
version: '3.0'
|
22
20
|
type: :runtime
|
23
21
|
prerelease: false
|
24
|
-
version_requirements:
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '3.0'
|
25
27
|
- !ruby/object:Gem::Dependency
|
26
|
-
name:
|
27
|
-
requirement:
|
28
|
-
none: false
|
28
|
+
name: moji
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
29
30
|
requirements:
|
30
|
-
- -
|
31
|
+
- - ">="
|
31
32
|
- !ruby/object:Gem::Version
|
32
33
|
version: '0'
|
33
34
|
type: :runtime
|
34
35
|
prerelease: false
|
35
|
-
version_requirements:
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
36
41
|
- !ruby/object:Gem::Dependency
|
37
42
|
name: rspec
|
38
|
-
requirement:
|
39
|
-
none: false
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
40
44
|
requirements:
|
41
|
-
- -
|
45
|
+
- - ">="
|
42
46
|
- !ruby/object:Gem::Version
|
43
|
-
version:
|
47
|
+
version: 3.0.0
|
44
48
|
type: :development
|
45
49
|
prerelease: false
|
46
|
-
version_requirements:
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: 3.0.0
|
47
55
|
description: GyomuRuby
|
48
|
-
email:
|
49
|
-
- rubyagile@qwik.tky.esm.co.jp
|
56
|
+
email:
|
50
57
|
executables: []
|
51
58
|
extensions: []
|
52
59
|
extra_rdoc_files: []
|
53
60
|
files:
|
54
|
-
- .gitignore
|
61
|
+
- ".gitignore"
|
62
|
+
- ".travis.yml"
|
55
63
|
- Gemfile
|
56
64
|
- HISTORY.md
|
57
65
|
- README.md
|
58
66
|
- Rakefile
|
59
67
|
- gyomu_ruby.gemspec
|
60
68
|
- lib/gyomu_ruby.rb
|
61
|
-
- lib/gyomu_ruby/
|
62
|
-
- lib/gyomu_ruby/
|
63
|
-
- lib/gyomu_ruby/core_ext/
|
69
|
+
- lib/gyomu_ruby/address_formatter.rb
|
70
|
+
- lib/gyomu_ruby/all_your_site_are_belong_to_ssl.rb
|
71
|
+
- lib/gyomu_ruby/core_ext/numeric.rb
|
72
|
+
- lib/gyomu_ruby/core_ext/numeric/round.rb
|
64
73
|
- lib/gyomu_ruby/core_ext/time.rb
|
65
74
|
- lib/gyomu_ruby/core_ext/time/biz_year.rb
|
75
|
+
- lib/gyomu_ruby/deprecation.rb
|
66
76
|
- lib/gyomu_ruby/forgery/dictionaries/ja_female_first_names
|
67
77
|
- lib/gyomu_ruby/forgery/dictionaries/ja_last_names
|
68
78
|
- lib/gyomu_ruby/forgery/dictionaries/ja_male_first_names
|
69
79
|
- lib/gyomu_ruby/forgery/forgeries/ja_name.rb
|
70
|
-
- lib/gyomu_ruby/
|
71
|
-
- lib/gyomu_ruby/
|
72
|
-
- lib/gyomu_ruby/
|
73
|
-
- lib/gyomu_ruby/
|
80
|
+
- lib/gyomu_ruby/helper_utility.rb
|
81
|
+
- lib/gyomu_ruby/master_data.rb
|
82
|
+
- lib/gyomu_ruby/master_data/form_builder_helper.rb
|
83
|
+
- lib/gyomu_ruby/master_data/form_helper.rb
|
84
|
+
- lib/gyomu_ruby/translated_from.rb
|
85
|
+
- lib/gyomu_ruby/validators/hankaku_validator.rb
|
74
86
|
- lib/gyomu_ruby/version.rb
|
87
|
+
- lib/gyomu_ruby/word_normalizer.rb
|
75
88
|
- masters/ext_tel_numbers.csv
|
76
|
-
-
|
77
|
-
- spec/core_ext/integer_spec.rb
|
89
|
+
- spec/core_ext/numeric_spec.rb
|
78
90
|
- spec/core_ext/time_spec.rb
|
91
|
+
- spec/fixtures/images/esm-gravater.png
|
92
|
+
- spec/gyomu_ruby/address_formatter_spec.rb
|
93
|
+
- spec/gyomu_ruby/master_data/form_builder_helper_spec.rb
|
94
|
+
- spec/gyomu_ruby/master_data_spec.rb
|
79
95
|
- spec/spec_helper.rb
|
80
|
-
homepage:
|
96
|
+
homepage: https://agile.esm.co.jp/
|
81
97
|
licenses: []
|
98
|
+
metadata: {}
|
82
99
|
post_install_message:
|
83
100
|
rdoc_options: []
|
84
101
|
require_paths:
|
85
102
|
- lib
|
86
103
|
required_ruby_version: !ruby/object:Gem::Requirement
|
87
|
-
none: false
|
88
104
|
requirements:
|
89
|
-
- -
|
105
|
+
- - ">="
|
90
106
|
- !ruby/object:Gem::Version
|
91
107
|
version: '0'
|
92
108
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
93
|
-
none: false
|
94
109
|
requirements:
|
95
|
-
- -
|
110
|
+
- - ">="
|
96
111
|
- !ruby/object:Gem::Version
|
97
112
|
version: '0'
|
98
113
|
requirements: []
|
99
|
-
|
100
|
-
rubygems_version: 1.8.15
|
114
|
+
rubygems_version: 3.4.10
|
101
115
|
signing_key:
|
102
|
-
specification_version:
|
116
|
+
specification_version: 4
|
103
117
|
summary: GyomuRuby
|
104
|
-
test_files:
|
105
|
-
- spec/core_ext/integer_spec.rb
|
106
|
-
- spec/core_ext/time_spec.rb
|
107
|
-
- spec/spec_helper.rb
|
108
|
-
has_rdoc:
|
118
|
+
test_files: []
|
@@ -1,74 +0,0 @@
|
|
1
|
-
# coding: utf-8
|
2
|
-
require 'securerandom'
|
3
|
-
|
4
|
-
module GyomuRuby
|
5
|
-
module AmazonWebService
|
6
|
-
class FileBucket
|
7
|
-
attr_accessor :backend
|
8
|
-
|
9
|
-
extend Forwardable
|
10
|
-
def_delegators :backend, *%w[bucket get delete]
|
11
|
-
|
12
|
-
def initialize(bucket = 'bucket')
|
13
|
-
@backend = Rails.env.production? || Rails.env.staging? ? RichMan.new(bucket) : PoorMan.new(bucket)
|
14
|
-
end
|
15
|
-
|
16
|
-
def put(io)
|
17
|
-
"#{Time.now.strftime('%Y%m%d%H%M')}_#{SecureRandom.hex(5)}".tap do |key|
|
18
|
-
@backend.put(key, io)
|
19
|
-
end
|
20
|
-
end
|
21
|
-
|
22
|
-
class PoorMan
|
23
|
-
require 'fileutils'
|
24
|
-
|
25
|
-
attr_reader :bucket
|
26
|
-
|
27
|
-
def initialize(bucket)
|
28
|
-
@bucket = bucket
|
29
|
-
path = Rails.root.join('tmp', @bucket)
|
30
|
-
FileUtils.mkdir_p path unless FileTest.exist? path
|
31
|
-
end
|
32
|
-
|
33
|
-
def put(key, io)
|
34
|
-
File.open(Rails.root.join('tmp', @bucket, key), 'w:BINARY') {|f| f.write(io.read)}
|
35
|
-
end
|
36
|
-
|
37
|
-
def get(key)
|
38
|
-
File.open(Rails.root.join('tmp', @bucket, key), 'r:BINARY') {|f| f.read }
|
39
|
-
end
|
40
|
-
|
41
|
-
def delete(key)
|
42
|
-
!!FileUtils.rm_r(Rails.root.join('tmp', @bucket, key))
|
43
|
-
end
|
44
|
-
end
|
45
|
-
|
46
|
-
class RichMan
|
47
|
-
require 'aws/s3'
|
48
|
-
|
49
|
-
attr_reader :bucket
|
50
|
-
|
51
|
-
def initialize(bucket)
|
52
|
-
@bucket = bucket
|
53
|
-
::AWS::S3::Bucket.find(@bucket)
|
54
|
-
rescue ::AWS::S3::NoSuchBucket
|
55
|
-
::AWS::S3::Bucket.create(@bucket)
|
56
|
-
end
|
57
|
-
|
58
|
-
def put(key, io)
|
59
|
-
::AWS::S3::S3Object.store(key, io, @bucket)
|
60
|
-
end
|
61
|
-
|
62
|
-
def get(key)
|
63
|
-
::AWS::S3::S3Object.value(key, @bucket) rescue nil
|
64
|
-
end
|
65
|
-
|
66
|
-
def delete(key)
|
67
|
-
::AWS::S3::S3Object.delete(key, @bucket) rescue false
|
68
|
-
end
|
69
|
-
end
|
70
|
-
end
|
71
|
-
end
|
72
|
-
|
73
|
-
AWS = AmazonWebService
|
74
|
-
end
|
@@ -1 +0,0 @@
|
|
1
|
-
require 'gyomu_ruby/core_ext/integer/round'
|
@@ -1,36 +0,0 @@
|
|
1
|
-
# coding: utf-8
|
2
|
-
module GyomuRuby
|
3
|
-
module OrdinarySystemDevelopment
|
4
|
-
module AddressFormatter
|
5
|
-
PREFS = File.read(
|
6
|
-
File.expand_path('../../../masters/prefectures.csv', File.dirname(__FILE__))
|
7
|
-
).lines.map(&:strip).freeze
|
8
|
-
|
9
|
-
ext_tel_numbers = File.read(
|
10
|
-
File.expand_path('../../../masters/ext_tel_numbers.csv', File.dirname(__FILE__))
|
11
|
-
).lines.map{|n| "0#{n.strip}" }
|
12
|
-
|
13
|
-
EXT_TEL_NUMBERS = (ext_tel_numbers + %w[050 070 080 090 0120]).sort.reverse.freeze
|
14
|
-
EXT_TEL_NUMBERS_RE = /\A(#{EXT_TEL_NUMBERS.sort.reverse.join('|')})/uo
|
15
|
-
|
16
|
-
module_function
|
17
|
-
|
18
|
-
def format_zipcode(zipcode_string, blank = '')
|
19
|
-
return blank if zipcode_string.blank?
|
20
|
-
zipcode_string.sub(/\A(\d{3})(\d{4})\Z/){ "#{$1}-#{$2}" }
|
21
|
-
end
|
22
|
-
|
23
|
-
def format_tel_no(telno_numeric_string, blank = '')
|
24
|
-
return blank if telno_numeric_string.blank?
|
25
|
-
telno_numeric_string.to_s.
|
26
|
-
sub(EXT_TEL_NUMBERS_RE){ "#{$1}-" }.
|
27
|
-
sub(/(\d{4})\Z/) { "-#{$1}" }
|
28
|
-
end
|
29
|
-
|
30
|
-
def prefecture_name(prefecture_code, blank = '')
|
31
|
-
return blank if prefecture_code.blank?
|
32
|
-
PREFS[prefecture_code.to_i - 1]
|
33
|
-
end
|
34
|
-
end
|
35
|
-
end
|
36
|
-
end
|
@@ -1,22 +0,0 @@
|
|
1
|
-
# coding:us-ascii
|
2
|
-
require 'rack'
|
3
|
-
|
4
|
-
module GyomuRuby
|
5
|
-
module OrdinarySystemDevelopment
|
6
|
-
class AllYourSiteAreBelongToSsl
|
7
|
-
def initialize(app)
|
8
|
-
@app = app
|
9
|
-
end
|
10
|
-
|
11
|
-
def call(env)
|
12
|
-
if env['HTTPS'] == 'on' || env['HTTP_X_FORWARDED_PROTO'] == 'https'
|
13
|
-
@app.call(env)
|
14
|
-
else
|
15
|
-
url = Rack::Request.new(env).url.sub(/^http:/, 'https:')
|
16
|
-
body = "<html><body>You are being <a href=\"#{url}\">redirected</a>.</body></html>"
|
17
|
-
[301, {'Location' => url, 'Content-Type' => 'text/html'}, [body]]
|
18
|
-
end
|
19
|
-
end
|
20
|
-
end
|
21
|
-
end
|
22
|
-
end
|
@@ -1,10 +0,0 @@
|
|
1
|
-
# coding: utf-8
|
2
|
-
|
3
|
-
module GyomuRuby
|
4
|
-
module OrdinarySystemDevelopment
|
5
|
-
osd_dir = 'gyomu_ruby/ordinary_system_development/'
|
6
|
-
autoload 'AllYourSiteAreBelongToSsl', osd_dir + 'all_your_site_are_belong_to_ssl'
|
7
|
-
autoload 'Translation', osd_dir + 'translated_from'
|
8
|
-
end
|
9
|
-
OSD = OrdinarySystemDevelopment
|
10
|
-
end
|
data/masters/prefectures.csv
DELETED
@@ -1,47 +0,0 @@
|
|
1
|
-
北海道
|
2
|
-
青森県
|
3
|
-
岩手県
|
4
|
-
宮城県
|
5
|
-
秋田県
|
6
|
-
山形県
|
7
|
-
福島県
|
8
|
-
茨城県
|
9
|
-
栃木県
|
10
|
-
群馬県
|
11
|
-
埼玉県
|
12
|
-
千葉県
|
13
|
-
東京都
|
14
|
-
神奈川県
|
15
|
-
新潟県
|
16
|
-
富山県
|
17
|
-
石川県
|
18
|
-
福井県
|
19
|
-
山梨県
|
20
|
-
長野県
|
21
|
-
岐阜県
|
22
|
-
静岡県
|
23
|
-
愛知県
|
24
|
-
三重県
|
25
|
-
滋賀県
|
26
|
-
京都府
|
27
|
-
大阪府
|
28
|
-
兵庫県
|
29
|
-
奈良県
|
30
|
-
和歌山県
|
31
|
-
鳥取県
|
32
|
-
島根県
|
33
|
-
岡山県
|
34
|
-
広島県
|
35
|
-
山口県
|
36
|
-
徳島県
|
37
|
-
香川県
|
38
|
-
愛媛県
|
39
|
-
高知県
|
40
|
-
福岡県
|
41
|
-
佐賀県
|
42
|
-
長崎県
|
43
|
-
熊本県
|
44
|
-
大分県
|
45
|
-
宮崎県
|
46
|
-
鹿児島県
|
47
|
-
沖縄県
|
@@ -1,18 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
require 'gyomu_ruby/core_ext/integer'
|
3
|
-
|
4
|
-
describe Integer, 'gyomu_ruby extentions' do
|
5
|
-
describe '#ceil' do
|
6
|
-
it { 101.ceil(50).should == 150 }
|
7
|
-
it { 151.ceil(50).should == 200 }
|
8
|
-
it { 121.ceil(3).should == 123 }
|
9
|
-
it { 123.ceil(3).should == 123 }
|
10
|
-
end
|
11
|
-
|
12
|
-
describe '#floor' do
|
13
|
-
it { 101.floor(50).should == 100 }
|
14
|
-
it { 151.floor(50).should == 150 }
|
15
|
-
it { 121.floor(3).should == 120 }
|
16
|
-
it { 123.floor(3).should == 123 }
|
17
|
-
end
|
18
|
-
end
|