eymiha 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
data/gem_package.rb ADDED
@@ -0,0 +1,31 @@
1
+ class GemPackage
2
+
3
+ attr_reader :name, :version, :files
4
+
5
+ def initialize
6
+ @name = 'eymiha'
7
+ @version = '0.1.0'
8
+ @files = FileList[
9
+ '*.rb',
10
+ 'lib/*',
11
+ 'test/*',
12
+ 'html/**/*'
13
+ ]
14
+ end
15
+
16
+ def fill_spec(s)
17
+ s.name = name
18
+ s.version = version
19
+ s.summary = "Eymiha environment and rubyism setup"
20
+ s.files = files.to_a
21
+ s.require_path = 'lib'
22
+ s.autorequire = 'eymiha'
23
+ s.has_rdoc = true
24
+ s.rdoc_options << "--all"
25
+ s.author = "Dave Anderson"
26
+ s.email = "dave@eymiha.com"
27
+ s.homepage = "http://www.eymiha.com"
28
+ s.rubyforge_project = "cori"
29
+ end
30
+
31
+ end
data/lib/eymiha.rb ADDED
@@ -0,0 +1,57 @@
1
+ # This file contains very lightweight, generally useful additions and
2
+ # modifications to the ruby core classes. While the additions should be no
3
+ # problem, and the modifications are not significantly obtrusive, they may
4
+ # present a problem if there are overlaps or dependencies.
5
+ #
6
+ # I use these in much of my code; you may find them useful too.
7
+
8
+ # A small addition to the general vocabulary.
9
+ class Module
10
+
11
+ # 'understands' reads better than 'include'
12
+ alias understands include
13
+
14
+ end
15
+
16
+
17
+ # Provides a general method raising on conversion problems.
18
+ class Object
19
+
20
+ # Raises an TypeError with a human-readable message when the instance src
21
+ # cannot be converted to an instance of type dest.
22
+ def raise_no_conversion(src,dest=self)
23
+ dest = dest.class.name unless dest.instance_of? String
24
+ raise TypeError, "Cannot convert '#{src.class.name}' to #{dest}"
25
+ end
26
+
27
+ end
28
+
29
+
30
+ # Provides a ruby-oriented string conversion.
31
+ class Hash
32
+
33
+ alias to_s_old to_s
34
+
35
+ # a general-purpose string conversion for hashes.
36
+ def to_s
37
+ strings = []
38
+ each_pair { |key, value| strings << "#{key} => #{value}" }
39
+ "{ #{strings.join ", "} }"
40
+ end
41
+
42
+ end
43
+
44
+
45
+ # Provides a ruby-oriented array conversion.
46
+ class Array
47
+
48
+ alias to_s_old to_s
49
+
50
+ # a general-purpose string conversion for arrays.
51
+ def to_s()
52
+ strings = []
53
+ each { |member| strings << "#{member}" }
54
+ "[ #{strings.join ", "} ]"
55
+ end
56
+
57
+ end
data/rakefile.rb ADDED
@@ -0,0 +1,2 @@
1
+ require 'gem_package'
2
+ require 'gem_raker'
data/test/tc_eymiha.rb ADDED
@@ -0,0 +1,68 @@
1
+ require 'test/unit'
2
+
3
+ require 'eymiha'
4
+
5
+ module Understanding
6
+
7
+ def understands?
8
+ true
9
+ end
10
+
11
+ end
12
+
13
+
14
+ class TC_understanding < Test::Unit::TestCase
15
+
16
+ understands Understanding
17
+
18
+ def test_understanding
19
+ assert(understands? == true)
20
+
21
+ end
22
+
23
+ end
24
+
25
+
26
+ class TC_object < Test::Unit::TestCase
27
+
28
+ def test_raise
29
+ assert_raise(TypeError) { raise_no_conversion(self,true) }
30
+ end
31
+
32
+ end
33
+
34
+
35
+ class TC_hash < Test::Unit::TestCase
36
+
37
+ def setup
38
+ @hash1 = { 1 => 'one' }
39
+ @hash2 = { [ :common ] => { 'time' => 'money' } }
40
+ @hash3 = { :elements => [ :earth, :air, :fire, :water] }
41
+ @hash4 = { 2 => 'two', 3=> 'three' }
42
+ end
43
+
44
+ def test_to_s
45
+ assert(@hash1.to_s == "{ 1 => one }")
46
+ assert(@hash2.to_s == "{ [ common ] => { time => money } }")
47
+ assert(@hash3.to_s == "{ elements => [ earth, air, fire, water ] }")
48
+ s = @hash4.to_s
49
+ assert((s == "{ 2 => two, 3 => three }") ||
50
+ (s == "{ 3 => three, 2 => two }"))
51
+ end
52
+
53
+ end
54
+
55
+
56
+ class TC_array < Test::Unit::TestCase
57
+
58
+ def setup
59
+ @array = [ 1, 'one', { 'time' => 'money' },
60
+ :elements, [ :earth, :air, :fire, :water] ]
61
+ end
62
+
63
+ def test_to_s
64
+ assert(@array.to_s == "[ 1, one, { time => money }, elements, [ earth, air, fire, water ] ]")
65
+ end
66
+
67
+ end
68
+
metadata ADDED
@@ -0,0 +1,49 @@
1
+ --- !ruby/object:Gem::Specification
2
+ rubygems_version: 0.9.0
3
+ specification_version: 1
4
+ name: eymiha
5
+ version: !ruby/object:Gem::Version
6
+ version: 0.1.0
7
+ date: 2007-05-10 00:00:00 -04:00
8
+ summary: Eymiha environment and rubyism setup
9
+ require_paths:
10
+ - lib
11
+ email: dave@eymiha.com
12
+ homepage: http://www.eymiha.com
13
+ rubyforge_project: cori
14
+ description:
15
+ autorequire: eymiha
16
+ default_executable:
17
+ bindir: bin
18
+ has_rdoc: true
19
+ required_ruby_version: !ruby/object:Gem::Version::Requirement
20
+ requirements:
21
+ - - ">"
22
+ - !ruby/object:Gem::Version
23
+ version: 0.0.0
24
+ version:
25
+ platform: ruby
26
+ signing_key:
27
+ cert_chain:
28
+ post_install_message:
29
+ authors:
30
+ - Dave Anderson
31
+ files:
32
+ - gem_package.rb
33
+ - rakefile.rb
34
+ - lib/eymiha.rb
35
+ - test/tc_eymiha.rb
36
+ test_files: []
37
+
38
+ rdoc_options:
39
+ - --all
40
+ extra_rdoc_files: []
41
+
42
+ executables: []
43
+
44
+ extensions: []
45
+
46
+ requirements: []
47
+
48
+ dependencies: []
49
+