simple-view 0.5 → 0.5.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.
data/Rakefile CHANGED
@@ -8,7 +8,5 @@ Motion::Project::App.setup do |app|
8
8
  app.name = 'SimpleViewDemo'
9
9
  app.deployment_target = '5.0'
10
10
 
11
- app.detect_dependencies = false
12
- app.files.unshift(Dir.glob(File.join(File.dirname(__FILE__), 'lib/simple_view/*.rb')))
13
- app.files.unshift(Dir.glob(File.join(File.dirname(__FILE__), 'lib/simple_view/extensions/*.rb')))
11
+ app.files.unshift(Dir.glob('./lib/simple_view/**/*.rb'))
14
12
  end
data/lib/simple-view.rb CHANGED
@@ -5,6 +5,5 @@ unless defined?(Motion::Project::Config)
5
5
  end
6
6
 
7
7
  Motion::Project::App.setup do |app|
8
- app.files.unshift(Dir.glob(File.join(File.dirname(__FILE__), 'simple_view/*.rb')))
9
- app.files.unshift(Dir.glob(File.join(File.dirname(__FILE__), 'simple_view/extensions/*.rb')))
8
+ app.files.unshift(Dir.glob(File.join(File.dirname(__FILE__), 'simple_view/**/*.rb')))
10
9
  end
@@ -1,9 +1,5 @@
1
- module SimpleView
2
- module FixnumExtensions
3
- def percent
4
- self / 100.0
5
- end
1
+ class Fixnum
2
+ def percent
3
+ self / 100.0
6
4
  end
