under-os 1.3.0 → 1.4.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (140) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +4 -0
  3. data/Gemfile.lock +25 -2
  4. data/README.md +1 -1
  5. data/Rakefile +2 -4
  6. data/lib/under-os.rb +3 -8
  7. data/under-os.gemspec +6 -2
  8. metadata +47 -191
  9. data/lib/assets/fontawesome-webfont.ttf +0 -0
  10. data/lib/assets/under-os.css +0 -115
  11. data/lib/under_os.rb +0 -41
  12. data/lib/under_os/app.rb +0 -33
  13. data/lib/under_os/color.rb +0 -184
  14. data/lib/under_os/config.rb +0 -33
  15. data/lib/under_os/core/array.rb +0 -5
  16. data/lib/under_os/core/hash.rb +0 -10
  17. data/lib/under_os/core/json.rb +0 -19
  18. data/lib/under_os/core/kernel.rb +0 -16
  19. data/lib/under_os/core/numeric.rb +0 -23
  20. data/lib/under_os/core/object.rb +0 -9
  21. data/lib/under_os/core/string.rb +0 -80
  22. data/lib/under_os/delegate.rb +0 -10
  23. data/lib/under_os/events.rb +0 -85
  24. data/lib/under_os/file.rb +0 -110
  25. data/lib/under_os/history.rb +0 -53
  26. data/lib/under_os/http.rb +0 -31
  27. data/lib/under_os/http/cookies.rb +0 -30
  28. data/lib/under_os/http/receiver.rb +0 -44
  29. data/lib/under_os/http/request.rb +0 -106
  30. data/lib/under_os/http/response.rb +0 -28
  31. data/lib/under_os/http/session.rb +0 -49
  32. data/lib/under_os/page.rb +0 -169
  33. data/lib/under_os/page/builder.rb +0 -96
  34. data/lib/under_os/page/layout.rb +0 -43
  35. data/lib/under_os/page/matcher.rb +0 -128
  36. data/lib/under_os/page/stylesheet.rb +0 -67
  37. data/lib/under_os/parser.rb +0 -24
  38. data/lib/under_os/parser/css.rb +0 -37
  39. data/lib/under_os/parser/html.rb +0 -97
  40. data/lib/under_os/point.rb +0 -47
  41. data/lib/under_os/screen.rb +0 -9
  42. data/lib/under_os/timer.rb +0 -65
  43. data/lib/under_os/ui.rb +0 -3
  44. data/lib/under_os/ui/alert.rb +0 -52
  45. data/lib/under_os/ui/button.rb +0 -42
  46. data/lib/under_os/ui/collection.rb +0 -65
  47. data/lib/under_os/ui/collection/cell.rb +0 -21
  48. data/lib/under_os/ui/collection/delegate.rb +0 -70
  49. data/lib/under_os/ui/collection/item.rb +0 -32
  50. data/lib/under_os/ui/collection/layout.rb +0 -43
  51. data/lib/under_os/ui/collection/styles.rb +0 -15
  52. data/lib/under_os/ui/div.rb +0 -3
  53. data/lib/under_os/ui/form.rb +0 -60
  54. data/lib/under_os/ui/icon.rb +0 -61
  55. data/lib/under_os/ui/icon/awesome.rb +0 -376
  56. data/lib/under_os/ui/icon/engine.rb +0 -10
  57. data/lib/under_os/ui/image.rb +0 -31
  58. data/lib/under_os/ui/input.rb +0 -140
  59. data/lib/under_os/ui/label.rb +0 -21
  60. data/lib/under_os/ui/locker.rb +0 -42
  61. data/lib/under_os/ui/navbar.rb +0 -123
  62. data/lib/under_os/ui/progress.rb +0 -17
  63. data/lib/under_os/ui/scroll.rb +0 -41
  64. data/lib/under_os/ui/select.rb +0 -95
  65. data/lib/under_os/ui/sidebar.rb +0 -45
  66. data/lib/under_os/ui/slider.rb +0 -37
  67. data/lib/under_os/ui/spinner.rb +0 -23
  68. data/lib/under_os/ui/style.rb +0 -21
  69. data/lib/under_os/ui/style/fonts.rb +0 -54
  70. data/lib/under_os/ui/style/margins.rb +0 -164
  71. data/lib/under_os/ui/style/outlining.rb +0 -170
  72. data/lib/under_os/ui/style/positioning.rb +0 -169
  73. data/lib/under_os/ui/switch.rb +0 -26
  74. data/lib/under_os/ui/textarea.rb +0 -19
  75. data/lib/under_os/ui/utils/animation.rb +0 -99
  76. data/lib/under_os/ui/utils/commons.rb +0 -70
  77. data/lib/under_os/ui/utils/dimensions.rb +0 -37
  78. data/lib/under_os/ui/utils/events.rb +0 -170
  79. data/lib/under_os/ui/utils/manipulation.rb +0 -44
  80. data/lib/under_os/ui/utils/position.rb +0 -21
  81. data/lib/under_os/ui/utils/size.rb +0 -21
  82. data/lib/under_os/ui/utils/styles.rb +0 -89
  83. data/lib/under_os/ui/utils/traversing.rb +0 -44
  84. data/lib/under_os/ui/utils/wrap.rb +0 -77
  85. data/lib/under_os/ui/view.rb +0 -31
  86. data/resources/test.png +0 -0
  87. data/spec/assets/app.css +0 -13
  88. data/spec/assets/test.css +0 -7
  89. data/spec/assets/test.html +0 -3
  90. data/spec/assets/test_page.rb +0 -2
  91. data/spec/lib/core/hash_spec.rb +0 -19
  92. data/spec/lib/core/json_spec.rb +0 -32
  93. data/spec/lib/core/numeric_spec.rb +0 -37
  94. data/spec/lib/core/string_spec.rb +0 -121
  95. data/spec/lib/under_os/color_spec.rb +0 -133
  96. data/spec/lib/under_os/events_spec.rb +0 -71
  97. data/spec/lib/under_os/file_spec.rb +0 -98
  98. data/spec/lib/under_os/http/cookies_spec.rb +0 -13
  99. data/spec/lib/under_os/http/request_spec.rb +0 -44
  100. data/spec/lib/under_os/http_spec.rb +0 -20
  101. data/spec/lib/under_os/page/builder_spec.rb +0 -128
  102. data/spec/lib/under_os/page/layout_spec.rb +0 -18
  103. data/spec/lib/under_os/page/matcher_spec.rb +0 -260
  104. data/spec/lib/under_os/page/stylesheet_spec.rb +0 -83
  105. data/spec/lib/under_os/page_spec.rb +0 -5
  106. data/spec/lib/under_os/parser/css_spec.rb +0 -77
  107. data/spec/lib/under_os/parser/html_spec.rb +0 -152
  108. data/spec/lib/under_os/parser_spec.rb +0 -16
  109. data/spec/lib/under_os/point_spec.rb +0 -54
  110. data/spec/lib/under_os/screen_spec.rb +0 -11
  111. data/spec/lib/under_os/timer_spec.rb +0 -93
  112. data/spec/lib/under_os/ui/button_spec.rb +0 -50
  113. data/spec/lib/under_os/ui/collection_spec.rb +0 -19
  114. data/spec/lib/under_os/ui/div_spec.rb +0 -24
  115. data/spec/lib/under_os/ui/form_spec.rb +0 -156
  116. data/spec/lib/under_os/ui/icon_spec.rb +0 -57
  117. data/spec/lib/under_os/ui/image_spec.rb +0 -39
  118. data/spec/lib/under_os/ui/input_spec.rb +0 -109
  119. data/spec/lib/under_os/ui/label_spec.rb +0 -22
  120. data/spec/lib/under_os/ui/locker_spec.rb +0 -31
  121. data/spec/lib/under_os/ui/progress_spec.rb +0 -31
  122. data/spec/lib/under_os/ui/scroll_spec.rb +0 -40
  123. data/spec/lib/under_os/ui/select_spec.rb +0 -135
  124. data/spec/lib/under_os/ui/sidebar_spec.rb +0 -35
  125. data/spec/lib/under_os/ui/slider_spec.rb +0 -69
  126. data/spec/lib/under_os/ui/spinner_spec.rb +0 -57
  127. data/spec/lib/under_os/ui/style/fonts_spec.rb +0 -73
  128. data/spec/lib/under_os/ui/style/margins_spec.rb +0 -106
  129. data/spec/lib/under_os/ui/style/outlining_spec.rb +0 -101
  130. data/spec/lib/under_os/ui/style/positioning_spec.rb +0 -69
  131. data/spec/lib/under_os/ui/style_spec.rb +0 -19
  132. data/spec/lib/under_os/ui/switch_spec.rb +0 -60
  133. data/spec/lib/under_os/ui/textarea_spec.rb +0 -34
  134. data/spec/lib/under_os/ui/utils/commons_spec.rb +0 -81
  135. data/spec/lib/under_os/ui/utils/events_spec.rb +0 -87
  136. data/spec/lib/under_os/ui/utils/manipulation_spec.rb +0 -130
  137. data/spec/lib/under_os/ui/utils/styles_spec.rb +0 -140
  138. data/spec/lib/under_os/ui/utils/traversing_spec.rb +0 -124
  139. data/spec/lib/under_os/ui/utils/wrap_spec.rb +0 -69
  140. data/spec/lib/under_os/ui/view_spec.rb +0 -39
@@ -1,87 +0,0 @@
1
- class MyView < UnderOs::UI::View
2
- attr_reader :args
3
-
4
- def handler_with_event(event)
5
- @args = [event]
6
- end
7
-
8
- def handler_without_event
9
- @args = []
10
- end
11
- end
12
-
13
- describe UnderOs::UI::Events do
14
- before do
15
- @view = UnderOs::UI::View.new
16
- end
17
-
18
- describe "#on" do
19
- before do
20
- @tapped = false
21
- @result = @view.on(:tap) { @tapped = true }
22
-
23
- @view.emit(:tap)
24
- end
25
-
26
- it "binds the event listener" do
27
- @tapped.should == true
28
- end
29
-
30
- it "returns the view object itself back" do
31
- @result.should.be.same_as @view
32
- end
33
- end
34
-
35
- describe "#off" do
36
- before do
37
- @tapped = false
38
- @view.on(:tap) { @tapped = true }
39
-
40
- @result = @view.off(:tap)
41
-
42
- @view.emit(:tap)
43
- end
44
-
45
- it "un-binds the event listener" do
46
- @tapped.should == false
47
- end
48
-
49
- it "returns the view object itself back" do
50
- @result.should.be.same_as @view
51
- end
52
- end
53
-
54
- describe "#emit" do
55
- before do
56
- @view.on(:tap) { |e| @event = e }
57
- @view.emit(:tap, custom: 'param')
58
- end
59
-
60
- it "emits an UI::Event" do
61
- @event.class.should == UnderOs::UI::Events::Event
62
- end
63
-
64
- it "sets the event target to the view" do
65
- @event.target.should.be.same_as @view
66
- end
67
- end
68
-
69
- describe "named event handlers" do
70
- before do
71
- @view = MyView.new
72
- end
73
-
74
- it "allows to bind a method by name with an event listener" do
75
- @view.on :tap, :handler_with_event
76
- @view.emit(:tap)
77
- @view.args.size.should == 1
78
- @view.args[0].class.should == UnderOs::UI::Events::Event
79
- end
80
-
81
- it "allows to bind a method by name without an event argument" do
82
- @view.on :tap, :handler_without_event
83
- @view.emit(:tap)
84
- @view.args.size.should == 0
85
- end
86
- end
87
- end
@@ -1,130 +0,0 @@
1
- describe UnderOs::UI::Manipulation do
2
- before do
3
- @v1 = UnderOs::UI::View.new
4
- @v2 = UnderOs::UI::View.new
5
- @v3 = UnderOs::UI::View.new
6
- end
7
-
8
- describe '#insert' do
9
- it "should let insert views inside of each other" do
10
- @v1.insert(@v2)
11
- @v1.insert(@v3)
12
-
13
- @v1.children.should == [@v2, @v3]
14
- end
15
-
16
- it "should let insert views on top of the subviews" do
17
- @v1.insert(@v2)
18
- @v1.insert(@v3, :top)
19
-
20
- @v1.children.should == [@v3, @v2]
21
- end
22
-
23
- it "should return the view itself after each operation" do
24
- @v1.insert(@v2).should == @v1
25
- @v1.insert(@v3).should == @v1
26
- end
27
-
28
- it "should accept lists of items" do
29
- @v1.insert([@v2, @v3])
30
- @v1.children.should == [@v2, @v3]
31
- end
32
- end
33
-
34
- describe '#append' do
35
- it "should append other views into the current one" do
36
- @v1.append(@v2)
37
- @v1.append(@v3)
38
-
39
- @v1.children.should == [@v2, @v3]
40
- end
41
-
42
- it "should allow to append several views as multiple arguments" do
43
- @v1.append(@v2, @v3)
44
-
45
- @v1.children.should == [@v2, @v3]
46
- end
47
-
48
- it "should return the view itself after each operation" do
49
- @v1.append(@v2).should == @v1
50
- @v1.append(@v3).should == @v1
51
- end
52
- end
53
-
54
- describe '#prepend' do
55
- it "should put all items on top" do
56
- @v1.prepend(@v2)
57
- @v1.prepend(@v3)
58
-
59
- @v1.children.should == [@v3, @v2]
60
- end
61
-
62
- it "should accept several views as multiple arguments" do
63
- @v1.prepend(@v2, @v3)
64
-
65
- @v1.children.should == [@v3, @v2]
66
- end
67
-
68
- it "should return the view itself after each operation" do
69
- @v1.prepend(@v2).should == @v1
70
- @v1.prepend(@v3).should == @v1
71
- end
72
- end
73
-
74
- describe '#insertTo' do
75
- it "should allow to insert view into others" do
76
- @v2.insertTo(@v1)
77
- @v3.insertTo(@v1)
78
-
79
- @v1.children.should == [@v2, @v3]
80
- end
81
-
82
- it "should allo to insert intems on top of the stack" do
83
- @v1.insert(@v2)
84
- @v3.insertTo(@v1, :top)
85
-
86
- @v1.children.should == [@v3, @v2]
87
- end
88
-
89
- it "should return the view itself after each operation" do
90
- @v2.insertTo(@v1).should == @v2
91
- @v3.insertTo(@v1).should == @v3
92
- end
93
- end
94
-
95
- describe '#remove' do
96
- it "should allow to remove items from superviews" do
97
- @v1.append(@v2, @v3)
98
-
99
- @v2.remove
100
-
101
- @v1.children.should == [@v3]
102
- end
103
-
104
- it "should not crash if there is no superviews" do
105
- @v1.remove
106
- @v2.remove
107
- @v3.remove
108
- true.should == true
109
- end
110
-
111
- it "should return the view iteslf back" do
112
- @v1.remove.should == @v1
113
- @v2.remove.should == @v2
114
- @v3.remove.should == @v3
115
- end
116
- end
117
-
118
- describe '#clear' do
119
- before { @v1.append(@v2, @v3) }
120
-
121
- it "should remove all the child elements" do
122
- @v1.clear
123
- @v1.children.should == []
124
- end
125
-
126
- it "should return itself back as a reference" do
127
- @v1.clear.should.be.same_as @v1
128
- end
129
- end
130
- end
@@ -1,140 +0,0 @@
1
- describe UnderOs::UI::Styles do
2
- before do
3
- @view = UnderOs::UI::View.new
4
- end
5
-
6
- describe '#style' do
7
- it "should return a style handler for the view" do
8
- style = @view.style
9
- style.class.should == UnderOs::UI::Style
10
- style.view.should.be.same_as @view._
11
- end
12
-
13
- it "should cache the styles handler instance" do
14
- @view.style.should.be.same_as @view.style
15
- end
16
-
17
- it "should allow to set the styles as a hash" do
18
- @view.style = {top: 10, left: 20}
19
- @view.style.top.should == 10
20
- @view.style.left.should == 20
21
- end
22
- end
23
-
24
- describe '#classNames' do
25
- it "should return an empty list by default" do
26
- @view.classNames.should == []
27
- end
28
-
29
- it "should allow to assign the lists" do
30
- @view.classNames = ['one', 'two']
31
- @view.classNames.should == ['one', 'two']
32
- end
33
-
34
- it "should remove dups on fly" do
35
- @view.classNames = ['one', 'two', 'two', 'one']
36
- @view.classNames.should == ['one', 'two']
37
- end
38
- end
39
-
40
- describe '#className' do
41
- it "should return an empty string by default" do
42
- @view.className.should == ''
43
- end
44
-
45
- it "should allow to assign new class names" do
46
- @view.className = 'one two'
47
- @view.className.should == 'one two'
48
- @view.classNames.should == ['one', 'two']
49
- end
50
- end
51
-
52
- describe '#hasClass' do
53
- it "should return 'true' if the view has the class" do
54
- @view.className = 'boo hoo'
55
- @view.hasClass('boo').should == true
56
- end
57
-
58
- it "should return false if the view has no class" do
59
- @view.className = 'boo hoo'
60
- @view.hasClass('foo').should == false
61
- end
62
- end
63
-
64
- describe '#addClass' do
65
- it "should add the class name if it's missing" do
66
- @view.addClass 'boo'
67
- @view.classNames.should == ['boo']
68
- end
69
-
70
- it "should not duplicat the class if it's already exists" do
71
- @view.classNames = ['boo']
72
- @view.addClass 'boo'
73
- @view.classNames.should == ['boo']
74
- end
75
-
76
- it "should return the view itself back" do
77
- @view.addClass('boo').should === @view
78
- end
79
- end
80
-
81
- describe '#removeClass' do
82
- it "should remove the class name if it was set" do
83
- @view.classNames = ['boo']
84
- @view.removeClass('boo')
85
- @view.classNames.should == []
86
- end
87
-
88
- it "should return the view itself back" do
89
- @view.removeClass('boo').should === @view
90
- end
91
- end
92
-
93
- describe '#toggleClass' do
94
- it "should add the class if it's missing" do
95
- @view.toggleClass('test')
96
- @view.classNames.should == ['test']
97
- end
98
-
99
- it "should remove the class if was set before" do
100
- @view.classNames = ['test']
101
- @view.toggleClass('test')
102
- @view.classNames.should == []
103
- end
104
-
105
- it "should return the view itself back" do
106
- @view.toggleClass('test').should === @view
107
- end
108
- end
109
-
110
- describe '#radioClass' do
111
- before do
112
- @v1 = UnderOs::UI::View.new.insertTo(@view)
113
- @v2 = UnderOs::UI::View.new.insertTo(@view)
114
- @v3 = UnderOs::UI::View.new.insertTo(@view)
115
- end
116
-
117
- it "should set the class only on one element" do
118
- @v2.radioClass('boo')
119
-
120
- @v1.hasClass('boo').should == false
121
- @v2.hasClass('boo').should == true
122
- @v1.hasClass('boo').should == false
123
- end
124
-
125
- it "should automatically remove the class from any of the siblings" do
126
- @v1.className = 'boo'
127
- @v3.className = 'boo'
128
-
129
- @v2.radioClass('boo')
130
-
131
- @v1.hasClass('boo').should == false
132
- @v2.hasClass('boo').should == true
133
- @v1.hasClass('boo').should == false
134
- end
135
-
136
- it "should return the view itself back" do
137
- @v2.radioClass('boo').should === @v2
138
- end
139
- end
140
- end
@@ -1,124 +0,0 @@
1
- describe UnderOs::UI::Traversing do
2
-
3
- before do
4
- @v1 = UnderOs::UI::View.new
5
- @v2 = UnderOs::UI::View.new
6
- @v3 = UnderOs::UI::View.new
7
- @v4 = UnderOs::UI::View.new
8
- @v5 = UnderOs::UI::View.new
9
- @v6 = UnderOs::UI::View.new
10
-
11
- @v1.append(
12
- @v2.append(
13
- @v3,
14
- @v4.append(
15
- @v5.append(
16
- @v6
17
- ))))
18
-
19
- @v2.className = 'v1 v2'
20
- @v3.className = 'v1 v3'
21
- @v4.className = 'v3 v4'
22
- @v5.className = 'v5'
23
- @v6.className = 'v6'
24
- end
25
-
26
- describe '#find' do
27
- it "should return a list of matching items from all levels" do
28
- @v1.find('.v1').should == [@v2, @v3]
29
- @v1.find('.v3').should == [@v3, @v4]
30
- end
31
-
32
- it "should return an empty list when nothing's found" do
33
- @v1.find(".non-existing").should == []
34
- end
35
- end
36
-
37
- describe '#first' do
38
- it "should return the first correctly matching view" do
39
- @v1.first('.v1').should == @v2
40
- @v1.first('.v3').should == @v3
41
- end
42
-
43
- it "should return nil when nothing matching found" do
44
- @v1.first('.non-existing').should == nil
45
- end
46
- end
47
-
48
- describe '#matches' do
49
- it "should return 'true' when it's given a matching css-rule" do
50
- @v2.matches('.v2').should == true
51
- end
52
-
53
- it "should return 'false' when it's given a non-matching css-rule" do
54
- @v2.matches('.something-else').should == false
55
- end
56
- end
57
-
58
- describe '#parent' do
59
- it "should be nil by default" do
60
- @v1.parent.should == nil
61
- end
62
-
63
- it "should return the correct view if the parent is set" do
64
- @v2.parent.should == @v1
65
- end
66
-
67
- it "should search for a matching parent if a css-rule was specified" do
68
- @v6.parent('.v4').should == @v4
69
- @v6.parent('.v2').should == @v2
70
- end
71
-
72
- it "should return nil if a css-rule was specified and nothing matches" do
73
- @v6.parent('.non-existing').should == nil
74
- end
75
- end
76
-
77
- describe '#children' do
78
- it "should return an empty array by default" do
79
- @v6.children.should == []
80
- end
81
-
82
- it "should return the list of children when there are some" do
83
- @v1.children.should == [@v2]
84
- @v2.children.should == [@v3, @v4]
85
- end
86
-
87
- it "should filter the list by a css-rule if one was given" do
88
- @v2.children('.v4').should == [@v4]
89
- @v2.children('.non-existing').should == []
90
- end
91
-
92
- it "should return an empty list on leaf elements like buttons" do
93
- UnderOs::UI::Image.new.children.should == []
94
- end
95
- end
96
-
97
- describe '#siblings' do
98
- it "should return the list of sibling nodes" do
99
- @v3.siblings.should == [@v4]
100
- @v4.siblings.should == [@v3]
101
- end
102
-
103
- it "should accept a css rule as a filter" do
104
- @v3.siblings('.v4').should == [@v4]
105
- @v3.siblings('.non-existing').should == []
106
- end
107
-
108
- it "should fall back to an empty list when there is no parent" do
109
- UnderOs::UI::View.new.siblings.should == []
110
- end
111
- end
112
-
113
- describe '#empty?' do
114
- it "should return true when there is no child elements" do
115
- view = UnderOs::UI::View.new
116
- view.empty?.should == true
117
- end
118
-
119
- it "should return false when there are child elements" do
120
- @v1.empty?.should == false
121
- end
122
- end
123
-
124
- end