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.
- checksums.yaml +4 -4
- data/Gemfile +4 -0
- data/Gemfile.lock +25 -2
- data/README.md +1 -1
- data/Rakefile +2 -4
- data/lib/under-os.rb +3 -8
- data/under-os.gemspec +6 -2
- metadata +47 -191
- data/lib/assets/fontawesome-webfont.ttf +0 -0
- data/lib/assets/under-os.css +0 -115
- data/lib/under_os.rb +0 -41
- data/lib/under_os/app.rb +0 -33
- data/lib/under_os/color.rb +0 -184
- data/lib/under_os/config.rb +0 -33
- data/lib/under_os/core/array.rb +0 -5
- data/lib/under_os/core/hash.rb +0 -10
- data/lib/under_os/core/json.rb +0 -19
- data/lib/under_os/core/kernel.rb +0 -16
- data/lib/under_os/core/numeric.rb +0 -23
- data/lib/under_os/core/object.rb +0 -9
- data/lib/under_os/core/string.rb +0 -80
- data/lib/under_os/delegate.rb +0 -10
- data/lib/under_os/events.rb +0 -85
- data/lib/under_os/file.rb +0 -110
- data/lib/under_os/history.rb +0 -53
- data/lib/under_os/http.rb +0 -31
- data/lib/under_os/http/cookies.rb +0 -30
- data/lib/under_os/http/receiver.rb +0 -44
- data/lib/under_os/http/request.rb +0 -106
- data/lib/under_os/http/response.rb +0 -28
- data/lib/under_os/http/session.rb +0 -49
- data/lib/under_os/page.rb +0 -169
- data/lib/under_os/page/builder.rb +0 -96
- data/lib/under_os/page/layout.rb +0 -43
- data/lib/under_os/page/matcher.rb +0 -128
- data/lib/under_os/page/stylesheet.rb +0 -67
- data/lib/under_os/parser.rb +0 -24
- data/lib/under_os/parser/css.rb +0 -37
- data/lib/under_os/parser/html.rb +0 -97
- data/lib/under_os/point.rb +0 -47
- data/lib/under_os/screen.rb +0 -9
- data/lib/under_os/timer.rb +0 -65
- data/lib/under_os/ui.rb +0 -3
- data/lib/under_os/ui/alert.rb +0 -52
- data/lib/under_os/ui/button.rb +0 -42
- data/lib/under_os/ui/collection.rb +0 -65
- data/lib/under_os/ui/collection/cell.rb +0 -21
- data/lib/under_os/ui/collection/delegate.rb +0 -70
- data/lib/under_os/ui/collection/item.rb +0 -32
- data/lib/under_os/ui/collection/layout.rb +0 -43
- data/lib/under_os/ui/collection/styles.rb +0 -15
- data/lib/under_os/ui/div.rb +0 -3
- data/lib/under_os/ui/form.rb +0 -60
- data/lib/under_os/ui/icon.rb +0 -61
- data/lib/under_os/ui/icon/awesome.rb +0 -376
- data/lib/under_os/ui/icon/engine.rb +0 -10
- data/lib/under_os/ui/image.rb +0 -31
- data/lib/under_os/ui/input.rb +0 -140
- data/lib/under_os/ui/label.rb +0 -21
- data/lib/under_os/ui/locker.rb +0 -42
- data/lib/under_os/ui/navbar.rb +0 -123
- data/lib/under_os/ui/progress.rb +0 -17
- data/lib/under_os/ui/scroll.rb +0 -41
- data/lib/under_os/ui/select.rb +0 -95
- data/lib/under_os/ui/sidebar.rb +0 -45
- data/lib/under_os/ui/slider.rb +0 -37
- data/lib/under_os/ui/spinner.rb +0 -23
- data/lib/under_os/ui/style.rb +0 -21
- data/lib/under_os/ui/style/fonts.rb +0 -54
- data/lib/under_os/ui/style/margins.rb +0 -164
- data/lib/under_os/ui/style/outlining.rb +0 -170
- data/lib/under_os/ui/style/positioning.rb +0 -169
- data/lib/under_os/ui/switch.rb +0 -26
- data/lib/under_os/ui/textarea.rb +0 -19
- data/lib/under_os/ui/utils/animation.rb +0 -99
- data/lib/under_os/ui/utils/commons.rb +0 -70
- data/lib/under_os/ui/utils/dimensions.rb +0 -37
- data/lib/under_os/ui/utils/events.rb +0 -170
- data/lib/under_os/ui/utils/manipulation.rb +0 -44
- data/lib/under_os/ui/utils/position.rb +0 -21
- data/lib/under_os/ui/utils/size.rb +0 -21
- data/lib/under_os/ui/utils/styles.rb +0 -89
- data/lib/under_os/ui/utils/traversing.rb +0 -44
- data/lib/under_os/ui/utils/wrap.rb +0 -77
- data/lib/under_os/ui/view.rb +0 -31
- data/resources/test.png +0 -0
- data/spec/assets/app.css +0 -13
- data/spec/assets/test.css +0 -7
- data/spec/assets/test.html +0 -3
- data/spec/assets/test_page.rb +0 -2
- data/spec/lib/core/hash_spec.rb +0 -19
- data/spec/lib/core/json_spec.rb +0 -32
- data/spec/lib/core/numeric_spec.rb +0 -37
- data/spec/lib/core/string_spec.rb +0 -121
- data/spec/lib/under_os/color_spec.rb +0 -133
- data/spec/lib/under_os/events_spec.rb +0 -71
- data/spec/lib/under_os/file_spec.rb +0 -98
- data/spec/lib/under_os/http/cookies_spec.rb +0 -13
- data/spec/lib/under_os/http/request_spec.rb +0 -44
- data/spec/lib/under_os/http_spec.rb +0 -20
- data/spec/lib/under_os/page/builder_spec.rb +0 -128
- data/spec/lib/under_os/page/layout_spec.rb +0 -18
- data/spec/lib/under_os/page/matcher_spec.rb +0 -260
- data/spec/lib/under_os/page/stylesheet_spec.rb +0 -83
- data/spec/lib/under_os/page_spec.rb +0 -5
- data/spec/lib/under_os/parser/css_spec.rb +0 -77
- data/spec/lib/under_os/parser/html_spec.rb +0 -152
- data/spec/lib/under_os/parser_spec.rb +0 -16
- data/spec/lib/under_os/point_spec.rb +0 -54
- data/spec/lib/under_os/screen_spec.rb +0 -11
- data/spec/lib/under_os/timer_spec.rb +0 -93
- data/spec/lib/under_os/ui/button_spec.rb +0 -50
- data/spec/lib/under_os/ui/collection_spec.rb +0 -19
- data/spec/lib/under_os/ui/div_spec.rb +0 -24
- data/spec/lib/under_os/ui/form_spec.rb +0 -156
- data/spec/lib/under_os/ui/icon_spec.rb +0 -57
- data/spec/lib/under_os/ui/image_spec.rb +0 -39
- data/spec/lib/under_os/ui/input_spec.rb +0 -109
- data/spec/lib/under_os/ui/label_spec.rb +0 -22
- data/spec/lib/under_os/ui/locker_spec.rb +0 -31
- data/spec/lib/under_os/ui/progress_spec.rb +0 -31
- data/spec/lib/under_os/ui/scroll_spec.rb +0 -40
- data/spec/lib/under_os/ui/select_spec.rb +0 -135
- data/spec/lib/under_os/ui/sidebar_spec.rb +0 -35
- data/spec/lib/under_os/ui/slider_spec.rb +0 -69
- data/spec/lib/under_os/ui/spinner_spec.rb +0 -57
- data/spec/lib/under_os/ui/style/fonts_spec.rb +0 -73
- data/spec/lib/under_os/ui/style/margins_spec.rb +0 -106
- data/spec/lib/under_os/ui/style/outlining_spec.rb +0 -101
- data/spec/lib/under_os/ui/style/positioning_spec.rb +0 -69
- data/spec/lib/under_os/ui/style_spec.rb +0 -19
- data/spec/lib/under_os/ui/switch_spec.rb +0 -60
- data/spec/lib/under_os/ui/textarea_spec.rb +0 -34
- data/spec/lib/under_os/ui/utils/commons_spec.rb +0 -81
- data/spec/lib/under_os/ui/utils/events_spec.rb +0 -87
- data/spec/lib/under_os/ui/utils/manipulation_spec.rb +0 -130
- data/spec/lib/under_os/ui/utils/styles_spec.rb +0 -140
- data/spec/lib/under_os/ui/utils/traversing_spec.rb +0 -124
- data/spec/lib/under_os/ui/utils/wrap_spec.rb +0 -69
- data/spec/lib/under_os/ui/view_spec.rb +0 -39
data/lib/under_os.rb
DELETED
@@ -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
|
data/lib/under_os/app.rb
DELETED
@@ -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
|
data/lib/under_os/color.rb
DELETED
@@ -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
|
data/lib/under_os/config.rb
DELETED
@@ -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
|
data/lib/under_os/core/array.rb
DELETED
data/lib/under_os/core/hash.rb
DELETED
data/lib/under_os/core/json.rb
DELETED
@@ -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
|
data/lib/under_os/core/kernel.rb
DELETED
@@ -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
|
data/lib/under_os/core/object.rb
DELETED
data/lib/under_os/core/string.rb
DELETED
@@ -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
|