plastic_cup 0.1.0 → 0.1.1

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 CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- OGI3ODk4MmZmMmM2MzYzYTk5ZmJlOGJiYmQ4YmVlZDU4YjM4YTFmYg==
4
+ ZTcyZjliNGZhNGY1YmMyZjliNzFiMmE3NTMxZWM4ZmYwMmZhNjNkMA==
5
5
  data.tar.gz: !binary |-
6
- NThhNDRiNWY5NzVmMTczZmZiOTZjMDVlMjNmZDc4YzhjMDQwYmFhZA==
6
+ MTY0Yzc5MjY4NzllMDk4ZjZkMTQyMWQwMzcxMTFiOTkyZThmMDkxNw==
7
7
  !binary "U0hBNTEy":
8
8
  metadata.gz: !binary |-
9
- YjVmN2ZjYjVlNDcyYzU0MGJhMmQ3NGY2YzAwYzA5N2RkMTliNjY3ZDNiOGJj
10
- ZjVlOWYzNzQxNjhlOTUwODQ4MmE2ZDIyN2JjMWMwMzg5MTBiMTE1M2QzMTI1
11
- YmFjODlmMmRmMjgyYjdiOGRjODQ0ZjU5OWE4OTg3NDQzNTYyMWQ=
9
+ NzlkODA5MWJmNmFhMDYzNDE3YWRmMTBhMjU5MWZjZWQ3MjgxZDhhNDE0MTNl
10
+ YmU5MGEzOTI4MDQ3NTExNjgwYWU0YmYwYjQ2MjgyNWJkNTg3MzZkYTdkNjUz
11
+ N2UxNGEzYjcyODJlODU5ZDIwMzhiZTlkMDNlMzhlYzdmYTRkYzg=
12
12
  data.tar.gz: !binary |-
13
- MDcwYWQ4NzczZTIxZmVmZWJhM2U0ZjdlZDhhODRiZjllMmJlODE2ZWJmZTkx
14
- NmMzNDg2MWMxZWNjOGY5MTlkMzM0MDdiNjZiOGRlZDU2YzZhMzdiMGY0NTY3
15
- N2Q2Y2FhMGE1MTBkNzNmYmYwNjQzMGJlMjFjYjYxNTk3MWQ4MmU=
13
+ ODFhMzU2MjcyNmQxOTQ2ODY2ODA4YTc4MTllZDZiOTZjOTEzMjcyYmVhZDkw
14
+ Yjc3OGUxNTZiZGEzNTZiZmM4NmE3NzhmZjliMjFjOTgxMzdjMGY4OTlkZTA1
15
+ MDMwZDBlOWFlNDFiZWRjY2U4NTViM2M5MzZhNWE4YWJhYWE3ODM=
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- plastic_cup (0.1.0)
4
+ plastic_cup (0.1.1)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
@@ -8,16 +8,7 @@ module PlasticCup
8
8
  if style.is_a?(Hash)
9
9
  apply_properties(target, style)
10
10
  else
11
- style_sheet = get_style_sheet(style)
12
- unless style_sheet.nil?
13
- extends = style_sheet.extends
14
- final_style = {}
15
- extends.each do |ext|
16
- ext_style_sheet = get_style_sheet(ext)
17
- final_style.merge!(ext_style_sheet.properties) unless ext_style_sheet.nil?
18
- end
19
- apply_properties(target, final_style.merge(style_sheet.properties))
20
- end
11
+ apply_properties(target, get_style_sheet_properties(style))
21
12
  end
22
13
  target
23
14
  end
@@ -41,6 +32,24 @@ module PlasticCup
41
32
  style_hash
42
33
  end
43
34
 
35
+ def self.get_style_sheet_properties(style)
36
+ style_sheet = get_style_sheet(style)
37
+ if style_sheet.nil?
38
+ {}
39
+ else
40
+ extends = style_sheet.extends
41
+ if extends.empty?
42
+ style_sheet.properties
43
+ else
44
+ final_style = {}
45
+ extends.each do |ext|
46
+ final_style.merge!(get_style_sheet_properties(ext))
47
+ end
48
+ final_style.merge(style_sheet.properties)
49
+ end
50
+ end
51
+ end
52
+
44
53
  # teacup/lib/teacup/handler.rb
45
54
  def self.handler(klass, *style_names, &block)
46
55
  if style_names.length == 0
@@ -1,3 +1,3 @@
1
1
  module PlasticCup
2
- VERSION = '0.1.0'
2
+ VERSION = '0.1.1'
3
3
  end
data/spec/base_spec.rb CHANGED
@@ -49,6 +49,30 @@ describe 'PlasticCup::Base' do
49
49
  button.tintColor.should == UIColor.greenColor
50
50
  end
51
51
 
52
+ it 'should support multiple layer extends' do
53
+ PlasticCup::Base.add_style_sheet(:grandma, {textAlignment: 2})
54
+ PlasticCup::Base.add_style_sheet(:mother, {extends: :grandma, placeholder: 'This is placeholder'})
55
+ PlasticCup::Base.add_style_sheet(:my_style, {extends: :mother, text: 'My Text'})
56
+
57
+ field = PlasticCup::Base.style(UITextField.new, :my_style)
58
+
59
+ field.textAlignment.should == 2
60
+ field.text.should == 'My Text'
61
+ field.placeholder.should == 'This is placeholder'
62
+ end
63
+
64
+ it 'should ignore missing extends style sheet' do
65
+ PlasticCup::Base.add_style_sheet(:grandma, {textAlignment: 3})
66
+ PlasticCup::Base.add_style_sheet(:mother, {extends: [:grandma, :nobody], placeholder: 'Mother placeholder'})
67
+ PlasticCup::Base.add_style_sheet(:my_style, {extends: [:mother, :et], text: 'My Style Text'})
68
+
69
+ field = PlasticCup::Base.style(UITextField.new, :my_style)
70
+
71
+ field.textAlignment.should == 3
72
+ field.text.should == 'My Style Text'
73
+ field.placeholder.should == 'Mother placeholder'
74
+ end
75
+
52
76
  end
53
77
 
54
78
  describe '#add_style_sheet and #get_style_sheet' do
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: plastic_cup
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - April Tsang
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-10-09 00:00:00.000000000 Z
11
+ date: 2013-10-10 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: ! 'Plastic Cup is a simplified version of Teacup, aiming at memory leak
14
14
  prevention.