cpb-generators 0.1.1 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/cpb/generators/class_generator.rb +13 -7
- data/lib/cpb/generators/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 728d97165e996862f94ce09f50c82dada923568e
|
4
|
+
data.tar.gz: 04700f2ae74432bc1c20df309ca6531ea8b74ba7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f8cc88398a07f20d0b82b21d0e4ff52287c21c058354e8238b65429b450b12e3e4038c1e0cc04a69e3d8ec7d51a98f9cd80882bf6efe78aae01d40d987f25693
|
7
|
+
data.tar.gz: 2b956015ce729ecec5ce8d130f9eeae86e55c4892492aa57713360003ada89bf33a1a7511ada995385fe8d4e7a01581982db784a712394c07047229b67acfe04
|
@@ -46,18 +46,24 @@ module Cpb
|
|
46
46
|
|
47
47
|
unless parts.empty?
|
48
48
|
i = parts.length
|
49
|
-
parts.inject(
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
end
|
55
|
-
end.call
|
49
|
+
parts.inject(constant_string(i+1,"class",first_part)) do |memo, namespace|
|
50
|
+
return_value = constant_string(i,"module",namespace,memo)
|
51
|
+
i -= 1
|
52
|
+
return_value
|
53
|
+
end
|
56
54
|
else
|
57
55
|
"class #{first_part}\nend"
|
58
56
|
end
|
59
57
|
end
|
60
58
|
|
59
|
+
def constant_string(level,type,name,children=nil)
|
60
|
+
return_value = tabs(level)
|
61
|
+
return_value += [type,name].join(" ")+"\n"
|
62
|
+
return_value += children if children
|
63
|
+
return_value += tabs(level)
|
64
|
+
return_value += "end\n"
|
65
|
+
end
|
66
|
+
|
61
67
|
def tabs(i)
|
62
68
|
" "*i
|
63
69
|
end
|