mb_string 0.1.6 → 0.1.7

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
  SHA1:
3
- metadata.gz: 54eeb4c76a30b4ea9892d7b2661bc1f74018e4c2
4
- data.tar.gz: 4bc33eb128d929b65e46a7c8e814e8ba5a61d2ed
3
+ metadata.gz: d144aa62bc361807eea6cdc3b4d8a55575ac6a88
4
+ data.tar.gz: ebca0a0086acde2f28949c7fa2bb474b1ca986e2
5
5
  SHA512:
6
- metadata.gz: f2257165ebfdab930310a57b65935ccf2b507efdf9545467356e175bdf6142b89275e9fc6e7823b7bbc4bdf00fde07b3a2ca827de74dcbab7c42cae10ceb5829
7
- data.tar.gz: fb66ded3fd3df193beb1f32233284683335375bc2c99bebc18c9609276f4055be657a2e35a3746d0886e6ad3febe264bbf4dd4b47c7bb32f8e214cd70bd30e94
6
+ metadata.gz: 18ab3b46aa2eefcfc8a112158de57e6707c58d24d8dcba2323b71af716f243cf236120de850ef13cadf510f78f2d990f3d276e37d5345bee3a5c8202c96e31ad
7
+ data.tar.gz: 251922d6f5a8cbbc3dd0709a2118697b7d416e85bef0a9b11b0b7885e142be2ba4a729cf926903968ac02bf50e5f365b42ec07715c30410c74d37d06bd3d3047
data/CHANGELOG.md CHANGED
@@ -1,3 +1,6 @@
1
+ ## 0.1.5 (Thu Apr 1 2016)
2
+ * Update gems [fe2a3a2]
3
+
1
4
  ## 0.1.5 (Thu Apr 1 2016)
2
5
  * Update gem [df4c549]
3
6
 
data/Gemfile CHANGED
@@ -1,4 +1,4 @@
1
- source 'https://rubygems.org'
1
+ source "https://rubygems.org"
2
2
 
3
3
  # Specify your gem's dependencies in mb_string.gemspec
4
4
  gemspec
data/Rakefile CHANGED
@@ -1,5 +1,5 @@
1
- require 'bundler/gem_tasks'
2
- require 'rspec/core/rake_task'
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
3
 
4
4
  RSpec::Core::RakeTask.new(:spec)
5
5
 
data/bin/console CHANGED
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
- require 'bundler/setup'
4
- require 'mb_string'
3
+ require "bundler/setup"
4
+ require "mb_string"
5
5
 
6
6
  # You can add fixtures and/or initialization code here to make experimenting
7
7
  # with your gem easier. You can also use a different console, if you like.
@@ -10,5 +10,5 @@ require 'mb_string'
10
10
  # require "pry"
11
11
  # Pry.start
12
12
 
13
- require 'irb'
13
+ require "irb"
14
14
  IRB.start
data/lib/mb_string.rb CHANGED
@@ -1,5 +1,5 @@
1
- require 'mb_string/version'
1
+ require "mb_string/version"
2
2
 
3
3
  module MbString
4
- require 'mb_string/core_ext/string'
4
+ require "mb_string/core_ext/string"
5
5
  end
@@ -1,20 +1,20 @@
1
- require 'unicode/display_width'
1
+ require "unicode/display_width"
2
2
  class String
3
- def mb_ljust(width, pad_str = ' ')
3
+ def mb_ljust(width, pad_str = " ")
4
4
  return ljust(width, pad_str) if ascii_only? && pad_str.ascii_only?
5
5
  mb_execute(width) do |pad_size|
6
6
  self + mb_build_padding(pad_size, pad_str)
7
7
  end
8
8
  end
9
9
 
10
- def mb_rjust(width, pad_str = ' ')
10
+ def mb_rjust(width, pad_str = " ")
11
11
  return rjust(width, pad_str) if ascii_only? && pad_str.ascii_only?
12
12
  mb_execute(width) do |pad_size|
13
13
  mb_build_padding(pad_size, pad_str, is_append_right: false) + self
14
14
  end
15
15
  end
16
16
 
