duffy 1.0.1 → 1.0.3

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: '031931bb20a67704daaeb756697289c59b8b4b17d20542e547f44b9a810f8937'
4
- data.tar.gz: 8d1d8ce9b7815f888604ff54be223a4efb4cecac8c5d6a8f3da7b63bb5be943b
3
+ metadata.gz: 7df1e7242cea2c5d050fd349e3ce7c1e62411748e3d4f2989abb06f556c60d2b
4
+ data.tar.gz: a06ca07b4db45a9e22417573050e023f3f4c201baa539102043b5c966026ac16
5
5
  SHA512:
6
- metadata.gz: 7eaf20af8b3da4f7d0524fa485cf08faa159fe706a93e5d3d63e6ca58e1e38b4460eed508b4a09ebd083b3261378cb215de93bb46c0d636a7e285d0999fccd44
7
- data.tar.gz: a33c601156a194d07e7a5675ca5ab94363181a1ccc6f2175e66fe6240e670fe1eddb454809637f47fde604a8f4de0a3c7c2d199b968a4cb2ee651ba85f63fab2
6
+ metadata.gz: 5ee65d7c98b2e67b94156235b359e85ab358d17498c32352c4de4577a25b411ab27642406c8ccdd96084f2e9661ac6a1d3534c74e66b84e176f48a2faadd5519
7
+ data.tar.gz: 2fd9aa7ce716a12cc82c70692f3ae4f6ef5b208a31d452970f94d648f51a64a4ca8e1f507526c53adef812402d64edb250af64c3012c10abf7f033dde6a76c12
data/.travis.yml CHANGED
@@ -1,6 +1,18 @@
1
+ env:
2
+ global:
3
+ - CC_TEST_REPORTER_ID=d77de389b3b98dc3b4f404875592cde5efbf22d5268880fc8e86c4c323871bb9
1
4
  language: ruby
2
5
  rvm:
3
- - 2.3.0
6
+ - 2.6.1
4
7
 
5
8
  before_install:
6
9
  - gem update bundler
10
+
11
+ before_script:
12
+ - curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter
13
+ - chmod +x ./cc-test-reporter
14
+ - ./cc-test-reporter before-build
15
+ script:
16
+ - bundle exec rspec
17
+ after_script:
18
+ - ./cc-test-reporter after-build --exit-code $TRAVIS_TEST_RESULT
data/duffy.gemspec CHANGED
@@ -19,8 +19,10 @@ Gem::Specification.new do |spec|
19
19
  spec.require_paths = ["lib"]
20
20
 
21
21
  spec.add_dependency 'activesupport' # Required for ActiveSupport::Configurable
22
- spec.add_development_dependency "bundler", "~> 1.7"
23
- spec.add_development_dependency "rake", "~> 10.0"
22
+ spec.add_development_dependency "bundler"
23
+ spec.add_development_dependency "rake"
24
24
  spec.add_development_dependency "rails", '>= 5.0'
25
25
  spec.add_development_dependency "rspec"
26
+ spec.add_development_dependency "simplecov"
27
+
26
28
  end
data/lib/duffy/array.rb CHANGED
@@ -10,8 +10,8 @@ class Array
10
10
  def to_box(safe: true)
11
11
  return nil if self.empty?
12
12
  b = safe ? "+-++ | +++" : "╔─╦╗ ║ ╚╩╝"
