snake_case 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 93b1e85e114f01bf5400e68b6c8e300710271c83
4
+ data.tar.gz: f52f65292681cf17374078074fd4c89185e24d0e
5
+ SHA512:
6
+ metadata.gz: 24775846810af9316f50f4963a9317d18051144c445d38373fd10d3f0ead648d022d734bfb538ec0ae11a178d38b3b55cc85c89adef0ead81660e528992103eb
7
+ data.tar.gz: d43feb77cff36cdbece2aafd93f5f5033948c5759175090416910b97cd801531f32bd4a69da97e32eeb7e74a06563b9228b07a4d69e63d4517e2abf8a26325b6
@@ -0,0 +1,19 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
18
+ build
19
+ .repl_history
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in snake_case.gemspec
4
+ gemspec
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2014 Jack Dean Watson-Hamblin
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,103 @@
1
+ # SnakeCase
2
+
3
+ For RubyMotion developers who are a fan of snake_case. Converting to snake_case, one API at a time.\n\nSlowly converting any API I use to snake_case or to a more idiomatic way of doing it. Lots of monkey patching, because RUBY!
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ gem 'snake_case'
10
+
11
+ And then execute:
12
+
13
+ $ bundle
14
+
15
+ Or install it yourself as:
16
+
17
+ $ gem install snake_case
18
+
19
+ ## Usage
20
+
21
+ This is just a reference for each class I've added methods to. Good to check out the actual source code and specs.
22
+
23
+ ### UIView
24
+
25
+ ```ruby
26
+ # Creating and configuring views
27
+ view = UIView.create
28
+ view = UIView.create do |v|
29
+ v.frame = [[10, 10], [10, 10]]
30
+ end
31
+
32
+ # Adding subviews
33
+ view << UIView.new
34
+
35
+ # Frame related helpers
36
+
37
+ # top / y
38
+ view.top # 10
39
+ view.top = 20
40
+ view.top # 20
41
+ view.frame.origin.y # 20
42
+
43
+ # left / x
44
+ view.left # 10
45
+ view.left = 20
46
+ view.left # 20
47
+ view.frame.origin.x # 20
48
+
49
+ # bottom / y
50
+ view.bottom # 20 (y + height)
51
+ view.bottom = 30
52
+ view.top # 20
53
+ view.bottom # 30
54
+
55
+ # right / x
56
+ view.right # 20 (x + width)
57
+ view.right = 30
58
+ view.left # 20
59
+ view.right # 30
60
+
61
+ # width
62
+ view.width # 10
63
+ view.width = 20
64
+ view.width # 20
65
+
66
+ # height
67
+ view.height # 10
68
+ view.height = 20
69
+ view.height # 20
70
+
71
+ # layer properties
72
+ view.corner_radius = 5
73
+ view.corner_radius # 5
74
+ view.layer.cornerRadius # 5
75
+
76
+ view.border_radius = 10
77
+ view.border_radius # 10
78
+ view.corner_radius # 10
79
+ view.layer.cornerRadius # 10
80
+
81
+ view.border_width = 15
82
+ view.border_width # 15
83
+ view.layer.borderWidth # 15
84
+
85
+ view.border_color = UIColor.greenColor
86
+ view.border_color # UIColor.greenColor.CGColor
87
+ view.layer.borderColor # UIColor.greenColor.CGColor
88
+
89
+ # aliases
90
+ view.size_to_fit # view.sizeToFit
91
+ view.redisplay # view.setNeedsDisplay
92
+ view.set_needs_display # view.setNeedsDisplay
93
+ view.background_color # view.backgroundColor
94
+ view.background_color= # view.backgroundColor=
95
+ ```
96
+
97
+ ## Contributing
98
+
99
+ 1. Fork it ( http://github.com/FluffyJack/snake_case/fork )
100
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
101
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
102
+ 4. Push to the branch (`git push origin my-new-feature`)
103
+ 5. Create new Pull Request
@@ -0,0 +1,27 @@
1
+ $:.unshift("/Library/RubyMotion/lib")
2
+ require 'motion/project/template/ios'
3
+
4
+ require 'bundler'
5
+ Bundler.require(:development)
6
+
7
+ require 'snake_case'
8
+
9
+ module Motion
10
+ module Project
11
+ class Config
12
+ def spec_files=(spec_files)
13
+ @spec_files = spec_files
14
+ end
15
+ end
16
+ end
17
+ end
18
+
19
+ Motion::Project::App.setup do |app|
20
+ app.name = 'snake_case'
21
+ app.version = SnakeCase::VERSION
22
+ app.redgreen_style = :full
23
+ app.detect_dependencies = true
24
+
25
+ app.spec_files -= Dir.glob('./spec/**/*.rb')
26
+ app.spec_files += Dir.glob('./spec/**/*.rb')
27
+ end
@@ -0,0 +1,5 @@
1
+ class AppDelegate
2
+ def application(application, didFinishLaunchingWithOptions:launchOptions)
3
+ true
4
+ end
5
+ end
@@ -0,0 +1,5 @@
1
+ Motion::Project::App.setup do |app|
2
+ parent = File.join(File.dirname(__FILE__), '..')
3
+ files = Dir.glob(File.join(parent, "motion/**/*.rb"))
4
+ app.files += files
5
+ end
@@ -0,0 +1,3 @@
1
+ module SnakeCase
2
+ VERSION = "0.0.1"
3
+ end
@@ -0,0 +1,116 @@
1
+ class UIView
2
+
3
+ class << self
4
+ def create
5
+ view = new
6
+ if block_given?
7
+ yield view
8
+ end
9
+ view
10
+ end
11
+ end
12
+
13
+ def <<(view)
14
+ self.addSubview(view)
15
+ end
16
+
17
+ def top
18
+ CGRectGetMinY(self.frame)
19
+ end
20
+
21
+ def top=(top)
22
+ self.frame = [[self.left, top], [self.width, self.height]]
23
+ end
24
+
25
+ def bottom
26
+ CGRectGetMaxY(self.frame)
27
+ end
28
+
29
+ def bottom=(bottom)
30
+ self.frame = [[self.left, bottom - self.height], [self.width, self.height]]
31
+ end
32
+
33
+ def left
34
+ CGRectGetMinX(self.frame)
35
+ end
36
+
37
+ def left=(left)
38
+ self.frame = [[left, self.top], [self.width, self.height]]
39
+ end
40
+
41
+ def right
42
+ CGRectGetMaxX(self.frame)
43
+ end
44
+
45
+ def right=(right)
46
+ self.frame = [[right - self.width, self.top], [self.width, self.height]]
47
+ end
48
+
49
+ def width
50
+ CGRectGetWidth(self.frame)
51
+ end
52
+
53
+ def width=(width)
54
+ self.frame = [[self.left, self.top], [width, self.height]]
55
+ end
56
+
57
+ def height
58
+ CGRectGetHeight(self.frame)
59
+ end
60
+
61
+ def height=(height)
62
+ self.frame = [[self.left, self.top], [self.width, height]]
63
+ end
64
+
65
+ def size_to_fit
66
+ self.sizeToFit
67
+ end
68
+
69
+ def redisplay
70
+ self.setNeedsDisplay
71
+ end
72
+
73
+ def set_needs_display
74
+ self.setNeedsDisplay
75
+ end
76
+
77
+ def corner_radius
78
+ self.layer.cornerRadius
79
+ end
80
+
81
+ def corner_radius=(radius)
82
+ self.layer.cornerRadius = radius
83
+ end
84
+
85
+ def border_radius
86
+ self.layer.cornerRadius
87
+ end
88
+
89
+ def border_radius=(radius)
90
+ self.layer.cornerRadius = radius
91
+ end
92
+
93
+ def border_color
94
+ self.layer.borderColor
95
+ end
96
+
97
+ def border_color=(color)
98
+ self.layer.borderColor = color.CGColor
99
+ end
100
+
101
+ def border_width
102
+ self.layer.borderWidth
103
+ end
104
+
105
+ def border_width=(width)
106
+ self.layer.borderWidth = width
107
+ end
108
+
109
+ def background_color
110
+ self.backgroundColor
111
+ end
112
+
113
+ def background_color=(color)
114
+ self.backgroundColor = color
115
+ end
116
+ end
@@ -0,0 +1,25 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'snake_case/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "snake_case"
8
+ spec.version = SnakeCase::VERSION
9
+ spec.authors = ["Jack Dean Watson-Hamblin"]
10
+ spec.email = ["info@fluffyjack.com"]
11
+ spec.summary = %q{For RubyMotion developers who are a fan of snake_case.}
12
+ spec.description = "For RubyMotion developers who are a fan of snake_case. Converting to snake_case, one API at a time.\n\nSlowly converting any API I use to snake_case or to a more idiomatic way of doing it. Lots of monkey patching, because RUBY!"
13
+ spec.homepage = "https://github.com/FluffyJack/snake_case"
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files -z`.split("\x0")
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(spec)/})
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.add_development_dependency "bundler", ">= 1.3.5"
22
+ spec.add_development_dependency "motion-redgreen"
23
+ spec.add_development_dependency "motion-stump"
24
+ spec.add_development_dependency "rake"
25
+ end
@@ -0,0 +1,204 @@
1
+ describe "UIView (snake_case)" do
2
+
3
+ before { @view = UIView.new }
4
+ after { @view = nil }
5
+
6
+ describe ".<<" do
7
+ it "adds a subview" do
8
+ @view.mock!(:addSubview)
9
+ @view << UIView.new
10
+ end
11
+ end
12
+
13
+ describe ".size_to_fit" do
14
+ it "calls sizeToFit" do
15
+ @view.mock!(:sizeToFit)
16
+ @view.size_to_fit
17
+ end
18
+ end
19
+
20
+ describe ".redisplay" do
21
+ it "calls setNeedsDisplay" do
22
+ @view.mock!(:setNeedsDisplay)
23
+ @view.redisplay
24
+ end
25
+ end
26
+
27
+ describe ".set_needs_display" do
28
+ it "calls setNeedsDisplay" do
29
+ @view.mock!(:setNeedsDisplay)
30
+ @view.set_needs_display
31
+ end
32
+ end
33
+
34
+ describe ".background_color" do
35
+ it "finds the backgroundColor" do
36
+ @view.backgroundColor = UIColor.purpleColor
37
+ @view.background_color.should == UIColor.purpleColor
38
+ end
39
+ end
40
+
41
+ describe ".background_color=" do
42
+ it "sets the backgroundColor" do
43
+ @view.background_color = UIColor.blueColor
44
+ @view.background_color.should == UIColor.blueColor
45
+ end
46
+ end
47
+
48
+ describe "#create" do
49
+ it "creates a view of the current class" do
50
+ @view = UIView.create
51
+ @view.class.should == UIView
52
+ end
53
+
54
+ it "allows configuration through a block" do
55
+ frame = CGRectMake(10, 10, 10, 10)
56
+ @view = UIView.create do |v|
57
+ v.frame = frame
58
+ end
59
+ @view.frame.should == frame
60
+ end
61
+ end
62
+
63
+ context "positioning and frames" do
64
+ before { @view.frame = [[40, 50], [150, 100]] }
65
+
66
+ describe ".top" do
67
+ it "finds the minimum y coordinate on the view's frame" do
68
+ @view.top.should == 50
69
+ end
70
+ end
71
+
72
+ describe ".top=" do
73
+ it "sets the y coordinate of the view's frame" do
74
+ @view.top = 15
75
+ @view.top.should == 15
76
+ end
77
+ end
78
+
79
+ describe ".bottom" do
80
+ it "finds the maximum y coordinate on the view's frame" do
81
+ @view.bottom.should == 150
82
+ end
83
+ end
84
+
85
+ describe ".bottom=" do
86
+ it "sets the y coordinate of the view's frame to make the .bottom equal to the value passed along" do
87
+ @view.bottom = 200
88
+ @view.bottom.should == 200
89
+ end
90
+ end
91
+
92
+ describe ".left" do
93
+ it "finds the minimum x coordinate on the view's frame" do
94
+ @view.left.should == 40
95
+ end
96
+ end
97
+
98
+ describe ".left=" do
99
+ it "sets the x coordinate of the view's frame" do
100
+ @view.left = 15
101
+ @view.left.should == 15
102
+ end
103
+ end
104
+
105
+ describe ".right" do
106
+ it "finds the maximum x coordinate on the view's frame" do
107
+ @view.right.should == 190
108
+ end
109
+ end
110
+
111
+ describe ".bottom=" do
112
+ it "sets the x coordinate of the view's frame to make the .right equal to the value passed along" do
113
+ @view.right = 290
114
+ @view.right.should == 290
115
+ end
116
+ end
117
+
118
+ describe ".width" do
119
+ it "finds the frame's width" do
120
+ @view.width.should == 150
121
+ end
122
+ end
123
+
124
+ describe ".width=" do
125
+ it "sets the frame's width" do
126
+ @view.width = 300
127
+ @view.width.should == 300
128
+ end
129
+ end
130
+
131
+ describe ".height" do
132
+ it "finds the frame's width" do
133
+ @view.height.should == 100
134
+ end
135
+ end
136
+
137
+ describe ".height=" do
138
+ it "sets the frame's height" do
139
+ @view.height = 400
140
+ @view.height.should == 400
141
+ end
142
+ end
143
+
144
+ end
145
+
146
+ context "layer properties" do
147
+ describe ".corner_radius" do
148
+ it "finds the view's layer's corner radius" do
149
+ @view.layer.cornerRadius = 5
150
+ @view.corner_radius.should == 5
151
+ end
152
+ end
153
+
154
+ describe ".corner_radius=" do
155
+ it "sets the view's layer's corner radius" do
156
+ @view.corner_radius = 15
157
+ @view.corner_radius.should == 15
158
+ end
159
+ end
160
+
161
+ describe ".border_radius" do
162
+ it "finds the view's layer's corner radius" do
163
+ @view.layer.cornerRadius = 10
164
+ @view.border_radius.should == 10
165
+ end
166
+ end
167
+
168
+ describe ".border_radius=" do
169
+ it "sets the view's layer's corner radius" do
170
+ @view.border_radius = 20
171
+ @view.border_radius.should == 20
172
+ end
173
+ end
174
+
175
+ describe ".border_color" do
176
+ it "finds the view's layer's border color" do
177
+ @view.layer.borderColor = UIColor.greenColor.CGColor
178
+ @view.border_color.should == UIColor.greenColor.CGColor
179
+ end
180
+ end
181
+
182
+ describe ".border_color=" do
183
+ it "sets the view's layer's border color using a UIColor" do
184
+ @view.border_color = UIColor.redColor
185
+ @view.border_color.should == UIColor.redColor.CGColor
186
+ end
187
+ end
188
+
189
+ describe ".border_width" do
190
+ it "finds the view's layer's border width" do
191
+ @view.layer.borderWidth = 10
192
+ @view.border_width.should == 10
193
+ end
194
+ end
195
+
196
+ describe ".border_width=" do
197
+ it "sets the view's layer's border width" do
198
+ @view.border_width = 20
199
+ @view.border_width.should == 20
200
+ end
201
+ end
202
+ end
203
+
204
+ end
metadata ADDED
@@ -0,0 +1,115 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: snake_case
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Jack Dean Watson-Hamblin
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-03-26 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: 1.3.5
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: 1.3.5
27
+ - !ruby/object:Gem::Dependency
28
+ name: motion-redgreen
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: motion-stump
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rake
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ description: |-
70
+ For RubyMotion developers who are a fan of snake_case. Converting to snake_case, one API at a time.
71
+
72
+ Slowly converting any API I use to snake_case or to a more idiomatic way of doing it. Lots of monkey patching, because RUBY!
73
+ email:
74
+ - info@fluffyjack.com
75
+ executables: []
76
+ extensions: []
77
+ extra_rdoc_files: []
78
+ files:
79
+ - ".gitignore"
80
+ - Gemfile
81
+ - LICENSE.txt
82
+ - README.md
83
+ - Rakefile
84
+ - app/app_delegate.rb
85
+ - lib/snake_case.rb
86
+ - lib/snake_case/version.rb
87
+ - motion/uikit/uiview+snake_case.rb
88
+ - snake_case.gemspec
89
+ - spec/uikit/uiview+snake_case_spec.rb
90
+ homepage: https://github.com/FluffyJack/snake_case
91
+ licenses:
92
+ - MIT
93
+ metadata: {}
94
+ post_install_message:
95
+ rdoc_options: []
96
+ require_paths:
97
+ - lib
98
+ required_ruby_version: !ruby/object:Gem::Requirement
99
+ requirements:
100
+ - - ">="
101
+ - !ruby/object:Gem::Version
102
+ version: '0'
103
+ required_rubygems_version: !ruby/object:Gem::Requirement
104
+ requirements:
105
+ - - ">="
106
+ - !ruby/object:Gem::Version
107
+ version: '0'
108
+ requirements: []
109
+ rubyforge_project:
110
+ rubygems_version: 2.1.11
111
+ signing_key:
112
+ specification_version: 4
113
+ summary: For RubyMotion developers who are a fan of snake_case.
114
+ test_files:
115
+ - spec/uikit/uiview+snake_case_spec.rb