ruby_motion_query 0.6.0 → 0.6.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +5 -5
- data/bin/rmq +11 -4
- data/lib/ruby_motion_query.rb +2 -1
- data/motion/ruby_motion_query/inspector_stylesheet.rb +1 -1
- data/motion/ruby_motion_query/rect.rb +11 -12
- data/motion/ruby_motion_query/stylers/ui_progress_view_styler.rb +24 -0
- data/motion/ruby_motion_query/stylers/ui_view_styler.rb +9 -2
- data/motion/ruby_motion_query/stylesheet.rb +1 -0
- data/motion/ruby_motion_query/traverse.rb +10 -6
- data/motion/ruby_motion_query/validation.rb +70 -0
- data/motion/ruby_motion_query/version.rb +1 -1
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6a97dab886591d15adcbca5f06dae750e7938c12
|
4
|
+
data.tar.gz: 44496f23c8aba6bc4b0c9d1d686c932bfca5d9b7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: deb2ae07fb598b80d15827148d833d44ff1b2dbe16af222acb14194b8e1702bd69c7bcb5f4a1a59c8d13ae045898cfe0e2524bce8cdafa7c7ecbcf25a702e8e4
|
7
|
+
data.tar.gz: 64bc7ca900954291b974dd027558c88b5cbf451b7f08be87b2121c9e427daa12d3ab5e85ba9c28f609fb6026bed0a2a8e0d6fd01191ceb7759612164b4fcb0e3
|
data/README.md
CHANGED
@@ -11,8 +11,6 @@ A fast, non-polluting, chaining, front-end library. It’s like jQuery for [Ruby
|
|
11
11
|
|
12
12
|
One of RMQ's goal is to have the best [documentation][1] of any RubyMotion UI library.
|
13
13
|
|
14
|
-
## v0.6.0
|
15
|
-
|
16
14
|
<br />
|
17
15
|
|
18
16
|
----------
|
@@ -27,8 +25,10 @@ One of RMQ's goal is to have the best [documentation][1] of any RubyMotion UI li
|
|
27
25
|
|
28
26
|
```
|
29
27
|
gem install ruby_motion_query
|
30
|
-
#
|
31
|
-
|
28
|
+
# Create an app
|
29
|
+
rmq create my_app
|
30
|
+
# Then
|
31
|
+
cd my_app
|
32
32
|
bundle
|
33
33
|
rake
|
34
34
|
```
|
@@ -55,7 +55,7 @@ or add it to your `Gemfile`:
|
|
55
55
|
|
56
56
|
- `gem 'ruby_motion_query'`
|
57
57
|
|
58
|
-
for **
|
58
|
+
for **edge RMQ**, add this to your `Gemfile`:
|
59
59
|
|
60
60
|
- `gem 'ruby_motion_query', :git => 'git@github.com:infinitered/rmq.git'`
|
61
61
|
|
data/bin/rmq
CHANGED
@@ -2,6 +2,7 @@
|
|
2
2
|
|
3
3
|
require "erb"
|
4
4
|
require "rubygems"
|
5
|
+
require 'open-uri'
|
5
6
|
|
6
7
|
$:.unshift(File.join(File.dirname(__FILE__), "/../motion/ruby_motion_query"))
|
7
8
|
require "version"
|
@@ -10,8 +11,9 @@ class RmqCommandLine
|
|
10
11
|
HELP_TEXT = %{ rmq version #{RubyMotionQuery::VERSION}
|
11
12
|
|
12
13
|
Some things you can do with the rmq command:
|
13
|
-
> rmq api
|
14
14
|
> rmq docs
|
15
|
+
> rmq docs query
|
16
|
+
> rmq docs "background image"
|
15
17
|
|
16
18
|
> rmq create my_new_app
|
17
19
|
|
@@ -161,14 +163,19 @@ unless ARGV.length > 0
|
|
161
163
|
end
|
162
164
|
|
163
165
|
action = ARGV[0]
|
166
|
+
query = ARGV[1]
|
164
167
|
|
165
168
|
case action
|
166
169
|
when 'create'
|
167
170
|
RmqCommandLine.create(ARGV[1], ARGV[2], ARGV[3])
|
168
|
-
when 'api'
|
169
|
-
`open http://rdoc.info/github/infinitered/rmq`
|
170
171
|
when 'docs'
|
171
|
-
|
172
|
+
if query
|
173
|
+
query = URI::encode(query)
|
174
|
+
url = "http://rubymotionquery.com?s=#{query}&post_type=document"
|
175
|
+
`open #{url}`
|
176
|
+
else
|
177
|
+
`open http://rubymotionquery.com/documentation`
|
178
|
+
end
|
172
179
|
when '--help', '-h'
|
173
180
|
puts RmqCommandLine::HELP_TEXT
|
174
181
|
when '-v', '--version'
|
data/lib/ruby_motion_query.rb
CHANGED
@@ -4,7 +4,8 @@ end
|
|
4
4
|
|
5
5
|
Motion::Project::App.setup do |app|
|
6
6
|
parent = File.join(File.dirname(__FILE__), '..')
|
7
|
-
files = [File.join(parent, 'motion/ruby_motion_query/
|
7
|
+
files = [File.join(parent, 'motion/ruby_motion_query/stylesheet.rb')]
|
8
|
+
files << [File.join(parent, 'motion/ruby_motion_query/stylers/ui_view_styler.rb')]
|
8
9
|
files << File.join(parent, 'motion/ruby_motion_query/stylers/ui_control_styler.rb')
|
9
10
|
files << Dir.glob(File.join(parent, "motion/**/*.rb"))
|
10
11
|
files.flatten!.uniq!
|
@@ -114,23 +114,22 @@ module RubyMotionQuery
|
|
114
114
|
|
115
115
|
def update_view_frame(view, params)
|
116
116
|
view.frame = object_to_cg_rect(params, view, view.frame, view.rmq.grid)
|
117
|
-
@_previous_view = RubyMotionQuery::RMQ.weak_ref(view)
|
118
117
|
end
|
119
118
|
|
120
119
|
def update_view_bounds(view, params)
|
121
120
|
view.frame = object_to_cg_rect(params, view, view.bounds, view.rmq.grid)
|
122
|
-
@_previous_view = RubyMotionQuery::RMQ.weak_ref(view)
|
123
121
|
end
|
124
122
|
|
125
|
-
#
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
123
|
+
# Previous sibling
|
124
|
+
def previous_view(view)
|
125
|
+
if view
|
126
|
+
pv = view.rmq.prev.get
|
127
|
+
if RubyMotionQuery::RMQ.is_blank?(pv)
|
128
|
+
nil
|
129
|
+
else
|
130
|
+
pv
|
131
|
+
end
|
132
|
+
end
|
134
133
|
end
|
135
134
|
|
136
135
|
def frame_for_view(view)
|
@@ -215,7 +214,7 @@ module RubyMotionQuery
|
|
215
214
|
centered = params[:centered]
|
216
215
|
|
217
216
|
# Previous
|
218
|
-
if prev_view = previous_view
|
217
|
+
if prev_view = previous_view(view)
|
219
218
|
if params_g && (prev_sv = prev_view.superview)
|
220
219
|
|
221
220
|
previous_root_view_point = vc.view.convertPoint(prev_view.origin, fromView: prev_sv)
|
@@ -0,0 +1,24 @@
|
|
1
|
+
module RubyMotionQuery
|
2
|
+
module Stylers
|
3
|
+
|
4
|
+
class UIProgressViewStyler < UIViewStyler
|
5
|
+
|
6
|
+
def progress_image=(value) ; @view.progressImage = value ; end
|
7
|
+
def progress_image ; @view.progressImage ; end
|
8
|
+
|
9
|
+
def progress_tint_color=(value) ; @view.progressTintColor = value ; end
|
10
|
+
def progress_tint_color ; @view.progressTintColor ; end
|
11
|
+
|
12
|
+
def progress_view_style=(value) ; @view.progressViewStyle = value ; end
|
13
|
+
def progress_view_style ; @view.progressViewStyle ; end
|
14
|
+
|
15
|
+
def track_image=(value) ; @view.trackImage = value ; end
|
16
|
+
def track_image ; @view.trackImage ; end
|
17
|
+
|
18
|
+
def track_tint_color=(value) ; @view.trackTintColor = value ; end
|
19
|
+
def track_tint_color ; @view.trackTintColor ; end
|
20
|
+
|
21
|
+
end
|
22
|
+
|
23
|
+
end
|
24
|
+
end
|
@@ -48,13 +48,20 @@ module RubyMotionQuery
|
|
48
48
|
end
|
49
49
|
|
50
50
|
def prev_frame
|
51
|
-
if pv = RubyMotionQuery::
|
51
|
+
if (pv = prev_view) && !RubyMotionQuery::RMQ.is_blank?(pv)
|
52
52
|
RubyMotionQuery::Rect.frame_for_view(pv)
|
53
|
+
else
|
54
|
+
CGRectZero
|
53
55
|
end
|
54
56
|
end
|
55
57
|
|
56
58
|
def prev_view
|
57
|
-
|
59
|
+
pv = @view.rmq.prev.get
|
60
|
+
if RubyMotionQuery::RMQ.is_blank?(pv)
|
61
|
+
nil
|
62
|
+
else
|
63
|
+
pv
|
64
|
+
end
|
58
65
|
end
|
59
66
|
|
60
67
|
def bounds=(value)
|
@@ -65,6 +65,7 @@ module RubyMotionQuery
|
|
65
65
|
when UISegmentedControl then Stylers::UISegmentedControlStyler.new(view)
|
66
66
|
when UIRefreshControl then Stylers::UIRefreshControlStyler.new(view)
|
67
67
|
when UIPageControl then Stylers::UIPageControlStyler.new(view)
|
68
|
+
when UIProgressView then Stylers::UIProgressViewStyler.new(view)
|
68
69
|
when UISlider then Stylers::UISliderStyler.new(view)
|
69
70
|
when UIStepper then Stylers::UIStepperStyler.new(view)
|
70
71
|
when UITabBar then Stylers::UITabBarStyler.new(view)
|
@@ -192,11 +192,12 @@ module RubyMotionQuery
|
|
192
192
|
end
|
193
193
|
|
194
194
|
|
195
|
-
# @return [RMQ] Sibling
|
195
|
+
# @return [RMQ] Sibling below the selected view(s) (in the subview array)
|
196
196
|
#
|
197
197
|
# @param selectors
|
198
198
|
#
|
199
199
|
# @example
|
200
|
+
# rmq(my_view).next.hide
|
200
201
|
# rmq(my_view).next(UITextField).focus
|
201
202
|
def next(*working_selectors)
|
202
203
|
normalize_selectors(working_selectors)
|
@@ -210,20 +211,23 @@ module RubyMotionQuery
|
|
210
211
|
end
|
211
212
|
end
|
212
213
|
|
213
|
-
# @return [RMQ] Sibling
|
214
|
+
# @return [RMQ] Sibling above the selected view(s) (in the subview array)
|
214
215
|
#
|
215
216
|
# @param selectors
|
216
217
|
#
|
217
218
|
# @example
|
219
|
+
# rmq(my_view).prev.hid
|
218
220
|
# rmq(my_view).prev(UITextField).focus
|
219
221
|
def prev(*working_selectors)
|
220
222
|
normalize_selectors(working_selectors)
|
221
223
|
|
222
224
|
filter do |view|
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
|
225
|
+
if sv = view.superview
|
226
|
+
subs = sv.subviews
|
227
|
+
location = subs.index(view)
|
228
|
+
if location > 0
|
229
|
+
subs[location - 1]
|
230
|
+
end
|
227
231
|
end
|
228
232
|
end
|
229
233
|
end
|
@@ -0,0 +1,70 @@
|
|
1
|
+
module RubyMotionQuery
|
2
|
+
class RMQ
|
3
|
+
# @return [Validation]
|
4
|
+
def self.validation
|
5
|
+
Validation
|
6
|
+
end
|
7
|
+
|
8
|
+
# @return [Validation]
|
9
|
+
def validation
|
10
|
+
Validation
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
class Validation
|
15
|
+
class << self
|
16
|
+
# Validation Regex from jQuery validation -> https://github.com/jzaefferer/jquery-validation/blob/master/src/core.js#L1094-L1200
|
17
|
+
EMAIL = Regexp.new('^[a-zA-Z0-9.!#$%&\'*+\/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$')
|
18
|
+
URL = Regexp.new('^(https?|s?ftp):\/\/(((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&\'\(\)\*\+,;=]|:)*@)?(((\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5]))|((([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.)+(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.?)(:\d*)?)(\/((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&\'\(\)\*\+,;=]|:|@)+(\/(([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&\'\(\)\*\+,;=]|:|@)*)*)?)?(\?((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&\'\(\)\*\+,;=]|:|@)|[\uE000-\uF8FF]|\/|\?)*)?(#((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&\'\(\)\*\+,;=]|:|@)|\/|\?)*)?$')
|
19
|
+
DATEISO = Regexp.new('^\d{4}[\/\-](0?[1-9]|1[012])[\/\-](0?[1-9]|[12][0-9]|3[01])$')
|
20
|
+
NUMBER = Regexp.new('^-?(?:\d+|\d{1,3}(?:,\d{3})+)?(?:\.\d+)?$')
|
21
|
+
DIGITS = Regexp.new('^\d+$')
|
22
|
+
# Other Fun by http://www.freeformatter.com/regex-tester.html
|
23
|
+
IPV4 = Regexp.new('^(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$')
|
24
|
+
TIME = Regexp.new('^(20|21|22|23|[01]\d|\d)((:[0-5]\d){1,2})$')
|
25
|
+
# Future Password strength validations -> http://stackoverflow.com/questions/5142103/regex-for-password-strength
|
26
|
+
USZIP = Regexp.new('^\d{5}(-\d{4})?$')
|
27
|
+
# 7 or 10 digit number, delimiters are spaces, dashes, or periods
|
28
|
+
USPHONE = Regexp.new('^(?:(?:\+?1\s*(?:[.-]\s*)?)?(?:(\s*([2-9]1[02-9]|[2-9][02-8]1|[2-9][02-8][02-9])\s*)|([2-9]1[02-9]|[2-9][02-8]1|[2-9][02-8][02-9]))\s*(?:[.-]\s*)?)?([2-9]1[02-9]|[2-9][02-9]1|[2-9][02-9]{2})\s*(?:[.-]\s*)?([0-9]{4})$')
|
29
|
+
|
30
|
+
|
31
|
+
@@validation_methods = {
|
32
|
+
:email => lambda { |value| Validation.regex_match?(value, EMAIL)},
|
33
|
+
:url => lambda { |value| Validation.regex_match?(value, URL)},
|
34
|
+
:dateiso => lambda { |value| Validation.regex_match?(value, DATEISO)},
|
35
|
+
:number => lambda { |value| Validation.regex_match?(value, NUMBER)},
|
36
|
+
:digits => lambda { |value| Validation.regex_match?(value, DIGITS)},
|
37
|
+
:ipv4 => lambda { |value| Validation.regex_match?(value, IPV4)},
|
38
|
+
:time => lambda { |value| Validation.regex_match?(value, TIME)},
|
39
|
+
:uszip => lambda { |value| Validation.regex_match?(value, USZIP)},
|
40
|
+
:usphone => lambda { |value| Validation.regex_match?(value, USPHONE)}
|
41
|
+
}
|
42
|
+
|
43
|
+
# Add tags
|
44
|
+
# @example
|
45
|
+
# rmq.validation.valid?('test@test.com', :email)
|
46
|
+
# rmq.validation.valid?(53.8, :number)
|
47
|
+
# rmq.validation.valid?(54, :digits)
|
48
|
+
# rmq.validation.valid?('https://www.tacoland.com', :url)
|
49
|
+
# rmq.validation.valid?('2014-03-02'), :dateiso)
|
50
|
+
#
|
51
|
+
# @return [Boolean]
|
52
|
+
def valid?(value, *rule_or_rules)
|
53
|
+
#shortcircuit if debugging
|
54
|
+
return true if RubyMotionQuery::RMQ.debugging?
|
55
|
+
rule_or_rules.each do |rule|
|
56
|
+
# only supported validations
|
57
|
+
raise "RMQ validation error: :#{rule} is not one of the supported validation methods." unless @@validation_methods.include?(rule)
|
58
|
+
#return false if validation_failed
|
59
|
+
return false unless @@validation_methods[rule].call(value)
|
60
|
+
end
|
61
|
+
true
|
62
|
+
end
|
63
|
+
|
64
|
+
def regex_match?(value, regex)
|
65
|
+
(value.to_s =~ regex) == 0
|
66
|
+
end
|
67
|
+
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ruby_motion_query
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.6.
|
4
|
+
version: 0.6.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Todd Werth
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2014-
|
12
|
+
date: 2014-07-02 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: bacon
|
@@ -81,6 +81,7 @@ files:
|
|
81
81
|
- motion/ruby_motion_query/stylers/ui_label_styler.rb
|
82
82
|
- motion/ruby_motion_query/stylers/ui_navigation_bar_styler.rb
|
83
83
|
- motion/ruby_motion_query/stylers/ui_page_control_styler.rb
|
84
|
+
- motion/ruby_motion_query/stylers/ui_progress_view_styler.rb
|
84
85
|
- motion/ruby_motion_query/stylers/ui_refresh_control_styler.rb
|
85
86
|
- motion/ruby_motion_query/stylers/ui_scroll_view_styler.rb
|
86
87
|
- motion/ruby_motion_query/stylers/ui_segmented_control_styler.rb
|
@@ -98,6 +99,7 @@ files:
|
|
98
99
|
- motion/ruby_motion_query/tags.rb
|
99
100
|
- motion/ruby_motion_query/traverse.rb
|
100
101
|
- motion/ruby_motion_query/utils.rb
|
102
|
+
- motion/ruby_motion_query/validation.rb
|
101
103
|
- motion/ruby_motion_query/version.rb
|
102
104
|
- templates/collection_view_controller/app/controllers/name_controller.rb
|
103
105
|
- templates/collection_view_controller/app/stylesheets/name_cell_stylesheet.rb
|