goku 0.1.2 → 0.1.3

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: b0b23937c240cf0b6bb118ed5adc36346d3374a1
4
- data.tar.gz: 7a64ecb8f6f6c9276966856a57b5bad8ecc61032
3
+ metadata.gz: 776341da05c544fc602e6a1eb8a08600d5591263
4
+ data.tar.gz: 0b6aff84049e139254a3a2cb05e079e63fea6e65
5
5
  SHA512:
6
- metadata.gz: d980b8b3e399d4a4e30b93f65d90f0ad1004cd3897358326218e6e91a4f0d07f34add3033b5ba49651ebfbf57760fb62f86e6b2a7942c4b8a3944c2fafcd8274
7
- data.tar.gz: 11a66615da5a61acb035754da848a9f41f2e443cf451b69a96d60c35808e7a96966bf3f7717f5c72f24d17baa320c91a02442a3f15fdcd246903ba04cfa8e169
6
+ metadata.gz: 124795947a1c067c4dae64d71c122bcbd47e411c733b37df242d0ade7e6407402c81c96877535751cee0edb456b296df80385dd835d7a6bffe8034f2f295c1a2
7
+ data.tar.gz: ffd1051312be156c5495d9317570988311a1bc3548ae65dbe8d95e1f9c04b61b0f72fae6a4db06f4525b33b857029aea986d61f343101a5470e8c21b92f9be26
@@ -1,5 +1,6 @@
1
1
  require "thor"
2
2
 
3
+ require "goku/path"
3
4
  require "goku/version"
4
5
 
5
6
  module Goku
@@ -2,13 +2,19 @@ module Goku
2
2
  class CLI < Thor
3
3
 
4
4
  desc "c PATH", "Create a class"
5
- def c(path)
6
- puts path
5
+ def c(raw_path)
6
+ path = Goku::Path.new(raw_path)
7
+
8
+ puts path.full
9
+ puts path.to_spec.full
7
10
  end
8
11
 
9
12
  desc "m PATH", "Create a module"
10
13
  def m(path)
11
- puts path
14
+ path = Goku::Path.new(raw_path)
15
+
16
+ puts path.full
17
+ puts path.to_spec.full
12
18
  end
13
19
 
14
20
  map "module" => "m"
@@ -0,0 +1,46 @@
1
+ module Goku
2
+ class PathConversionError < StandardError; end
3
+
4
+ class Path
5
+ attr_reader :full
6
+
7
+ def initialize(raw_path)
8
+ @full= raw_path
9
+ end
10
+
11
+ def directories
12
+ File.dirname(full).split("/")
13
+ end
14
+
15
+ def filename
16
+ File.basename(full, extension)
17
+ end
18
+
19
+ def extension
20
+ File.extname(full)
21
+ end
22
+
23
+ def spec?
24
+ directories.first == "spec"
25
+ end
26
+
27
+ def implementation?
28
+ !spec?
29
+ end
30
+
31
+ def to_spec
32
+ raise Goku::PathConversionError.new("Path is already a specification") if spec?
33
+
34
+ Goku::Path.new(File.join(["spec", directories, "#{filename}_spec#{extension}"]))
35
+ end
36
+
37
+ def to_implementation
38
+ raise Goku::PathConversionError.new("Path is already an implementation") if implementation?
39
+
40
+ Goku::Path.new(File.join([directories.drop(1), "#{filename.gsub(/_spec$/, "")}#{extension}"]))
41
+ end
42
+
43
+ alias :test? :spec?
44
+
45
+ end
46
+ end
@@ -1,3 +1,3 @@
1
1
  module Goku
2
- VERSION = "0.1.2"
2
+ VERSION = "0.1.3"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: goku
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Igor Šarčević
@@ -87,6 +87,7 @@ files:
87
87
  - goku.gemspec
88
88
  - lib/goku.rb
89
89
  - lib/goku/cli.rb
90
+ - lib/goku/path.rb
90
91
  - lib/goku/version.rb
91
92
  homepage: https://github.com/shiroyasha/goku
92
93
  licenses: