Class: Transpec::Project

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(path = Dir.pwd) ⇒ Project

Returns a new instance of Project.



10
11
12
# File 'lib/transpec/project.rb', line 10

def initialize(path = Dir.pwd)
  @path = path
end

Instance Attribute Details

#pathObject (readonly)

Returns the value of attribute path.



8
9
10
# File 'lib/transpec/project.rb', line 8

def path
  @path
end

Instance Method Details

#basenameObject



14
15
16
# File 'lib/transpec/project.rb', line 14

def basename
  File.basename(path)
end

#require_bundler?Boolean

Returns:

  • (Boolean)


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

def require_bundler?
  gemfile_path = File.join(path, 'Gemfile')
  File.exist?(gemfile_path)
end

#rspec_versionObject



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

def rspec_version
  @rspec_version ||= RSpecVersion.new(fetch_rspec_version)
end

#with_bundler_clean_envObject



27
28
29
30
31
32
33
34
35
36
37
# File 'lib/transpec/project.rb', line 27

def with_bundler_clean_env
  if defined?(Bundler) && require_bundler?
    Bundler.with_clean_env do
      # Bundler.with_clean_env cleans environment variables
      # which are set after bundler is loaded.
      yield
    end
  else
    yield
  end
end