under-os 1.3.0 → 1.4.0

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 (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,41 +0,0 @@
1
- module UnderOs
2
- VERSION='1.3.0'
3
-
4
- #
5
- # Generic ecosystem extension hook, for plugins and such
6
- #
7
- # require('under-os')
8
- #
9
- # UnderOs.extend __FILE__ do |app|
10
- # app.extra_things..
11
- # end
12
- #
13
- def self.extend(__file__, &block)
14
- UnderOs.setup_callbacks[__file__] = block
15
- UnderOs.setup_callbacks.size == 1 && Motion::Project::App.instance_eval do
16
- alias :setup_before_under_os :setup
17
- def setup(*args, &block)
18
- config.setup_blocks << proc do |app|
19
- UnderOs.setup_callbacks.each do |__file__, block|
20
- Dir.glob(File.dirname(__file__) + '/**/*.rb').reverse.each do |file|
21
- app.files.insert(0, file) if file != __file__
22
- end
23
-
24
- module_assets_folder = File.dirname(__file__) + "/assets"
25
- app.resources_dirs << module_assets_folder if File.exists?(module_assets_folder)
26
-
27
- block.call(app) if block
28
- end
29
- end
30
-
31
- setup_before_under_os *args, &block
32
- end
33
- end
34
- end
35
-
36
- def self.setup_callbacks
37
- @callbacks ||= {}
38
- end
39
- end
40
-
41
- UOS = UnderOS = UnderOs
@@ -1,33 +0,0 @@
1
- class UnderOs::App
2
-
3
- class << self
4
- def start(&block)
5
- @start_block = block
6
- end
7
-
8
- def setup(ios_app, options)
9
- @history = UnderOs::History.new
10
-
11
- instance_exec self, &@start_block
12
-
13
- @window = UIWindow.alloc.initWithFrame(UIScreen.mainScreen.bounds)
14
- @window.rootViewController = @history._
15
- @window.makeKeyAndVisible
16
- end
17
-
18
- def config
19
- @config ||= UnderOs::Config.new(self)
20
- end
21
-
22
- def history
23
- @history
24
- end
25
-
26
- def stylesheet
27
- @stylesheet ||= UnderOs::Page::Stylesheet.new.tap do |stylesheet|
28
- stylesheet.load('under-os.css')
29
- stylesheet.load('application.css')
30
- end
31
- end
32
- end
33
- end
@@ -1,184 +0,0 @@
1
- class UnderOs::Color
2
- attr_accessor :ui
3
-
4
- CACHE = {}
5
-
6
- def self.new(*args)
7
- color = Converter.ui_color_from(*args)
8
- CACHE[color] ||= super(color)
9
- end
10
-
11
- def initialize(ui_color)
12
- @ui = ui_color
13
- end
14
-
15
- def cg
16
- @ui.CGColor
17
- end
18
-
19
- def ci
20
- @ui.CIColor
21
- end
22
-
23
- def invert
24
- self.class.new to_rgba.tap do |rgba|
25
- rgba[0] = 255 - rgba[0]
26
- rgba[1] = 255 - rgba[1]
27
- rgba[2] = 255 - rgba[2]
28
- end
29
- end
30
-
31
- def to_rgba
32
- r = Pointer.new(:float)
33
- g = Pointer.new(:float)
34
- b = Pointer.new(:float)
35
- a = Pointer.new(:float)
36
-
37
- @ui.getRed(r, green:g, blue:b, alpha:a)
38
-
39
- r = (255 * r[0]).round
40
- g = (255 * g[0]).round
41
- b = (255 * b[0]).round
42
-
43
- [r,g,b,a[0]]
44
- end
45
-
46
- def to_rgb
47
- to_rgba.slice(0, 3)
48
- end
49
-
50
- def to_hex
51
- r, g, b = to_rgb
52
- int = (r << 16) + (g << 8) + b
53
- '#' + int.to_s(16).rjust(6, '0')
54
- end
55
-
56
- def to_s
57
- to_hex
58
- end
59
-
60
- def ==(color)
61
- color = if color.is_a?(self.class)
62
- color
63
- else
64
- color = [color] if ! color.is_a?(Array)
65
- self.class.new(*color)
66
- end
67
-
68
- to_s == color.to_s
69
- end
70
-
71
- module Converter
72
- extend self
73
-
74
- def ui_color_from(*args)
75
- origin = args.size == 1 ? args[0] : args
76
-
77
- if origin.is_a?(UIColor) then origin
78
- elsif origin.is_a?(Array) then color_from_array(*origin)
79
- elsif origin.is_a?(String) then color_from_string(origin)
80
- elsif origin.is_a?(Symbol) then color_from_string(origin.to_s)
81
- elsif origin.is_a?(Float) then color_from_param(origin)
82
- elsif origin.is_a?(Integer) then color_from_param(origin / 100.0)
83
- else UIColor.redColor # fallback
84
- end
85
- end
86
-
87
- def color_from_array(r,g,b,a=1.0)
88
- r = r / 255.0 if r.is_a?(Integer) || r > 1.0
89
- g = g / 255.0 if g.is_a?(Integer) || g > 1.0
90
- b = b / 255.0 if b.is_a?(Integer) || b > 1.0
91
-
92
- UIColor.colorWithRed(r, green: g, blue: b, alpha: a)
93
- end
94
-
95
- def color_from_string(name)
96
- name = name.downcase.strip
97
- name = ALIASES[name] || name
98
-
99
- return UIColor.send("#{name}Color") if IOS_COLORS.include?(name)
100
-
101
- name = HTML_COLORS[name] || name
102
- name = "#" + name[1]*2 + name[2]*2 + name[3]*2 if name =~ /^#[abcdef0-9]{3}$/
103
-
104
- r, g, b, a = color_2_rgba(name)
105
-
106
- color_from_array(r, g, b, a || 1.0)
107
- end
108
-
109
- def color_2_rgba(color)
110
- if color =~ /^#[abcdef0-9]{6}$/
111
- hex_2_rgb(color)
112
- elsif m = color.match(/^rgb\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d*)\s*\)$/)
113
- [m[1].to_i, m[2].to_i, m[3].to_i]
114
- elsif m = color.match(/^rgba\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d*)\s*,\s*([\d\.]+)\s*\)$/)
115
- [m[1].to_i, m[2].to_i, m[3].to_i, m[4].to_f]
116
- else
117
- raise "Malformed color spec: #{color.inspect}"
118
- end
119
- end
120
-
121
- def color_from_param(param) # 0.0..1.0
122
- color_from_array *param_2_rgb(param)
123
- end
124
-
125
- def hex_2_rgb(hex)
126
- int = hex[1..-1].to_i(16)
127
-
128
- r = (int & 0xFF0000) >> 16
129
- g = (int & 0xFF00) >> 8
130
- b = (int & 0xFF)
131
-
132
- [r, g, b]
133
- end
134
-
135
- def param_2_rgb(a) # 0.0..1.0
136
- x = 1 / 6.0
137
- s = a % x / x
138
- r = 1 - s
139
-
140
- if a < x then [1.0, s, 0.0]
141
- elsif a < x * 2 then [r, 1.0, 0.0]
142
- elsif a < x * 3 then [0.0, 1.0, s]
143
- elsif a < x * 4 then [0.0, r, 1.0]
144
- elsif a < x * 5 then [s, 0.0, 1.0]
145
- else [1.0, 0.0, r]
146
- end
147
- end
148
-
149
- ALIASES = {
150
- 'transparent' => 'clear',
151
- 'darkgray' => 'darkGray',
152
- 'lightgray' => 'lightGray'
153
- }
154
-
155
- IOS_COLORS = %w[
156
- black
157
- darkGray
158
- lightGray
159
- white
160
- gray
161
- red
162
- green
163
- blue
164
- cyan
165
- yellow
166
- magenta
167
- orange
168
- purple
169
- brown
170
- clear
171
- ].freeze
172
-
173
- HTML_COLORS = {
174
- maroon: '#800000',
175
- olive: '#808000',
176
- fuchsia: '#ff00ff',
177
- lime: '#00ff00',
178
- navy: '#000080',
179
- aqua: '#00ffff',
180
- teal: '#008080',
181
- silver: '#c0c0c0',
182
- }.freeze
183
- end
184
- end
@@ -1,33 +0,0 @@
1
- #
2
- # Application config proxy
3
- #
4
- class UnderOs::Config
5
-
6
- def initialize(app)
7
- @app = app
8
- end
9
-
10
- def root_page
11
- @app.history.root_page
12
- end
13
-
14
- def root_page=(page)
15
- @app.history.root_page = page
16
- end
17
-
18
- def status_bar
19
- @status_bar
20
- end
21
-
22
- def status_bar=(visible)
23
- @status_bar = visible
24
- end
25
-
26
- def navbar
27
- @app.history.navbar.visible
28
- end
29
-
30
- def navbar=(visible)
31
- @app.history.navbar.__send__ visible ? :show : :hide, false
32
- end
33
- end
@@ -1,5 +0,0 @@
1
- class Array
2
- def to_query(key)
3
- collect { |value| value.to_query("#{key}[]") }.join '&'
4
- end
5
- end
@@ -1,10 +0,0 @@
1
- class Hash
2
- #
3
- # Converts a hash into an URL query string
4
- #
5
- def to_query(namespace=nil)
6
- map do |key, value|
7
- value.to_query(namespace ? "#{namespace}[#{key}]" : key)
8
- end.sort * '&'
9
- end
10
- end
@@ -1,19 +0,0 @@
1
- class JSON
2
- class Malformed < StandardError ; end
3
-
4
- def self.parse(string, encoding=nil)
5
- error = Pointer.new(:object)
6
- data = NSJSONSerialization.JSONObjectWithData string.to_data(encoding), options:0, error:error
7
-
8
- if error[0]
9
- raise Malformed
10
- else
11
- data
12
- end
13
- end
14
-
15
- def self.generate(object, pretty=false)
16
- options = pretty ? NSJSONWritingPrettyPrinted : 0
17
- NSJSONSerialization.dataWithJSONObject(object, options:options, error:nil).to_s
18
- end
19
- end
@@ -1,16 +0,0 @@
1
- module Kernel
2
- def u(css_rule)
3
- return UnderOs::App.history.current_page if css_rule == 'page'
4
- return UnderOs::App.history.navbar if css_rule == 'navbar'
5
-
6
- elements = UnderOs::App.history.current_page.find(css_rule)
7
-
8
- if elements.size == 0
9
- nil
10
- elsif elements.size == 1
11
- elements[0]
12
- else
13
- elements
14
- end
15
- end
16
- end
@@ -1,23 +0,0 @@
1
- class Numeric
2
- def milliseconds
3
- UnderOs::Timer::Duration.new(self.to_f / 1000)
4
- end
5
-
6
- alias :ms :milliseconds
7
-
8
- def seconds
9
- UnderOs::Timer::Duration.new(self)
10
- end
11
-
12
- def minutes
13
- UnderOs::Timer::Duration.new(self * 60)
14
- end
15
-
16
- def hours
17
- UnderOs::Timer::Duration.new(self * 3600)
18
- end
19
-
20
- def days
21
- UnderOs::Timer::Duration.new(self * 86400)
22
- end
23
- end
@@ -1,9 +0,0 @@
1
- class Object
2
- def to_query(key)
3
- "#{key.to_s.url_encode}=#{to_s.url_encode}"
4
- end
5
-
6
- def to_json(pretty=nil)
7
- JSON.generate(self, pretty)
8
- end
9
- end
@@ -1,80 +0,0 @@
1
- class String
2
- def underscore
3
- gsub(/([a-z\d])([A-Z]+)/, '\1_\2').gsub('-', '_').downcase
4
- end
5
-
6
- def camelize
7
- gsub(/(\-|_)+([a-z])?/){|m| $2 ? $2.upcase : ''}
8
- end
9
-
10
- def dasherize
11
- underscore.gsub('_', '-')
12
- end
13
-
14
- def capitalize
15
- self[0].upcase + slice(1, size)
16
- end
17
-
18
- def starts_with?(substr)
19
- index(substr) == 0
20
- end
21
-
22
- def ends_with?(substr)
23
- rindex(substr) == size - substr.size
24
- end
25
-
26
- def blank?
27
- self !~ /[^[:space:]]/
28
- end
29
-
30
- def constantize
31
- names = self.split('::')
32
- names.shift if names.empty? || names.first.empty?
33
-
34
- constant = Object
35
- names.each do |name|
36
- constant = constant.const_defined?(name) ? constant.const_get(name) : constant.const_missing(name)
37
- end
38
- constant
39
- end
40
-
41
- def url_encode(encoding=nil)
42
- stringByAddingPercentEscapesUsingEncoding ENCODINGS[encoding] || NSUTF8StringEncoding
43
- end
44
-
45
- def url_decode(encoding=nil)
46
- stringByReplacingPercentEscapesUsingEncoding ENCODINGS[encoding] || NSUTF8StringEncoding
47
- end
48
-
49
- def to_data(encoding=nil)
50
- dataUsingEncoding ENCODINGS[encoding] || NSUTF8StringEncoding
51
- end
52
-
53
- ENCODINGS = {
54
- 'utf-8' => NSUTF8StringEncoding,
55
- 'utf-16' => NSUTF16StringEncoding,
56
- 'utf-32' => NSUTF32StringEncoding,
57
- 'ascii' => NSASCIIStringEncoding,
58
- 'latin1' => NSISOLatin1StringEncoding,
59
- 'latin2' => NSISOLatin2StringEncoding,
60
- 'cp1250' => NSWindowsCP1250StringEncoding,
61
- 'cp1251' => NSWindowsCP1251StringEncoding,
62
- 'cp1252' => NSWindowsCP1252StringEncoding,
63
- 'cp1253' => NSWindowsCP1253StringEncoding,
64
- 'cp1254' => NSWindowsCP1254StringEncoding,
65
-
66
-
67
- # NSNEXTSTEPStringEncoding = 2,
68
- # NSJapaneseEUCStringEncoding = 3,
69
- # NSSymbolStringEncoding = 6,
70
- # NSNonLossyASCIIStringEncoding = 7,
71
- # NSShiftJISStringEncoding = 8,
72
- # NSISO2022JPStringEncoding = 21,
73
- # NSMacOSRomanStringEncoding = 30,
74
- # NSUTF16BigEndianStringEncoding = 0x90000100,
75
- # NSUTF16LittleEndianStringEncoding = 0x94000100,
76
- # NSUTF32BigEndianStringEncoding = 0x98000100,
77
- # NSUTF32LittleEndianStringEncoding = 0x9c000100,
78
- # NSProprietaryStringEncoding = 65536
79
- }
80
- end