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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 4283e3df2472b537a1aa10f4324267fc9a4a90e8
4
- data.tar.gz: 7949f50c7124319606630c82eaeab2aa689a484a
3
+ metadata.gz: 10b3c8d7d655d2182fc655af633cafccabdfe460
4
+ data.tar.gz: 064e5f501609992377c5579cb398dd2db2c26e37
5
5
  SHA512:
6
- metadata.gz: 32cd5a61f8cfb11e00f2b69e1aeaa6ddeec451605719b826dbd8acca764b934130eccddb02f41843d9e4188b2465011f7f63419005af57a658c6f183cc9acf8a
7
- data.tar.gz: c102ddcd8d60f0d611c22c0d6b7033c1952147f6c9fdcfb69e272d050b5c3d54398ae4f03aafe580d32d0162cc317d1d2970048c1d0df76948c5424c51ddeb7a
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
- $:.unshift('/Library/RubyMotion/lib')
3
- if ENV.fetch('platform', 'ios') == 'ios'
4
- require 'motion/project/template/ios'
5
- elsif ENV['platform'] == 'osx'
6
- require 'motion/project/template/osx'
7
- else
8
- raise "Unsupported platform #{ENV['platform']}"
9
- end
10
- require 'bundler'
11
- Bundler.require
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
- # Use `rake config' to see complete project settings.
15
- app.name = 'rm-extensions'
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
- def describe(constraint)
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
@@ -1,3 +1,3 @@
1
1
  module RMExtensions
2
- VERSION = "0.1.9"
2
+ VERSION = "0.1.10"
3
3
  end
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.9
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 00:00:00.000000000 Z
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: