rcommons 0.8.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (42) hide show
  1. data/COPYING +202 -0
  2. data/Changes.rdoc +4 -0
  3. data/README.rdoc +21 -0
  4. data/Rakefile +277 -0
  5. data/doc/jamis.rb +589 -0
  6. data/lib/commons.rb +44 -0
  7. data/lib/commons/io/filename_utils.rb +54 -0
  8. data/lib/commons/lang/builder/to_s_builder.rb +124 -0
  9. data/lib/commons/lang/builder/to_s_style.rb +493 -0
  10. data/lib/commons/lang/class_loader.rb +77 -0
  11. data/lib/commons/lang/class_utils.rb +50 -0
  12. data/lib/commons/lang/object_utils.rb +61 -0
  13. data/lib/commons/lang/state_error.rb +41 -0
  14. data/lib/commons/lang/system_utils.rb +113 -0
  15. data/lib/commons/lang/time/date_utils.rb +47 -0
  16. data/lib/commons/lang/time/duration_format_utils.rb +279 -0
  17. data/lib/commons/lang/time/stop_watch.rb +207 -0
  18. data/lib/commons/logging/impl/log4r_logger.rb +159 -0
  19. data/lib/commons/logging/impl/log_factory_impl.rb +253 -0
  20. data/lib/commons/logging/impl/no_op_log.rb +59 -0
  21. data/lib/commons/logging/impl/simple_log.rb +251 -0
  22. data/lib/commons/logging/log.rb +106 -0
  23. data/lib/commons/logging/log_configuration_error.rb +40 -0
  24. data/lib/commons/logging/log_factory.rb +177 -0
  25. data/lib/commons/ruby/exception.rb +46 -0
  26. data/lib/commons/ruby/log4r.rb +34 -0
  27. data/lib/commons/ruby/log4r/logger.rb +116 -0
  28. data/lib/commons/ruby/string.rb +55 -0
  29. data/lib/commons/ruby/test/unit.rb +33 -0
  30. data/lib/commons/ruby/test/unit/assertions.rb +50 -0
  31. data/lib/commons/util/properties.rb +84 -0
  32. data/test/commons/io/filename_utils_test.rb +69 -0
  33. data/test/commons/lang/builder/to_s_builder_test.rb +101 -0
  34. data/test/commons/lang/system_utils_test.rb +75 -0
  35. data/test/commons/lang/time/duration_format_utils_test.rb +261 -0
  36. data/test/commons/lang/time/stop_watch_test.rb +232 -0
  37. data/test/commons/logging/impl/log4r_logger_test.rb +133 -0
  38. data/test/commons/logging/log_factory_test.rb +80 -0
  39. data/test/commons/ruby/string_test.rb +64 -0
  40. data/test/commons/util/properties_test.rb +92 -0
  41. data/test/log4r/logger_test.rb +92 -0
  42. metadata +123 -0
@@ -0,0 +1,64 @@
1
+ # = String Test Case
2
+ #
3
+ #--
4
+ # Ruby version 1.8
5
+ #
6
+ # == Authors
7
+ # * Yomei Komiya
8
+ #
9
+ # == Copyright
10
+ # 2008 the original author or authors.
11
+ #
12
+ # == License
13
+ # Apache License 2.0
14
+ #
15
+ # Licensed under the Apache License, Version 2.0 (the "License");
16
+ # you may not use this file except in compliance with the License.
17
+ # You may obtain a copy of the License at
18
+ #
19
+ # http://www.apache.org/licenses/LICENSE-2.0
20
+ #
21
+ # Unless required by applicable law or agreed to in writing, software
22
+ # distributed under the License is distributed on an "AS IS" BASIS,
23
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
24
+ # See the License for the specific language governing permissions and
25
+ # limitations under the License.
26
+ #++
27
+ # == Version
28
+ # SVN: $Id: string_test.rb 76 2008-10-12 11:45:33Z whitestar $
29
+ #
30
+ # == Since
31
+ # File available since Release 0.8.0
32
+
33
+ require 'commons/ruby/test/unit'
34
+
35
+ require 'commons/ruby/string'
36
+
37
+ class StringTest < Test::Unit::TestCase
38
+
39
+ def setup
40
+ end
41
+
42
+
43
+ def teardown
44
+ end
45
+
46
+
47
+ def test_substring
48
+ assert_equal('abcdef', 'abcdef'.substring(0))
49
+ assert_equal('cdef', 'abcdef'.substring(2))
50
+ assert_equal('f', 'abcdef'.substring(5))
51
+ assert_equal('', 'abcdef'.substring(6))
52
+
53
+ assert_equal('ab', 'abcdef'.substring(0, 2))
54
+ assert_equal('c', 'abcdef'.substring(2, 3))
55
+ assert_equal('de', 'abcdef'.substring(3, 5))
56
+ end
57
+
58
+
59
+ def test_replace_all
60
+ assert_equal('aBcaBc', 'abcabc'.replace_all(/b/, 'B'))
61
+ assert_equal('abcabc', 'abcabc'.replace_all(/z/, 'Z'))
62
+ end
63
+
64
+ end
@@ -0,0 +1,92 @@
1
+ # = Properties
2
+ #
3
+ #--
4
+ # Ruby version 1.8
5
+ #
6
+ # == Authors
7
+ # * Yomei Komiya
8
+ #
9
+ # == Copyright
10
+ # 2008 the original author or authors.
11
+ #
12
+ # == License
13
+ # Apache License 2.0
14
+ #
15
+ # Licensed under the Apache License, Version 2.0 (the "License");
16
+ # you may not use this file except in compliance with the License.
17
+ # You may obtain a copy of the License at
18
+ #
19
+ # http://www.apache.org/licenses/LICENSE-2.0
20
+ #
21
+ # Unless required by applicable law or agreed to in writing, software
22
+ # distributed under the License is distributed on an "AS IS" BASIS,
23
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
24
+ # See the License for the specific language governing permissions and
25
+ # limitations under the License.
26
+ #++
27
+ # == Version
28
+ # SVN: $Id: properties_test.rb 76 2008-10-12 11:45:33Z whitestar $
29
+ #
30
+ # == Since
31
+ # File available since Release 0.8.0
32
+
33
+ require 'commons/ruby/test/unit'
34
+
35
+ require 'commons/util/properties'
36
+
37
+ module Commons
38
+ module Util
39
+
40
+ class PropertiesTest < Test::Unit::TestCase
41
+
42
+ def setup
43
+ @props = Properties.new
44
+ props_path = File.dirname(__FILE__) + '/sample.properties'
45
+ File.open(props_path, 'r') {|file|
46
+ @props.load(file)
47
+ }
48
+ end
49
+
50
+
51
+ def teardown
52
+ end
53
+
54
+
55
+ def test_initialize
56
+ props = Properties.new
57
+ assert_true(props.properties.empty?)
58
+ # TODO:
59
+ end
60
+
61
+
62
+ def test_load
63
+ expected = Hash[
64
+ 'test.key1', 'value1',
65
+ 'test.key2', 'value2']
66
+ assert_equal(expected, @props.properties)
67
+ end
68
+
69
+
70
+ def test_property_names
71
+ expected = Array['test.key1', 'test.key2']
72
+ assert_equal(expected, @props.property_names)
73
+ end
74
+
75
+
76
+ def test_get_property
77
+ default_value = 'default'
78
+ assert_equal(default_value, @props.get_property('no_key', default_value))
79
+
80
+ assert_nil(@props.get_property('no_key'))
81
+ end
82
+
83
+
84
+ def test_set_property
85
+ expected = 'value200'
86
+ @props.set_property('key200', expected)
87
+ assert_equal(expected, @props.get_property('key200'))
88
+ end
89
+ end
90
+
91
+ end
92
+ end
@@ -0,0 +1,92 @@
1
+ # = Log4r Logger Test Case
2
+ #
3
+ #--
4
+ # Ruby version 1.8
5
+ #
6
+ # == Authors
7
+ # * Yomei Komiya
8
+ #
9
+ # == Copyright
10
+ # 2008 the original author or authors.
11
+ #
12
+ # == License
13
+ # Apache License 2.0
14
+ #
15
+ # Licensed under the Apache License, Version 2.0 (the "License");
16
+ # you may not use this file except in compliance with the License.
17
+ # You may obtain a copy of the License at
18
+ #
19
+ # http://www.apache.org/licenses/LICENSE-2.0
20
+ #
21
+ # Unless required by applicable law or agreed to in writing, software
22
+ # distributed under the License is distributed on an "AS IS" BASIS,
23
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
24
+ # See the License for the specific language governing permissions and
25
+ # limitations under the License.
26
+ #++
27
+ # == Version
28
+ # SVN: $Id: logger_test.rb 76 2008-10-12 11:45:33Z whitestar $
29
+ #
30
+ # == Since
31
+ # File available since Release 0.8.0
32
+
33
+ #require 'log4r'
34
+ require 'commons/ruby/log4r'
35
+
36
+ require 'log4r/configurator'
37
+ require 'log4r/yamlconfigurator'
38
+
39
+ require 'commons/ruby/test/unit'
40
+
41
+ module Log4r
42
+
43
+ class LoggerTest < Test::Unit::TestCase
44
+ LOG = Logger.get_logger(self.name)
45
+
46
+ def setup
47
+ end
48
+
49
+
50
+ def teardown
51
+ end
52
+
53
+
54
+ def test_log_by_xml_configurator
55
+ if LOG.debug?
56
+ LOG.debug('This is DEBUG log by LOG.')
57
+ end
58
+ LOG.info('This is INFO log by LOG.')
59
+ LOG.warn('This is WARN log by LOG.')
60
+ LOG.error('This is ERROR log by LOG.')
61
+ LOG.fatal('This is FATAL log by LOG.')
62
+
63
+ #Configurator.load_xml_file(File.dirname(__FILE__) + '/log4r.xml');
64
+ logger = Logger.get_logger(self.class.name)
65
+ #logger = Logger.new(self.class.name)
66
+
67
+ if logger.debug?
68
+ logger.debug('This is DEBUG log.')
69
+ end
70
+ logger.info('This is INFO log.')
71
+ logger.warn('This is WARN log.')
72
+ logger.error('This is ERROR log.')
73
+ logger.fatal('This is FATAL log.')
74
+ end
75
+
76
+
77
+ def test_log_by_yaml_configurator
78
+ YamlConfigurator.load_yaml_file(File.dirname(__FILE__) + '/log4r.yaml');
79
+ logger = Logger.get_logger(self.class.name)
80
+ #logger = Logger.new(self.class.name)
81
+
82
+ if logger.debug?
83
+ logger.debug('This is DEBUG log.')
84
+ end
85
+ logger.info('This is INFO log.')
86
+ logger.warn('This is WARN log.')
87
+ logger.error('This is ERROR log.')
88
+ logger.fatal('This is FATAL log.')
89
+ end
90
+ end
91
+
92
+ end
metadata ADDED
@@ -0,0 +1,123 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: rcommons
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.8.0
5
+ platform: ruby
6
+ authors:
7
+ - Yomei Komiya
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+
12
+ date: 2008-11-09 00:00:00 +09:00
13
+ default_executable:
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ name: facets
17
+ version_requirement:
18
+ version_requirements: !ruby/object:Gem::Requirement
19
+ requirements:
20
+ - - ">="
21
+ - !ruby/object:Gem::Version
22
+ version: 2.4.4
23
+ version:
24
+ - !ruby/object:Gem::Dependency
25
+ name: log4r
26
+ version_requirement:
27
+ version_requirements: !ruby/object:Gem::Requirement
28
+ requirements:
29
+ - - ">="
30
+ - !ruby/object:Gem::Version
31
+ version: 1.0.5
32
+ version:
33
+ description:
34
+ email: ""
35
+ executables: []
36
+
37
+ extensions: []
38
+
39
+ extra_rdoc_files:
40
+ - README.rdoc
41
+ - Changes.rdoc
42
+ files:
43
+ - lib/commons/ruby/log4r/logger.rb
44
+ - lib/commons/ruby/log4r.rb
45
+ - lib/commons/ruby/test/unit/assertions.rb
46
+ - lib/commons/ruby/test/unit.rb
47
+ - lib/commons/ruby/string.rb
48
+ - lib/commons/ruby/exception.rb
49
+ - lib/commons/io/filename_utils.rb
50
+ - lib/commons/lang/class_loader.rb
51
+ - lib/commons/lang/time/duration_format_utils.rb
52
+ - lib/commons/lang/time/date_utils.rb
53
+ - lib/commons/lang/time/stop_watch.rb
54
+ - lib/commons/lang/class_utils.rb
55
+ - lib/commons/lang/system_utils.rb
56
+ - lib/commons/lang/builder/to_s_style.rb
57
+ - lib/commons/lang/builder/to_s_builder.rb
58
+ - lib/commons/lang/state_error.rb
59
+ - lib/commons/lang/object_utils.rb
60
+ - lib/commons/logging/log_factory.rb
61
+ - lib/commons/logging/log_configuration_error.rb
62
+ - lib/commons/logging/log.rb
63
+ - lib/commons/logging/impl/log_factory_impl.rb
64
+ - lib/commons/logging/impl/log4r_logger.rb
65
+ - lib/commons/logging/impl/no_op_log.rb
66
+ - lib/commons/logging/impl/simple_log.rb
67
+ - lib/commons/util/properties.rb
68
+ - lib/commons.rb
69
+ - test/log4r/logger_test.rb
70
+ - test/commons/ruby/string_test.rb
71
+ - test/commons/io/filename_utils_test.rb
72
+ - test/commons/lang/system_utils_test.rb
73
+ - test/commons/lang/time/stop_watch_test.rb
74
+ - test/commons/lang/time/duration_format_utils_test.rb
75
+ - test/commons/lang/builder/to_s_builder_test.rb
76
+ - test/commons/logging/log_factory_test.rb
77
+ - test/commons/logging/impl/log4r_logger_test.rb
78
+ - test/commons/util/properties_test.rb
79
+ - doc/jamis.rb
80
+ - README.rdoc
81
+ - Changes.rdoc
82
+ - Rakefile
83
+ - COPYING
84
+ has_rdoc: true
85
+ homepage: http://rcommons.sourceforge.jp/wikiu/
86
+ post_install_message:
87
+ rdoc_options:
88
+ - --title
89
+ - rCommons 0.8.0 API documentation
90
+ - --main
91
+ - README.rdoc
92
+ require_paths:
93
+ - lib
94
+ required_ruby_version: !ruby/object:Gem::Requirement
95
+ requirements:
96
+ - - ">="
97
+ - !ruby/object:Gem::Version
98
+ version: "0"
99
+ version:
100
+ required_rubygems_version: !ruby/object:Gem::Requirement
101
+ requirements:
102
+ - - ">="
103
+ - !ruby/object:Gem::Version
104
+ version: "0"
105
+ version:
106
+ requirements: []
107
+
108
+ rubyforge_project: rcommons
109
+ rubygems_version: 1.1.1
110
+ signing_key:
111
+ specification_version: 2
112
+ summary: Common libraries for Ruby similar to Apache Commons.
113
+ test_files:
114
+ - test/log4r/logger_test.rb
115
+ - test/commons/ruby/string_test.rb
116
+ - test/commons/io/filename_utils_test.rb
117
+ - test/commons/lang/system_utils_test.rb
118
+ - test/commons/lang/time/stop_watch_test.rb
119
+ - test/commons/lang/time/duration_format_utils_test.rb
120
+ - test/commons/lang/builder/to_s_builder_test.rb
121
+ - test/commons/logging/log_factory_test.rb
122
+ - test/commons/logging/impl/log4r_logger_test.rb
123
+ - test/commons/util/properties_test.rb