17
- def mb_center(width, pad_str = ' ')
17
+ def mb_center(width, pad_str = " ")
18
18
  return center(width, pad_str) if ascii_only? && pad_str.ascii_only?
19
19
  mb_execute(width) do |pad_size|
20
20
  left_pad_size = pad_size / 2
@@ -30,11 +30,11 @@ class String
30
30
  def mb_truncate(truncate_at, options = {})
31
31
  return dup unless display_width > truncate_at
32
32
 
33
- omission = options[:omission] || '...'
33
+ omission = options[:omission] || "..."
34
34
  length_with_room_for_omission = truncate_at - omission.display_width
35
35
 
36
36
  size = 0
37
- slice = ''
37
+ slice = ""
38
38
  each_char do |c|
39
39
  char_size = c.display_width
40
40
  if size + char_size > length_with_room_for_omission
@@ -49,39 +49,39 @@ class String
49
49
 
50
50
  private
51
51
 
52
- def mb_execute(width)
53
- pad_size = [width - display_width, 0].max
54
- return self if pad_size.zero?
55
- yield(pad_size)
56
- end
52
+ def mb_execute(width)
53
+ pad_size = [width - display_width, 0].max
54
+ return self if pad_size.zero?
55
+ yield(pad_size)
56
+ end
57
57
 
58
- def mb_build_padding(pad_size, pad_str, is_append_right: true)
59
- pad_display_width = pad_str.display_width
60
- pad_num, mod = pad_size.divmod(pad_display_width)
61
- padding = pad_str * pad_num
62
- if mod > 0
63
- padding = mb_tweak_reminder(pad_str, mod, padding)
64
- padding = append_reminder_space(padding, is_append_right) if pad_size > padding.display_width
58
+ def mb_build_padding(pad_size, pad_str, is_append_right: true)
59
+ pad_display_width = pad_str.display_width
60
+ pad_num, mod = pad_size.divmod(pad_display_width)
61
+ padding = pad_str * pad_num
62
+ if mod > 0
63
+ padding = mb_tweak_reminder(pad_str, mod, padding)
64
+ padding = append_reminder_space(padding, is_append_right) if pad_size > padding.display_width
65
+ end
66
+ padding
65
67
  end
66
- padding
67
- end
68
68
 
69
- def mb_tweak_reminder(pad_str, mod, padding)
70
- pad_str.each_char do |c|
71
- char_display_width = c.display_width
72
- if mod >= char_display_width
73
- padding << c
74
- mod -= char_display_width
69
+ def mb_tweak_reminder(pad_str, mod, padding)
70
+ pad_str.each_char do |c|
71
+ char_display_width = c.display_width
72
+ if mod >= char_display_width
73
+ padding << c
74
+ mod -= char_display_width
75
+ end
75
76
  end
77
+ padding
76
78
  end
77
- padding
78
- end
79
79
 
80
- def append_reminder_space(padding, is_append_right)
81
- if is_append_right
82
- padding + ' '
83
- else
84
- ' ' + padding
80
+ def append_reminder_space(padding, is_append_right)
81
+ if is_append_right
82
+ padding + " "
83
+ else
84
+ " " + padding
85
+ end
85
86
  end
86
- end
87
87
  end
@@ -1,3 +1,3 @@
1
1
  module MbString
2
- VERSION = '0.1.6'
2
+ VERSION = "0.1.7"
3
3
  end
data/mb_string.gemspec CHANGED
@@ -1,31 +1,31 @@
1
1
  # coding: utf-8
2
- lib = File.expand_path('../lib', __FILE__)
2
+ lib = File.expand_path("../lib", __FILE__)
3
3
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
- require 'mb_string/version'
4
+ require "mb_string/version"
5
5
 
6
6
  Gem::Specification.new do |spec|
7
- spec.name = 'mb_string'
7
+ spec.name = "mb_string"
8
8
  spec.version = MbString::VERSION
9
- spec.authors = ['rochefort']
10
- spec.email = ['terasawan@gmail.com']
9
+ spec.authors = ["rochefort"]
10
+ spec.email = ["terasawan@gmail.com"]
11
11
 
12
- spec.summary = 'You can use mb_ljust, mb_rjust, mb_center for multibyte strings.'
12
+ spec.summary = "You can use mb_ljust, mb_rjust, mb_center for multibyte strings."
13
13
  spec.description = spec.summary
14
- spec.homepage = 'https://github.com/rochefort/mb_string'
15
- spec.license = 'MIT'
14
+ spec.homepage = "https://github.com/rochefort/mb_string"
15
+ spec.license = "MIT"
16
16
 
17
17
  spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
18
- spec.bindir = 'exe'
18
+ spec.bindir = "exe"
19
19
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
20
- spec.require_paths = ['lib']
20
+ spec.require_paths = ["lib"]
21
21
 
22
- spec.add_dependency 'unicode-display_width', '~> 1.0.3'
22
+ spec.add_dependency "unicode-display_width", "~> 1.1.1"
23
23
 
24
- spec.add_development_dependency 'bundler', '~> 1.10'
25
- spec.add_development_dependency 'rake', '~> 11.1.2'
26
- spec.add_development_dependency 'rspec', '~> 3.4.0'
27
- spec.add_development_dependency 'simplecov', '~> 0.11.0'
24
+ spec.add_development_dependency "bundler", "~> 1.10"
25
+ spec.add_development_dependency "rake", "~> 11.3.0"
26
+ spec.add_development_dependency "rspec", "~> 3.5.0"
27
+ spec.add_development_dependency "simplecov", "~> 0.12.0"
28
28
 
29
- spec.add_development_dependency 'coveralls'
30
- spec.add_development_dependency 'codeclimate-test-reporter'
29
+ spec.add_development_dependency "coveralls", "~> 0.8.15"
30
+ spec.add_development_dependency "codeclimate-test-reporter"
31
31
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mb_string
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.6
4
+ version: 0.1.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - rochefort
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-03-31 00:00:00.000000000 Z
11
+ date: 2016-11-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: unicode-display_width
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: 1.0.3
19
+ version: 1.1.1
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: 1.0.3
26
+ version: 1.1.1
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: bundler
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -44,56 +44,56 @@ dependencies:
44
44
  requirements:
45
45
  - - "~>"
46
46
  - !ruby/object:Gem::Version
47
- version: 11.1.2
47
+ version: 11.3.0
48
48
  type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
52
  - - "~>"
53
53
  - !ruby/object:Gem::Version
54
- version: 11.1.2
54
+ version: 11.3.0
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: rspec
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
59
  - - "~>"
60
60
  - !ruby/object:Gem::Version
61
- version: 3.4.0
61
+ version: 3.5.0
62
62
  type: :development
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
66
  - - "~>"
67
67
  - !ruby/object:Gem::Version
68
- version: 3.4.0
68
+ version: 3.5.0
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: simplecov
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
73
  - - "~>"
74
74
  - !ruby/object:Gem::Version
75
- version: 0.11.0
75
+ version: 0.12.0
76
76
  type: :development
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
80
  - - "~>"
81
81
  - !ruby/object:Gem::Version
82
- version: 0.11.0
82
+ version: 0.12.0
83
83
  - !ruby/object:Gem::Dependency
84
84
  name: coveralls
85
85
  requirement: !ruby/object:Gem::Requirement
86
86
  requirements:
87
- - - ">="
87
+ - - "~>"
88
88
  - !ruby/object:Gem::Version
89
- version: '0'
89
+ version: 0.8.15
90
90
  type: :development
91
91
  prerelease: false
92
92
  version_requirements: !ruby/object:Gem::Requirement
93
93
  requirements:
94
- - - ">="
94
+ - - "~>"
95
95
  - !ruby/object:Gem::Version
96
- version: '0'
96
+ version: 0.8.15
97
97
  - !ruby/object:Gem::Dependency
98
98
  name: codeclimate-test-reporter
99
99
  requirement: !ruby/object:Gem::Requirement
@@ -149,7 +149,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
149
149
  version: '0'
150
150
  requirements: []
151
151
  rubyforge_project:
152
- rubygems_version: 2.5.1
152
+ rubygems_version: 2.6.6
153
153
  signing_key:
154
154
  specification_version: 4
155
155
  summary: You can use mb_ljust, mb_rjust, mb_center for multibyte strings.