teacup 1.2.5 → 1.2.7

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.
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- teacup (1.2.3)
4
+ teacup (1.2.5)
5
5
  rake
6
6
 
7
7
  GEM
@@ -88,22 +88,22 @@ module Teacup
88
88
  [
89
89
  Teacup::Constraint.new(:self, :left).equals(relative_to, :left),
90
90
  ]
91
- when :top_left
91
+ when :top_left, :topleft
92
92
  [
93
93
  Teacup::Constraint.new(:self, :left).equals(relative_to, :left),
94
94
  Teacup::Constraint.new(:self, :top).equals(relative_to, :top),
95
95
  ]
96
- when :top_right
96
+ when :top_right, :topright
97
97
  [
98
98
  Teacup::Constraint.new(:self, :right).equals(relative_to, :right),
99
99
  Teacup::Constraint.new(:self, :top).equals(relative_to, :top),
100
100
  ]
101
- when :bottom_right
101
+ when :bottom_right, :bottomright
102
102
  [
103
103
  Teacup::Constraint.new(:self, :right).equals(relative_to, :right),
104
104
  Teacup::Constraint.new(:self, :bottom).equals(relative_to, :bottom),
105
105
  ]
106
- when :bottom_left
106
+ when :bottom_left, :bottomleft
107
107
  [
108
108
  Teacup::Constraint.new(:self, :left).equals(relative_to, :left),
109
109
  Teacup::Constraint.new(:self, :bottom).equals(relative_to, :bottom),
@@ -26,10 +26,6 @@ module Teacup
26
26
 
27
27
  right.each do |key, value|
28
28
  if not target.has_key? key
29
- if value.is_a?(Hash)
30
- # make a copy of the Hash
31
- value = Teacup::merge_defaults!({}, value)
32
- end
33
29
  target[key] = value
34
30
  elsif value.is_a?(Hash) and left[key].is_a?(Hash)
35
31
  target[key] = Teacup::merge_defaults(left[key], value, (left==target ? left[key] : {}))
@@ -25,7 +25,7 @@ module Teacup
25
25
  Teacup::Constraint.new(:self, :right).equals(:superview, :right).plus(x)
26
26
  end
27
27
 
28
- def constrain_center_x(x)
28
+ def constrain_center_x(x=0)
29
29
  Teacup::Constraint.new(:self, :center_x).equals(:superview, :center_x).plus(x)
30
30
  end
31
31
 
@@ -37,7 +37,7 @@ module Teacup
37
37
  Teacup::Constraint.new(:self, :bottom).equals(:superview, :bottom).plus(y)
38
38
  end
39
39
 
40
- def constrain_center_y(y)
40
+ def constrain_center_y(y=0)
41
41
  Teacup::Constraint.new(:self, :center_y).equals(:superview, :center_y).plus(y)
42
42
  end
43
43
 
@@ -28,9 +28,15 @@ module Teacup
28
28
  class Stylesheet
29
29
  def iPhone ; 1 << 1 ; end
30
30
  def iPhoneRetina ; 1 << 2 ; end
31
- def iPhone5 ; 1 << 3 ; end
32
- def iPad ; 1 << 4 ; end
33
- def iPadRetina ; 1 << 5 ; end
31
+ def iPhone4 ; 1 << 3 ; end
32
+ def iPhone35 ; 1 << 4 ; end
33
+ def iPad ; 1 << 5 ; end
34
+ def iPadRetina ; 1 << 6 ; end
35
+
36
+ def iPhone5
37
+ NSLog('TEACUP WARNING: iPhone5 method is deprecated in lieu of size-based method names (iPhone4, iPhone35)')
38
+ 1 << 3
39
+ end
34
40
 
35
41
  # returns the device size in points, regardless of status bar
36
42
  def screen_size
@@ -50,11 +56,15 @@ module Teacup
50
56
  @@this_device = 0
51
57
  if UIDevice.currentDevice.userInterfaceIdiom == UIUserInterfaceIdiomPhone
52
58
  @@this_device |= iPhone
53
- if UIScreen.mainScreen.respond_to? :scale
59
+
60
+ if UIScreen.mainScreen.respond_to?(:scale) && UIScreen.mainScreen.scale == 2
54
61
  @@this_device |= iPhoneRetina
55
- if UIScreen.mainScreen.bounds.size.height == 568
56
- @@this_device |= iPhone5
57
- end
62
+ end
63
+
64
+ if UIScreen.mainScreen.bounds.size.height == 568
65
+ @@this_device |= iPhone4
66
+ else
67
+ @@this_device |= iPhone35
58
68
  end
59
69
  else
60
70
  @@this_device |= iPad
@@ -1,5 +1,5 @@
1
1
  module Teacup
2
2
 
3
- VERSION = '1.2.5'
3
+ VERSION = '1.2.7'
4
4
 
5
5
  end
@@ -61,7 +61,7 @@ class UIView
61
61
  end
62
62
 
63
63
  # lastly, go up the chain; either a controller or superview
64
- if ! retval && nextResponder
64
+ if ! retval && nextResponder && nextResponder.respond_to?(:stylesheet)
65
65
  retval = nextResponder.stylesheet
66
66
  end
67
67
 
@@ -51,7 +51,7 @@ describe "Teacup::Stylesheet" do
51
51
  title: "Example!",
52
52
  frame: [[0, 0], [100, 100]],
53
53
  layer: {
54
- borderRadius: 10,
54
+ borderWidth: 10,
55
55
  opacity: 0.5
56
56
  }
57
57
 
@@ -59,7 +59,7 @@ describe "Teacup::Stylesheet" do
59
59
  backgroundColor: :blue,
60
60
  frame: [[100, 100], [200, 200]],
61
61
  layer: {
62
- borderRadius: 20
62
+ borderWidth: 20
63
63
  }
64
64
  end
65
65
  end
@@ -73,8 +73,8 @@ describe "Teacup::Stylesheet" do
73
73
  @stylesheet.query(:example_button)[:frame].should == [[100, 100], [200, 200]]
74
74
  end
75
75
 
76
- it 'should give merge hashes' do
77
- @stylesheet.query(:example_button)[:layer][:borderRadius].should == 20
76
+ it 'should merge hashes' do
77
+ @stylesheet.query(:example_button)[:layer][:borderWidth].should == 20
78
78
  @stylesheet.query(:example_button)[:layer][:opacity].should == 0.5
79
79
  end
80
80
  end
@@ -122,12 +122,19 @@ describe "Teacup::Stylesheet" do
122
122
  import :importedbyname
123
123
 
124
124
  style :label,
125
- backgroundColor: :blue
125
+ backgroundColor: :blue,
126
+ layer: {
127
+ borderWidth: 2,
128
+ }
126
129
  end
127
130
 
128
131
  Teacup::Stylesheet.new(:importedbyname) do
129
132
  style :label,
130
- title: "Imported by name"
133
+ title: "Imported by name",
134
+ layer: {
135
+ borderWidth: 1,
136
+ borderColor: :red,
137
+ }
131
138
  end
132
139
 
133
140
  @name_importer = Teacup::Stylesheet.new do
@@ -167,6 +174,11 @@ describe "Teacup::Stylesheet" do
167
174
  @oo_name_importer.query(:label)[:backgroundColor].should == :blue
168
175
  end
169
176
 
177
+ it 'should merge properties' do
178
+ @oo_name_importer.query(:label)[:layer][:borderWidth].should == 2
179
+ @oo_name_importer.query(:label)[:layer][:borderColor].should == :red
180
+ end
181
+
170
182
  it 'should work with a value' do
171
183
  imported_anonymously = Teacup::Stylesheet.new do
172
184
  style :label,
@@ -214,7 +226,7 @@ describe "Teacup::Stylesheet" do
214
226
  import :most_generic
215
227
 
216
228
  style :label,
217
- borderRadius: 10,
229
+ borderWidth: 10,
218
230
  title: "Stylesheet"
219
231
  end
220
232
 
@@ -227,9 +239,15 @@ describe "Teacup::Stylesheet" do
227
239
  end
228
240
  end
229
241
 
242
+ after do
243
+ Teacup::Stylesheet.stylesheets.delete(:most_generic)
244
+ Teacup::Stylesheet.stylesheets.delete(:stylesheet)
245
+ Teacup::Stylesheet.stylesheets.delete(:most_specific)
246
+ end
247
+
230
248
  it 'should union different properties for the same rule' do
231
249
  @stylesheet.query(:label)[:backgroundColor].should == :blue
232
- @stylesheet.query(:label)[:borderRadius] == 10
250
+ @stylesheet.query(:label)[:borderWidth] == 10
233
251
  end
234
252
 
235
253
  it 'should give the importer precedence' do
@@ -239,7 +257,7 @@ describe "Teacup::Stylesheet" do
239
257
  it 'should follow chains of imports' do
240
258
  @most_specific.query(:label)[:title].should == "Most specific"
241
259
  @most_specific.query(:label)[:font].should == "IMPACT"
242
- @most_specific.query(:label)[:borderRadius].should == 10
260
+ @most_specific.query(:label)[:borderWidth].should == 10
243
261
  @most_specific.query(:label)[:backgroundColor].should == :blue
244
262
  end
245
263
 
@@ -295,13 +313,13 @@ describe "Teacup::Stylesheet" do
295
313
  backgroundColor: :blue
296
314
 
297
315
  style :my_textfield, extends: [:textfield, :input],
298
- borderRadius: 10
316
+ borderWidth: 10
299
317
  end
300
318
 
301
319
  stylesheet.query(:my_textfield)[:text].should == "Extended"
302
320
  stylesheet.query(:my_textfield)[:backgroundColor].should == :blue
303
321
  stylesheet.query(:my_textfield)[:origin].should == [0, 0]
304
- stylesheet.query(:my_textfield)[:borderRadius].should == 10
322
+ stylesheet.query(:my_textfield)[:borderWidth].should == 10
305
323
  end
306
324
 
307
325
  it 'should give precedence to imported rules over extended rules' do
@@ -311,7 +329,7 @@ describe "Teacup::Stylesheet" do
311
329
  backgroundColor: :blue
312
330
 
313
331
  style :my_textfield, extends: :textfield,
314
- borderRadius: 10
332
+ borderWidth: 10
315
333
 
316
334
  import Teacup::Stylesheet.new{
317
335
  style :my_textfield,
@@ -321,7 +339,7 @@ describe "Teacup::Stylesheet" do
321
339
 
322
340
  stylesheet.query(:my_textfield)[:text].should == "Imported"
323
341
  stylesheet.query(:my_textfield)[:backgroundColor].should == :blue
324
- stylesheet.query(:my_textfield)[:borderRadius].should == 10
342
+ stylesheet.query(:my_textfield)[:borderWidth].should == 10
325
343
  end
326
344
 
327
345
  it 'should import rules using a deep merge strategy' do
@@ -329,19 +347,19 @@ describe "Teacup::Stylesheet" do
329
347
  import Teacup::Stylesheet.new{
330
348
  style :my_textfield,
331
349
  layer: {
332
- borderRadius: 1,
350
+ borderWidth: 1,
333
351
  opacity: 0.5
334
352
  }
335
353
  }
336
354
 
337
355
  style :my_textfield,
338
356
  layer: {
339
- borderRadius: 10
357
+ borderWidth: 10
340
358
  }
341
359
  end
342
360
 
343
361
  stylesheet.query(:my_textfield)[:layer][:opacity].should == 0.5
344
- stylesheet.query(:my_textfield)[:layer][:borderRadius].should == 10
362
+ stylesheet.query(:my_textfield)[:layer][:borderWidth].should == 10
345
363
  end
346
364
 
347
365
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: teacup
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.5
4
+ version: 1.2.7
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-02-12 00:00:00.000000000 Z
12
+ date: 2013-02-22 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rake