ib 0.2.2 → 0.2.3
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/lib/ib/generator.rb +8 -3
- data/lib/ib/parser.rb +23 -9
- data/lib/ib/version.rb +1 -1
- data/spec/fixtures/empty_view.rb +3 -0
- data/spec/generator_spec.rb +13 -0
- data/spec/parser_spec.rb +2 -2
- metadata +4 -4
data/lib/ib/generator.rb
CHANGED
@@ -31,8 +31,10 @@ OBJC
|
|
31
31
|
end
|
32
32
|
|
33
33
|
def generate_objc files
|
34
|
-
|
35
|
-
|
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
|
-
|
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
|
-
|
17
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
30
|
-
|
31
|
-
|
40
|
+
info[:outlets] = find_outlets(s)
|
41
|
+
info[:outlet_collections] = find_outlet_collections(s)
|
42
|
+
info[:actions] = find_actions(s)
|
32
43
|
|
33
|
-
|
44
|
+
info[:path] = path
|
45
|
+
|
46
|
+
infos << info
|
47
|
+
end
|
34
48
|
|
35
|
-
|
49
|
+
infos
|
36
50
|
end
|
37
51
|
|
38
52
|
def find_class src
|
data/lib/ib/version.rb
CHANGED
data/spec/fixtures/empty_view.rb
CHANGED
data/spec/generator_spec.rb
CHANGED
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 ==
|
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.
|
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-
|
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:
|
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:
|
119
|
+
hash: 3876131364109550006
|
120
120
|
none: false
|
121
121
|
requirements: []
|
122
122
|
rubyforge_project:
|