core_ex 0.2.0 → 0.3.1
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.
- data/NEWS +39 -1
- data/SPEC.dyn.yml +6 -6
- data/SPEC.gemspec +13 -0
- data/SPEC.yml +3 -3
- data/lib/core_ex/dependencies_ext/constant_load_path.rb +23 -0
- data/lib/core_ex/embedded_tests.rb +29 -23
- data/lib/core_ex/enumerable.rb +10 -18
- data/lib/core_ex/exception.rb +24 -21
- data/lib/core_ex/file_utils.rb +51 -0
- data/lib/core_ex/module/attr_once.rb +41 -0
- data/lib/core_ex/module/import.rb +28 -0
- data/lib/core_ex/module/mix_in_with_args.rb +267 -0
- data/lib/core_ex/object/instance_eval_with_args.rb +56 -0
- data/lib/core_ex/object/singleton_class.rb +78 -0
- data/lib/core_ex/object/the_first_time.rb +32 -0
- data/lib/core_ex/pathname.rb +268 -164
- data/lib/core_ex/proc.rb +77 -0
- data/lib/core_ex/rakefile_base.rf +93 -51
- data/lib/core_ex/require.rb +43 -384
- data/lib/core_ex/string.rb +52 -41
- data/lib/core_ex/time.rb +26 -41
- data/lib/core_ex/try_dup.rb +68 -0
- data/lib/core_ex/yaml.rb +103 -100
- data/lib/core_ex.rb +246 -35
- data/lib/{core_ex/dtime.rb → d_time.rb} +36 -22
- data/lib/{core_ex/dumpable_proc.rb → dumpable_proc.rb} +1 -2
- data/lib/{core_ex/pathlist.rb → path_list.rb} +111 -63
- data/lib/{core_ex/temp_path.rb → temp_path.rb} +55 -41
- data/lib/{core_ex/test/unit/ui/yaml/testrunner.rb → test/unit/u_i/yaml/test_runner.rb} +7 -10
- data/lib/{core_ex/version.rb → version.rb} +4 -7
- data/lib/yaml_extension.rb +78 -0
- data/test/check-core_ex.yml +6 -8
- data/test/check-pkg-core_ex.yml +3 -6
- data/test/sanity/multiple-requires.yml +41 -17
- data/test/sanity/single-requires.yml +36 -20
- data/test/sanity-suite.yml +5 -7
- data/test/test-unit-setup.rb +11 -3
- data/test/unit-suite.yml +8 -9
- metadata +35 -13
- data/lib/core_ex/attr_once.rb +0 -36
- data/lib/core_ex/fileutils.rb +0 -44
@@ -1,24 +1,40 @@
|
|
1
1
|
---
|
2
2
|
|
3
|
-
CoreEx Sanity Single Requires Test Suite:
|
3
|
+
CoreEx Sanity Single Requires Test Suite: !S::Iterate
|
4
4
|
|
5
|
-
|
6
|
-
|
7
|
-
regexp: !re ^<<pwd>>\/\.\.\/\.\.\/lib\/(.*)\.rb$
|
5
|
+
over: !pathlist <<pwd>>/../../lib/(*).rb
|
6
|
+
iter: [it_file, it_name]
|
8
7
|
test:
|
9
|
-
<<
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
8
|
+
<<it_name>>: !S::Suite
|
9
|
+
attributes: !S::Cmd
|
10
|
+
command: ruby
|
11
|
+
exit: 0
|
12
|
+
error: ""
|
13
|
+
output: !re 0 failures, 0 errors$
|
14
|
+
args: -I<<pwd>>/../../lib
|
15
|
+
contents:
|
16
|
+
- require:
|
17
|
+
input: |
|
18
|
+
require 'core_ex'
|
19
|
+
require '<<it_name>>'
|
20
|
+
require 'test/unit'
|
21
|
+
class TC_ < Test::Unit::TestCase
|
22
|
+
def test_definitions
|
23
|
+
assert($LOADED_FEATURES.include?('<<it_name>>.rb'),
|
24
|
+
"<<it_name>> not in $LOADED_FEATURES")
|
25
|
+
end
|
26
|
+
end
|
27
|
+
- lazy loading:
|
28
|
+
input: |
|
29
|
+
require 'core_ex'
|
30
|
+
require 'test/unit'
|
31
|
+
class TC_ < Test::Unit::TestCase
|
32
|
+
def test_definitions
|
33
|
+
assert_nothing_raised('cannot camelmize <<it_name>>') do
|
34
|
+
@camel = '<<it_name>>'.camelize
|
35
|
+
end
|
36
|
+
assert_nothing_raised("#@camel not defined?") do
|
37
|
+
@camel.constantize
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
data/test/sanity-suite.yml
CHANGED
@@ -1,12 +1,10 @@
|
|
1
1
|
---
|
2
2
|
|
3
|
-
CoreEx Sanity Test Suite:
|
3
|
+
CoreEx Sanity Test Suite: !S::Iterate
|
4
4
|
|
5
|
-
|
6
|
-
|
7
|
-
regexp : !re ([^\/]*)\.yml$
|
5
|
+
over: !pathlist <<pwd>>/(sanity/**/*.yml)
|
6
|
+
iter: [it_file, it_name]
|
8
7
|
|
9
8
|
test:
|
10
|
-
<<
|
11
|
-
|
12
|
-
import : <<path>>
|
9
|
+
<<it_name>>: !S::Import
|
10
|
+
import : <<it_file>>
|
data/test/test-unit-setup.rb
CHANGED
@@ -2,10 +2,18 @@
|
|
2
2
|
raise 'Do not load CoreEx before me' if defined? CoreEx
|
3
3
|
require 'pathname'
|
4
4
|
$VERBOSE = true
|
5
|
-
|
5
|
+
lib = (Pathname.new(__FILE__).dirname.parent + 'lib').expand_path.cleanpath
|
6
|
+
$: << lib
|
6
7
|
args = ARGV.inject(nil) { |accu, x| (accu)? accu << x : ((x == '--')? [] : accu) } || ARGV
|
7
8
|
path = Pathname.new(args[0]).expand_path.cleanpath
|
8
9
|
EMBEDDED_TEST_MODE = Regexp.new(path)
|
10
|
+
$LOAD_PATH << lib.parent.parent + 'lib'
|
9
11
|
require 'core_ex'
|
10
|
-
|
11
|
-
|
12
|
+
Test::Unit::UI::Yaml::TestRunner.import!
|
13
|
+
begin
|
14
|
+
file = path.ext('').to_s.sub(/^#{lib}\/*/, '')
|
15
|
+
file.camelize.constantize unless file.empty?
|
16
|
+
rescue NameError
|
17
|
+
require file
|
18
|
+
end
|
19
|
+
run_embedded_test_sections
|
data/test/unit-suite.yml
CHANGED
@@ -1,14 +1,13 @@
|
|
1
1
|
---
|
2
2
|
|
3
|
-
CoreEx Unit Test Suite:
|
3
|
+
CoreEx Unit Test Suite: !S::Iterate
|
4
4
|
|
5
|
-
|
6
|
-
|
7
|
-
regexp : !re ([^/]*)\.rb$
|
5
|
+
over : !pathlist <<pwd>>/../lib/(**/*).rb
|
6
|
+
iter : [it_file, it_name]
|
8
7
|
|
9
8
|
test:
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
9
|
+
Unit test <<it_name>>: !S::RUnit
|
10
|
+
input: !path <<pwd>>/test-unit-setup.rb
|
11
|
+
args: <<it_file>>
|
12
|
+
dir: <<pwd>>
|
13
|
+
verbose: true
|
metadata
CHANGED
@@ -1,10 +1,10 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
|
-
rubygems_version: 0.8.
|
2
|
+
rubygems_version: 0.8.11
|
3
3
|
specification_version: 1
|
4
4
|
name: core_ex
|
5
5
|
version: !ruby/object:Gem::Version
|
6
|
-
version: 0.
|
7
|
-
date: 2005-
|
6
|
+
version: 0.3.1
|
7
|
+
date: 2005-09-16 00:00:00 +02:00
|
8
8
|
summary: CoreEx is a proposal for a standard library extension.
|
9
9
|
require_paths:
|
10
10
|
- lib
|
@@ -19,7 +19,7 @@ description: "CoreEx is designed to provides a simple but quite useful extens
|
|
19
19
|
also some new features like attr_once, DTime, TempPath, Version,
|
20
20
|
embedded_tests, filelist (almost from rake), a common Rakefile, and an
|
21
21
|
extension of the require system."
|
22
|
-
autorequire:
|
22
|
+
autorequire:
|
23
23
|
default_executable:
|
24
24
|
bindir: bin
|
25
25
|
has_rdoc: false
|
@@ -31,28 +31,39 @@ required_ruby_version: !ruby/object:Gem::Version::Requirement
|
|
31
31
|
version: 0.0.0
|
32
32
|
version:
|
33
33
|
platform: ruby
|
34
|
+
signing_key:
|
35
|
+
cert_chain:
|
34
36
|
authors:
|
35
37
|
- Nicolas Despr�s
|
36
38
|
- Nicolas Pouillard
|
37
39
|
files:
|
38
40
|
- lib/core_ex.rb
|
39
|
-
- lib/
|
40
|
-
- lib/
|
41
|
-
- lib/
|
41
|
+
- lib/d_time.rb
|
42
|
+
- lib/dumpable_proc.rb
|
43
|
+
- lib/path_list.rb
|
44
|
+
- lib/temp_path.rb
|
45
|
+
- lib/version.rb
|
46
|
+
- lib/yaml_extension.rb
|
42
47
|
- lib/core_ex/embedded_tests.rb
|
43
48
|
- lib/core_ex/enumerable.rb
|
44
49
|
- lib/core_ex/exception.rb
|
45
|
-
- lib/core_ex/
|
46
|
-
- lib/core_ex/pathlist.rb
|
50
|
+
- lib/core_ex/file_utils.rb
|
47
51
|
- lib/core_ex/pathname.rb
|
52
|
+
- lib/core_ex/proc.rb
|
48
53
|
- lib/core_ex/rakefile_base.rf
|
49
54
|
- lib/core_ex/require.rb
|
50
55
|
- lib/core_ex/string.rb
|
51
|
-
- lib/core_ex/temp_path.rb
|
52
56
|
- lib/core_ex/time.rb
|
53
|
-
- lib/core_ex/
|
57
|
+
- lib/core_ex/try_dup.rb
|
54
58
|
- lib/core_ex/yaml.rb
|
55
|
-
- lib/core_ex/
|
59
|
+
- lib/core_ex/dependencies_ext/constant_load_path.rb
|
60
|
+
- lib/core_ex/module/attr_once.rb
|
61
|
+
- lib/core_ex/module/import.rb
|
62
|
+
- lib/core_ex/module/mix_in_with_args.rb
|
63
|
+
- lib/core_ex/object/instance_eval_with_args.rb
|
64
|
+
- lib/core_ex/object/singleton_class.rb
|
65
|
+
- lib/core_ex/object/the_first_time.rb
|
66
|
+
- lib/test/unit/u_i/yaml/test_runner.rb
|
56
67
|
- test/check-core_ex.yml
|
57
68
|
- test/check-pkg-core_ex.yml
|
58
69
|
- test/resources
|
@@ -74,6 +85,7 @@ files:
|
|
74
85
|
- Rakefile
|
75
86
|
- README
|
76
87
|
- SPEC.dyn.yml
|
88
|
+
- SPEC.gemspec
|
77
89
|
- SPEC.yml
|
78
90
|
test_files: []
|
79
91
|
rdoc_options: []
|
@@ -81,4 +93,14 @@ extra_rdoc_files: []
|
|
81
93
|
executables: []
|
82
94
|
extensions: []
|
83
95
|
requirements: []
|
84
|
-
dependencies:
|
96
|
+
dependencies:
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: activesupport
|
99
|
+
version_requirement:
|
100
|
+
version_requirements: !ruby/object:Gem::Version::Requirement
|
101
|
+
requirements:
|
102
|
+
-
|
103
|
+
- "~>"
|
104
|
+
- !ruby/object:Gem::Version
|
105
|
+
version: 1.1.1
|
106
|
+
version:
|
data/lib/core_ex/attr_once.rb
DELETED
@@ -1,36 +0,0 @@
|
|
1
|
-
# Copyright: Copyright (c) 2004 Nicolas Despres. All rights reserved.
|
2
|
-
# Author: Nicolas Despres <polrop@lrde.epita.fr>.
|
3
|
-
# License: Gnu General Public License.
|
4
|
-
|
5
|
-
# $LastChangedBy: ertai $
|
6
|
-
# $Id: attr_once.rb 249 2005-05-31 13:23:42Z ertai $
|
7
|
-
|
8
|
-
|
9
|
-
class Module
|
10
|
-
|
11
|
-
# You can use this method as you use attr_reader. Must be used only with
|
12
|
-
# immutable object.
|
13
|
-
#
|
14
|
-
# This method is imported from the Date implementation. It provides a way
|
15
|
-
# to compute only once the value of getter. Basically, the first time, the
|
16
|
-
# getter is used, its result is computed and stored in an attribute with the
|
17
|
-
# same name. The second times only the attribute is returned.
|
18
|
-
def attr_once(*ids)
|
19
|
-
for id in ids
|
20
|
-
module_eval <<-"end;", __FILE__, __LINE__
|
21
|
-
alias_method :__#{id.to_i}__, :#{id.to_s}
|
22
|
-
private :__#{id.to_i}__
|
23
|
-
def #{id.to_s}(*args, &block)
|
24
|
-
if defined? @__#{id.to_i}__
|
25
|
-
@__#{id.to_i}__
|
26
|
-
elsif ! self.frozen?
|
27
|
-
@__#{id.to_i}__ ||= __#{id.to_i}__(*args, &block)
|
28
|
-
else
|
29
|
-
__#{id.to_i}__(*args, &block)
|
30
|
-
end
|
31
|
-
end
|
32
|
-
end;
|
33
|
-
end
|
34
|
-
end
|
35
|
-
|
36
|
-
end # class Module
|
data/lib/core_ex/fileutils.rb
DELETED
@@ -1,44 +0,0 @@
|
|
1
|
-
# Copyright: Copyright (c) 2005 Nicolas Pouillard. All rights reserved.
|
2
|
-
# Author: Nicolas Pouillard <ertai@lrde.epita.fr>.
|
3
|
-
# License: Gnu General Public License.
|
4
|
-
|
5
|
-
# $LastChangedBy: ertai $
|
6
|
-
# $Id: fileutils.rb 249 2005-05-31 13:23:42Z ertai $
|
7
|
-
|
8
|
-
require 'fileutils'
|
9
|
-
|
10
|
-
module FileUtils
|
11
|
-
|
12
|
-
alias remove_dir_without_chmod remove_dir
|
13
|
-
|
14
|
-
def remove_dir (dir, force = false) #:nodoc:
|
15
|
-
dir = dir.sub(%r</\z>, '')
|
16
|
-
first_time_p = true
|
17
|
-
begin
|
18
|
-
Dir.foreach(dir) do |file|
|
19
|
-
next if /\A\.\.?\z/ =~ file
|
20
|
-
path = "#{dir}/#{file.untaint}"
|
21
|
-
if File.symlink?(path)
|
22
|
-
remove_file path, force
|
23
|
-
elsif File.directory?(path)
|
24
|
-
remove_dir path, force
|
25
|
-
else
|
26
|
-
remove_file path, force
|
27
|
-
end
|
28
|
-
end
|
29
|
-
begin
|
30
|
-
Dir.rmdir dir
|
31
|
-
rescue Errno::ENOENT
|
32
|
-
raise unless force
|
33
|
-
end
|
34
|
-
rescue
|
35
|
-
if first_time_p
|
36
|
-
first_time_p = false
|
37
|
-
File.chmod 0777, dir
|
38
|
-
retry
|
39
|
-
end
|
40
|
-
raise
|
41
|
-
end
|
42
|
-
end
|
43
|
-
|
44
|
-
end
|