Class: ZedTestToggle::Project

Inherits:
Object
  • Object
show all
Defined in:
lib/zed_test_toggle/project.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(root) ⇒ Project

Returns a new instance of Project.



7
8
9
# File 'lib/zed_test_toggle/project.rb', line 7

def initialize(root)
  @root = root.delete_suffix("/")
end

Instance Attribute Details

#rootObject (readonly)

Returns the value of attribute root.



5
6
7
# File 'lib/zed_test_toggle/project.rb', line 5

def root
  @root
end

Instance Method Details

#src_pathsObject



11
12
13
14
15
16
17
# File 'lib/zed_test_toggle/project.rb', line 11

def src_paths
  if gem?
    ["lib", ""]
  else
    ["app", "lib"]
  end
end

#test_anchorObject



23
24
25
# File 'lib/zed_test_toggle/project.rb', line 23

def test_anchor
  spec? ? "spec" : "test"
end

#test_pathsObject



19
20
21
# File 'lib/zed_test_toggle/project.rb', line 19

def test_paths
  [test_anchor, File.join(test_anchor, "lib")]
end

#test_regexesObject



27
28
29
30
31
32
33
# File 'lib/zed_test_toggle/project.rb', line 27

def test_regexes
  if spec?
    [/_spec\.rb$/]
  else
    [/_test\.rb$/, /test_[a-zA-Z0-9_]*\.rb$/]
  end
end

#testify(path) ⇒ Object



35
36
37
# File 'lib/zed_test_toggle/project.rb', line 35

def testify(path)
  path.gsub(/\.rb$/, test_suffix)
end