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.
Files changed (86) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +2 -0
  3. data/.travis.yml +3 -2
  4. data/Gemfile +7 -0
  5. data/HISTORY.md +7 -0
  6. data/README.md +3 -1
  7. data/Rakefile +8 -1
  8. data/cliutils.gemspec +1 -0
  9. data/lib/cliutils/configuration.rb +1 -1
  10. data/lib/cliutils/constants.rb +1 -1
  11. data/lib/cliutils/ext/hash_extensions.rb +16 -12
  12. data/lib/cliutils/messaging.rb +2 -116
  13. data/lib/cliutils/messenger.rb +109 -0
  14. data/lib/cliutils/prefs/pref.rb +10 -10
  15. data/lib/cliutils/prefs/pref_actions/open_url_action.rb +1 -1
  16. data/lib/cliutils/prefs/pref_validators/filepath_exists_validator.rb +2 -0
  17. data/lib/cliutils/prefs/pref_validators/url_validator.rb +1 -1
  18. data/lib/cliutils/prefs.rb +1 -1
  19. data/lib/cliutils/pretty_io.rb +0 -10
  20. data/lib/cliutils.rb +1 -1
  21. data/spec/action/open_url_action_spec.rb +20 -0
  22. data/spec/action/pref_action_spec.rb +11 -0
  23. data/spec/behavior/capitalize_behavior_spec.rb +11 -0
  24. data/spec/behavior/expand_filepath_behavior_spec.rb +11 -0
  25. data/spec/behavior/lowercase_behavior_spec.rb +11 -0
  26. data/spec/behavior/pref_behavior_spec.rb +11 -0
  27. data/spec/behavior/prefix_behavior_spec.rb +12 -0
  28. data/spec/behavior/suffix_behavior_spec.rb +12 -0
  29. data/spec/behavior/titlecase_behavior_spec.rb +10 -0
  30. data/spec/behavior/uppercase_behavior_spec.rb +11 -0
  31. data/spec/configuration_spec.rb +37 -0
  32. data/spec/configurator_spec.rb +104 -0
  33. data/spec/ext/hash_extensions_spec.rb +54 -0
  34. data/spec/ext/logger_extensions_spec.rb +20 -0
  35. data/spec/ext/string_extensions_spec.rb +26 -0
  36. data/spec/messaging_spec.rb +91 -0
  37. data/spec/pref_spec.rb +144 -0
  38. data/spec/prefs_spec.rb +150 -0
  39. data/spec/spec_helper.rb +16 -0
  40. data/spec/validator/alphabetic_validator_spec.rb +20 -0
  41. data/spec/validator/alphanumeric_validator_spec.rb +20 -0
  42. data/spec/validator/date_validator_spec.rb +20 -0
  43. data/spec/validator/datetime_validator_spec.rb +20 -0
  44. data/spec/validator/filepath_exists_validator_spec.rb +20 -0
  45. data/spec/validator/non_nil_validator_spec.rb +24 -0
  46. data/spec/validator/number_validator_spec.rb +20 -0
  47. data/spec/validator/pref_validator_spec.rb +11 -0
  48. data/spec/validator/time_validator_spec.rb +20 -0
  49. data/spec/validator/url_validator_spec.rb +20 -0
  50. data/{test/test_files → support}/configuration.yaml +1 -1
  51. data/support/prefstest.yaml +27 -0
  52. data/{test/test_files → support}/test_action.rb +0 -0
  53. data/support/test_action_empty.rb +7 -0
  54. data/{test/test_files → support}/test_behavior.rb +2 -2
  55. data/support/test_behavior_empty.rb +6 -0
  56. data/{test/test_files → support}/test_validator.rb +0 -2
  57. data/support/test_validator_empty.rb +7 -0
  58. data/test/pref_test.rb +0 -1
  59. data/test/prefs_test.rb +64 -1
  60. data/test/test_helper.rb +2 -2
  61. metadata +91 -67
  62. data/lib/cliutils/logger_delegator.rb +0 -49
  63. data/test/action_tests/open_url_action_test.rb +0 -12
  64. data/test/behavior_tests/capitalize_behavior_test.rb +0 -11
  65. data/test/behavior_tests/expand_filepath_behavior_test.rb +0 -11
  66. data/test/behavior_tests/lowercase_behavior_test.rb +0 -11
  67. data/test/behavior_tests/prefix_behavior_test.rb +0 -12
  68. data/test/behavior_tests/suffix_behavior_test.rb +0 -12
  69. data/test/behavior_tests/titlecase_behavior_test.rb +0 -11
  70. data/test/behavior_tests/uppercase_behavior_test.rb +0 -11
  71. data/test/configuration_test.rb +0 -49
  72. data/test/configurator_test.rb +0 -63
  73. data/test/hash_extensions_test.rb +0 -51
  74. data/test/logger_extensions_test.rb +0 -17
  75. data/test/messaging_test.rb +0 -53
  76. data/test/string_extesions_test.rb +0 -28
  77. data/test/test_files/prefstest.yaml +0 -38
  78. data/test/validator_tests/alphabetic_validator_test.rb +0 -22
  79. data/test/validator_tests/alphanumeric_validator_test.rb +0 -22
  80. data/test/validator_tests/date_validator_test.rb +0 -22
  81. data/test/validator_tests/datetime_validator_test.rb +0 -22
  82. data/test/validator_tests/filepath_exists_validator_test.rb +0 -22
  83. data/test/validator_tests/non_nil_validator_test.rb +0 -30
  84. data/test/validator_tests/number_validator_test.rb +0 -22
  85. data/test/validator_tests/time_validator_test.rb +0 -22
  86. 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