13
- out = (b[0] + self.map{ |x| b[1] * (x.to_s.length + 2) }.join(b[2]) + b[3])[0,80] + "\n"
13
+ out = (b[0] + self.map{ |x| b[1] * (x.to_s.gsub(/\e\[([;\d]+)?m/, '').length + 2) }.join(b[2]) + b[3])[0,80] + "\n"
14
14
  out << (b[5,2] + self.join(b[4,3]) + b[4,2])[0,80] + "\n"
15
- out << (b[7] + self.map{ |x| b[1] * (x.to_s.length + 2) }.join(b[8]) + b[9])[0,80]
15
+ out << (b[7] + self.map{ |x| b[1] * (x.to_s.gsub(/\e\[([;\d]+)?m/, '').length + 2) }.join(b[8]) + b[9])[0,80]
16
16
  end
17
17
  end
data/lib/duffy/version.rb CHANGED
@@ -1,8 +1,10 @@
1
1
  module Duffy
2
- VERSION = '1.0.1'
2
+ VERSION = '1.0.3'
3
3
  end
4
4
 
5
5
  # History
6
+ # 1.0.3 - to_box methods now accept ANSI colored strings.
7
+ # 1.0.2 - Added SimpleCov and added some more String tests.
6
8
  # 1.0.1 - Added String.to_box and Array.to_box. Nice for text banners.
7
9
  # 1.0.0 - Using Shellwords to escape directory listing in System.freespace.
8
10
  # 0.3.6 - Added disk freespace method. Looks at working directory.
data/spec/spec_helper.rb CHANGED
@@ -1,3 +1,6 @@
1
+ require 'simplecov'
2
+ SimpleCov.start
3
+
1
4
  require 'bundler/setup'
2
5
  require 'rails'
3
6
  Bundler.setup
data/spec/string_spec.rb CHANGED
@@ -2,6 +2,53 @@ require 'spec_helper'
2
2
 
3
3
  describe String do
4
4
 
5
+ describe "md5" do
6
+ it "generates an md5sum of the given string" do
7
+ expect("foobar".md5).to eq "3858f62230ac3c915f300c664312c63f"
8
+ end
9
+ end
10
+
11
+ describe "pretty_phone" do
12
+ it "formats an American phone number with Area Code" do
13
+ expect("1234567890".pretty_phone).to eq "(123) 456-7890"
14
+ end
15
+
16
+ it "formats an American phone number without Area Code" do
17
+ expect("4567890".pretty_phone).to eq "456-7890"
18
+ end
19
+
20
+ it "leaves longer strings alone" do
21
+ expect("11234567890".pretty_phone).to eq "11234567890"
22
+ end
23
+
24
+ it "leaves shorter strings alone" do
25
+ expect("1123".pretty_phone).to eq "1123"
26
+ end
27
+ end
28
+
29
+ describe "smart_titlecase" do
30
+ { "foo" => "Foo",
31
+ "IMPORTANT STUFF" => "Important Stuff",
32
+ "123 main st." => "123 Main St.",
33
+ "a tale of two cities" => "A Tale of Two Cities"
34
+ }.each do |before, after|
35
+ it "#{before.ljust(20)} => #{after}" do
36
+ expect(before.smart_titlecase).to eq after
37
+ end
38
+ end
39
+ end
40
+
41
+ describe "to_alpha" do
42
+ it "strips everything but a-z and A-Z" do
43
+ expect("123abc$%^DEF".to_alpha).to eq "abcDEF"
44
+ end
45
+ end
46
+ describe "to_alpha_numeric" do
47
+ it "strips everything but a-z, A-Z and 0-9" do
48
+ expect("123abc$%^DEF".to_alpha_numeric).to eq "123abcDEF"
49
+ end
50
+ end
51
+
5
52
  describe "to_box" do
6
53
  it "creates a safe box around a string" do
7
54
  expect("foobar".to_box).to eq "+--------+\n| foobar |\n+--------+"
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: duffy
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.1
4
+ version: 1.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jacob Duffy
@@ -28,30 +28,30 @@ dependencies:
28
28
  name: bundler
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - "~>"
31
+ - - ">="
32
32
  - !ruby/object:Gem::Version
33
- version: '1.7'
33
+ version: '0'
34
34
  type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - "~>"
38
+ - - ">="
39
39
  - !ruby/object:Gem::Version
40
- version: '1.7'
40
+ version: '0'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: rake
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - "~>"
45
+ - - ">="
46
46
  - !ruby/object:Gem::Version
47
- version: '10.0'
47
+ version: '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: '10.0'
54
+ version: '0'
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: rails
57
57
  requirement: !ruby/object:Gem::Requirement
@@ -80,6 +80,20 @@ dependencies:
80
80
  - - ">="
81
81
  - !ruby/object:Gem::Version
82
82
  version: '0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: simplecov
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
83
97
  description: Random collection of useful things.
84
98
  email:
85
99
  - duffy.jp@gmail.com