ib 0.2.5 → 0.2.6

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 CHANGED
@@ -125,6 +125,12 @@ Here is [sample app](https://github.com/yury/ibsample)
125
125
 
126
126
  **Note** : this app is build for iOS 6.0
127
127
 
128
+ # Another Sample app
129
+
130
+ Here is [another sample app](https://github.com/hqmq/whereami)
131
+
132
+ 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.
133
+
128
134
  ## Contributing
129
135
 
130
136
  1. Fork it
data/lib/ib/generator.rb CHANGED
@@ -35,7 +35,7 @@ OBJC
35
35
  files.map do |path, infos|
36
36
  infos.each do |info|
37
37
  output << <<-OBJC
38
- @interface #{info[:class][0][0]} : #{info[:class][0][1]}
38
+ @interface #{info[:class][0][0]}#{info[:class][0][1] ? ": #{info[:class][0][1]}" : ""}
39
39
 
40
40
  #{info[:outlets].map {|name, type| "@property IBOutlet #{generate_type(type)} #{name};" }.join("\n")}
41
41
 
data/lib/ib/parser.rb CHANGED
@@ -1,6 +1,6 @@
1
1
  class IB::Parser
2
2
  NAME_REGEX = /[a-zA-Z][_a-zA-Z0-9]*/
3
- CLASS_REGEX = /^[ \t]*class[ \t]+(#{NAME_REGEX})[ \t]*<[ \t]*(#{NAME_REGEX})/
3
+ CLASS_REGEX = /^[ \t]*class[ \t]+(#{NAME_REGEX})([ \t]*<[ \t]*(#{NAME_REGEX}))?/
4
4
  OUTLET_REGEX = /^[ \t]+(ib_)?outlet(_accessor)?[ \t]+:(#{NAME_REGEX})[ \t]*?(,[ \t]*['"]?(#{NAME_REGEX}))?/
5
5
  OUTLET_COLLECTION_REGEX = /^[ \t]+(ib_)?outlet_collection(_accessor)?[ \t]+:(#{NAME_REGEX})[ \t]*?(,[ \t]*['"]?(#{NAME_REGEX}))?/
6
6
  METHOD_REF_REGEX = /^[ \t]+(ib_action)[ \t]:(#{NAME_REGEX})/
@@ -9,8 +9,12 @@ class IB::Parser
9
9
 
10
10
  def find_all(dir_or_files)
11
11
  all = {}
12
- files = dir_or_files
13
- files = Dir.glob("#{dir_or_files}/**/*.rb").to_a if dir_or_files.class == String
12
+ files = case dir_or_files
13
+ when Array
14
+ dir_or_files.flatten
15
+ else
16
+ Dir.glob("#{dir_or_files.to_s}/**/*.rb").to_a
17
+ end
14
18
 
15
19
  files.each do |file|
16
20
  infos = find(file)
@@ -43,6 +47,13 @@ class IB::Parser
43
47
 
44
48
  info[:path] = path
45
49
 
50
+ # skip empty classes
51
+ if info[:outlets].empty? &&
52
+ info[:outlet_collections].empty? &&
53
+ info[:actions].empty? && info[:class][0][1].nil?
54
+ next
55
+ end
56
+
46
57
  infos << info
47
58
  end
48
59
 
@@ -50,7 +61,9 @@ class IB::Parser
50
61
  end
51
62
 
52
63
  def find_class src
53
- src.scan CLASS_REGEX
64
+ src.scan(CLASS_REGEX).map do |groups|
65
+ [groups[0], groups[2]]
66
+ end
54
67
  end
55
68
 
56
69
  def find_outlets src
data/lib/ib/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module IB
2
- VERSION = "0.2.5"
2
+ VERSION = "0.2.6"
3
3
  end
@@ -0,0 +1,7 @@
1
+ class AppDelegate
2
+ extend IB
3
+
4
+ outlet :window, UIWindow
5
+ outlet :navigationController, UINavigationController
6
+
7
+ end
@@ -7,7 +7,19 @@ describe IB::Generator do
7
7
  files = IB::Parser.new.find_all("spec/fixtures")
8
8
  stubs = IB::Generator.new.generate_objc(files)
9
9
  stubs.should == <<-OBJC
10
- @interface CustomView : UIView
10
+ @interface AppDelegate
11
+
12
+ @property IBOutlet UIWindow * window;
13
+ @property IBOutlet UINavigationController * navigationController;
14
+
15
+
16
+
17
+
18
+
19
+ @end
20
+
21
+
22
+ @interface CustomView: UIView
11
23
 
12
24
  @property IBOutlet UIGreenLabel * greenLabel;
13
25
  @property IBOutlet UILabel * redLabel;
@@ -28,7 +40,7 @@ describe IB::Generator do
28
40
  @end
29
41
 
30
42
 
31
- @interface EmptyView : UIView
43
+ @interface EmptyView: UIView
32
44
 
33
45
 
34
46
 
@@ -39,7 +51,7 @@ describe IB::Generator do
39
51
  @end
40
52
 
41
53
 
42
- @interface AnotherView : EmptyView
54
+ @interface AnotherView: EmptyView
43
55
 
44
56
 
45
57
 
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: ib
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.2.5
5
+ version: 0.2.6
6
6
  platform: ruby
7
7
  authors:
8
8
  - Yury Korolev
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2013-01-14 00:00:00.000000000 Z
13
+ date: 2013-02-07 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: xcodeproj
@@ -84,6 +84,7 @@ files:
84
84
  - lib/ib/project.rb
85
85
  - lib/ib/tasks.rb
86
86
  - lib/ib/version.rb
87
+ - spec/fixtures/app_delegate.rb
87
88
  - spec/fixtures/custom_view.rb
88
89
  - spec/fixtures/empty_view.rb
89
90
  - spec/fixtures/simple_class.rb
@@ -106,7 +107,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
106
107
  - - ! '>='
107
108
  - !ruby/object:Gem::Version
108
109
  version: '0'
109
- hash: 2426120223194462333
110
+ hash: -4290769984599407242
110
111
  segments:
111
112
  - 0
112
113
  required_rubygems_version: !ruby/object:Gem::Requirement
@@ -115,7 +116,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
115
116
  - - ! '>='
116
117
  - !ruby/object:Gem::Version
117
118
  version: '0'
118
- hash: 2426120223194462333
119
+ hash: -4290769984599407242
119
120
  segments:
120
121
  - 0
121
122
  requirements: []
@@ -125,6 +126,7 @@ signing_key:
125
126
  specification_version: 3
126
127
  summary: Small portion of love to interface builder with rubymotion
127
128
  test_files:
129
+ - spec/fixtures/app_delegate.rb
128
130
  - spec/fixtures/custom_view.rb
129
131
  - spec/fixtures/empty_view.rb
130
132
  - spec/fixtures/simple_class.rb