motion-pixate-layout 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- motion-pixate-layout (0.0.1)
4
+ motion-pixate-layout (0.0.3)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
@@ -1,6 +1,6 @@
1
1
  module MotionPixateLayout
2
2
  class Layout
3
- attr_accessor :selector
3
+ attr_accessor :selector, :view_attributes
4
4
  attr_reader :after, :before, :blocks
5
5
 
6
6
  def initialize
@@ -17,7 +17,7 @@ module MotionPixateLayout
17
17
  def method_missing(method_name, *args)
18
18
  if Kernel.constants.include?(method_name.to_sym)
19
19
  view_class = Kernel.const_get(method_name.to_s)
20
- raise "#{view_class.name} is not a known UIView subclass" unless view_class < UIView
20
+ raise "#{view_class.name} is not a known UIView subclass" unless view_class <= UIView
21
21
  return subview(view_class, *args)
22
22
  else
23
23
  raise "#{method_name} is not defined. Should be a subclass of UIView."
@@ -41,6 +41,7 @@ module MotionPixateLayout
41
41
 
42
42
  def run
43
43
  apply_selector
44
+ apply_attributes
44
45
  run_blocks controller, layout.before
45
46
  run_blocks self, layout.blocks
46
47
  run_blocks controller, layout.after
@@ -54,6 +55,12 @@ module MotionPixateLayout
54
55
  end
55
56
  end
56
57
 
58
+ def apply_attributes
59
+ layout.view_attributes.each do |key, value|
60
+ view.public_send "#{key}=", value
61
+ end
62
+ end
63
+
57
64
  def run_blocks(context, blocks)
58
65
  blocks.each { |block| context.instance_eval &block }
59
66
  end
@@ -1,3 +1,3 @@
1
1
  module MotionPixateLayout
2
- Version = '0.0.2'
2
+ Version = '0.0.3'
3
3
  end
@@ -1,8 +1,9 @@
1
1
  class UIViewController
2
2
  class << self
3
- def pixate_layout(selector='', &block)
3
+ def pixate_layout(selector='', attributes={}, &block)
4
4
  if block_given?
5
5
  pixate_layout.selector = MotionPixateLayout::Selector.new(selector)
6
+ pixate_layout.view_attributes = attributes
6
7
  pixate_layout.blocks << block
7
8
  else
8
9
  @_pixate_layout ||= MotionPixateLayout::Layout.new
@@ -8,8 +8,9 @@ describe "MotionPixateLayout::Layout" do
8
8
  @before_called = true
9
9
  end
10
10
 
11
- pixate_layout '#view-id.view-class.view-class-2' do
11
+ pixate_layout '#view-id.view-class.view-class-2', accessibilityLabel: 'main view' do
12
12
  UILabel '#style-id.class1.class2', text: 'Test Label'
13
+ UIView '#subview'
13
14
  end
14
15
 
15
16
  after_pixate_layout do
@@ -23,6 +24,10 @@ describe "MotionPixateLayout::Layout" do
23
24
  UIViewController.should.respond_to :pixate_layout
24
25
  end
25
26
 
27
+ it 'calls mutators for hash parameters' do
28
+ controller.view.accessibilityLabel.should == 'main view'
29
+ end
30
+
26
31
  it 'sets the style id of its view from the selector' do
27
32
  controller.view.styleId.should == 'view-id'
28
33
  end
@@ -32,7 +37,7 @@ describe "MotionPixateLayout::Layout" do
32
37
  end
33
38
 
34
39
  it "adds subviews that are specified in its block" do
35
- controller.view.subviews.size.should == 1
40
+ controller.view.subviews.size.should == 2
36
41
  end
37
42
 
38
43
  it "assigns the styleID from subview selectors" do
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: motion-pixate-layout
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-05-06 00:00:00.000000000 Z
12
+ date: 2013-05-15 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: motion-pixate