ib 0.3.0 → 0.3.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 +4 -4
- data/README.md +28 -10
- data/lib/ib/outlets.rb +1 -1
- data/lib/ib/parser.rb +2 -2
- data/lib/ib/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bc66435cfe528826f654ee90f00c8a0bb9721d91
|
4
|
+
data.tar.gz: 1a04d108d3a405a40089da32d95877cb4a922b0b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 90835174ea6556b95b4391f9439201feeda54a399f61a0d805b2aa2158ef3b187cfbce6024681563d2b26ea92f2223c284fe64eb508c1875c36f4d410b5b02ae
|
7
|
+
data.tar.gz: bc5656aa841af939a83176e83b97490a4a4827ed54e9cf05440663c739f5880a1502552e1678129305e808628e66c1e2c589235f4f6ad17d433ddab7d4effe81
|
data/README.md
CHANGED
@@ -1,6 +1,6 @@
|
|
1
|
-
# IB
|
1
|
+
# IB
|
2
2
|
|
3
|
-
|
3
|
+
RubyMotion interface builder support (yes, with outlets)
|
4
4
|
|
5
5
|
<a href='http://spellhub.com/projects/project/7'><img src="http://spellhub.com/projects/status/7" height="18"></a>
|
6
6
|
|
@@ -20,15 +20,17 @@ Or install it yourself as:
|
|
20
20
|
|
21
21
|
$ gem install ib
|
22
22
|
|
23
|
+
Or use RubyMotion [templates by @infiniteNIL](https://github.com/infiniteNIL/RubyMotionTemplates)
|
24
|
+
|
23
25
|
In your Rake file:
|
24
26
|
|
25
27
|
```ruby
|
26
28
|
|
27
|
-
$:.unshift("/Library/RubyMotion/lib")
|
28
|
-
require 'motion/project'
|
29
|
+
$:.unshift("/Library/RubyMotion/lib")
|
30
|
+
require 'motion/project'
|
29
31
|
|
30
32
|
# if you use bundler
|
31
|
-
require 'bundler'
|
33
|
+
require 'bundler'
|
32
34
|
Bundler.require
|
33
35
|
|
34
36
|
# if you are not using bundler
|
@@ -54,7 +56,7 @@ class HelloController < UIViewController
|
|
54
56
|
# define ib outlet
|
55
57
|
outlet :title, UILabel # @property IBOutlet UILabel * title;
|
56
58
|
outlet :untyped_label # @property IBOutlet id untyped_label;
|
57
|
-
|
59
|
+
|
58
60
|
# define ib outlet collection
|
59
61
|
outlet_collection :labels, UILabel # @property IBOutletCollection(UILabel) NSArray * labels;
|
60
62
|
|
@@ -64,10 +66,12 @@ class HelloController < UIViewController
|
|
64
66
|
end
|
65
67
|
```
|
66
68
|
|
67
|
-
**NOTE:** If you include methods and attributes from module, you can use `ib_outlet` and `ib_action` to make them visible in
|
69
|
+
**NOTE:** If you include methods and attributes from module, you can use `ib_outlet` and `ib_action` to make them visible in Interface Builder
|
68
70
|
|
69
71
|
```ruby
|
70
72
|
module TouchLogger
|
73
|
+
outlet :my_button, UIButton
|
74
|
+
|
71
75
|
def controlTouched sender
|
72
76
|
puts "touched"
|
73
77
|
end
|
@@ -78,7 +82,9 @@ class LogController < UIViewController
|
|
78
82
|
|
79
83
|
include TouchLogger
|
80
84
|
|
85
|
+
ib_outlet :my_button
|
81
86
|
ib_action :controlTouched
|
87
|
+
|
82
88
|
end
|
83
89
|
```
|
84
90
|
|
@@ -112,15 +118,23 @@ class HelloController < UIViewController
|
|
112
118
|
end
|
113
119
|
```
|
114
120
|
|
115
|
-
|
121
|
+
### Using Interface Builder
|
122
|
+
|
123
|
+
Running `rake ib:open` will create a ib.xcodeproj in the root of your app and open XCode. You can create Storyboards or nibs, and save them in your `resources` directory in order to be picked up by RubyMotion.
|
116
124
|
|
117
|
-
|
125
|
+
Everytime you make a change in your ruby files (like adding a new outlet or action method) you have to run `rake ib:open` in order to let Interface Builder see the changes.
|
126
|
+
|
127
|
+
**Tip** : add ib.xcodeproj to your .gitignore
|
128
|
+
|
129
|
+
### How it works
|
130
|
+
|
131
|
+
This gem parses your Ruby code and generates two Objective-c files (Stub.m and Stub.h) which are populated with the classes, methods and outlets you have defined. This is necessary for Interface Builder to bind outlets and actions to your code.
|
118
132
|
|
119
133
|
# Sample app
|
120
134
|
|
121
135
|
Here is [sample app](https://github.com/yury/ibsample)
|
122
136
|
|
123
|
-
1. clone it
|
137
|
+
1. clone it
|
124
138
|
2. run `bundle`
|
125
139
|
3. run `rake ib:open` to change story board
|
126
140
|
4. run `rake` to run app in simulator
|
@@ -131,6 +145,10 @@ Here is [sample app](https://github.com/yury/ibsample)
|
|
131
145
|
|
132
146
|
Here is [another sample app](https://github.com/hqmq/whereami)
|
133
147
|
|
148
|
+
# OS X Sample app
|
149
|
+
|
150
|
+
Here is [OS X sample app](https://github.com/MarkVillacampa/motion-osx-ib)
|
151
|
+
|
134
152
|
You can play around with it in the same way as the Sample app above. This sample uses a single xib file rather than a storyboard.
|
135
153
|
|
136
154
|
## Contributing
|
data/lib/ib/outlets.rb
CHANGED
data/lib/ib/parser.rb
CHANGED
@@ -16,7 +16,7 @@ class IB::Parser
|
|
16
16
|
else
|
17
17
|
Dir.glob("#{dir_or_files.to_s}/**/*.rb").to_a
|
18
18
|
end
|
19
|
-
|
19
|
+
|
20
20
|
files.each do |file|
|
21
21
|
infos = find(file)
|
22
22
|
if infos.length > 0
|
@@ -40,7 +40,7 @@ class IB::Parser
|
|
40
40
|
pairs << src.length
|
41
41
|
(pairs.length - 1).times do |i|
|
42
42
|
s = src[pairs[i], pairs[i+1]]
|
43
|
-
info = {class
|
43
|
+
info = {:class => find_class(s)}
|
44
44
|
|
45
45
|
info[:outlets] = find_outlets(s)
|
46
46
|
info[:outlet_collections] = find_outlet_collections(s)
|
data/lib/ib/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ib
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Yury Korolev
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-
|
12
|
+
date: 2013-06-11 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: xcodeproj
|