ruby-ext 0.2.2 → 0.2.3

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 (101) hide show
  1. data/.git/COMMIT_EDITMSG +1 -1
  2. data/.git/index +0 -0
  3. data/.git/logs/HEAD +3 -0
  4. data/.git/logs/refs/heads/master +3 -0
  5. data/.git/logs/refs/remotes/origin/master +3 -0
  6. data/.git/objects/3a/5fe0dc6aaa6e41eb8dd865fa7d7100f4e68ced +0 -0
  7. data/.git/objects/49/3774d80093f4ec3c6c3bfad21e1c8c9eaf41ec +0 -0
  8. data/.git/objects/52/94913c6107b381d1378279e58551fa2be7cecb +0 -0
  9. data/.git/objects/57/ab6c10ddf4eff75d98b5770a2c2bf573b692cd +0 -0
  10. data/.git/objects/61/beeaa4bc6790a469babafbdc7395e9e19dcb5d +0 -0
  11. data/.git/objects/62/3a67b104c04e24316da21f3e229e1bc2ba9d31 +0 -0
  12. data/.git/objects/6d/1da4d8a2949a1a9714d5f9979c7ee9613d7cfd +0 -0
  13. data/.git/objects/7f/2c583d1fdcc5313140c57778be8b0d45824be9 +0 -0
  14. data/.git/objects/9f/e2acc9bded3dc0d29b1dfc7dc1b3bed5d72c8f +0 -0
  15. data/.git/objects/e1/3f643da891453763504616e4f5a8195b8ffdb9 +0 -0
  16. data/.git/objects/ee/69f9fad83c5b0668b62622037094e989d3c394 +0 -0
  17. data/.git/refs/heads/master +1 -1
  18. data/.git/refs/remotes/origin/master +1 -1
  19. data/Rakefile +2 -2
  20. data/lib/ruby_ext/should.rb +14 -0
  21. data/old/README +860 -0
  22. data/old/lib/RubyExt/ClassLoader.rb +142 -0
  23. data/old/lib/RubyExt/ExtraBlankSlate.rb +14 -0
  24. data/old/lib/RubyExt/ImportAll.rb +9 -0
  25. data/old/lib/RubyExt/Localization/Module.rb +12 -0
  26. data/old/lib/RubyExt/Localization/Object.rb +19 -0
  27. data/old/lib/RubyExt/Localization/require.rb +3 -0
  28. data/old/lib/RubyExt/Localization.rb +28 -0
  29. data/old/lib/RubyExt/Log.config.sample +57 -0
  30. data/old/lib/RubyExt/Log.rb +59 -0
  31. data/old/lib/RubyExt/Path.rb +91 -0
  32. data/old/lib/RubyExt/Resource/file_system_provider.rb +273 -0
  33. data/old/lib/RubyExt/StateMashine.rb +176 -0
  34. data/old/lib/RubyExt/array.rb +24 -0
  35. data/old/lib/RubyExt/class.rb +0 -0
  36. data/old/lib/RubyExt/debug.rb +71 -0
  37. data/old/lib/RubyExt/false_class.rb +5 -0
  38. data/old/lib/RubyExt/kernel.rb +3 -0
  39. data/old/lib/RubyExt/module.rb +26 -0
  40. data/old/lib/RubyExt/nil_class.rb +5 -0
  41. data/old/lib/RubyExt/observable.rb +25 -0
  42. data/old/lib/RubyExt/require.rb +1 -0
  43. data/old/lib/RubyExt/require_base.rb +1 -0
  44. data/old/lib/RubyExt/resource.rb +172 -0
  45. data/old/lib/RubyExt/true_class.rb +5 -0
  46. data/old/rakefile +52 -0
  47. data/old/require.rb +3 -0
  48. data/old/require_base.rb +3 -0
  49. data/old/spec/RubyExt/ForClassLoader/ClassA.rb +4 -0
  50. data/old/spec/RubyExt/ForClassLoader/LoadCount.rb +1 -0
  51. data/old/spec/RubyExt/ForClassLoader/ModuleA/ClassB.rb +3 -0
  52. data/old/spec/RubyExt/ForClassLoader/ModuleA/ClassInsideAnonymousClass.rb +3 -0
  53. data/old/spec/RubyExt/ForClassLoader/ModuleA/InfinityLoop.rb +3 -0
  54. data/old/spec/RubyExt/ForClassLoader/ModuleA/ModuleB/ClassC.rb +3 -0
  55. data/old/spec/RubyExt/ForClassLoader/ModuleA/SameName/SomeClass.rb +2 -0
  56. data/old/spec/RubyExt/ForClassLoader/ModuleA/SameName.rb +2 -0
  57. data/old/spec/RubyExt/ForClassLoader/Scope/ScopeA1.rb +3 -0
  58. data/old/spec/RubyExt/ForClassLoader/Scope/ScopeB1.rb +5 -0
  59. data/old/spec/RubyExt/ForKernel/Raise2.rb +5 -0
  60. data/old/spec/RubyExt/ForKernel/RaiseWithoutSelf.rb +9 -0
  61. data/old/spec/RubyExt/ForLocalization/NS/A.rb +3 -0
  62. data/old/spec/RubyExt/ForLocalization/NS/A.ru.localization.yaml +2 -0
  63. data/old/spec/RubyExt/ForLocalization/NS/B.rb +22 -0
  64. data/old/spec/RubyExt/ForLocalization/NS/B.ru.localization.yaml +3 -0
  65. data/old/spec/RubyExt/ForLocalization/NS.ru.localization.yaml +2 -0
  66. data/old/spec/RubyExt/ForModule/NS1/A.data +1 -0
  67. data/old/spec/RubyExt/ForModule/NS1/A.rb +1 -0
  68. data/old/spec/RubyExt/ForModule/NS1/A2.rb +1 -0
  69. data/old/spec/RubyExt/ForModule/NS1/B.rb +2 -0
  70. data/old/spec/RubyExt/ForModule/NS1/B2.rb +1 -0
  71. data/old/spec/RubyExt/ForModule/NS1.data +1 -0
  72. data/old/spec/RubyExt/ForModule/NS2/A.data +1 -0
  73. data/old/spec/RubyExt/ForModule/NS2/A.rb +3 -0
  74. data/old/spec/RubyExt/ForModule/NS2/B.rb +3 -0
  75. data/old/spec/RubyExt/ForModule/NS2/M.data +1 -0
  76. data/old/spec/RubyExt/ForModule/NS2/M.rb +3 -0
  77. data/old/spec/RubyExt/ForResource/ChangedClass.rb +1 -0
  78. data/old/spec/RubyExt/ForResource/ChangedClass.res/Text.txt +0 -0
  79. data/old/spec/RubyExt/ForResource/ChangedClass.txt +0 -0
  80. data/old/spec/RubyExt/ForResource/ProviderChaining/ProviderABaseDir/ChainTest.rb +3 -0
  81. data/old/spec/RubyExt/ForResource/ProviderChaining/ProviderABaseDir/ChainTest.resource +1 -0
  82. data/old/spec/RubyExt/ForResource/ProviderChaining/ProviderABaseDir/ClassExistOnlyInProviderA.rb +3 -0
  83. data/old/spec/RubyExt/ForResource/ProviderChaining/ProviderBBaseDir/ChainTest.rb +3 -0
  84. data/old/spec/RubyExt/ForResource/ProviderChaining/ProviderBBaseDir/ChainTest.resource +1 -0
  85. data/old/spec/RubyExt/ForResource/ResourceExtension.rb +1 -0
  86. data/old/spec/RubyExt/ForResource/ResourceExtension.res/Data.yaml +2 -0
  87. data/old/spec/RubyExt/ForResource/ResourceTest/Test.rb +11 -0
  88. data/old/spec/RubyExt/ForResource/ResourceTest/Test.res/Data.txt +1 -0
  89. data/old/spec/RubyExt/ForResource/ResourceTest/Test.res/txt +1 -0
  90. data/old/spec/array_spec.rb +27 -0
  91. data/old/spec/class_loader_spec.rb +94 -0
  92. data/old/spec/import_all_spec.rb +21 -0
  93. data/old/spec/kernel_spec.rb +29 -0
  94. data/old/spec/localization_spec.rb +49 -0
  95. data/old/spec/module_spec.rb +14 -0
  96. data/old/spec/object_spec.rb +8 -0
  97. data/old/spec/observable_spec.rb +44 -0
  98. data/old/spec/path_spec.rb +169 -0
  99. data/old/spec/resource_spec.rb +136 -0
  100. data/old/spec/state_machine_spec.rb +201 -0
  101. metadata +93 -2
@@ -0,0 +1,172 @@
1
+ module RubyExt
2
+ module Resource
3
+ @monitor = Monitor.new
4
+ @providers = []
5
+ @resource_extensions = {}
6
+
7
+ class NotExist < RuntimeError
8
+
9
+ end
10
+
11
+ class << self
12
+ include Observable
13
+
14
+ def add_resource_provider provider
15
+ @providers.unshift provider
16
+ end
17
+
18
+ def providers
19
+ raise "There's no any Resource Provider!" if @providers.empty?
20
+ @providers
21
+ end
22
+
23
+ def register_resource_extension extension, load, save
24
+ @monitor.synchronize do
25
+ @resource_extensions[extension] = load, save
26
+ end
27
+ end
28
+
29
+ def unregister_resource_extension extension
30
+ @monitor.synchronize do
31
+ @resource_extensions.delete extension
32
+ end
33
+ end
34
+
35
+ # Returns from first Provider that contains this Class.
36
+ def class_get class_name
37
+ @monitor.synchronize do
38
+ providers.each do |p|
39
+ begin
40
+ return p.class_get(class_name)
41
+ rescue NotExist;
42
+ end
43
+ end
44
+ raise "Class '#{class_name}' doesn't exist!"
45
+ end
46
+ end
47
+
48
+ # Search for first Provider that contains Class Namespace and creates Class in it, then exits.
49
+ def class_set class_name, data, *args
50
+ @monitor.synchronize do
51
+ namespace = Module.namespace_for class_name
52
+ namespace = namespace ? namespace.to_s : nil
53
+ found = true
54
+ providers.each do |p|
55
+ next unless !namespace or p.class_exist?(namespace)
56
+ p.class_set class_name, data, *args
57
+ break
58
+ end
59
+ raise "Namespace '#{namespace}' doesn't exist!" unless found
60
+ end
61
+ end
62
+
63
+ def class_exist? class_name
64
+ @monitor.synchronize do
65
+ providers.any?{|p| p.class_exist? class_name}
66
+ end
67
+ end
68
+
69
+ # Deletes in each Providers.
70
+ def class_delete class_name
71
+ @monitor.synchronize do
72
+ providers.each{|p| p.class_delete class_name}
73
+ end
74
+ end
75
+
76
+ # def class_namespace_exist? namespace_name
77
+ # @monitor.synchronize do
78
+ # providers.any?{|p| p.class_namespace_exist? namespace_name}
79
+ # end
80
+ # end
81
+
82
+ # Search each Provider that contains this Class and returns first found Resource.
83
+ def resource_get klass, resource_name
84
+ @monitor.synchronize do
85
+ providers.each do |p|
86
+ next unless p.class_exist?(klass.name)
87
+ begin
88
+ data = p.resource_get(klass.name, resource_name)
89
+
90
+ if data
91
+ extension = File.extname(resource_name)
92
+ if @resource_extensions.include? extension
93
+ load, save = @resource_extensions[extension]
94
+ data = load.call data, klass, resource_name
95
+ end
96
+ end
97
+
98
+ return data
99
+ rescue NotExist;
100
+ end
101
+ end
102
+ raise "Resource '#{resource_name}' for Class '#{klass.name}' doesn't exist!"
103
+ end
104
+ end
105
+
106
+ # Deletes Resource in all Providers.
107
+ def resource_delete klass, resource_name
108
+ @monitor.synchronize do
109
+ providers.each do |p|
110
+ next unless p.class_exist?(klass.name)
111
+ p.resource_delete klass.name, resource_name
112
+ end
113
+ end
114
+ end
115
+
116
+ # Set Resource in fist Provider that contains this Class.
117
+ def resource_set klass, resource_name, data
118
+ @monitor.synchronize do
119
+ extension = File.extname(resource_name)
120
+ if @resource_extensions.include? extension
121
+ load, save = @resource_extensions[extension]
122
+ data = save.call data, klass, resource_name
123
+ end
124
+
125
+ found = false
126
+ providers.each do |p|
127
+ next unless p.class_exist?(klass.name)
128
+ p.resource_set klass.name, resource_name, data
129
+ found = true
130
+ break
131
+ end
132
+
133
+ raise "Class '#{klass.name}' doesn't exist!" unless found
134
+ end
135
+ end
136
+
137
+ # Check also for Class existence.
138
+ def resource_exist? klass, resource_name
139
+ @monitor.synchronize do
140
+ providers.any? do |p|
141
+ next unless p.class_exist?(klass.name)
142
+ p.resource_exist? klass.name, resource_name
143
+ end
144
+ end
145
+ end
146
+
147
+ def class_to_virtual_file class_name
148
+ @monitor.synchronize do
149
+ providers.each do |p|
150
+ begin
151
+ return p.class_to_virtual_file class_name
152
+ rescue NotExist;
153
+ end
154
+ end
155
+ raise "Class '#{class_name}' doesn't exist!"
156
+ end
157
+ end
158
+
159
+ # def class_to_virtual_path class_name
160
+ # @monitor.synchronize do
161
+ # providers.each do |p|
162
+ # begin
163
+ # return p.class_to_virtual_path class_name
164
+ # rescue NotExist;
165
+ # end
166
+ # end
167
+ # raise "Class '#{class_name}' doesn't exist!"
168
+ # end
169
+ # end
170
+ end
171
+ end
172
+ end
@@ -0,0 +1,5 @@
1
+ class TrueClass
2
+ def copy
3
+ true
4
+ end
5
+ end
data/old/rakefile ADDED
@@ -0,0 +1,52 @@
1
+ require 'rake'
2
+ require 'spec/rake/spectask'
3
+
4
+ Dir.chdir File.dirname(__FILE__)
5
+
6
+ # Specs
7
+ task :default => :spec
8
+
9
+ Spec::Rake::SpecTask.new('spec') do |t|
10
+ t.spec_files = FileList["spec/**/*_spec.rb"]
11
+ t.libs = ["lib", "spec"]
12
+ end
13
+
14
+ # Gem
15
+ require 'rake/clean'
16
+ require 'rake/gempackagetask'
17
+ require 'fileutils'
18
+
19
+ spec = Gem::Specification.new do |s|
20
+ s.name = "RubyExt"
21
+ s.version = "0.1.1"
22
+ s.summary = "A set of Ruby language extensions, mainly for ActivePoint Project"
23
+ s.description = "A set of Ruby language extensions, mainly for ActivePoint Project"
24
+ s.author = "Alexey Petrushin"
25
+ # s.email = ""
26
+ s.homepage = "http://www.bos-tec.com"
27
+ s.rubyforge_project = "RubyExt"
28
+
29
+ s.platform = Gem::Platform::RUBY
30
+ s.has_rdoc = true
31
+ s.extra_rdoc_files = ["README"]
32
+
33
+ s.files = (%w{rakefile README} + Dir.glob("{lib,spec}/**/*"))\
34
+ .select{|f| f !~ /^\./}
35
+ # s.executables = ['restclient']
36
+ # s.add_dependency("BlueCloth", ">= 0.0.4")
37
+ s.add_dependency "facets"
38
+
39
+ s.require_path = "lib"
40
+ end
41
+
42
+ Rake::GemPackageTask.new(spec) do |p|
43
+ package_dir = "#{File.expand_path File.dirname(__FILE__)}/../build"
44
+ # FileUtils.mkdir package_dir unless File.exist? package_dir
45
+ p.need_tar = true if RUBY_PLATFORM !~ /mswin/
46
+ p.need_zip = true
47
+ p.package_dir = package_dir
48
+ end
49
+
50
+ CLEAN.include [ 'pkg', '*.gem']
51
+
52
+ task :release => [:gem, :clean]
data/old/require.rb ADDED
@@ -0,0 +1,3 @@
1
+ require 'RubyExt/_check_and_load'
2
+ RubyExt.check_and_load __FILE__, %w{lib spec}
3
+ require 'RubyExt/_require'
@@ -0,0 +1,3 @@
1
+ require 'RubyExt/_check_and_load'
2
+ RubyExt.check_and_load __FILE__, %w{lib spec}
3
+ require 'RubyExt/_require_base'
@@ -0,0 +1,4 @@
1
+ class ClassA
2
+
3
+ end
4
+ # Do not delete this comment on last line! It's the Test!
@@ -0,0 +1 @@
1
+ class LoadCount; end
@@ -0,0 +1,3 @@
1
+ class ClassB
2
+ end
3
+ # Do not delete this comment on last line! It's the Test!
@@ -0,0 +1,3 @@
1
+ class ClassInsideAnonymousClass
2
+
3
+ end
@@ -0,0 +1,3 @@
1
+ class InvalidInfinityLoopName
2
+
3
+ end
@@ -0,0 +1,3 @@
1
+ class ClassC
2
+ ClassB
3
+ end
@@ -0,0 +1,2 @@
1
+ class SomeClass
2
+ end
@@ -0,0 +1,2 @@
1
+ class SameName
2
+ end
@@ -0,0 +1,3 @@
1
+ class ScopeA1
2
+
3
+ end
@@ -0,0 +1,5 @@
1
+ class ScopeB1
2
+ class InnerClass; end
3
+
4
+ InnerClass::ScopeA1
5
+ end
@@ -0,0 +1,5 @@
1
+ class Raise2
2
+ def test o
3
+ o.test2
4
+ end
5
+ end
@@ -0,0 +1,9 @@
1
+ class RaiseWithoutSelf
2
+ def test
3
+ raise_without_self "Error"
4
+ end
5
+
6
+ def test2
7
+ raise_without_self "Error", [RaiseWithoutSelf, Raise2]
8
+ end
9
+ end
@@ -0,0 +1,3 @@
1
+ class A
2
+
3
+ end
@@ -0,0 +1,2 @@
1
+ ---
2
+ "Class Hierarchy English": "Class Hierarchy Russian"
@@ -0,0 +1,22 @@
1
+ class B < A
2
+ def message
3
+ to_l("English")
4
+ end
5
+
6
+ def class_hierarchy_message
7
+ to_l("Class Hierarchy English")
8
+ end
9
+
10
+ def namespace_hierarchy_message
11
+ to_l("Namespace Hierarchy English")
12
+ end
13
+
14
+ def substitution
15
+ value = 10
16
+ to_l("English \#{value}", binding)
17
+ end
18
+
19
+ def not_localized
20
+ to_l("English Not Localized")
21
+ end
22
+ end
@@ -0,0 +1,3 @@
1
+ ---
2
+ "English": "Russian"
3
+ "English #{value}": "Russian #{value}"
@@ -0,0 +1,2 @@
1
+ ---
2
+ "Namespace Hierarchy English": "Namespace Hierarchy Russian"
@@ -0,0 +1 @@
1
+ A.data
@@ -0,0 +1 @@
1
+ class A; end
@@ -0,0 +1 @@
1
+ class A2; end
@@ -0,0 +1,2 @@
1
+ class B < ForModule::NS1::A
2
+ end
@@ -0,0 +1 @@
1
+ class B2 < ForModule::NS1::A2; end
@@ -0,0 +1 @@
1
+ NS1.data
@@ -0,0 +1 @@
1
+ A.data
@@ -0,0 +1,3 @@
1
+ class A
2
+
3
+ end
@@ -0,0 +1,3 @@
1
+ class B < ForModule::NS2::A
2
+ include ForModule::NS2::M
3
+ end
@@ -0,0 +1 @@
1
+ M.data
@@ -0,0 +1,3 @@
1
+ module M
2
+
3
+ end
@@ -0,0 +1 @@
1
+ class ChangedClass; end
File without changes
@@ -0,0 +1,3 @@
1
+ class ChainTest;
2
+ # "ProviderA"
3
+ end
@@ -0,0 +1,3 @@
1
+ class ClassExistOnlyInProviderA
2
+ # ClassExistOnlyInProviderA
3
+ end
@@ -0,0 +1,3 @@
1
+ class ChainTest;
2
+ # "ProviderB"
3
+ end
@@ -0,0 +1 @@
1
+ class ResourceExtension; end
@@ -0,0 +1,2 @@
1
+ ---
2
+ :value: true
@@ -0,0 +1,11 @@
1
+ require 'ActivePoint/require'
2
+
3
+ #y({:en => WGUIExt::Editors::RichTextData.new})
4
+
5
+ v = ObjectModel::Types::ObjectType.yaml_load %{---
6
+ :en: !ruby/object:WGUIExt::Editors::RichTextData
7
+ resources: []
8
+
9
+ text: ""}
10
+
11
+ p v
@@ -0,0 +1,27 @@
1
+ require 'RubyExt/require'
2
+ require 'spec'
3
+
4
+ module RubyExt
5
+ describe 'Array' do
6
+ class Respond
7
+ def test; 2 end
8
+ end
9
+
10
+ it "sort_by_weight" do
11
+ a = [:a, :b, :c]
12
+ w = [3, 2, 1]
13
+ a.sort_by_weight(w).should == [:c, :b, :a]
14
+ a.should == [:a, :b, :c]
15
+ a.sort_by_weight! w
16
+ a.should == [:c, :b, :a]
17
+ end
18
+
19
+ it "sort_by_weight (from error)" do
20
+ a = ["Attributes", "Micelaneous", "Containers", "Tools"]
21
+ w = [0, 0, -1, -2]
22
+ a.sort_by_weight! w
23
+ a.should == ["Tools", "Containers", "Attributes", "Micelaneous"]
24
+ w.should == [-2, -1, 0, 0]
25
+ end
26
+ end
27
+ end
@@ -0,0 +1,94 @@
1
+ require 'RubyExt/require_base'
2
+ require 'spec'
3
+
4
+ module RubyExt
5
+ describe "PackageManager" do
6
+ it "Should load classes only one time" do
7
+ class CustomObserver
8
+ attr_reader :list
9
+ def initialize
10
+ @list = []
11
+ end
12
+
13
+ def update_class klass
14
+ @list << klass
15
+ end
16
+ end
17
+ obs = CustomObserver.new
18
+ RubyExt::ClassLoader.add_observer obs
19
+ ForClassLoader::LoadCount
20
+ ForClassLoader::LoadCount
21
+ RubyExt::ClassLoader.delete_observers
22
+ obs.list.inject(0){|count, klass| klass == ForClassLoader::LoadCount ? count + 1 : count}.
23
+ should == 1
24
+ end
25
+
26
+ it "Should load classes From Multiple directories" do
27
+
28
+ end
29
+
30
+ it "Class has the same name as package" do
31
+ ForClassLoader::ModuleA::SameName
32
+ RubyExt::ForClassLoader::ModuleA::SameName::SomeClass
33
+ end
34
+
35
+ it "Infinity Loop" do
36
+ lambda{ForClassLoader::ModuleA::InfinityLoop}.
37
+ should raise_error(/Class Name .+ doesn't correspond to File Name/)
38
+ end
39
+
40
+ it "Core" do
41
+ ForClassLoader::ModuleA::ModuleB::ClassC.new
42
+ end
43
+
44
+
45
+ module ForClassLoader::ModuleA
46
+ class << self
47
+ def anonymous
48
+ ClassInsideAnonymousClass
49
+ end
50
+ end
51
+ end
52
+
53
+ it "Should works inside Anonymous Class" do
54
+ ForClassLoader::ModuleA.anonymous
55
+ end
56
+
57
+ it "Should raise exception if class isn't defined in scope" do
58
+ ForClassLoader::Scope::ScopeA1
59
+ RubyExt::ClassLoader.error_on_defined_constant = true
60
+ lambda{ForClassLoader::Scope::ScopeB1}.
61
+ should raise_error(/Class '.+' is not defined in the '.+' Namespace!/)
62
+ end
63
+
64
+ it "Class Reloading" do
65
+ fname = File.join(File.dirname(__FILE__), 'RubyExt/ForClassLoader/ModuleA/ClassReloading.rb')
66
+ File.delete fname if File.exist? fname
67
+ File.open(fname, 'w') do |f|
68
+ f.write %{\
69
+ class ClassReloading
70
+ def test
71
+ 1
72
+ end
73
+ end}
74
+ end
75
+
76
+ test = ForClassLoader::ModuleA::ClassReloading.new
77
+ test.test.should == 1
78
+
79
+ File.open(fname, 'w') do |f|
80
+ f.write %{\
81
+ class ClassReloading
82
+ def test
83
+ 2
84
+ end
85
+ end}
86
+ end
87
+
88
+ RubyExt::ClassLoader.reload_class(ForClassLoader::ModuleA::ClassReloading.name)
89
+ test.test.should == 2
90
+
91
+ File.delete fname if File.exist? fname
92
+ end
93
+ end
94
+ end
@@ -0,0 +1,21 @@
1
+ require 'RubyExt/require_base'
2
+ require 'spec'
3
+
4
+ module RubyExt
5
+ describe "ImportAll" do
6
+ class A
7
+ class B; end
8
+ class C; end
9
+ class D; end
10
+ end
11
+
12
+ class E
13
+ extend RubyExt::ImportAll
14
+ import_all A
15
+ end
16
+
17
+ it do
18
+ E::B
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,29 @@
1
+ require 'RubyExt/require'
2
+ require 'spec'
3
+
4
+ module RubyExt
5
+ describe 'Kernel' do
6
+
7
+ it "raise_without_self" do
8
+ begin
9
+ ForKernel::RaiseWithoutSelf.new.test
10
+ rescue RuntimeError => e
11
+ stack = e.backtrace
12
+ stack.any?{|line| line =~ /RaiseWithoutSelf/}.should be_false
13
+ stack.any?{|line| line =~ /kernel_spec/}.should be_true
14
+ end
15
+ end
16
+
17
+ it "raise_without_self" do
18
+ begin
19
+ t1 = ForKernel::RaiseWithoutSelf.new
20
+ ForKernel::Raise2.new.test t1
21
+ rescue RuntimeError => e
22
+ stack = e.backtrace
23
+ stack.any?{|line| line =~ /RaiseWithoutSelf/}.should be_false
24
+ stack.any?{|line| line =~ /Raise2/}.should be_false
25
+ stack.any?{|line| line =~ /kernel_spec/}.should be_true
26
+ end
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,49 @@
1
+ require 'spec'
2
+ require 'RubyExt/Localization/require'
3
+
4
+ module RubyExt
5
+ describe "RubyExt::Localization" do
6
+ before :each do
7
+ RubyExt::Localization.default_language = :en
8
+ RubyExt::Localization.language = nil
9
+ end
10
+
11
+ it "Default Language" do
12
+ ForLocalization::NS::B.new.message.should == "English"
13
+ RubyExt::Localization.default_language = :ru
14
+ ForLocalization::NS::B.new.message.should == "Russian"
15
+ end
16
+
17
+ it "Not Localized" do
18
+ RubyExt::Localization.default_language = :ru
19
+ ForLocalization::NS::B.new.not_localized.should == "English Not Localized"
20
+ end
21
+
22
+ it "Language set" do
23
+ ForLocalization::NS::B.new.message.should == "English"
24
+ RubyExt::Localization.language = lambda{:ru}
25
+ ForLocalization::NS::B.new.message.should == "Russian"
26
+ end
27
+
28
+ it "Language not set" do
29
+ RubyExt::Localization.language = lambda{nil}
30
+ ForLocalization::NS::B.new.message.should == "English"
31
+ end
32
+
33
+ it "Class Hierarchy" do
34
+ RubyExt::Localization.language = lambda{:ru}
35
+ ForLocalization::NS::B.new.class_hierarchy_message.should == "Class Hierarchy Russian"
36
+ end
37
+
38
+ it "Namespace Hierarchy" do
39
+ RubyExt::Localization.language = lambda{:ru}
40
+ ForLocalization::NS::B.new.namespace_hierarchy_message.should ==
41
+ "Namespace Hierarchy Russian"
42
+ end
43
+
44
+ it "Substitution" do
45
+ RubyExt::Localization.language = lambda{:ru}
46
+ ForLocalization::NS::B.new.substitution.should == "Russian 10"
47
+ end
48
+ end
49
+ end