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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 6434d531210bbe68b924f68261e48c0240d7496d
4
- data.tar.gz: cc4a5914f47d335adfd0806c9189404baa955fbe
3
+ metadata.gz: 728d97165e996862f94ce09f50c82dada923568e
4
+ data.tar.gz: 04700f2ae74432bc1c20df309ca6531ea8b74ba7
5
5
  SHA512:
6
- metadata.gz: 65bb66ea286ff2406faf18b0b9f8c585728ba09207084b27513f9cf328fd0a35e13e313b0f2afae14064f136a0a9486fe5570c92b5555412aeedc7d78caedc3d
7
- data.tar.gz: 3e4eb1393727e71607953604c2e0e1440b5b9c3263e73455e718e9323b3136f5709f735c403da43a2c7930e83fc5c3eef544f9a0568e3174e52ce914ebb9c2cf
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(lambda { "#{tabs(parts.length)}class #{first_part}\n#{tabs(parts.length)}end\n" }) do |memo, namespace|
50
- lambda do
51
- "#{tabs(i-=1)}module #{namespace}\n" +
52
- memo.call +
53
- "#{tabs(i)}end\n"
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
@@ -1,5 +1,5 @@
1
1
  module Cpb
2
2
  module Generators
3
- VERSION = "0.1.1"
3
+ VERSION = "0.1.2"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cpb-generators
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Caleb Buxton