motion_luc 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +17 -0
- data/.rvmrc +1 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +86 -0
- data/Rakefile +3 -0
- data/lib/motion_luc.rb +12 -0
- data/lib/motion_luc/defaults.rb +41 -0
- data/lib/motion_luc/label/fit.rb +9 -0
- data/lib/motion_luc/object/localize.rb +5 -0
- data/lib/motion_luc/object/try.rb +11 -0
- data/lib/version.rb +3 -0
- data/motion_luc.gemspec +21 -0
- metadata +90 -0
data/.gitignore
ADDED
data/.rvmrc
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
rvm use 1.9.3
|
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2013 Jelle Vandebeeck
|
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.
|
data/README.md
ADDED
@@ -0,0 +1,86 @@
|
|
1
|
+
# Motion Luc
|
2
|
+
|
3
|
+
Generate the Core Data model from your RubyMotion code. Never open XCode again!
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
The installation is simple. Just add this line to you Gemfile:
|
8
|
+
|
9
|
+
gem 'motion_luc'
|
10
|
+
|
11
|
+
Execute:
|
12
|
+
|
13
|
+
$ bundle install
|
14
|
+
|
15
|
+
And BOOM, you're on your way!
|
16
|
+
|
17
|
+
## What's included?
|
18
|
+
|
19
|
+
### Try
|
20
|
+
|
21
|
+
You can use the Ruby on Rails like try method to try a method and if it doesn't exist no exception will be raised but instead nil will be returned.
|
22
|
+
|
23
|
+
object_variable.try :testing
|
24
|
+
|
25
|
+
### Localize
|
26
|
+
|
27
|
+
Localize as fast as possible with this function that you can easily use everywhere. No more description, just pass the key and let iOS do the rest.
|
28
|
+
|
29
|
+
localize "key.in.strings.file"
|
30
|
+
|
31
|
+
### Defaults
|
32
|
+
|
33
|
+
Just by defining the DEFAULT_KEYS, you get easier access to the NSUserDefaults. Add there to your globals.rb:
|
34
|
+
|
35
|
+
DEFAULT_KEYS = %w(username password)
|
36
|
+
|
37
|
+
And next you can call these methods below:
|
38
|
+
|
39
|
+
Defaults.instance.username
|
40
|
+
Defaults.instance.username = "me"
|
41
|
+
Defaults.instance.username?
|
42
|
+
|
43
|
+
Defaults.instance.password
|
44
|
+
Defaults.instance.password = "je"
|
45
|
+
Defaults.instance.password?
|
46
|
+
|
47
|
+
### Fit
|
48
|
+
|
49
|
+
You can automatically resize a label until it fits the text. Just call fit on the label instance.
|
50
|
+
|
51
|
+
label_variable.fit
|
52
|
+
|
53
|
+
## Contributing
|
54
|
+
|
55
|
+
It would be awesome if you contribute!
|
56
|
+
|
57
|
+
1. Fork it
|
58
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
59
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
60
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
61
|
+
5. Create new Pull Request
|
62
|
+
|
63
|
+
## License
|
64
|
+
|
65
|
+
Copyright (c) 2013 Jelle Vandebeeck
|
66
|
+
|
67
|
+
MIT License
|
68
|
+
|
69
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
70
|
+
a copy of this software and associated documentation files (the
|
71
|
+
"Software"), to deal in the Software without restriction, including
|
72
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
73
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
74
|
+
permit persons to whom the Software is furnished to do so, subject to
|
75
|
+
the following conditions:
|
76
|
+
|
77
|
+
The above copyright notice and this permission notice shall be
|
78
|
+
included in all copies or substantial portions of the Software.
|
79
|
+
|
80
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
81
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
82
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
83
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
84
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
85
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
86
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/Rakefile
ADDED
data/lib/motion_luc.rb
ADDED
@@ -0,0 +1,12 @@
|
|
1
|
+
unless defined?(Motion::Project::Config)
|
2
|
+
raise "This file must be required within a RubyMotion project Rakefile."
|
3
|
+
end
|
4
|
+
|
5
|
+
Motion::Project::App.setup do |app|
|
6
|
+
Dir.glob(File.join(File.dirname(__FILE__), "motion_luc/**/*.rb")).each do |file|
|
7
|
+
app.files.unshift(file)
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
module MotionLuc
|
12
|
+
end
|
@@ -0,0 +1,41 @@
|
|
1
|
+
class Defaults
|
2
|
+
def self.instance
|
3
|
+
Dispatch.once { @instance ||= Defaults.new }
|
4
|
+
@instance
|
5
|
+
end
|
6
|
+
|
7
|
+
DEFAULT_KEYS.each do |key|
|
8
|
+
define_method "#{key}=", do |new_value|
|
9
|
+
set_key("#{key}", value:new_value)
|
10
|
+
end
|
11
|
+
|
12
|
+
define_method "#{key}" do
|
13
|
+
get_key("#{key}")
|
14
|
+
end
|
15
|
+
|
16
|
+
define_method "#{key}?" do
|
17
|
+
value = get_key("#{key}")
|
18
|
+
!value.nil? and !value.empty?
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
protected
|
23
|
+
|
24
|
+
def defaults
|
25
|
+
@defaults ||= App.user_cache
|
26
|
+
end
|
27
|
+
|
28
|
+
def set_key(key, value:value)
|
29
|
+
if value.nil?
|
30
|
+
defaults.removeObjectForKey(key)
|
31
|
+
else
|
32
|
+
defaults[key] = value
|
33
|
+
end
|
34
|
+
defaults.synchronize
|
35
|
+
end
|
36
|
+
|
37
|
+
def get_key(key)
|
38
|
+
defaults.synchronize
|
39
|
+
defaults[key]
|
40
|
+
end
|
41
|
+
end
|
@@ -0,0 +1,9 @@
|
|
1
|
+
class UILabel
|
2
|
+
def fit
|
3
|
+
if text.nil?
|
4
|
+
self.frame = CGRect.new(self.frame.origin, CGSizeZero)
|
5
|
+
else
|
6
|
+
self.frame = CGRect.new(self.frame.origin, CGSize.new(self.text.sizeWithFont(self.font, constrainedToSize:CGSize.new(9999, self.frame.size.height)).width, self.frame.size.height))
|
7
|
+
end
|
8
|
+
end
|
9
|
+
end
|
data/lib/version.rb
ADDED
data/motion_luc.gemspec
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |gem|
|
7
|
+
gem.name = "motion_luc"
|
8
|
+
gem.version = MotionLuc::VERSION
|
9
|
+
gem.authors = ["Jelle Vandebeeck"]
|
10
|
+
gem.email = ["jelle@fousa.be"]
|
11
|
+
gem.description = %q{Different kind of utilities for RubyMotion the way I use it.}
|
12
|
+
gem.summary = %q{Different kind of utilities for RubyMotion the way I use it.}
|
13
|
+
gem.homepage = "http://github.com/fousa/motion_luc/"
|
14
|
+
|
15
|
+
gem.files = `git ls-files`.split($/)
|
16
|
+
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
17
|
+
gem.require_paths = ["lib"]
|
18
|
+
|
19
|
+
gem.add_development_dependency 'rake'
|
20
|
+
gem.add_dependency 'bubble-wrap'
|
21
|
+
end
|
metadata
ADDED
@@ -0,0 +1,90 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: motion_luc
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Jelle Vandebeeck
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2013-02-25 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: rake
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '0'
|
22
|
+
type: :development
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ! '>='
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '0'
|
30
|
+
- !ruby/object:Gem::Dependency
|
31
|
+
name: bubble-wrap
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
33
|
+
none: false
|
34
|
+
requirements:
|
35
|
+
- - ! '>='
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: '0'
|
38
|
+
type: :runtime
|
39
|
+
prerelease: false
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ! '>='
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: '0'
|
46
|
+
description: Different kind of utilities for RubyMotion the way I use it.
|
47
|
+
email:
|
48
|
+
- jelle@fousa.be
|
49
|
+
executables: []
|
50
|
+
extensions: []
|
51
|
+
extra_rdoc_files: []
|
52
|
+
files:
|
53
|
+
- .gitignore
|
54
|
+
- .rvmrc
|
55
|
+
- Gemfile
|
56
|
+
- LICENSE.txt
|
57
|
+
- README.md
|
58
|
+
- Rakefile
|
59
|
+
- lib/motion_luc.rb
|
60
|
+
- lib/motion_luc/defaults.rb
|
61
|
+
- lib/motion_luc/label/fit.rb
|
62
|
+
- lib/motion_luc/object/localize.rb
|
63
|
+
- lib/motion_luc/object/try.rb
|
64
|
+
- lib/version.rb
|
65
|
+
- motion_luc.gemspec
|
66
|
+
homepage: http://github.com/fousa/motion_luc/
|
67
|
+
licenses: []
|
68
|
+
post_install_message:
|
69
|
+
rdoc_options: []
|
70
|
+
require_paths:
|
71
|
+
- lib
|
72
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
73
|
+
none: false
|
74
|
+
requirements:
|
75
|
+
- - ! '>='
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
version: '0'
|
78
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
79
|
+
none: false
|
80
|
+
requirements:
|
81
|
+
- - ! '>='
|
82
|
+
- !ruby/object:Gem::Version
|
83
|
+
version: '0'
|
84
|
+
requirements: []
|
85
|
+
rubyforge_project:
|
86
|
+
rubygems_version: 1.8.25
|
87
|
+
signing_key:
|
88
|
+
specification_version: 3
|
89
|
+
summary: Different kind of utilities for RubyMotion the way I use it.
|
90
|
+
test_files: []
|