opal-activesupport 0.2.0 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +7 -0
- data/Rakefile +9 -2
- data/lib/opal/activesupport/version.rb +1 -1
- data/opal-activesupport.gemspec +1 -1
- data/opal/active_support/core_ext/array.rb +2 -0
- data/opal/active_support/core_ext/array/grouping.rb +99 -0
- data/opal/active_support/core_ext/array/wrap.rb +45 -0
- data/opal/active_support/core_ext/module.rb +2 -0
- data/opal/active_support/core_ext/module/delegation.rb +64 -0
- data/opal/active_support/core_ext/module/introspection.rb +62 -0
- data/test/abstract_unit.rb +46 -0
- data/test/core_ext/array_ext_test.rb +471 -0
- data/test/core_ext/blank_test.rb +24 -0
- data/{spec/core_ext/class/attribute_spec.rb → test/core_ext/class/attribute_test.rb} +16 -20
- data/test/core_ext/kernel_test.rb +124 -0
- data/test/core_ext/module/remove_method_test.rb +29 -0
- data/test/core_ext/module_test.rb +439 -0
- data/{spec/core_ext/numeric_spec.rb → test/core_ext/numeric_ext_test.rb} +110 -116
- data/test/core_ext/object_and_class_ext_test.rb +183 -0
- data/test/core_ext/string_ext_test.rb +628 -0
- data/{spec → test}/empty_bool.rb +0 -0
- data/{spec → test}/inflector_test_cases.rb +0 -0
- data/test/minitest/autorun.rb +29 -0
- metadata +39 -30
- data/spec/core_ext/array/extract_options_spec.rb +0 -49
- data/spec/core_ext/kernel_spec.rb +0 -9
- data/spec/core_ext/module/remove_method_spec.rb +0 -29
- data/spec/core_ext/object/blank_spec.rb +0 -40
- data/spec/core_ext/object/try_spec.rb +0 -102
- data/spec/core_ext/string_spec.rb +0 -71
- data/spec/spec_helper.rb +0 -26
data/{spec → test}/empty_bool.rb
RENAMED
File without changes
|
File without changes
|
@@ -0,0 +1,29 @@
|
|
1
|
+
require 'minitest'
|
2
|
+
|
3
|
+
def Minitest.run args = []
|
4
|
+
# PORT: removed
|
5
|
+
#self.load_plugins
|
6
|
+
|
7
|
+
options = process_args args
|
8
|
+
|
9
|
+
reporter = Minitest::CompositeReporter.new
|
10
|
+
reporter << Minitest::SummaryReporter.new(options[:io], options)
|
11
|
+
reporter << Minitest::ProgressReporter.new(options[:io], options)
|
12
|
+
|
13
|
+
self.reporter = reporter # this makes it available to plugins
|
14
|
+
# PORT: removed
|
15
|
+
#self.init_plugins options
|
16
|
+
self.reporter = nil # runnables shouldn't depend on the reporter, ever
|
17
|
+
|
18
|
+
reporter.start
|
19
|
+
__run reporter, options
|
20
|
+
# PORT: removed
|
21
|
+
#self.parallel_executor.shutdown
|
22
|
+
reporter.report
|
23
|
+
|
24
|
+
# PORT: modified
|
25
|
+
reporter.passed?
|
26
|
+
# `window.OPAL_TEST_EXIT_STATUS = #{reporter.passed?}`
|
27
|
+
end
|
28
|
+
|
29
|
+
at_exit { exit Minitest.run }
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: opal-activesupport
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Elia Schito
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-12-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: opal
|
@@ -31,19 +31,19 @@ dependencies:
|
|
31
31
|
- !ruby/object:Gem::Version
|
32
32
|
version: 1.0.0
|
33
33
|
- !ruby/object:Gem::Dependency
|
34
|
-
name: opal-
|
34
|
+
name: opal-minitest
|
35
35
|
requirement: !ruby/object:Gem::Requirement
|
36
36
|
requirements:
|
37
|
-
- - "
|
37
|
+
- - ">="
|
38
38
|
- !ruby/object:Gem::Version
|
39
|
-
version: 0
|
39
|
+
version: '0'
|
40
40
|
type: :development
|
41
41
|
prerelease: false
|
42
42
|
version_requirements: !ruby/object:Gem::Requirement
|
43
43
|
requirements:
|
44
|
-
- - "
|
44
|
+
- - ">="
|
45
45
|
- !ruby/object:Gem::Version
|
46
|
-
version: 0
|
46
|
+
version: '0'
|
47
47
|
- !ruby/object:Gem::Dependency
|
48
48
|
name: rake
|
49
49
|
requirement: !ruby/object:Gem::Requirement
|
@@ -66,6 +66,7 @@ extensions: []
|
|
66
66
|
extra_rdoc_files: []
|
67
67
|
files:
|
68
68
|
- ".gitignore"
|
69
|
+
- ".travis.yml"
|
69
70
|
- Gemfile
|
70
71
|
- LICENSE.txt
|
71
72
|
- README.md
|
@@ -78,6 +79,8 @@ files:
|
|
78
79
|
- opal/active_support/core_ext.rb
|
79
80
|
- opal/active_support/core_ext/array.rb
|
80
81
|
- opal/active_support/core_ext/array/extract_options.rb
|
82
|
+
- opal/active_support/core_ext/array/grouping.rb
|
83
|
+
- opal/active_support/core_ext/array/wrap.rb
|
81
84
|
- opal/active_support/core_ext/class.rb
|
82
85
|
- opal/active_support/core_ext/class/attribute.rb
|
83
86
|
- opal/active_support/core_ext/enumerable.rb
|
@@ -88,6 +91,8 @@ files:
|
|
88
91
|
- opal/active_support/core_ext/kernel.rb
|
89
92
|
- opal/active_support/core_ext/kernel/singleton_class.rb
|
90
93
|
- opal/active_support/core_ext/module.rb
|
94
|
+
- opal/active_support/core_ext/module/delegation.rb
|
95
|
+
- opal/active_support/core_ext/module/introspection.rb
|
91
96
|
- opal/active_support/core_ext/module/remove_method.rb
|
92
97
|
- opal/active_support/core_ext/numeric.rb
|
93
98
|
- opal/active_support/core_ext/numeric/calculations.rb
|
@@ -104,17 +109,19 @@ files:
|
|
104
109
|
- opal/active_support/inflector/inflections.rb
|
105
110
|
- opal/active_support/time.rb
|
106
111
|
- opal/opal-activesupport.rb
|
107
|
-
-
|
108
|
-
-
|
109
|
-
-
|
110
|
-
-
|
111
|
-
-
|
112
|
-
-
|
113
|
-
-
|
114
|
-
-
|
115
|
-
-
|
116
|
-
-
|
117
|
-
-
|
112
|
+
- test/abstract_unit.rb
|
113
|
+
- test/core_ext/array_ext_test.rb
|
114
|
+
- test/core_ext/blank_test.rb
|
115
|
+
- test/core_ext/class/attribute_test.rb
|
116
|
+
- test/core_ext/kernel_test.rb
|
117
|
+
- test/core_ext/module/remove_method_test.rb
|
118
|
+
- test/core_ext/module_test.rb
|
119
|
+
- test/core_ext/numeric_ext_test.rb
|
120
|
+
- test/core_ext/object_and_class_ext_test.rb
|
121
|
+
- test/core_ext/string_ext_test.rb
|
122
|
+
- test/empty_bool.rb
|
123
|
+
- test/inflector_test_cases.rb
|
124
|
+
- test/minitest/autorun.rb
|
118
125
|
homepage: http://opalrb.org
|
119
126
|
licenses: []
|
120
127
|
metadata: {}
|
@@ -139,19 +146,21 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
139
146
|
version: '0'
|
140
147
|
requirements: []
|
141
148
|
rubyforge_project:
|
142
|
-
rubygems_version: 2.4.
|
149
|
+
rubygems_version: 2.4.8
|
143
150
|
signing_key:
|
144
151
|
specification_version: 4
|
145
152
|
summary: The port of the glorious ActiveSupport for Opal
|
146
153
|
test_files:
|
147
|
-
-
|
148
|
-
-
|
149
|
-
-
|
150
|
-
-
|
151
|
-
-
|
152
|
-
-
|
153
|
-
-
|
154
|
-
-
|
155
|
-
-
|
156
|
-
-
|
157
|
-
-
|
154
|
+
- test/abstract_unit.rb
|
155
|
+
- test/core_ext/array_ext_test.rb
|
156
|
+
- test/core_ext/blank_test.rb
|
157
|
+
- test/core_ext/class/attribute_test.rb
|
158
|
+
- test/core_ext/kernel_test.rb
|
159
|
+
- test/core_ext/module/remove_method_test.rb
|
160
|
+
- test/core_ext/module_test.rb
|
161
|
+
- test/core_ext/numeric_ext_test.rb
|
162
|
+
- test/core_ext/object_and_class_ext_test.rb
|
163
|
+
- test/core_ext/string_ext_test.rb
|
164
|
+
- test/empty_bool.rb
|
165
|
+
- test/inflector_test_cases.rb
|
166
|
+
- test/minitest/autorun.rb
|
@@ -1,49 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
# require 'abstract_unit'
|
4
|
-
# require 'active_support/core_ext/array'
|
5
|
-
# require 'active_support/core_ext/hash'
|
6
|
-
|
7
|
-
class HashSubclass < Hash
|
8
|
-
end
|
9
|
-
|
10
|
-
class ExtractableHashSubclass < Hash
|
11
|
-
def extractable_options?
|
12
|
-
true
|
13
|
-
end
|
14
|
-
end
|
15
|
-
|
16
|
-
describe Array do
|
17
|
-
describe '#extract_options!' do
|
18
|
-
it 'extracts options' do
|
19
|
-
assert_equal({}, [].extract_options!)
|
20
|
-
assert_equal({}, [1].extract_options!)
|
21
|
-
assert_equal({ a: :b }, [{ a: :b }].extract_options!)
|
22
|
-
assert_equal({ a: :b }, [1, { a: :b }].extract_options!)
|
23
|
-
end
|
24
|
-
|
25
|
-
it 'doesnt extract hash subclasses' do
|
26
|
-
hash = HashSubclass.new
|
27
|
-
hash[:foo] = 1
|
28
|
-
array = [hash]
|
29
|
-
options = array.extract_options!
|
30
|
-
assert_equal({}, options)
|
31
|
-
assert_equal([hash], array)
|
32
|
-
end
|
33
|
-
|
34
|
-
it 'extracts extractable subclass' do
|
35
|
-
hash = ExtractableHashSubclass.new
|
36
|
-
hash[:foo] = 1
|
37
|
-
array = [hash]
|
38
|
-
options = array.extract_options!
|
39
|
-
assert_equal({ foo: 1 }, options)
|
40
|
-
assert_equal([], array)
|
41
|
-
end
|
42
|
-
|
43
|
-
it 'extracts hash with indifferent access' do
|
44
|
-
array = [{ foo: 1 }.with_indifferent_access]
|
45
|
-
options = array.extract_options!
|
46
|
-
assert_equal(1, options[:foo])
|
47
|
-
end
|
48
|
-
end
|
49
|
-
end
|
@@ -1,29 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
module RemoveMethodTests
|
4
|
-
class A
|
5
|
-
def do_something
|
6
|
-
return 1
|
7
|
-
end
|
8
|
-
end
|
9
|
-
end
|
10
|
-
|
11
|
-
describe Module do
|
12
|
-
describe '#remove_possible_method' do
|
13
|
-
it 'removes method from an object' do
|
14
|
-
RemoveMethodTests::A.class_eval{
|
15
|
-
self.remove_possible_method(:do_something)
|
16
|
-
}
|
17
|
-
assert !RemoveMethodTests::A.new.respond_to?(:do_something)
|
18
|
-
end
|
19
|
-
end
|
20
|
-
|
21
|
-
describe '#redefine_method' do
|
22
|
-
it 'redefines method in an object' do
|
23
|
-
RemoveMethodTests::A.class_eval{
|
24
|
-
self.redefine_method(:do_something) { return 100 }
|
25
|
-
}
|
26
|
-
assert_equal 100, RemoveMethodTests::A.new.do_something
|
27
|
-
end
|
28
|
-
end
|
29
|
-
end
|
@@ -1,40 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
require 'active_support/core_ext/object/blank'
|
3
|
-
require 'empty_bool'
|
4
|
-
|
5
|
-
describe 'Object#blank?' do
|
6
|
-
BLANK = [ EmptyTrue.new, nil, false, '', ' ', " \n\t \r ", ' ', [], {} ]
|
7
|
-
NOT = [ EmptyFalse.new, Object.new, true, 0, 1, 'a', [nil], { nil => 0 } ]
|
8
|
-
|
9
|
-
BLANK.each do |v|
|
10
|
-
describe "The value of #{v.inspect}" do
|
11
|
-
it 'is #blank?' do
|
12
|
-
v.blank?.should == true
|
13
|
-
end
|
14
|
-
|
15
|
-
it 'is not #present?' do
|
16
|
-
v.present?.should == false
|
17
|
-
end
|
18
|
-
|
19
|
-
it 'has nil #presence' do
|
20
|
-
v.presence.should == nil
|
21
|
-
end
|
22
|
-
end
|
23
|
-
end
|
24
|
-
|
25
|
-
NOT.each do |v|
|
26
|
-
describe "The value of #{v.inspect}" do
|
27
|
-
it 'is not #blank?' do
|
28
|
-
v.blank?.should == false
|
29
|
-
end
|
30
|
-
|
31
|
-
it 'is not #present?' do
|
32
|
-
v.present?.should == true
|
33
|
-
end
|
34
|
-
|
35
|
-
it 'has self #presence' do
|
36
|
-
v.presence.should == v
|
37
|
-
end
|
38
|
-
end
|
39
|
-
end
|
40
|
-
end
|
@@ -1,102 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe Object do
|
4
|
-
describe '#try' do
|
5
|
-
before do
|
6
|
-
@string = "Hello"
|
7
|
-
end
|
8
|
-
|
9
|
-
it 'nonexisting method' do
|
10
|
-
method = :undefined_method
|
11
|
-
assert !@string.respond_to?(method)
|
12
|
-
assert_nil @string.try(method)
|
13
|
-
end
|
14
|
-
|
15
|
-
it 'nonexisting method with arguments' do
|
16
|
-
method = :undefined_method
|
17
|
-
assert !@string.respond_to?(method)
|
18
|
-
assert_nil @string.try(method, 'llo', 'y')
|
19
|
-
end
|
20
|
-
|
21
|
-
it 'nonexisting method bang' do
|
22
|
-
method = :undefined_method
|
23
|
-
assert !@string.respond_to?(method)
|
24
|
-
assert_raise(NoMethodError) { @string.try!(method) }
|
25
|
-
end
|
26
|
-
|
27
|
-
it 'nonexisting method with arguments bang' do
|
28
|
-
method = :undefined_method
|
29
|
-
assert !@string.respond_to?(method)
|
30
|
-
assert_raise(NoMethodError) { @string.try!(method, 'llo', 'y') }
|
31
|
-
end
|
32
|
-
|
33
|
-
it 'valid method' do
|
34
|
-
assert_equal 5, @string.try(:size)
|
35
|
-
end
|
36
|
-
|
37
|
-
it 'argument forwarding' do
|
38
|
-
assert_equal 'Hey', @string.try(:sub, 'llo', 'y')
|
39
|
-
end
|
40
|
-
|
41
|
-
it 'block forwarding' do
|
42
|
-
assert_equal 'Hey', @string.try(:sub, 'llo') { |match| 'y' }
|
43
|
-
end
|
44
|
-
|
45
|
-
it 'nil to type' do
|
46
|
-
assert_nil nil.try(:to_s)
|
47
|
-
assert_nil nil.try(:to_i)
|
48
|
-
end
|
49
|
-
|
50
|
-
it 'false try' do
|
51
|
-
assert_equal 'false', false.try(:to_s)
|
52
|
-
end
|
53
|
-
|
54
|
-
it 'try only block' do
|
55
|
-
assert_equal @string.reverse, @string.try { |s| s.reverse }
|
56
|
-
end
|
57
|
-
|
58
|
-
it 'try only block bang' do
|
59
|
-
assert_equal @string.reverse, @string.try! { |s| s.reverse }
|
60
|
-
end
|
61
|
-
|
62
|
-
it 'try only block nil' do
|
63
|
-
ran = false
|
64
|
-
nil.try { ran = true }
|
65
|
-
assert_equal false, ran
|
66
|
-
end
|
67
|
-
|
68
|
-
it 'try with instance eval block' do
|
69
|
-
assert_equal @string.reverse, @string.try { reverse }
|
70
|
-
end
|
71
|
-
|
72
|
-
it 'try with instance eval block bang' do
|
73
|
-
assert_equal @string.reverse, @string.try! { reverse }
|
74
|
-
end
|
75
|
-
|
76
|
-
it 'try with private method bang' do
|
77
|
-
klass = Class.new do
|
78
|
-
private
|
79
|
-
|
80
|
-
def private_method
|
81
|
-
'private method'
|
82
|
-
end
|
83
|
-
end
|
84
|
-
|
85
|
-
# Opal doesn't currently support private methods
|
86
|
-
# assert_raise(NoMethodError) { klass.new.try!(:private_method) }
|
87
|
-
end
|
88
|
-
|
89
|
-
it 'try with private method' do
|
90
|
-
klass = Class.new do
|
91
|
-
private
|
92
|
-
|
93
|
-
def private_method
|
94
|
-
'private method'
|
95
|
-
end
|
96
|
-
end
|
97
|
-
|
98
|
-
# Opal doesn't currently support private methods
|
99
|
-
# assert_nil klass.new.try(:private_method)
|
100
|
-
end
|
101
|
-
end
|
102
|
-
end
|
@@ -1,71 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
require 'active_support/core_ext/string'
|
3
|
-
require 'inflector_test_cases'
|
4
|
-
|
5
|
-
module InflectorTestCases
|
6
|
-
describe 'String' do
|
7
|
-
# include InflectorTestCases
|
8
|
-
|
9
|
-
describe "#demodulize" do
|
10
|
-
it "removes any preceding module name from the string" do
|
11
|
-
"Foo::Bar".demodulize.should == "Bar"
|
12
|
-
"Foo::Bar::Baz".demodulize.should == "Baz"
|
13
|
-
end
|
14
|
-
|
15
|
-
it "has no affect on strings with no module seperator" do
|
16
|
-
"SomeClassName".demodulize.should == "SomeClassName"
|
17
|
-
end
|
18
|
-
end
|
19
|
-
|
20
|
-
describe '#underscore' do
|
21
|
-
it "camel to underscore" do
|
22
|
-
CamelToUnderscore.each do |camel, underscore|
|
23
|
-
camel.underscore.should eq(underscore)
|
24
|
-
end
|
25
|
-
|
26
|
-
"HTMLTidy".underscore.should eq("html_tidy")
|
27
|
-
"HTMLTidyGenerator".underscore.should eq("html_tidy_generator")
|
28
|
-
end
|
29
|
-
|
30
|
-
it "replaces '-' in dasherized strings with underscores" do
|
31
|
-
"well-hello-there".underscore.should == "well_hello_there"
|
32
|
-
end
|
33
|
-
|
34
|
-
it "converts single all-upcase strings into lowercase" do
|
35
|
-
"OMG".underscore.should == "omg"
|
36
|
-
end
|
37
|
-
|
38
|
-
it "splits word bounderies and seperates using underscore" do
|
39
|
-
"AdamBeynon".underscore.should == "adam_beynon"
|
40
|
-
end
|
41
|
-
|
42
|
-
it "does not split when 2 or more capitalized letters together" do
|
43
|
-
"HTMLParser".underscore.should == "html_parser"
|
44
|
-
end
|
45
|
-
end
|
46
|
-
|
47
|
-
describe '#dasherize' do
|
48
|
-
it 'dasherizes' do
|
49
|
-
{
|
50
|
-
"street" => "street",
|
51
|
-
"street_address" => "street-address",
|
52
|
-
"person_street_address" => "person-street-address",
|
53
|
-
}.each_pair do |underscore, dashes|
|
54
|
-
underscore.dasherize.should == dashes
|
55
|
-
end
|
56
|
-
end
|
57
|
-
end
|
58
|
-
|
59
|
-
describe '#camelize' do
|
60
|
-
it 'camelizes' do
|
61
|
-
CamelToUnderscore.each do |camel, underscore|
|
62
|
-
underscore.camelize.should == camel
|
63
|
-
end
|
64
|
-
end
|
65
|
-
|
66
|
-
it 'accepts :lower to keep the first letter lowercase' do
|
67
|
-
'Capital'.camelize(:lower).should == 'capital'
|
68
|
-
end
|
69
|
-
end
|
70
|
-
end
|
71
|
-
end
|