super_module 1.1.1 → 1.2.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,16 @@
1
+ # Uses CRLF for line breaks to provide a test case for having SuperModule work with it
2
+ # This is done to test support for Windows Ruby files, which usually use CRLF for line breaks
3
+ module Support::V1::FakeActiveModel
4
+
5
+ include SuperModule
6
+
7
+ def self.validates(attribute, options)
8
+ validations << [attribute, options]
9
+ end
10
+
11
+ def self.validations
12
+ @validations ||= []
13
+ end
14
+
15
+ end
16
+
@@ -0,0 +1,87 @@
1
+ module Support::V1::Foo
2
+ include SuperModule
3
+ include Support::V1::FakeActiveModel
4
+ validates 'foo', {:presence => true}
5
+
6
+ class << self
7
+ def foo_class_self
8
+ 'self.foo_class_self'
9
+ end
10
+
11
+ def foo_class_self_define_method; 'self.foo_class_self_define_method'; end
12
+
13
+ def foo_private_declaration_follow_up
14
+ 'self.foo_private_declaration_follow_up'
15
+ end
16
+ private :foo_private_declaration_follow_up
17
+
18
+ def foo_protected_declaration_follow_up
19
+ 'self.foo_protected_declaration_follow_up'
20
+ end
21
+ protected :foo_protected_declaration_follow_up
22
+
23
+ private
24
+ def foo_private
25
+ 'self.foo_private'
26
+ end
27
+
28
+ protected
29
+ def foo_protected
30
+ 'self.foo_protected'
31
+ end
32
+
33
+ end
34
+
35
+ def self.meh
36
+ self
37
+ end
38
+
39
+ def self.foo
40
+ 'self.foo'
41
+ end
42
+
43
+ def self.foo_one_line; 'self.foo_one_line'; end
44
+
45
+ def self.foo_single_param(param1)
46
+ "self.foo(#{param1})"
47
+ end
48
+
49
+ def self.foo_multi_params(param1, param2, param3)
50
+ "self.foo(#{param1},#{param2},#{param3})"
51
+ end
52
+
53
+ def self.foo_block(&formatter)
54
+ formatter.call('self.foo')
55
+ end
56
+
57
+ def self.foo_single_param_block(param1, &formatter)
58
+ formatter.call('self.foo', param1)
59
+ end
60
+
61
+ def self.foo_multi_params_block(param1, param2, param3, &formatter)
62
+ formatter.call('self.foo', param1, param2, param3)
63
+ end
64
+
65
+ public
66
+
67
+ def self.empty
68
+ end
69
+
70
+ def self.empty_one_empty_line
71
+
72
+ end
73
+
74
+ def self.empty_with_comment
75
+ # no op
76
+ end
77
+
78
+ def self.empty_one_line_definition; end
79
+
80
+ def self.empty_one_line_definition_with_spaces; end
81
+
82
+ def foo
83
+ 'foo'
84
+ end
85
+
86
+ end
87
+
@@ -0,0 +1,6 @@
1
+ module Support::V2
2
+ end
3
+ require File.join(File.dirname(__FILE__), 'v2', 'fake_active_model')
4
+ require File.join(File.dirname(__FILE__), 'v2', 'foo')
5
+ require File.join(File.dirname(__FILE__), 'v2', 'bar')
6
+ require File.join(File.dirname(__FILE__), 'v2', 'baz')
@@ -0,0 +1,52 @@
1
+ require 'forwardable'
2
+
3
+ module Support::V2
4
+ super_module :Bar do
5
+ include Foo
6
+ include Comparable
7
+ validates 'bar', {:presence => true}
8
+ attr_reader :created_at
9
+
10
+ # Defines singleton methods via class << self to provide as a test case for SuperModule
11
+ class << self
12
+ include Forwardable
13
+
14
+ def barrable
15
+ @barrable
16
+ end
17
+
18
+ def barrable=(value)
19
+ @barrable = value
20
+ end
21
+
22
+ def make_barrable
23
+ self.barrable = true
24
+ end
25
+ end
26
+
27
+ make_barrable
28
+ def_delegators :@bar, :length
29
+
30
+ def initialize
31
+ @bar = bar
32
+ @created_at = Time.now.to_f
33
+ end
34
+
35
+ def bar
36
+ 'bar'
37
+ end
38
+
39
+ # Defines singleton method via a form of eval (class_eval) to provide as a test case for SuperModule
40
+ class_eval do
41
+ def self.bar
42
+ 'self.bar'
43
+ end
44
+ end
45
+
46
+ def <=>(other)
47
+ created_at <=> other.created_at
48
+ end
49
+
50
+ end
51
+
52
+ end
@@ -0,0 +1,27 @@
1
+ super_module 'Support::V2::Baz' do
2
+ include Support::V2::Bar
3
+ make_barrable
4
+ validates 'baz', {:presence => true}
5
+ attr_reader :baz_factor
6
+
7
+ class << self
8
+ def baz
9
+ 'self.baz'
10
+ end
11
+ end
12
+
13
+ def initialize(baz_factor)
14
+ super()
15
+ @baz_factor = baz_factor
16
+ end
17
+
18
+ def baz
19
+ 'baz'
20
+ end
21
+
22
+ def <=>(other)
23
+ baz_factor <=> other.baz_factor
24
+ end
25
+
26
+ end
27
+
@@ -0,0 +1,14 @@
1
+ # Uses CRLF for line breaks to provide a test case for having SuperModule work with it
2
+ # This is done to test support for Windows Ruby files, which usually use CRLF for line breaks
3
+ super_module 'Support::V2::FakeActiveModel' do
4
+
5
+ def self.validates(attribute, options)
6
+ validations << [attribute, options]
7
+ end
8
+
9
+ def self.validations
10
+ @validations ||= []
11
+ end
12
+
13
+ end
14
+
@@ -0,0 +1,87 @@
1
+ module Support
2
+ super_module 'V2::Foo' do
3
+ include V2::FakeActiveModel
4
+ validates 'foo', {:presence => true}
5
+
6
+ class << self
7
+ def foo_class_self
8
+ 'self.foo_class_self'
9
+ end
10
+
11
+ def foo_class_self_define_method; 'self.foo_class_self_define_method'; end
12
+
13
+ def foo_private_declaration_follow_up
14
+ 'self.foo_private_declaration_follow_up'
15
+ end
16
+ private :foo_private_declaration_follow_up
17
+
18
+ def foo_protected_declaration_follow_up
19
+ 'self.foo_protected_declaration_follow_up'
20
+ end
21
+ protected :foo_protected_declaration_follow_up
22
+
23
+ private
24
+ def foo_private
25
+ 'self.foo_private'
26
+ end
27
+
28
+ protected
29
+ def foo_protected
30
+ 'self.foo_protected'
31
+ end
32
+
33
+ end
34
+
35
+ def self.meh
36
+ self
37
+ end
38
+
39
+ def self.foo
40
+ 'self.foo'
41
+ end
42
+
43
+ def self.foo_one_line; 'self.foo_one_line'; end
44
+
45
+ def self.foo_single_param(param1)
46
+ "self.foo(#{param1})"
47
+ end
48
+
49
+ def self.foo_multi_params(param1, param2, param3)
50
+ "self.foo(#{param1},#{param2},#{param3})"
51
+ end
52
+
53
+ def self.foo_block(&formatter)
54
+ formatter.call('self.foo')
55
+ end
56
+
57
+ def self.foo_single_param_block(param1, &formatter)
58
+ formatter.call('self.foo', param1)
59
+ end
60
+
61
+ def self.foo_multi_params_block(param1, param2, param3, &formatter)
62
+ formatter.call('self.foo', param1, param2, param3)
63
+ end
64
+
65
+ public
66
+
67
+ def self.empty
68
+ end
69
+
70
+ def self.empty_one_empty_line
71
+
72
+ end
73
+
74
+ def self.empty_with_comment
75
+ # no op
76
+ end
77
+
78
+ def self.empty_one_line_definition; end
79
+
80
+ def self.empty_one_line_definition_with_spaces; end
81
+
82
+ def foo
83
+ 'foo'
84
+ end
85
+
86
+ end
87
+ end
@@ -0,0 +1,6 @@
1
+ module Support::V2Alt
2
+ end
3
+ require File.join(File.dirname(__FILE__), 'v2_alt', 'fake_active_model')
4
+ require File.join(File.dirname(__FILE__), 'v2_alt', 'foo')
5
+ require File.join(File.dirname(__FILE__), 'v2_alt', 'bar')
6
+ require File.join(File.dirname(__FILE__), 'v2_alt', 'baz')
@@ -0,0 +1,52 @@
1
+ require 'forwardable'
2
+
3
+ module Support::V2Alt
4
+ Bar = super_module do
5
+ include Foo
6
+ include Comparable
7
+ validates 'bar', {:presence => true}
8
+ attr_reader :created_at
9
+
10
+ # Defines singleton methods via class << self to provide as a test case for SuperModule
11
+ class << self
12
+ include Forwardable
13
+
14
+ def barrable
15
+ @barrable
16
+ end
17
+
18
+ def barrable=(value)
19
+ @barrable = value
20
+ end
21
+
22
+ def make_barrable
23
+ self.barrable = true
24
+ end
25
+ end
26
+
27
+ make_barrable
28
+ def_delegators :@bar, :length
29
+
30
+ def initialize
31
+ @bar = bar
32
+ @created_at = Time.now.to_f
33
+ end
34
+
35
+ def bar
36
+ 'bar'
37
+ end
38
+
39
+ # Defines singleton method via a form of eval (class_eval) to provide as a test case for SuperModule
40
+ class_eval do
41
+ def self.bar
42
+ 'self.bar'
43
+ end
44
+ end
45
+
46
+ def <=>(other)
47
+ created_at <=> other.created_at
48
+ end
49
+
50
+ end
51
+
52
+ end
@@ -0,0 +1,27 @@
1
+ Support::V2Alt::Baz = super_module do
2
+ include Support::V2::Bar
3
+ make_barrable
4
+ validates 'baz', {:presence => true}
5
+ attr_reader :baz_factor
6
+
7
+ class << self
8
+ def baz
9
+ 'self.baz'
10
+ end
11
+ end
12
+
13
+ def initialize(baz_factor)
14
+ super()
15
+ @baz_factor = baz_factor
16
+ end
17
+
18
+ def baz
19
+ 'baz'
20
+ end
21
+
22
+ def <=>(other)
23
+ baz_factor <=> other.baz_factor
24
+ end
25
+
26
+ end
27
+
@@ -0,0 +1,14 @@
1
+ # Uses CRLF for line breaks to provide a test case for having SuperModule work with it
2
+ # This is done to test support for Windows Ruby files, which usually use CRLF for line breaks
3
+ Support::V2Alt::FakeActiveModel = super_module do
4
+
5
+ def self.validates(attribute, options)
6
+ validations << [attribute, options]
7
+ end
8
+
9
+ def self.validations
10
+ @validations ||= []
11
+ end
12
+
13
+ end
14
+
@@ -0,0 +1,87 @@
1
+ module Support
2
+ V2Alt::Foo = super_module do
3
+ include V2::FakeActiveModel
4
+ validates 'foo', {:presence => true}
5
+
6
+ class << self
7
+ def foo_class_self
8
+ 'self.foo_class_self'
9
+ end
10
+
11
+ def foo_class_self_define_method; 'self.foo_class_self_define_method'; end
12
+
13
+ def foo_private_declaration_follow_up
14
+ 'self.foo_private_declaration_follow_up'
15
+ end
16
+ private :foo_private_declaration_follow_up
17
+
18
+ def foo_protected_declaration_follow_up
19
+ 'self.foo_protected_declaration_follow_up'
20
+ end
21
+ protected :foo_protected_declaration_follow_up
22
+
23
+ private
24
+ def foo_private
25
+ 'self.foo_private'
26
+ end
27
+
28
+ protected
29
+ def foo_protected
30
+ 'self.foo_protected'
31
+ end
32
+
33
+ end
34
+
35
+ def self.meh
36
+ self
37
+ end
38
+
39
+ def self.foo
40
+ 'self.foo'
41
+ end
42
+
43
+ def self.foo_one_line; 'self.foo_one_line'; end
44
+
45
+ def self.foo_single_param(param1)
46
+ "self.foo(#{param1})"
47
+ end
48
+
49
+ def self.foo_multi_params(param1, param2, param3)
50
+ "self.foo(#{param1},#{param2},#{param3})"
51
+ end
52
+
53
+ def self.foo_block(&formatter)
54
+ formatter.call('self.foo')
55
+ end
56
+
57
+ def self.foo_single_param_block(param1, &formatter)
58
+ formatter.call('self.foo', param1)
59
+ end
60
+
61
+ def self.foo_multi_params_block(param1, param2, param3, &formatter)
62
+ formatter.call('self.foo', param1, param2, param3)
63
+ end
64
+
65
+ public
66
+
67
+ def self.empty
68
+ end
69
+
70
+ def self.empty_one_empty_line
71
+
72
+ end
73
+
74
+ def self.empty_with_comment
75
+ # no op
76
+ end
77
+
78
+ def self.empty_one_line_definition; end
79
+
80
+ def self.empty_one_line_definition_with_spaces; end
81
+
82
+ def foo
83
+ 'foo'
84
+ end
85
+
86
+ end
87
+ end