ruby_motion_query 0.3.6 → 0.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.
- checksums.yaml +8 -8
- data/README.md +99 -7
- data/bin/rmq +141 -20
- data/motion/ruby_motion_query/animations.rb +29 -0
- data/motion/ruby_motion_query/base.rb +59 -1
- data/motion/ruby_motion_query/device.rb +4 -0
- data/motion/ruby_motion_query/position.rb +15 -0
- data/motion/ruby_motion_query/stylers/ui_view_styler.rb +5 -0
- data/motion/ruby_motion_query/version.rb +3 -0
- data/templates/controller/app/controllers/name_controller.rb +37 -0
- data/templates/controller/app/stylesheets/name_controller_stylesheet.rb +11 -0
- data/templates/controller/spec/controllers/name_controller.rb +9 -0
- data/templates/lib/lib/name.rb +4 -0
- data/templates/lib/spec/lib/name.rb +9 -0
- data/templates/model/app/models/name.rb +30 -0
- data/templates/model/spec/models/name.rb +12 -0
- data/templates/shared/app/shared/name.rb +4 -0
- data/templates/shared/spec/shared/name.rb +9 -0
- data/templates/view/app/stylesheets/name_stylesheet.rb +10 -0
- data/templates/view/app/views/name.rb +25 -0
- data/templates/view/spec/views/name.rb +9 -0
- metadata +15 -2
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
YWZiNGJkMWFiMTc2YjliNjFhYjQxZWE4YTEwYmNkYWM1Yzg0NTViZA==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
MjlhMTIzYmUwYmJiNDhhZjE2YWI3NTlkM2IwYzY4YzE1NjhhNTQwOA==
|
7
7
|
!binary "U0hBNTEy":
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
MTM3YWEyYjY3YTMyZDVhZDk5NGZkZGRiODZiNzA1NzUxYzZjZTJlNTQyNDFk
|
10
|
+
NDc5MDIxNjFiY2UxMDhkY2ZkODJjNjhmMTI0NzYwNWFiMWRmYWJlZWIzYWIz
|
11
|
+
ZDUwYmNkN2U2YmZjMTYyOTVjNjkxNzQ1YWMyNDg0MjlmMWMzOGY=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
YmExY2QwZDU1NTc3NjA3MGQ2MDFkMmE2ZWNhM2MyNDI2Y2Y2YjhiZmY0YjM0
|
14
|
+
NWQ1M2UzMDYzODBjZWM0ZTg5ZGE4NmJkYjUyZGY4ZGYzZGE0YjJmNmQxZGY0
|
15
|
+
NjczZWE1MmI3ZDIzZDZmNDk1Zjk1MjRhNzA2Mzg0ZjE0Mjc2MzM=
|
data/README.md
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|

