ruby_motion_query 1.3.2 → 1.3.3
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 +4 -4
- data/lib/ruby_motion_query.rb +4 -0
- data/motion/ext.rb +24 -15
- data/motion/ruby_motion_query/stylesheet.rb +35 -0
- data/motion/ruby_motion_query/utils.rb +16 -0
- data/motion/ruby_motion_query/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4af6aa73cedcfee0e9779696b6aba1b487875e12
|
4
|
+
data.tar.gz: 046515ebe027e0d3161d62eb5f45d84b3cd8aa66
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 73c0dbb90e91d58dea1bea33e9f1020e56fac0fd8bab8849057f768879c38e409e39b42bbce6cefe4db3a39125b77a2257534b392a3c8a55645f22ad28215bde
|
7
|
+
data.tar.gz: 82af998393074a7f53cb872ba7252a639985cccdaf5441783bf20271acf1b5438465416ef9dbfdb29bf88a93bc3d66d18b22c129a5f1a461a83ca1c8424a2884
|
data/lib/ruby_motion_query.rb
CHANGED
@@ -11,4 +11,8 @@ Motion::Project::App.setup do |app|
|
|
11
11
|
files << Dir.glob(File.join(parent, "motion/**/*.rb"))
|
12
12
|
files.flatten!.uniq!
|
13
13
|
app.files.unshift files
|
14
|
+
app.development do
|
15
|
+
app.info_plist["ProjectBuildTime"] = Time.now
|
16
|
+
app.info_plist["ProjectRootPath"] = File.absolute_path(app.project_dir)
|
17
|
+
end
|
14
18
|
end
|
data/motion/ext.rb
CHANGED
@@ -70,37 +70,46 @@ if RUBYMOTION_ENV == "development"
|
|
70
70
|
private
|
71
71
|
|
72
72
|
def enable_rmq_live_stylesheets(interval)
|
73
|
-
# Get list of stylesheet files
|
74
73
|
return unless root_path = RubyMotionQuery::RMQ.project_path
|
75
74
|
|
75
|
+
# Get list of stylesheet files
|
76
76
|
path_query = "#{root_path}/app/stylesheets/*.rb"
|
77
|
-
puts path_query if @live_reload_debug
|
78
77
|
stylesheet_file_paths = Dir.glob(path_query)
|
79
|
-
stylesheet_file_paths.delete_if{|stylesheet| stylesheet =~ /application_stylesheet\.rb$/}
|
80
|
-
puts stylesheet_file_paths if @live_reload_debug
|
81
78
|
|
82
79
|
stylesheets = stylesheet_file_paths.inject({}) do |out, stylesheet_path_file|
|
83
|
-
|
84
|
-
|
85
|
-
out[
|
80
|
+
klass_name = File.basename(stylesheet_path_file, '.rb')
|
81
|
+
klass_name = klass_name.gsub("_", " ").gsub(/\b(?<!['’`])[a-z]/){ $&.capitalize }.gsub(/\s/, "")
|
82
|
+
out[klass_name] = {
|
83
|
+
class_name: klass_name,
|
86
84
|
path: stylesheet_path_file,
|
87
|
-
modified: File.mtime(stylesheet_path_file)
|
85
|
+
modified: File.mtime(stylesheet_path_file),
|
88
86
|
}
|
89
87
|
out
|
90
88
|
end
|
91
89
|
|
90
|
+
if @live_reload_debug
|
91
|
+
puts "path_query: #{path_query}\n"
|
92
|
+
puts stylesheet_file_paths
|
93
|
+
#puts stylesheets.to_s
|
94
|
+
end
|
95
|
+
|
96
|
+
# Check if any stylesheets have been modified
|
92
97
|
@live_reload_timer = RubyMotionQuery::App.every(interval) do
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
98
|
+
style_changed = false
|
99
|
+
stylesheets.each do |key, stylesheet|
|
100
|
+
|
101
|
+
modified_at = File.mtime(stylesheet[:path])
|
102
|
+
if modified_at > stylesheet[:modified]
|
97
103
|
code = File.read(stylesheet[:path])
|
98
|
-
puts "Reloaded #{
|
104
|
+
puts "Reloaded #{stylesheet[:class_name]}" if @live_reload_debug
|
99
105
|
eval(code)
|
100
|
-
|
101
|
-
|
106
|
+
stylesheet[:modified] = modified_at
|
107
|
+
style_changed = true
|
102
108
|
end
|
109
|
+
|
103
110
|
end
|
111
|
+
|
112
|
+
rmq.view_controller.rmq.all.and_self.reapply_styles if style_changed
|
104
113
|
end
|
105
114
|
|
106
115
|
"Live reloading of RMQ stylesheets is now on."
|
@@ -132,6 +132,41 @@ module RubyMotionQuery
|
|
132
132
|
end
|
133
133
|
end
|
134
134
|
|
135
|
+
def log_stylers(markdown = false)
|
136
|
+
styler_constants_names = Stylers.constants.grep(/.*Styler$/).sort
|
137
|
+
$s = styler_constants_names
|
138
|
+
styler_constants_names.delete(:UIViewStyler)
|
139
|
+
styler_constants_names.unshift(:UIViewStyler)
|
140
|
+
|
141
|
+
object_methods = Object.public_instance_methods
|
142
|
+
ui_view_styler_methods = (Stylers::UIViewStyler.public_instance_methods - object_methods).sort
|
143
|
+
|
144
|
+
# remove deprecated methods, sorry for this hack
|
145
|
+
deprecated = [:"left", :"left=:", :"x", :"x=:", :"top", :"top=:", :"y", :"y=:", :"from_right", :"from_right=:",
|
146
|
+
:"width", :"width=:", :"height", :"height=:", :"bottom", :"bottom=:", :"from_bottom", :"from_bottom=:"]
|
147
|
+
|
148
|
+
|
149
|
+
styler_constants_names.each do |constant_name|
|
150
|
+
constant_name = constant_name.gsub(/^:/, '')
|
151
|
+
styler_constant = RubyMotionQuery::Stylers.const_get(constant_name)
|
152
|
+
|
153
|
+
methods = if constant_name == "UIViewStyler"
|
154
|
+
(ui_view_styler_methods - deprecated).sort
|
155
|
+
else
|
156
|
+
(styler_constant.public_instance_methods - ui_view_styler_methods - object_methods).sort
|
157
|
+
end
|
158
|
+
methods = methods.map do |method|
|
159
|
+
method = method.gsub(/:$/, '')
|
160
|
+
method << "(value)" if method.end_with?("=")
|
161
|
+
method
|
162
|
+
end
|
163
|
+
|
164
|
+
puts "#{'## ' if markdown}#{constant_name}\n\n"
|
165
|
+
puts "* #{methods.join("\n* ")}"
|
166
|
+
puts "\n\n"
|
167
|
+
end
|
168
|
+
end
|
169
|
+
|
135
170
|
protected
|
136
171
|
|
137
172
|
# Override to set your own stylers, or just open up the styler classes
|
@@ -118,6 +118,22 @@ end)
|
|
118
118
|
|
119
119
|
ppath
|
120
120
|
end
|
121
|
+
|
122
|
+
# To use this, put this in your Rakefile:
|
123
|
+
# app.development do
|
124
|
+
# app.info_plist["ProjectBuildTime"] = Time.now
|
125
|
+
# end
|
126
|
+
def build_time
|
127
|
+
if btime = NSBundle.mainBundle.infoDictionary["ProjectBuildTime"]
|
128
|
+
else
|
129
|
+
puts %(
|
130
|
+
[RMQ Warning] The build_time method requires that this code is in your RakeFile:
|
131
|
+
app.development do
|
132
|
+
app.info_plist["ProjectBuildTime"] = Time.now
|
133
|
+
end)
|
134
|
+
end
|
135
|
+
btime
|
136
|
+
end
|
121
137
|
end
|
122
138
|
end
|
123
139
|
|
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: 1.3.
|
4
|
+
version: 1.3.3
|
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: 2015-04-
|
12
|
+
date: 2015-04-20 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: bacon
|