ib 0.0.5 → 0.1.0
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/README.md +22 -0
- data/lib/ib/generator.rb +24 -1
- data/lib/ib/project.rb +8 -4
- data/lib/ib/version.rb +1 -1
- metadata +4 -4
data/README.md
CHANGED
@@ -39,6 +39,28 @@ end
|
|
39
39
|
|
40
40
|
## Usage
|
41
41
|
|
42
|
+
### Manual Way
|
43
|
+
|
44
|
+
extend your class with IB module
|
45
|
+
|
46
|
+
```ruby
|
47
|
+
class HelloController < UIViewController
|
48
|
+
extend IB
|
49
|
+
|
50
|
+
attr_accessor :title
|
51
|
+
|
52
|
+
# define ib outlet
|
53
|
+
ib_outlet :title, UILabel
|
54
|
+
|
55
|
+
def someAction
|
56
|
+
end
|
57
|
+
|
58
|
+
# define ib action
|
59
|
+
ib_action :someAction
|
60
|
+
end
|
61
|
+
```
|
62
|
+
|
63
|
+
### Generators Way
|
42
64
|
Generate controller with folllowing command:
|
43
65
|
|
44
66
|
```
|
data/lib/ib/generator.rb
CHANGED
@@ -4,14 +4,27 @@ class IB::Generator
|
|
4
4
|
|
5
5
|
FileUtils.mkpath dest
|
6
6
|
|
7
|
-
File.open("#{dest}/
|
7
|
+
File.open("#{dest}/Stubs.h", 'w') do |f|
|
8
8
|
f.write <<-OBJC
|
9
9
|
// Generated by IB v#{IB::VERSION} gem. Do not edit it manually
|
10
10
|
// Run `rake design` to refresh
|
11
11
|
|
12
|
+
#import <Foundation/Foundation.h>
|
13
|
+
#import <CoreData/CoreData.h>
|
12
14
|
#import <UIKit/UIKit.h>
|
13
15
|
|
14
16
|
#{generate_objc(files)}
|
17
|
+
OBJC
|
18
|
+
end
|
19
|
+
|
20
|
+
File.open("#{dest}/Stubs.m", 'w') do |f|
|
21
|
+
f.write <<-OBJC
|
22
|
+
// Generated by IB v#{IB::VERSION} gem. Do not edit it manually
|
23
|
+
// Run `rake design` to refresh
|
24
|
+
|
25
|
+
#import "Stubs.h"
|
26
|
+
|
27
|
+
#{generate_objc_impl(files)}
|
15
28
|
OBJC
|
16
29
|
end
|
17
30
|
|
@@ -26,6 +39,16 @@ OBJC
|
|
26
39
|
|
27
40
|
#{info[:actions].map {|action| "-(IBAction) #{action[0]}:(id) sender;" }.join("\n")}
|
28
41
|
|
42
|
+
@end
|
43
|
+
OBJC
|
44
|
+
end.join("\n" * 2)
|
45
|
+
end
|
46
|
+
|
47
|
+
def generate_objc_impl files
|
48
|
+
src = files.map do |path, info|
|
49
|
+
<<-OBJC
|
50
|
+
@implementation #{info[:class][0][0]}
|
51
|
+
|
29
52
|
@end
|
30
53
|
OBJC
|
31
54
|
end.join("\n" * 2)
|
data/lib/ib/project.rb
CHANGED
@@ -4,12 +4,17 @@ class IB::Project
|
|
4
4
|
target = project.targets.new_static_library(:ios, 'ui')
|
5
5
|
|
6
6
|
resources = project.groups.new('path' => resources_path, 'name' => 'Resources')
|
7
|
-
support = project.groups.new('name' => 'Supporting Files')
|
7
|
+
support = project.groups.new('name' => 'Supporting Files', 'path' => 'ui.xcodeproj')
|
8
8
|
pods = project.groups.new('name' => 'Pods')
|
9
9
|
|
10
|
-
stubs_path = "ui.xcodeproj/stubs.h"
|
11
10
|
IB::Generator.new.write(app_path, "ui.xcodeproj")
|
12
|
-
support.files.new 'path' =>
|
11
|
+
support.files.new 'path' => 'Stubs.h', 'sourceTree' => '<group>'
|
12
|
+
|
13
|
+
path = Pathname.new("Stubs.m")
|
14
|
+
desc = Xcodeproj::Project::PBXNativeTarget::SourceFileDescription.new(path, nil, nil)
|
15
|
+
file = target.add_source_files([desc]).first
|
16
|
+
file.source_tree = '<group>'
|
17
|
+
support.files << file
|
13
18
|
|
14
19
|
resource_exts = %W{xcdatamodeld png jpg jpeg storyboard xib lproj}
|
15
20
|
Dir.glob("#{resources_path}/**/*.{#{resource_exts.join(",")}}") do |file|
|
@@ -37,7 +42,6 @@ class IB::Project
|
|
37
42
|
target.frameworks_build_phases.first << file
|
38
43
|
end
|
39
44
|
|
40
|
-
|
41
45
|
project.save_as("ui.xcodeproj")
|
42
46
|
end
|
43
47
|
end
|
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.0
|
4
|
+
version: 0.1.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2012-07-
|
13
|
+
date: 2012-07-15 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: xcodeproj
|
@@ -108,7 +108,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
108
108
|
version: '0'
|
109
109
|
segments:
|
110
110
|
- 0
|
111
|
-
hash:
|
111
|
+
hash: 1976209642130019168
|
112
112
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
113
113
|
none: false
|
114
114
|
requirements:
|
@@ -117,7 +117,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
117
117
|
version: '0'
|
118
118
|
segments:
|
119
119
|
- 0
|
120
|
-
hash:
|
120
|
+
hash: 1976209642130019168
|
121
121
|
requirements: []
|
122
122
|
rubyforge_project:
|
123
123
|
rubygems_version: 1.8.24
|