rm-extensions 0.1.9 → 0.1.10
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +7 -0
- data/Rakefile +15 -13
- data/lib/motion/layout.rb +23 -5
- data/lib/rm-extensions/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: 10b3c8d7d655d2182fc655af633cafccabdfe460
|
4
|
+
data.tar.gz: 064e5f501609992377c5579cb398dd2db2c26e37
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ac1bc79b513e9b0adbafe309a3c6e795883c05b34eca599af6a730cf37cfdec82a2cda180b74137a41cb5a14e4a13098a3b5df49fb7fb2c80884c94a2d059ecf
|
7
|
+
data.tar.gz: 0ae909d56376adfd984be7dcbbbb4e36e26b5e39b093881040e4e261e71ffd8e7fb37d18286dda5d1e0f8025e7cce55cc6a3b36e01e96499f5a39a24b33a124d
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,10 @@
|
|
1
|
+
## 0.1.10
|
2
|
+
|
3
|
+
[Commit history](https://github.com/joenoon/rm-extensions/compare/v0.1.9...v0.1.10)
|
4
|
+
|
5
|
+
* Layout: compact constraint(s) passed to #remove so a nil can be passed to reduce code
|
6
|
+
* Layout: adjust how to describe existing constraints
|
7
|
+
|
1
8
|
## 0.1.9
|
2
9
|
|
3
10
|
[Commit history](https://github.com/joenoon/rm-extensions/compare/v0.1.8...v0.1.9)
|
data/Rakefile
CHANGED
@@ -1,16 +1,18 @@
|
|
1
1
|
require "bundler/gem_tasks"
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
2
|
+
if ENV['rubymotion']
|
3
|
+
$:.unshift('/Library/RubyMotion/lib')
|
4
|
+
if ENV.fetch('platform', 'ios') == 'ios'
|
5
|
+
require 'motion/project/template/ios'
|
6
|
+
elsif ENV['platform'] == 'osx'
|
7
|
+
require 'motion/project/template/osx'
|
8
|
+
else
|
9
|
+
raise "Unsupported platform #{ENV['platform']}"
|
10
|
+
end
|
11
|
+
require 'bundler'
|
12
|
+
Bundler.require
|
12
13
|
|
13
|
-
Motion::Project::App.setup do |app|
|
14
|
-
|
15
|
-
|
14
|
+
Motion::Project::App.setup do |app|
|
15
|
+
# Use `rake config' to see complete project settings.
|
16
|
+
app.name = 'rm-extensions'
|
17
|
+
end
|
16
18
|
end
|
data/lib/motion/layout.rb
CHANGED
@@ -78,7 +78,7 @@ module RMExtensions
|
|
78
78
|
end
|
79
79
|
|
80
80
|
def remove(constraint)
|
81
|
-
constraints = [ constraint ].flatten
|
81
|
+
constraints = [ constraint ].flatten.compact
|
82
82
|
@view.removeConstraints(constraints)
|
83
83
|
@constraints.keys.each do |key|
|
84
84
|
@constraints.delete(key) if constraints.include?(@constraints.fetch(key))
|
@@ -303,19 +303,37 @@ module RMExtensions
|
|
303
303
|
eq(str, true)
|
304
304
|
end
|
305
305
|
|
306
|
+
def describe_constraint(constraint)
|
307
|
+
self.class.describe_constraint(@subviews, constraint)
|
308
|
+
end
|
309
|
+
|
310
|
+
def describe_view
|
311
|
+
self.class.describe_view(@subviews, @view)
|
312
|
+
end
|
313
|
+
|
306
314
|
# transforms an NSLayoutConstraint into a string. this string is for debugging and produces
|
307
315
|
# a verbose translation. its not meant to be copied directly as an equation.
|
308
|
-
|
316
|
+
# pass the subviews hash just as you would to Layout#subviews=, followed by the NSLayoutConstraint
|
317
|
+
def self.describe_constraint(subviews, constraint)
|
309
318
|
subviews_inverse = subviews.invert
|
310
|
-
item = subviews_inverse[constraint.firstItem]
|
319
|
+
item = subviews_inverse[constraint.firstItem] || "view"
|
311
320
|
item_attribute = ATTRIBUTE_LOOKUP_INVERSE[constraint.firstAttribute]
|
312
321
|
related_by = RELATED_BY_LOOKUP_INVERSE[constraint.relation]
|
313
|
-
to_item = subviews_inverse[constraint.secondItem]
|
322
|
+
to_item = subviews_inverse[constraint.secondItem] || "view"
|
314
323
|
to_item_attribute = ATTRIBUTE_LOOKUP_INVERSE[constraint.secondAttribute]
|
315
324
|
multiplier = constraint.multiplier
|
316
325
|
constant = constraint.constant
|
317
326
|
priority = PRIORITY_LOOKUP_INVERSE[constraint.priority] || constraint.priority
|
318
|
-
"#{item}.#{item_attribute} #{related_by} #{to_item}.#{to_item_attribute} * #{multiplier} + #{constant} @ #{priority}"
|
327
|
+
"#{constraint.description}\n#{item}.#{item_attribute} #{related_by} #{to_item}.#{to_item_attribute} * #{multiplier} + #{constant} @ #{priority}"
|
328
|
+
end
|
329
|
+
|
330
|
+
# transforms a view's NSLayoutConstraints into strings.
|
331
|
+
# pass the subviews hash just as you would to Layout#subviews=, followed by the view to
|
332
|
+
# describe
|
333
|
+
def self.describe_view(subviews, view)
|
334
|
+
view.constraints.map do |constraint|
|
335
|
+
describe_constraint(subviews, constraint)
|
336
|
+
end.join("\n")
|
319
337
|
end
|
320
338
|
|
321
339
|
private
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rm-extensions
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.10
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Joe Noon
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-09-
|
11
|
+
date: 2013-09-15 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: Extensions and helpers for dealing with various areas of rubymotion
|
14
14
|
email:
|