7
- end
8
-
9
- Fixnum.send(:include, SimpleView::FixnumExtensions)
5
+ end
@@ -1,65 +1,61 @@
1
- module SimpleView
2
- module StringExtensions
3
- def underscore
4
- word = self.dup
5
- word.gsub!(/::/, '/')
6
- word.gsub!(/([A-Z\d]+)([A-Z][a-z])/,'\1_\2')
7
- word.gsub!(/([a-z\d])([A-Z])/,'\1_\2')
8
- word.tr!("-", "_")
9
- word.downcase!
10
- word
11
- end
12
-
13
- def to_color
14
- html_colour = self.dup
15
- html_colour.gsub!(%r{[#;]}, '')
16
-
17
- case html_colour.size
18
- when 3
19
- colours = html_colour.scan(%r{[0-9A-Fa-f]}).map { |el| (el * 2).to_i(16) }
20
- when 6
21
- colours = html_colour.scan(%r<[0-9A-Fa-f]{2}>).map { |el| el.to_i(16) }
22
- else
23
- return ::UIColor.clearColor if html_colour == 'transparent' || 'clear'
24
- raise ArgumentError
25
- end
1
+ class String
2
+ def underscore
3
+ word = self.dup
4
+ word.gsub!(/::/, '/')
5
+ word.gsub!(/([A-Z\d]+)([A-Z][a-z])/,'\1_\2')
6
+ word.gsub!(/([a-z\d])([A-Z])/,'\1_\2')
7
+ word.tr!("-", "_")
8
+ word.downcase!
9
+ word
10
+ end
26
11
 
27
- ::UIColor.colorWithRed(colours[0]/255.0, green: colours[1]/255.0, blue: colours[2]/255.0, alpha: 1)
12
+ def to_color
13
+ html_colour = self.dup
14
+ html_colour.gsub!(%r{[#;]}, '')
15
+
16
+ case html_colour.size
17
+ when 3
18
+ colours = html_colour.scan(%r{[0-9A-Fa-f]}).map { |el| (el * 2).to_i(16) }
19
+ when 6
20
+ colours = html_colour.scan(%r<[0-9A-Fa-f]{2}>).map { |el| el.to_i(16) }
21
+ else
22
+ return ::UIColor.clearColor if html_colour == 'transparent' || 'clear'
23
+ raise ArgumentError
28
24
  end
29
25
 
30
- def to_font
31
- bold = false
32
- italic = false
33
- size = ::UIFont.systemFontSize
34
- font_name = nil
35
-
36
- self.split(' ').each do |comp|
37
- if comp == "bold"
38
- bold = true
39
- elsif comp == "italic"
40
- italic = true
41
- elsif comp.to_f > 0
42
- size = comp.to_f
43
- elsif comp.length > 4
44
- font_name = comp
45
- end
46
- end
26
+ ::UIColor.colorWithRed(colours[0]/255.0, green: colours[1]/255.0, blue: colours[2]/255.0, alpha: 1)
27
+ end
47
28
 
48
- if font_name
49
- ::UIFont.fontWithName(font_name, size: size)
50
- elsif bold
51
- ::UIFont.boldSystemFontOfSize(size)
52
- elsif italic
53
- ::UIFont.italicSystemFontOfSize(size)
54
- else
55
- ::UIFont.systemFontOfSize(size)
29
+ def to_font
30
+ bold = false
31
+ italic = false
32
+ size = ::UIFont.systemFontSize
33
+ font_name = nil
34
+
35
+ self.split(' ').each do |comp|
36
+ if comp == "bold"
37
+ bold = true
38
+ elsif comp == "italic"
39
+ italic = true
40
+ elsif comp.to_f > 0
41
+ size = comp.to_f
42
+ elsif comp.length > 4
43
+ font_name = comp
56
44
  end
57
45
  end
58
46
 
59
- def to_image
60
- ::UIImage.imageNamed self
47
+ if font_name
48
+ ::UIFont.fontWithName(font_name, size: size)
49
+ elsif bold
50
+ ::UIFont.boldSystemFontOfSize(size)
51
+ elsif italic
52
+ ::UIFont.italicSystemFontOfSize(size)
53
+ else
54
+ ::UIFont.systemFontOfSize(size)
61
55
  end
62
56
  end
63
- end
64
57
 
65
- String.send(:include, SimpleView::StringExtensions)
58
+ def to_image
59
+ ::UIImage.imageNamed self
60
+ end
61
+ end
@@ -1,9 +1,5 @@
1
- module SimpleView
2
- module UIColorExtensions
3
- def to_color
4
- self
5
- end
1
+ class UIColor
2
+ def to_color
3
+ self
6
4
  end
7
- end
8
-
9
- UIColor.send(:include, SimpleView::UIColorExtensions)
5
+ end
@@ -1,9 +1,5 @@
1
- module SimpleView
2
- module UIFontExtensions
3
- def to_font
4
- self
5
- end
1
+ class UIFont
2
+ def to_font
3
+ self
6
4
  end
7
- end
8
-
9
- UIFont.send(:include, SimpleView::UIFontExtensions)
5
+ end
@@ -1,9 +1,5 @@
1
- module SimpleView
2
- module UIImageExtensions
3
- def to_image
4
- self
5
- end
1
+ class UIImage
2
+ def to_image
3
+ self
6
4
  end
7
- end
8
-
9
- UIImage.send(:include, SimpleView::UIImageExtensions)
5
+ end
@@ -1,68 +1,59 @@
1
- module SimpleView
2
- module UIViewExtensions
3
- module Traversing
4
- attr_accessor :name
1
+ class UIView
2
+ attr_accessor :name
5
3
 
6
- def find name
7
- subviews.each do |subview|
8
- return subview if subview.name == name
9
- end
10
- nil
11
- end
12
- alias_method :subview, :find
13
-
14
- def sibling name
15
- if superview
16
- superview.find name
17
- else
18
- nil
19
- end
20
- end
4
+ def find name
5
+ subviews.each do |subview|
6
+ return subview if subview.name == name
7
+ end
8
+ nil
9
+ end
10
+ alias_method :subview, :find
21
11
 
22
- def closest name
23
- view = sibling name
24
- if view.nil? && superview
25
- view = superview.closest name
26
- end
27
- view
28
- end
12
+ def sibling name
13
+ if superview
14
+ superview.find name
15
+ else
16
+ nil
29
17
  end
18
+ end
30
19
 
31
- module Dimensions
32
- def left
33
- self.frame.origin.x
34
- end
20
+ def closest name
21
+ view = sibling name
22
+ if view.nil? && superview
23
+ view = superview.closest name
24
+ end
25
+ view
26
+ end
35
27
 
36
- def setLeft value
37
- self.frame = [[value, self.frame.origin.y], [self.frame.size.width, self.frame.size.height]]
38
- end
28
+ def left
29
+ self.frame.origin.x
30
+ end
39
31
 
40
- def top
41
- self.frame.origin.y
42
- end
32
+ def setLeft value
33
+ self.frame = [[value, self.frame.origin.y], [self.frame.size.width, self.frame.size.height]]
34
+ end
43
35
 
44
- def setTop value
45
- self.frame = [[self.frame.origin.x, value], [self.frame.size.width, self.frame.size.height]]
46
- end
36
+ def top
37
+ self.frame.origin.y
38
+ end
47
39
 
48
- def width
49
- self.frame.size.width
50
- end
40
+ def setTop value
41
+ self.frame = [[self.frame.origin.x, value], [self.frame.size.width, self.frame.size.height]]
42
+ end
51
43
 
52
- def setWidth value
53
- self.frame = [[self.frame.origin.x, self.frame.origin.y], [value, self.frame.size.height]]
54
- end
44
+ def width
45
+ self.frame.size.width
46
+ end
55
47
 
56
- def height
57
- self.frame.size.height
58
- end
48
+ def setWidth value
49
+ self.frame = [[self.frame.origin.x, self.frame.origin.y], [value, self.frame.size.height]]
50
+ end
59
51
 
60
- def setHeight value
61
- self.frame = [[self.frame.origin.x, self.frame.origin.y], [self.frame.size.width, value]]
62
- end
63
- end
52
+ def height
53
+ self.frame.size.height
64
54
  end
65
- end
66
55
 
67
- UIView.send(:include, SimpleView::UIViewExtensions::Traversing)
68
- UIView.send(:include, SimpleView::UIViewExtensions::Dimensions)
56
+ def setHeight value
57
+ self.frame = [[self.frame.origin.x, self.frame.origin.y], [self.frame.size.width, value]]
58
+ end
59
+ end
@@ -1,3 +1,3 @@
1
1
  module SimpleView
2
- VERSION = "0.5"
2
+ VERSION = "0.5.1"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: simple-view
3
3
  version: !ruby/object:Gem::Version
4
- version: '0.5'
4
+ version: 0.5.1
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-01-26 00:00:00.000000000 Z
12
+ date: 2013-01-30 00:00:00.000000000 Z
13
13
  dependencies: []
14
14
  description: RubyMotion DSL for UIKit
15
15
  email: