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,44 +0,0 @@
1
- #
2
- # The ui-views manipulation functionality
3
- #
4
- module UnderOs::UI::Manipulation
5
-
6
- def insert(view, position=:end)
7
- if view.is_a?(Array)
8
- view.each{|v| insert(v, position)}
9
- else
10
- if position == :top
11
- @_.insertSubview(view._, atIndex: 0)
12
- else
13
- @_.addSubview(view._)
14
- end
15
- end
16
-
17
- self
18
- end
19
-
20
- def append(*views)
21
- views.each{|v| insert(v)}
22
- self
23
- end
24
-
25
- def prepend(*views)
26
- views.each{|v| insert(v, :top) }
27
- self
28
- end
29
-
30
- def insertTo(view, position=nil)
31
- view.insert(self, position)
32
- self
33
- end
34
-
35
- def remove
36
- @_.removeFromSuperview
37
- self
38
- end
39
-
40
- def clear
41
- children.each(&:remove)
42
- self
43
- end
44
- end
@@ -1,21 +0,0 @@
1
- class UnderOs::UI::Position < UnderOs::Point
2
- def initialize(view)
3
- @view = view
4
- end
5
-
6
- def x
7
- @view.style.left
8
- end
9
-
10
- def x=(position)
11
- @view.style.left = position
12
- end
13
-
14
- def y
15
- @view.style.top
16
- end
17
-
18
- def y=(position)
19
- @view.style.top = position
20
- end
21
- end
@@ -1,21 +0,0 @@
1
- class UnderOs::UI::Size < UnderOs::Point
2
- def initialize(view)
3
- @view = view
4
- end
5
-
6
- def x
7
- @view.style.width
8
- end
9
-
10
- def x=(size)
11
- @view.style.width = size
12
- end
13
-
14
- def y
15
- @view.style.height
16
- end
17
-
18
- def y=(size)
19
- @view.style.height = size
20
- end
21
- end
@@ -1,89 +0,0 @@
1
- #
2
- # The styles handling API for UIView
3
- #
4
- module UnderOs::UI::Styles
5
- def style(hash=nil)
6
- if hash
7
- self.style = hash
8
- self
9
- else
10
- @_style ||= UnderOs::UI::Style.new(_, tagName.downcase.to_sym)
11
- end
12
- end
13
-
14
- def style=(hash)
15
- hash.each{ |key, value| style.__send__("#{key}=", value)}
16
- end
17
-
18
- def className
19
- classNames.join(' ')
20
- end
21
-
22
- def className=(names)
23
- self.classNames = names.scan(/([a-z0-9\-_]+)/).map{|e| e[0]}
24
- end
25
-
26
- def classNames
27
- @_class_names ||= []
28
- end
29
-
30
- def classNames=(list)
31
- repaint_if_classes_change do
32
- @_class_names = list.uniq.map(&:to_s)
33
- end
34
- end
35
-
36
- def hasClass(name)
37
- classNames.include?(name)
38
- end
39
-
40
- def addClass(name)
41
- repaint_if_classes_change do
42
- self.classNames += [name]
43
- end
44
- end
45
-
46
- def removeClass(name)
47
- repaint_if_classes_change do
48
- self.classNames -= [name]
49
- end
50
- end
51
-
52
- def toggleClass(name)
53
- if hasClass(name)
54
- removeClass name
55
- else
56
- addClass name
57
- end
58
- end
59
-
60
- def radioClass(name)
61
- parent.children.each do |view|
62
- view.removeClass(name) if view != self
63
- end
64
-
65
- addClass name
66
- end
67
-
68
- def repaint(stylesheet=nil, &block)
69
- stylesheet ||= page && page.stylesheet
70
-
71
- if stylesheet
72
- styles = stylesheet.styles_for(self)
73
- styles = block.call(styles) if block_given?
74
- self.style = styles
75
- children.each{ |view| view.repaint(stylesheet) }
76
- end
77
-
78
- self
79
- end
80
-
81
- private
82
-
83
- def repaint_if_classes_change
84
- prev_list = @_class_names.to_s
85
- yield if block_given?
86
- repaint if prev_list != @_class_names.to_s
87
- self
88
- end
89
- end
@@ -1,44 +0,0 @@
1
- module UnderOs::UI::Traversing
2
- def first(css_rule)
3
- find(css_rule)[0]
4
- end
5
-
6
- def find(css_rule)
7
- [].tap do |result|
8
- children.each do |view|
9
- result << view if view.matches(css_rule)
10
- view.find(css_rule).each do |sub|
11
- result << sub
12
- end
13
- end
14
- end
15
- end
16
-
17
- def matches(css_rule)
18
- UnderOs::Page::StylesMatcher.new(css_rule).match(self)
19
- end
20
-
21
- def parent(css_rule=nil)
22
- if ! css_rule
23
- UnderOs::UI::View.new(@_.superview) if @_.superview
24
- else
25
- parent = self
26
- while parent.is_a?(UnderOs::UI::View) && (parent = parent.parent)
27
- return parent if parent.matches(css_rule)
28
- end
29
- end
30
- end
31
-
32
- def children(css_rule=nil)
33
- result = @_.subviews.map{|v| UnderOs::UI::View.new(v) if v}.compact
34
- css_rule ? result.select{|v| v.matches(css_rule)} : result
35
- end
36
-
37
- def siblings(css_rule=nil)
38
- parent ? (parent.children(css_rule) - [self]) : []
39
- end
40
-
41
- def empty?
42
- @_.subviews.empty?
43
- end
44
- end
@@ -1,77 +0,0 @@
1
- #
2
- # The raw -> abstraction wrapping code
3
- # for UI::Views
4
- #
5
- module UnderOs::UI::Wrap
6
- INSTANCES_CACHE = {}
7
- RAW_WRAPS_MAP = {}
8
- WRAPS_TAGS_MAP = {}
9
-
10
- def self.included(base)
11
- base.instance_eval do
12
- attr_accessor :_
13
-
14
- def self.wraps(raw_class, options={})
15
- RAW_WRAPS_MAP[self] = raw_class
16
- tag(options[:tag]) if options[:tag]
17
- end
18
-
19
- def self.tag(name)
20
- WRAPS_TAGS_MAP[name.to_s] = self
21
- end
22
-
23
- def self.new(options={}, *args, &block)
24
- return INSTANCES_CACHE[options] if INSTANCES_CACHE[options]
25
-
26
- if options.is_a?(UIView)
27
- klass = find_wrap_for(options.class)
28
- view = options; options = args.shift || {}
29
- else
30
- klass = self
31
- view = find_raw_class_for(self).alloc
32
- if view.class == UICollectionView
33
- view.initWithFrame([[0, 0], [0, 0]], collectionViewLayout: UICollectionViewFlowLayout.alloc.init)
34
- else
35
- view.initWithFrame([[0, 0], [0, 0]])
36
- end
37
- end
38
-
39
- return nil if ! klass
40
-
41
- klass.alloc.tap do |inst|
42
- INSTANCES_CACHE[inst._ = view] = inst
43
- inst.__send__ :initialize, options, *args, &block
44
- end
45
- end
46
-
47
- def self.rewrap(view, *args, &block)
48
- view = view._ if view.is_a?(UnderOs::UI::View)
49
-
50
- alloc.tap do |inst|
51
- INSTANCES_CACHE[inst._ = view] = inst
52
- inst.__send__ :initialize, *args, &block
53
- end
54
- end
55
-
56
- def self.find_wrap_for(raw_class)
57
- RAW_WRAPS_MAP.each do |wrap, raw|
58
- return wrap if raw == raw_class
59
- end
60
-
61
- return nil
62
- end
63
-
64
- def self.find_raw_class_for(wrap)
65
- while wrap
66
- return RAW_WRAPS_MAP[wrap] if RAW_WRAPS_MAP[wrap]
67
- wrap = wrap.superclass
68
- end
69
- end
70
-
71
- def self.wrap_for(raw_view)
72
- INSTANCES_CACHE[raw_view]
73
- end
74
- end
75
- end
76
-
77
- end
@@ -1,31 +0,0 @@
1
- class UnderOs::UI::View
2
- include UnderOs::UI::Wrap
3
- include UnderOs::UI::Events
4
- include UnderOs::UI::Styles
5
- include UnderOs::UI::Commons
6
- include UnderOs::UI::Animation
7
- include UnderOs::UI::Dimensions
8
- include UnderOs::UI::Traversing
9
- include UnderOs::UI::Manipulation
10
-
11
- wraps UIView, tag: 'view'
12
-
13
- def initialize(options={})
14
- self.id = options.delete(:id) if options.has_key?(:id)
15
- self.className = options.delete(:class) if options.has_key?(:class)
16
- self.style = options.delete(:style) if options.has_key?(:style)
17
- self.on = options.delete(:on) if options.has_key?(:on)
18
- self.data = options.delete(:data) if options.has_key?(:data)
19
- end
20
-
21
- def inspect
22
- params = {tag: tagName}
23
- params[:id] = id if id
24
- params[:class] = className unless classNames.empty?
25
- params = params.map do |key, value|
26
- "#{key}=\"#{value}\""
27
- end
28
-
29
- "#<#{self.class.name} #{params.join(" ")}>"
30
- end
31
- end
Binary file
@@ -1,13 +0,0 @@
1
- page {
2
- background: white;
3
- }
4
-
5
- .test {
6
- background: blue;
7
- border-radius: 5;
8
- color: yellow;
9
- }
10
-
11
- view.test {
12
- border-radius: 10;
13
- }
@@ -1,7 +0,0 @@
1
- page {
2
- background: yellow;
3
- }
4
-
5
- .test {
6
- background: green;
7
- }
@@ -1,3 +0,0 @@
1
- <page title="Hello World">
2
- <button id="hello">Say Hello</button>
3
- </page>
@@ -1,2 +0,0 @@
1
- class TestPage < UnderOs::Page
2
- end
@@ -1,19 +0,0 @@
1
- describe Hash do
2
- describe '#to_query' do
3
- it "converts a simple hash into a query string" do
4
- {a: 1, b: 2}.to_query.should == 'a=1&b=2'
5
- end
6
-
7
- it "converts nested hashes into queries correctly" do
8
- {a: 1, b: {c: {d: 4}}}.to_query.should == 'a=1&b%5Bc%5D%5Bd%5D=4'
9
- end
10
-
11
- it "handles array values correctly" do
12
- {a: [1,2,3,4]}.to_query.should == 'a%5B%5D=1&a%5B%5D=2&a%5B%5D=3&a%5B%5D=4'
13
- end
14
-
15
- it "escapes any URL sensitive characters in the values" do
16
- {a: '%= '}.to_query.should == 'a=%25=%20'
17
- end
18
- end
19
- end
@@ -1,32 +0,0 @@
1
- describe JSON do
2
- describe ".parse" do
3
- it "parses correct json strings" do
4
- JSON.parse('{"a":1,"b":true,"c":["data"]}').should == {
5
- "a" => 1, "b" => true, "c" => ["data"]
6
- }
7
- end
8
-
9
- it "raises an exception on malformed data" do
10
- -> {
11
- JSON.parse("malformed")
12
- }.should.raise(JSON::Malformed)
13
- end
14
- end
15
-
16
- describe ".generate" do
17
- it "generates JSON string out of objects" do
18
- JSON.generate({a:1, b:true, c:[:data]}).should ==
19
- '{"a":1,"b":true,"c":["data"]}'
20
- end
21
-
22
- it "generates pretty print when asked" do
23
- JSON.generate({a:1, b:true, c:[:data]}, :pretty).should ==
24
- "{\n \"a\" : 1,\n \"b\" : true,\n \"c\" : [\n \"data\"\n ]\n}"
25
- end
26
-
27
- it "allows to export things directly of objects" do
28
- {a:1, b:true, c:[:data]}.to_json.should ==
29
- '{"a":1,"b":true,"c":["data"]}'
30
- end
31
- end
32
- end
@@ -1,37 +0,0 @@
1
- describe Numeric do
2
-
3
- describe '#milliseconds' do
4
- it "returns timer duration in milliseconds" do
5
- 10.milliseconds.should == UnderOs::Timer::Duration.new(0.01)
6
- end
7
-
8
- it "has the 'ms' alias" do
9
- 10.milliseconds.should == 10.ms
10
- end
11
- end
12
-
13
- describe '#seconds' do
14
- it "returns the time duration in seconds" do
15
- 10.seconds.should == UnderOs::Timer::Duration.new(10)
16
- end
17
- end
18
-
19
- describe '#minutes' do
20
- it "returns the time duration in minutes" do
21
- 10.minutes.should == UnderOs::Timer::Duration.new(10 * 60)
22
- end
23
- end
24
-
25
- describe '#hours' do
26
- it "returns the time duration in hours" do
27
- 10.hours.should == UnderOs::Timer::Duration.new(10 * 60 * 60)
28
- end
29
- end
30
-
31
- describe '#days' do
32
- it "returns the time duration in days" do
33
- 10.days.should == UnderOs::Timer::Duration.new(10 * 60 * 60 * 24)
34
- end
35
- end
36
-
37
- end