ib 0.2.2 → 0.2.3

Sign up to get free protection for your applications and to get access to all the features.
data/lib/ib/generator.rb CHANGED
@@ -31,8 +31,10 @@ OBJC
31
31
  end
32
32
 
33
33
  def generate_objc files
34
- src = files.map do |path, info|
35
- <<-OBJC
34
+ output = ""
35
+ files.map do |path, infos|
36
+ infos.each do |info|
37
+ output << <<-OBJC
36
38
  @interface #{info[:class][0][0]} : #{info[:class][0][1]}
37
39
 
38
40
  #{info[:outlets].map {|name, type| "@property IBOutlet #{generate_type(type)} #{name};" }.join("\n")}
@@ -43,7 +45,10 @@ OBJC
43
45
 
44
46
  @end
45
47
  OBJC
46
- end.join("\n" * 2)
48
+ output << "\n\n"
49
+ end
50
+ end
51
+ output
47
52
  end
48
53
 
49
54
  def generate_objc_impl files
data/lib/ib/parser.rb CHANGED
@@ -13,8 +13,9 @@ class IB::Parser
13
13
  files = Dir.glob("#{dir_or_files}/**/*.rb").to_a if dir_or_files.class == String
14
14
 
15
15
  files.each do |file|
16
- if info = find(file)
17
- all[file] = info
16
+ infos = find(file)
17
+ if infos.length > 0
18
+ all[file] = infos
18
19
  end
19
20
  end
20
21
  all
@@ -22,17 +23,30 @@ class IB::Parser
22
23
 
23
24
  def find(path)
24
25
  src = File.read(path)
25
- info = {class: find_class(src)}
26
+ offsets = []
27
+ src.scan CLASS_REGEX do |b|
28
+ offsets << $~.offset(0)
29
+ end
30
+
31
+ return [] if offsets.length == 0
32
+ infos = []
33
+ pairs = offsets.map {|o| o[0]}
26
34
 
27
- return false if info[:class].length == 0
35
+ pairs << src.length
36
+ (pairs.length - 1).times do |i|
37
+ s = src[pairs[i], pairs[i+1]]
38
+ info = {class: find_class(s)}
28
39
 
29
- info[:outlets] = find_outlets(src)
30
- info[:outlet_collections] = find_outlet_collections(src)
31
- info[:actions] = find_actions(src)
40
+ info[:outlets] = find_outlets(s)
41
+ info[:outlet_collections] = find_outlet_collections(s)
42
+ info[:actions] = find_actions(s)
32
43
 
33
- info[:path] = path
44
+ info[:path] = path
45
+
46
+ infos << info
47
+ end
34
48
 
35
- info
49
+ infos
36
50
  end
37
51
 
38
52
  def find_class src
data/lib/ib/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module IB
2
- VERSION = "0.2.2"
2
+ VERSION = "0.2.3"
3
3
  end
@@ -1,2 +1,5 @@
1
1
  class EmptyView < UIView
2
+ end
3
+
4
+ class AnotherView < EmptyView
2
5
  end
@@ -37,6 +37,19 @@ describe IB::Generator do
37
37
 
38
38
 
39
39
  @end
40
+
41
+
42
+ @interface AnotherView : EmptyView
43
+
44
+
45
+
46
+
47
+
48
+
49
+
50
+ @end
51
+
52
+
40
53
  OBJC
41
54
  end
42
55
  end
data/spec/parser_spec.rb CHANGED
@@ -4,7 +4,7 @@ require "ib/parser"
4
4
 
5
5
  describe IB::Parser do
6
6
  it "finds outlets and actions" do
7
- info = IB::Parser.new.find("spec/fixtures/custom_view.rb")
7
+ info = IB::Parser.new.find("spec/fixtures/custom_view.rb").first
8
8
  info[:class].should == [["CustomView", "UIView"]]
9
9
  info[:outlets].should == [
10
10
  ["greenLabel", "UIGreenLabel"],
@@ -28,7 +28,7 @@ describe IB::Parser do
28
28
  end
29
29
 
30
30
  it "detects simple classes" do
31
- IB::Parser.new.find("spec/fixtures/simple_class.rb").should == false
31
+ IB::Parser.new.find("spec/fixtures/simple_class.rb").length.should == 0
32
32
  end
33
33
 
34
34
  it "finds all infos" do
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: ib
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.2.2
5
+ version: 0.2.3
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: 2012-12-01 00:00:00.000000000 Z
13
+ date: 2012-12-07 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  version_requirements: !ruby/object:Gem::Requirement
@@ -107,7 +107,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
107
107
  version: '0'
108
108
  segments:
109
109
  - 0
110
- hash: -2351586432581253994
110
+ hash: 3876131364109550006
111
111
  none: false
112
112
  required_rubygems_version: !ruby/object:Gem::Requirement
113
113
  requirements:
@@ -116,7 +116,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
116
116
  version: '0'
117
117
  segments:
118
118
  - 0
119
- hash: -2351586432581253994
119
+ hash: 3876131364109550006
120
120
  none: false
121
121
  requirements: []
122
122
  rubyforge_project: