cliutils 2.1.4 → 2.2.0
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/.gitignore +2 -0
- data/.travis.yml +3 -2
- data/Gemfile +7 -0
- data/HISTORY.md +7 -0
- data/README.md +3 -1
- data/Rakefile +8 -1
- data/cliutils.gemspec +1 -0
- data/lib/cliutils/configuration.rb +1 -1
- data/lib/cliutils/constants.rb +1 -1
- data/lib/cliutils/ext/hash_extensions.rb +16 -12
- data/lib/cliutils/messaging.rb +2 -116
- data/lib/cliutils/messenger.rb +109 -0
- data/lib/cliutils/prefs/pref.rb +10 -10
- data/lib/cliutils/prefs/pref_actions/open_url_action.rb +1 -1
- data/lib/cliutils/prefs/pref_validators/filepath_exists_validator.rb +2 -0
- data/lib/cliutils/prefs/pref_validators/url_validator.rb +1 -1
- data/lib/cliutils/prefs.rb +1 -1
- data/lib/cliutils/pretty_io.rb +0 -10
- data/lib/cliutils.rb +1 -1
- data/spec/action/open_url_action_spec.rb +20 -0
- data/spec/action/pref_action_spec.rb +11 -0
- data/spec/behavior/capitalize_behavior_spec.rb +11 -0
- data/spec/behavior/expand_filepath_behavior_spec.rb +11 -0
- data/spec/behavior/lowercase_behavior_spec.rb +11 -0
- data/spec/behavior/pref_behavior_spec.rb +11 -0
- data/spec/behavior/prefix_behavior_spec.rb +12 -0
- data/spec/behavior/suffix_behavior_spec.rb +12 -0
- data/spec/behavior/titlecase_behavior_spec.rb +10 -0
- data/spec/behavior/uppercase_behavior_spec.rb +11 -0
- data/spec/configuration_spec.rb +37 -0
- data/spec/configurator_spec.rb +104 -0
- data/spec/ext/hash_extensions_spec.rb +54 -0
- data/spec/ext/logger_extensions_spec.rb +20 -0
- data/spec/ext/string_extensions_spec.rb +26 -0
- data/spec/messaging_spec.rb +91 -0
- data/spec/pref_spec.rb +144 -0
- data/spec/prefs_spec.rb +150 -0
- data/spec/spec_helper.rb +16 -0
- data/spec/validator/alphabetic_validator_spec.rb +20 -0
- data/spec/validator/alphanumeric_validator_spec.rb +20 -0
- data/spec/validator/date_validator_spec.rb +20 -0
- data/spec/validator/datetime_validator_spec.rb +20 -0
- data/spec/validator/filepath_exists_validator_spec.rb +20 -0
- data/spec/validator/non_nil_validator_spec.rb +24 -0
- data/spec/validator/number_validator_spec.rb +20 -0
- data/spec/validator/pref_validator_spec.rb +11 -0
- data/spec/validator/time_validator_spec.rb +20 -0
- data/spec/validator/url_validator_spec.rb +20 -0
- data/{test/test_files → support}/configuration.yaml +1 -1
- data/support/prefstest.yaml +27 -0
- data/{test/test_files → support}/test_action.rb +0 -0
- data/support/test_action_empty.rb +7 -0
- data/{test/test_files → support}/test_behavior.rb +2 -2
- data/support/test_behavior_empty.rb +6 -0
- data/{test/test_files → support}/test_validator.rb +0 -2
- data/support/test_validator_empty.rb +7 -0
- data/test/pref_test.rb +0 -1
- data/test/prefs_test.rb +64 -1
- data/test/test_helper.rb +2 -2
- metadata +91 -67
- data/lib/cliutils/logger_delegator.rb +0 -49
- data/test/action_tests/open_url_action_test.rb +0 -12
- data/test/behavior_tests/capitalize_behavior_test.rb +0 -11
- data/test/behavior_tests/expand_filepath_behavior_test.rb +0 -11
- data/test/behavior_tests/lowercase_behavior_test.rb +0 -11
- data/test/behavior_tests/prefix_behavior_test.rb +0 -12
- data/test/behavior_tests/suffix_behavior_test.rb +0 -12
- data/test/behavior_tests/titlecase_behavior_test.rb +0 -11
- data/test/behavior_tests/uppercase_behavior_test.rb +0 -11
- data/test/configuration_test.rb +0 -49
- data/test/configurator_test.rb +0 -63
- data/test/hash_extensions_test.rb +0 -51
- data/test/logger_extensions_test.rb +0 -17
- data/test/messaging_test.rb +0 -53
- data/test/string_extesions_test.rb +0 -28
- data/test/test_files/prefstest.yaml +0 -38
- data/test/validator_tests/alphabetic_validator_test.rb +0 -22
- data/test/validator_tests/alphanumeric_validator_test.rb +0 -22
- data/test/validator_tests/date_validator_test.rb +0 -22
- data/test/validator_tests/datetime_validator_test.rb +0 -22
- data/test/validator_tests/filepath_exists_validator_test.rb +0 -22
- data/test/validator_tests/non_nil_validator_test.rb +0 -30
- data/test/validator_tests/number_validator_test.rb +0 -22
- data/test/validator_tests/time_validator_test.rb +0 -22
- data/test/validator_tests/url_validator_test.rb +0 -22
@@ -1,22 +0,0 @@
|
|
1
|
-
require 'test_helper'
|
2
|
-
|
3
|
-
require File.join(File.dirname(__FILE__), '..', '..', 'lib/cliutils/prefs/pref_validators/alphabetic_validator')
|
4
|
-
|
5
|
-
# Tests for the Configurator class
|
6
|
-
class TestAlphabeticValidator < Test::Unit::TestCase
|
7
|
-
def test_valid
|
8
|
-
v = CLIUtils::AlphabeticValidator.new
|
9
|
-
v.validate('bachya')
|
10
|
-
|
11
|
-
assert_equal(v.is_valid, 0)
|
12
|
-
assert_equal(v.message, 'Response is not alphabetic: bachya')
|
13
|
-
end
|
14
|
-
|
15
|
-
def test_invalid
|
16
|
-
v = CLIUtils::AlphabeticValidator.new
|
17
|
-
v.validate('12345')
|
18
|
-
|
19
|
-
assert_not_equal(v.is_valid, 0)
|
20
|
-
assert_equal(v.message, 'Response is not alphabetic: 12345')
|
21
|
-
end
|
22
|
-
end
|
@@ -1,22 +0,0 @@
|
|
1
|
-
require 'test_helper'
|
2
|
-
|
3
|
-
require File.join(File.dirname(__FILE__), '..', '..', 'lib/cliutils/prefs/pref_validators/alphanumeric_validator')
|
4
|
-
|
5
|
-
# Tests for the Configurator class
|
6
|
-
class TestAlphanumericValidator < Test::Unit::TestCase
|
7
|
-
def test_valid
|
8
|
-
v = CLIUtils::AlphanumericValidator.new
|
9
|
-
v.validate('bachya91238 ')
|
10
|
-
|
11
|
-
assert_equal(v.is_valid, 0)
|
12
|
-
assert_equal(v.message, 'Response is not alphanumeric: bachya91238 ')
|
13
|
-
end
|
14
|
-
|
15
|
-
def test_invalid
|
16
|
-
v = CLIUtils::AlphanumericValidator.new
|
17
|
-
v.validate('!@&^')
|
18
|
-
|
19
|
-
assert_not_equal(v.is_valid, 0)
|
20
|
-
assert_equal(v.message, 'Response is not alphanumeric: !@&^')
|
21
|
-
end
|
22
|
-
end
|
@@ -1,22 +0,0 @@
|
|
1
|
-
require 'test_helper'
|
2
|
-
|
3
|
-
require File.join(File.dirname(__FILE__), '..', '..', 'lib/cliutils/prefs/pref_validators/date_validator')
|
4
|
-
|
5
|
-
# Tests for the Configurator class
|
6
|
-
class TestDateValidator < Test::Unit::TestCase
|
7
|
-
def test_valid
|
8
|
-
v = CLIUtils::DateValidator.new
|
9
|
-
v.validate('2014-02-01')
|
10
|
-
|
11
|
-
assert_equal(v.is_valid, true)
|
12
|
-
assert_equal(v.message, 'Response is not a date: 2014-02-01')
|
13
|
-
end
|
14
|
-
|
15
|
-
def test_invalid
|
16
|
-
v = CLIUtils::DateValidator.new
|
17
|
-
v.validate('!@&^')
|
18
|
-
|
19
|
-
assert_equal(v.is_valid, false)
|
20
|
-
assert_equal(v.message, 'Response is not a date: !@&^')
|
21
|
-
end
|
22
|
-
end
|
@@ -1,22 +0,0 @@
|
|
1
|
-
require 'test_helper'
|
2
|
-
|
3
|
-
require File.join(File.dirname(__FILE__), '..', '..', 'lib/cliutils/prefs/pref_validators/datetime_validator')
|
4
|
-
|
5
|
-
# Tests for the Configurator class
|
6
|
-
class TestDatetimeValidator < Test::Unit::TestCase
|
7
|
-
def test_valid
|
8
|
-
v = CLIUtils::DatetimeValidator.new
|
9
|
-
v.validate('2014-02-01 12:34 PM')
|
10
|
-
|
11
|
-
assert_equal(v.is_valid, true)
|
12
|
-
assert_equal(v.message, 'Response is not a datetime: 2014-02-01 12:34 PM')
|
13
|
-
end
|
14
|
-
|
15
|
-
def test_invalid
|
16
|
-
v = CLIUtils::DatetimeValidator.new
|
17
|
-
v.validate('!@&^')
|
18
|
-
|
19
|
-
assert_equal(v.is_valid, false)
|
20
|
-
assert_equal(v.message, 'Response is not a datetime: !@&^')
|
21
|
-
end
|
22
|
-
end
|
@@ -1,22 +0,0 @@
|
|
1
|
-
require 'test_helper'
|
2
|
-
|
3
|
-
require File.join(File.dirname(__FILE__), '..', '..', 'lib/cliutils/prefs/pref_validators/filepath_exists_validator')
|
4
|
-
|
5
|
-
# Tests for the Configurator class
|
6
|
-
class TestFilepathExistsValidator < Test::Unit::TestCase
|
7
|
-
def test_valid
|
8
|
-
v = CLIUtils::FilepathExistsValidator.new
|
9
|
-
v.validate('/tmp')
|
10
|
-
|
11
|
-
assert_equal(v.is_valid, true)
|
12
|
-
assert_equal(v.message, 'Path does not exist locally: /tmp')
|
13
|
-
end
|
14
|
-
|
15
|
-
def test_invalid
|
16
|
-
v = CLIUtils::FilepathExistsValidator.new
|
17
|
-
v.validate('asdasd')
|
18
|
-
|
19
|
-
assert_equal(v.is_valid, false)
|
20
|
-
assert_equal(v.message, 'Path does not exist locally: asdasd')
|
21
|
-
end
|
22
|
-
end
|
@@ -1,30 +0,0 @@
|
|
1
|
-
require 'test_helper'
|
2
|
-
|
3
|
-
require File.join(File.dirname(__FILE__), '..', '..', 'lib/cliutils/prefs/pref_validators/non_nil_validator')
|
4
|
-
|
5
|
-
# Tests for the Configurator class
|
6
|
-
class TestNonNilValidator < Test::Unit::TestCase
|
7
|
-
def test_valid
|
8
|
-
v = CLIUtils::NonNilValidator.new
|
9
|
-
v.validate('asdasdasd')
|
10
|
-
|
11
|
-
assert_equal(v.is_valid, true)
|
12
|
-
assert_equal(v.message, 'Nil text not allowed')
|
13
|
-
end
|
14
|
-
|
15
|
-
def test_invalid_1
|
16
|
-
v = CLIUtils::NonNilValidator.new
|
17
|
-
v.validate('')
|
18
|
-
|
19
|
-
assert_equal(v.is_valid, false)
|
20
|
-
assert_equal(v.message, 'Nil text not allowed')
|
21
|
-
end
|
22
|
-
|
23
|
-
def test_invalid_2
|
24
|
-
v = CLIUtils::NonNilValidator.new
|
25
|
-
v.validate(nil)
|
26
|
-
|
27
|
-
assert_equal(v.is_valid, false)
|
28
|
-
assert_equal(v.message, 'Nil text not allowed')
|
29
|
-
end
|
30
|
-
end
|
@@ -1,22 +0,0 @@
|
|
1
|
-
require 'test_helper'
|
2
|
-
|
3
|
-
require File.join(File.dirname(__FILE__), '..', '..', 'lib/cliutils/prefs/pref_validators/number_validator')
|
4
|
-
|
5
|
-
# Tests for the Configurator class
|
6
|
-
class TestNumberValidator < Test::Unit::TestCase
|
7
|
-
def test_valid
|
8
|
-
v = CLIUtils::NumberValidator.new
|
9
|
-
v.validate('1234.112')
|
10
|
-
|
11
|
-
assert_equal(v.is_valid, 0)
|
12
|
-
assert_equal(v.message, 'Response is not a number: 1234.112')
|
13
|
-
end
|
14
|
-
|
15
|
-
def test_invalid
|
16
|
-
v = CLIUtils::NumberValidator.new
|
17
|
-
v.validate('abcdefg')
|
18
|
-
|
19
|
-
assert_not_equal(v.is_valid, 0)
|
20
|
-
assert_equal(v.message, 'Response is not a number: abcdefg')
|
21
|
-
end
|
22
|
-
end
|
@@ -1,22 +0,0 @@
|
|
1
|
-
require 'test_helper'
|
2
|
-
|
3
|
-
require File.join(File.dirname(__FILE__), '..', '..', 'lib/cliutils/prefs/pref_validators/time_validator')
|
4
|
-
|
5
|
-
# Tests for the Configurator class
|
6
|
-
class TestTimeValidator < Test::Unit::TestCase
|
7
|
-
def test_valid
|
8
|
-
v = CLIUtils::TimeValidator.new
|
9
|
-
v.validate('12:43 AM')
|
10
|
-
|
11
|
-
assert_equal(v.is_valid, 0)
|
12
|
-
assert_equal(v.message, 'Response is not a time: 12:43 AM')
|
13
|
-
end
|
14
|
-
|
15
|
-
def test_invalid
|
16
|
-
v = CLIUtils::TimeValidator.new
|
17
|
-
v.validate('bzzzp')
|
18
|
-
|
19
|
-
assert_not_equal(v.is_valid, 0)
|
20
|
-
assert_equal(v.message, 'Response is not a time: bzzzp')
|
21
|
-
end
|
22
|
-
end
|
@@ -1,22 +0,0 @@
|
|
1
|
-
require 'test_helper'
|
2
|
-
|
3
|
-
require File.join(File.dirname(__FILE__), '..', '..', 'lib/cliutils/prefs/pref_validators/url_validator')
|
4
|
-
|
5
|
-
# Tests for the Configurator class
|
6
|
-
class TestUrlValidator < Test::Unit::TestCase
|
7
|
-
def test_valid
|
8
|
-
v = CLIUtils::UrlValidator.new
|
9
|
-
v.validate('http://www.google.com')
|
10
|
-
|
11
|
-
assert_equal(v.is_valid, 0)
|
12
|
-
assert_equal(v.message, 'Response is not a url: http://www.google.com')
|
13
|
-
end
|
14
|
-
|
15
|
-
def test_invalid
|
16
|
-
v = CLIUtils::UrlValidator.new
|
17
|
-
v.validate('basdahd0283123')
|
18
|
-
|
19
|
-
assert_not_equal(v.is_valid, 0)
|
20
|
-
assert_equal(v.message, 'Response is not a url: basdahd0283123')
|
21
|
-
end
|
22
|
-
end
|