|
2
2
|
|
3
3
|
# RubyMotionQuery - RMQ
|
4
|
-
A
|
4
|
+
A fast, muggle, nonpolluting, jQuery-like library for [RubyMotion](http://rubymotion.com).
|
5
5
|
|
6
6
|
**The [RMQ Introductory Guide and other info][1] is a great place to start.**
|
7
7
|
|
@@ -40,17 +40,39 @@ RMQ **doesn't require any** other wrapper or gem.
|
|
40
40
|
Some of the code in RMQ came from BubbleWrap and Sugarcube. Not too much but some did. I thank you BubbleWrap and Sugarcube teams for your work.
|
41
41
|
|
42
42
|
## Quick Start
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
43
|
+
|
44
|
+
```
|
45
|
+
gem install ruby_motion_query
|
46
|
+
rmq create my_app
|
47
|
+
cd my_app
|
48
|
+
bundle
|
49
|
+
rake
|
50
|
+
```
|
51
|
+
|
52
|
+
Or, if you use **rbenv**:
|
53
|
+
|
54
|
+
```
|
55
|
+
gem install ruby_motion_query
|
56
|
+
rmq create my_app
|
57
|
+
rbenv rehash
|
58
|
+
cd my_app
|
59
|
+
bundle
|
60
|
+
rake
|
61
|
+
```
|
62
|
+
|
48
63
|
|
49
64
|
## Installation
|
50
65
|
|
51
66
|
RMQ **requires no other gems**. If you use stuff like **scale** and certain animations it will require some frameworks (like QuartzCore or CoreGraphics)
|
52
67
|
|
53
68
|
- `gem install ruby_motion_query`
|
69
|
+
|
70
|
+
If you use rbenv
|
71
|
+
|
72
|
+
- `rbenv rehash`
|
73
|
+
|
74
|
+
Require it
|
75
|
+
|
54
76
|
- `require 'ruby_motion_query'`
|
55
77
|
|
56
78
|
or add it to your `Gemfile`:
|
@@ -68,7 +90,7 @@ for **bleeding edge**, add this to your `Gemfile`:
|
|
68
90
|
|
69
91
|
git clone git@github.com:infinitered/rmq.git
|
70
92
|
cd rmq
|
71
|
-
rake
|
93
|
+
rake
|
72
94
|
|
73
95
|
The example app works in any orientation, on both iPhone and iPad. Notice how the benchmark popup is done with RMQ, then think about how you'd do that without it.
|
74
96
|
|
@@ -142,6 +164,33 @@ rmq(my_view).get
|
|
142
164
|
rmq(UILabel).get
|
143
165
|
```
|
144
166
|
|
167
|
+
### Command-line Tool
|
168
|
+
|
169
|
+
RMQ provides a command-line tool, mostly for generating files:
|
170
|
+
```
|
171
|
+
> rmq create my_app
|
172
|
+
```
|
173
|
+
|
174
|
+
Here are the commands available to you:
|
175
|
+
```
|
176
|
+
> rmq api
|
177
|
+
> rmq docs
|
178
|
+
|
179
|
+
> rmq create my_new_app
|
180
|
+
> rmq create model foo
|
181
|
+
> rmq create controller bar
|
182
|
+
> rmq create view foo_bar
|
183
|
+
> rmq create shared some_class_used_app_wide
|
184
|
+
> rmq create lib some_class_used_by_multiple_apps
|
185
|
+
|
186
|
+
# To test the create command without actually creating any files, do:
|
187
|
+
> rmq create view my_view dry_run
|
188
|
+
|
189
|
+
> rmq help
|
190
|
+
```
|
191
|
+
|
192
|
+
|
193
|
+
|
145
194
|
### Selectors
|
146
195
|
|
147
196
|
- Constant
|
@@ -410,6 +459,7 @@ rmq(my_view).animations.fade_out(duration: 0.8)
|
|
410
459
|
|
411
460
|
rmq(my_view).animations.blink
|
412
461
|
rmq(my_view).animations.throb
|
462
|
+
rmq(my_view).animations.drop_and_spin
|
413
463
|
|
414
464
|
rmq.animations.start_spinner
|
415
465
|
rmq.animations.stop_spinner
|
@@ -575,6 +625,7 @@ The following are the only pollution in RMQ
|
|
575
625
|
- your_controller.rb
|
576
626
|
- your_other_controller.rb
|
577
627
|
- models
|
628
|
+
- shared
|
578
629
|
- stylers
|
579
630
|
- ui_view_styler.rb
|
580
631
|
- ui_button_styler.rb
|
@@ -583,7 +634,47 @@ The following are the only pollution in RMQ
|
|
583
634
|
- application_stylesheet.rb (inherit from RubyMotionQuery::Stylesheet)
|
584
635
|
- your_stylesheet.rb (inherit from ApplicationStylesheet)
|
585
636
|
- your_other_stylesheet.rb (inherit from ApplicationStylesheet)
|
637
|
+
- your_view_stylesheet.rb (module, included an any controller's stylesheet that needs it)
|
586
638
|
- views
|
639
|
+
- lib
|
640
|
+
- resource
|
641
|
+
- spec
|
642
|
+
- controllers
|
643
|
+
- lib
|
644
|
+
- models
|
645
|
+
- shared
|
646
|
+
- stylers
|
647
|
+
- views
|
648
|
+
|
649
|
+
### Debugging
|
650
|
+
|
651
|
+
Adding rmq_debug=true to rake turns on some debugging features that are too slow or verbose to include in a normal build. It's great for normal use in the simulator, but you'll want to leave it off if you're measuring performance.
|
652
|
+
```
|
653
|
+
rake rmq_debug=true
|
654
|
+
```
|
655
|
+
|
656
|
+
Use this to add your optional debugging code
|
657
|
+
```ruby
|
658
|
+
rmq.debugging?
|
659
|
+
=> true
|
660
|
+
```
|
661
|
+
|
662
|
+
```ruby
|
663
|
+
rmq.log :tree
|
664
|
+
rmq.all.log
|
665
|
+
rmq.all.log :wide
|
666
|
+
|
667
|
+
rmq(Section).log :tree
|
668
|
+
# 163792144 is the ID a button
|
669
|
+
rmq(163792144).style{|st| st.background_color = rmq.color.blue}
|
670
|
+
|
671
|
+
rmq(Section).children.and_self.log :wide
|
672
|
+
|
673
|
+
rmq(UILabel).animations.blink
|
674
|
+
|
675
|
+
# Show subview index and thus zorder of Section within Section's parent
|
676
|
+
rmq(Section).parent.children.log
|
677
|
+
```
|
587
678
|
|
588
679
|
----------
|
589
680
|
|
@@ -898,6 +989,7 @@ def ui_view_kitchen_sink(st)
|
|
898
989
|
st.background_color = color.red
|
899
990
|
|
900
991
|
st.scale = 1.5
|
992
|
+
st.rotation = 45
|
901
993
|
end
|
902
994
|
```
|
903
995
|
|
data/bin/rmq
CHANGED
@@ -1,37 +1,158 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
|
3
|
+
require "erb"
|
4
|
+
require "rubygems"
|
5
|
+
|
6
|
+
$:.unshift(File.join(File.dirname(__FILE__), "/../motion/ruby_motion_query"))
|
7
|
+
require "version"
|
8
|
+
|
9
|
+
class RmqCommandLine
|
10
|
+
HELP_TEXT = %{ rmq version #{RubyMotionQuery::VERSION}
|
11
|
+
|
12
|
+
Some things you can do with the rmq command:
|
13
|
+
> rmq api
|
14
|
+
> rmq docs
|
15
|
+
|
16
|
+
> rmq create my_new_app
|
17
|
+
|
18
|
+
> rmq create model foo
|
19
|
+
> rmq create controller foos
|
20
|
+
> rmq create view bar
|
21
|
+
> rmq create shared some_class_used_app_wide
|
22
|
+
> rmq create lib some_class_used_by_multiple_apps
|
23
|
+
|
24
|
+
> rmq -h, --help
|
25
|
+
> rmq -v, --version }
|
26
|
+
|
27
|
+
class << self
|
28
|
+
VALID_CREATE_TYPES = [:model, :controller, :view, :shared, :lib]
|
29
|
+
|
30
|
+
def create(template_or_app_name, name, options)
|
31
|
+
@dry_run = true if options == 'dry_run'
|
32
|
+
|
33
|
+
if name
|
34
|
+
if VALID_CREATE_TYPES.include?(template_or_app_name.to_sym)
|
35
|
+
insert_from_template(template_or_app_name, name)
|
36
|
+
else
|
37
|
+
puts "RMQ - Invalid command, do something like this: rmq create controller my_controller\n"
|
38
|
+
end
|
39
|
+
else
|
40
|
+
create_app(template_or_app_name)
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
def create_app(app_name)
|
45
|
+
puts ' Creating app'
|
46
|
+
|
47
|
+
`motion create --template=git@github.com:infinitered/rmq-template.git #{app_name}`
|
48
|
+
|
49
|
+
puts %{
|
50
|
+
Complete. Things you should do:
|
51
|
+
> cd #{app_name}
|
52
|
+
> bundle
|
53
|
+
> rake spec
|
54
|
+
> rake
|
55
|
+
(main)> exit
|
56
|
+
|
57
|
+
Then try these:
|
58
|
+
> rake retina=3.5
|
59
|
+
> rake retina=4
|
60
|
+
> rake device_family=ipad
|
61
|
+
> rake device }
|
62
|
+
|
63
|
+
end
|
64
|
+
|
65
|
+
def template_path(template_name)
|
66
|
+
sub_path = "templates/#{template_name}/"
|
67
|
+
|
68
|
+
# First check local directory, use that if it exists
|
69
|
+
if Dir.exist?("#{Dir.pwd}/#{sub_path}")
|
70
|
+
"#{Dir.pwd}/#{sub_path}"
|
71
|
+
else # Then check the gem
|
72
|
+
begin
|
73
|
+
spec = Gem::Specification.find_by_name("ruby_motion_query")
|
74
|
+
gem_root = spec.gem_dir
|
75
|
+
"#{gem_root}/#{sub_path}"
|
76
|
+
rescue Exception => e
|
77
|
+
puts "RMQ - could not find template directory\n"
|
78
|
+
nil
|
79
|
+
end
|
80
|
+
end
|
81
|
+
end
|
82
|
+
|
83
|
+
def insert_from_template(template_name, name)
|
84
|
+
puts "\n Creating #{template_name}: #{name}\n\n"
|
85
|
+
|
86
|
+
return unless (@template_path = template_path(template_name))
|
87
|
+
files = Dir["#{@template_path}**/*"].select {|f| !File.directory? f}
|
88
|
+
|
89
|
+
@name = name.gsub(/(controller|stylesheet)/,'')
|
90
|
+
@name_camel_case = @name.split('_').map{|word| word.capitalize}.join
|
91
|
+
|
92
|
+
files.each do |template_file_path_and_name|
|
93
|
+
@in_app_path = File.dirname(template_file_path_and_name).gsub(@template_path, '')
|
94
|
+
@ext = File.extname(template_file_path_and_name)
|
95
|
+
@file_name = File.basename(template_file_path_and_name, @ext)
|
96
|
+
|
97
|
+
@new_file_name = @file_name.gsub('name', @name)
|
98
|
+
@new_file_path_name = "#{Dir.pwd}/#{@in_app_path}/#{@new_file_name}#{@ext}"
|
99
|
+
|
100
|
+
if @dry_run
|
101
|
+
puts "\n Instance vars:"
|
102
|
+
self.instance_variables.each{|var| puts " #{var} = #{self.instance_variable_get(var)}"}
|
103
|
+
puts
|
104
|
+
end
|
105
|
+
|
106
|
+
if Dir.exist?(@in_app_path)
|
107
|
+
puts " Using existing directory: #{@in_app_path}"
|
108
|
+
else
|
109
|
+
puts " \u0394 Creating directory: #{@in_app_path}"
|
110
|
+
Dir.mkdir(@in_app_path) unless @dry_run
|
111
|
+
end
|
112
|
+
|
113
|
+
results = load_and_parse_erb(template_file_path_and_name)
|
114
|
+
|
115
|
+
if File.exists?(@new_file_path_name)
|
116
|
+
puts " X File exists, SKIPPING: #{@new_file_path_name}"
|
117
|
+
else
|
118
|
+
puts " \u0394 Creating file: #{@new_file_path_name}"
|
119
|
+
File.open(@new_file_path_name, 'w+') { |file| file.write(results) } unless @dry_run
|
120
|
+
end
|
121
|
+
end
|
122
|
+
|
123
|
+
puts "\n Done"
|
124
|
+
end
|
125
|
+
|
126
|
+
def load_and_parse_erb(template_file_name_and_path)
|
127
|
+
template_file = File.open(template_file_name_and_path, 'r').read
|
128
|
+
erb = ERB.new(template_file)
|
129
|
+
erb.result(binding)
|
130
|
+
end
|
131
|
+
end
|
132
|
+
end
|
133
|
+
|
134
|
+
|
135
|
+
# Process input, execute actions
|
3
136
|
unless ARGV.length > 0
|
4
|
-
puts
|
137
|
+
puts "RMQ - Invalid command, do something like this: rmq create my_new_app\n"
|
138
|
+
puts RmqCommandLine::HELP_TEXT
|
5
139
|
exit
|
6
140
|
end
|
7
141
|
|
8
|
-
|
9
142
|
action = ARGV[0]
|
10
|
-
value = ARGV[1]
|
11
143
|
|
12
144
|
case action
|
13
145
|
when 'create'
|
14
|
-
|
15
|
-
|
16
|
-
puts %{
|
17
|
-
Complete. Things you should do:
|
18
|
-
> cd #{value}
|
19
|
-
> bundle
|
20
|
-
> rake spec
|
21
|
-
> rake
|
22
|
-
(main)> exit
|
23
|
-
|
24
|
-
Then try these:
|
25
|
-
> rake retina=3.5
|
26
|
-
> rake retina=4
|
27
|
-
> rake device_family=ipad
|
28
|
-
> rake device }
|
29
|
-
|
146
|
+
RmqCommandLine.create(ARGV[1], ARGV[2], ARGV[3])
|
30
147
|
when 'api'
|
31
148
|
`open http://rdoc.info/github/infinitered/rmq`
|
32
149
|
when 'docs'
|
33
150
|
`open http://infinitered.com/rmq`
|
151
|
+
when '--help', '-h'
|
152
|
+
puts RmqCommandLine::HELP_TEXT
|
153
|
+
when '-v', '--version'
|
154
|
+
puts RubyMotionQuery::VERSION
|
34
155
|
else
|
35
156
|
puts 'RMQ - Invalid action'
|
36
|
-
|
157
|
+
puts RmqCommandLine::HELP_TEXT
|
37
158
|
end
|
@@ -102,6 +102,35 @@ module RubyMotionQuery
|
|
102
102
|
)
|
103
103
|
end
|
104
104
|
|
105
|
+
def drop_and_spin(opts = {})
|
106
|
+
remove_view = opts[:remove_view]
|
107
|
+
opts.merge!({
|
108
|
+
duration: 0.4 + (rand(8) / 10),
|
109
|
+
options: UIViewAnimationOptionCurveEaseIn|UIViewAnimationOptionBeginFromCurrentState,
|
110
|
+
animations: -> (cq) {
|
111
|
+
cq.style do |st|
|
112
|
+
st.top = @rmq.device.height + st.height
|
113
|
+
st.rotation = 180 + rand(50)
|
114
|
+
end
|
115
|
+
},
|
116
|
+
completion: -> (did_finish, q) {
|
117
|
+
if did_finish
|
118
|
+
q.style do |st|
|
119
|
+
st.rotation = 0
|
120
|
+
end
|
121
|
+
|
122
|
+
if remove_view
|
123
|
+
q.remove
|
124
|
+
else
|
125
|
+
q.hide.move(t:0)
|
126
|
+
end
|
127
|
+
end
|
128
|
+
}
|
129
|
+
})
|
130
|
+
|
131
|
+
@rmq.animate(opts)
|
132
|
+
end
|
133
|
+
|
105
134
|
# @return [RMQ]
|
106
135
|
def blink
|
107
136
|
self.fade_out(duration: 0.2, after: lambda {|did_finish, rmq| rmq.animations.fade_in(duration: 0.2)})
|
@@ -164,7 +164,8 @@ module RubyMotionQuery
|
|
164
164
|
|
165
165
|
# Super useful in the console. log outputs to the console a table of the selected views
|
166
166
|
#
|
167
|
-
# @param :wide outputs wide format (really wide, but awesome: rmq.all.log :wide)
|
167
|
+
# @param :wide outputs wide format (really wide, but awesome: rmq.all.log :wide). :tree outputs the
|
168
|
+
# log in a tree form
|
168
169
|
#
|
169
170
|
# @return [String]
|
170
171
|
#
|
@@ -193,7 +194,18 @@ module RubyMotionQuery
|
|
193
194
|
# 168204512 | UIView | 0 | |
|
194
195
|
# - - - - - - | - - - - - - - - - - - | - - - - - - - - - - - - | - - - - - - - - - - - - - - - - |
|
195
196
|
# RMQ 278442176. 6 selected. selectors: [UIImageView]#
|
197
|
+
#
|
198
|
+
# @example
|
199
|
+
# rmq.log :tree
|
200
|
+
#
|
201
|
+
# @example
|
202
|
+
# rmq.all.log :wide
|
196
203
|
def log(opt = nil)
|
204
|
+
if opt == :tree
|
205
|
+
puts tree_to_s(selected)
|
206
|
+
return
|
207
|
+
end
|
208
|
+
|
197
209
|
wide = (opt == :wide)
|
198
210
|
out = "\n object_id | class | style_name | frame |"
|
199
211
|
out << "\n" unless wide
|
@@ -234,9 +246,55 @@ module RubyMotionQuery
|
|
234
246
|
puts out
|
235
247
|
end
|
236
248
|
|
249
|
+
def tree_to_s(selected_views, depth = 0)
|
250
|
+
out = ""
|
251
|
+
|
252
|
+
selected_views.each do |view|
|
253
|
+
first = (view == selected_views.first)
|
254
|
+
last = (view == selected_views.last)
|
255
|
+
|
256
|
+
if depth == 0
|
257
|
+
out << "\n"
|
258
|
+
else
|
259
|
+
0.upto(depth - 1).each do |i|
|
260
|
+
out << (i == (depth - 1) ? ' ├' : ' │')
|
261
|
+
end
|
262
|
+
end
|
263
|
+
|
264
|
+
out << '───'
|
265
|
+
|
266
|
+
out << " #{view.class.name[0..21]}"
|
267
|
+
out << " ( #{view.rmq_data.style_name[0..23]} )" if view.rmq_data.style_name
|
268
|
+
out << " #{view.object_id.to_s}"
|
269
|
+
out << " [ #{view.rmq_data.tag_names.join(',')} ]" if view.rmq_data.tag_names.length > 0
|
270
|
+
|
271
|
+
if view.origin
|
272
|
+
format = '#0.#'
|
273
|
+
s = " {l: #{RMQ.format.numeric(view.origin.x, format)}"
|
274
|
+
s << ", t: #{RMQ.format.numeric(view.origin.y, format)}"
|
275
|
+
s << ", w: #{RMQ.format.numeric(view.size.width, format)}"
|
276
|
+
s << ", h: #{RMQ.format.numeric(view.size.height, format)}}"
|
277
|
+
out << s
|
278
|
+
end
|
279
|
+
|
280
|
+
out << "\n"
|
281
|
+
out << tree_to_s(view.subviews, depth + 1)
|
282
|
+
end
|
283
|
+
|
284
|
+
out
|
285
|
+
end
|
286
|
+
|
237
287
|
class << self
|
238
288
|
attr_accessor :cache_controller_rmqs
|
239
289
|
@cache_controller_rmqs = true
|
290
|
+
|
291
|
+
def debugging?
|
292
|
+
@debugging ||= ENV['rmq_debug'] == 'true'
|
293
|
+
end
|
294
|
+
|
295
|
+
def debugging=(flag)
|
296
|
+
@debugging = flag
|
297
|
+
end
|
240
298
|
end
|
241
299
|
|
242
300
|
protected
|
@@ -37,5 +37,20 @@ module RubyMotionQuery
|
|
37
37
|
self
|
38
38
|
end
|
39
39
|
|
40
|
+
# @return [Array] or [CGSize]
|
41
|
+
def location_in_root_view
|
42
|
+
self.location_in(self.root_view)
|
43
|
+
end
|
44
|
+
|
45
|
+
# @return [Array] or [CGSize]
|
46
|
+
def location_in(view)
|
47
|
+
out = []
|
48
|
+
selected.each do |selected_view|
|
49
|
+
out << selected_view.convertRect(selected_view.bounds, toView: view).origin
|
50
|
+
end
|
51
|
+
out = out.first if out.length == 1
|
52
|
+
out
|
53
|
+
end
|
54
|
+
|
40
55
|
end
|
41
56
|
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
class <%= @name_camel_case %>Controller < UIViewController
|
2
|
+
|
3
|
+
def viewDidLoad
|
4
|
+
super
|
5
|
+
|
6
|
+
rmq.stylesheet = <%= @name_camel_case %>ControllerStylesheet
|
7
|
+
rmq(self.view).apply_style :root_view
|
8
|
+
|
9
|
+
# Create your views here
|
10
|
+
end
|
11
|
+
|
12
|
+
# Remove if you are only supporting portrait
|
13
|
+
def supportedInterfaceOrientations
|
14
|
+
UIInterfaceOrientationMaskAll
|
15
|
+
end
|
16
|
+
|
17
|
+
# Remove if you are only supporting portrait
|
18
|
+
def willAnimateRotationToInterfaceOrientation(orientation, duration: duration)
|
19
|
+
rmq.all.reapply_styles
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
|
24
|
+
__END__
|
25
|
+
|
26
|
+
# You don't have to reapply styles to all UIViews, if you want to optimize,
|
27
|
+
# another way to do it is tag the views you need to restyle in your stylesheet,
|
28
|
+
# then only reapply the tagged views, like so:
|
29
|
+
def logo(st)
|
30
|
+
st.frame = {t: 10, w: 200, h: 96}
|
31
|
+
st.centered = :horizontal
|
32
|
+
st.image = image.resource('logo')
|
33
|
+
st.tag(:reapply_style)
|
34
|
+
end
|
35
|
+
|
36
|
+
# Then in willAnimateRotationToInterfaceOrientation
|
37
|
+
rmq(:reapply_style).reapply_styles
|
@@ -0,0 +1,11 @@
|
|
1
|
+
class <%= @name_camel_case %>ControllerStylesheet < ApplicationStylesheet
|
2
|
+
|
3
|
+
def setup
|
4
|
+
# Add sytlesheet specific setup stuff here.
|
5
|
+
# Add application specific setup stuff in application_stylesheet.rb
|
6
|
+
end
|
7
|
+
|
8
|
+
def root_view(st)
|
9
|
+
st.background_color = color.white
|
10
|
+
end
|
11
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
class <%= @name_camel_case %>
|
2
|
+
def initialize(params = {})
|
3
|
+
end
|
4
|
+
|
5
|
+
def update(params = {})
|
6
|
+
self
|
7
|
+
end
|
8
|
+
|
9
|
+
def delete
|
10
|
+
end
|
11
|
+
|
12
|
+
def save
|
13
|
+
true
|
14
|
+
end
|
15
|
+
|
16
|
+
class << self
|
17
|
+
def create(params = {})
|
18
|
+
<%= @name_camel_case %>.new(params).tap do |<%= @name %>|
|
19
|
+
<%= @name %>.save
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
def find(id_or_params)
|
24
|
+
end
|
25
|
+
|
26
|
+
def all
|
27
|
+
<%= @name_camel_case %>.find(:all)
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
class <%= @name_camel_case %> < UIView
|
2
|
+
|
3
|
+
def rmq_did_create(self_in_rmq)
|
4
|
+
|
5
|
+
self_in_rmq.tap do |q|
|
6
|
+
q.apply_style :<%= @name %>
|
7
|
+
|
8
|
+
# Add subviews here, like so:
|
9
|
+
#q.append(UILabel, :some_label)
|
10
|
+
end
|
11
|
+
|
12
|
+
end
|
13
|
+
|
14
|
+
end
|
15
|
+
|
16
|
+
|
17
|
+
# To style this view include its stylesheet at the top of each controller's
|
18
|
+
# stylesheet that is going to use it:
|
19
|
+
# class SomeStylesheet < ApplicationStylesheet
|
20
|
+
# include <%= @stylesheet_name %>
|
21
|
+
|
22
|
+
# Another option is to use your controller's stylesheet to style this view. This
|
23
|
+
# works well if only one controller uses it. If you do that, delete the
|
24
|
+
# view's stylesheet with:
|
25
|
+
# rm app/stylesheets/views/<%= @name %>.rb
|
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.
|
4
|
+
version: 0.4.0
|
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: 2013-09
|
12
|
+
date: 2013-10-09 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: bacon
|
@@ -91,6 +91,19 @@ files:
|
|
91
91
|
- motion/ruby_motion_query/tags.rb
|
92
92
|
- motion/ruby_motion_query/traverse.rb
|
93
93
|
- motion/ruby_motion_query/utils.rb
|
94
|
+
- motion/ruby_motion_query/version.rb
|
95
|
+
- templates/controller/app/controllers/name_controller.rb
|
96
|
+
- templates/controller/app/stylesheets/name_controller_stylesheet.rb
|
97
|
+
- templates/controller/spec/controllers/name_controller.rb
|
98
|
+
- templates/lib/lib/name.rb
|
99
|
+
- templates/lib/spec/lib/name.rb
|
100
|
+
- templates/model/app/models/name.rb
|
101
|
+
- templates/model/spec/models/name.rb
|
102
|
+
- templates/shared/app/shared/name.rb
|
103
|
+
- templates/shared/spec/shared/name.rb
|
104
|
+
- templates/view/app/stylesheets/name_stylesheet.rb
|
105
|
+
- templates/view/app/views/name.rb
|
106
|
+
- templates/view/spec/views/name.rb
|
94
107
|
- bin/rmq
|
95
108
|
homepage: http://infinitered.com/rmq
|
96
109
|
licenses:
|