Class: Diffend::Repository
- Inherits:
-
Object
- Object
- Diffend::Repository
- Defined in:
- lib/diffend/repository.rb
Overview
Repository for specs
Constant Summary collapse
- REPOSITORIES_PATH =
Repositories path
File.join( File.('..', Bundler.bin_path), 'repositories' ).freeze
- SUPPORTED =
List of supported repositories split by command
{ 'install' => %w[ with_gemfile_lock with_gemfile_lock_with_added_gem with_gemfile_lock_with_changed_gem_version with_gemfile_lock_with_locked_gem_version with_gemfile_lock_with_removed_gem with_gemfile_lock_with_two_platforms with_gemfile_lock_with_two_primary_sources with_gemfile_lock_with_two_sources without_gemfile_lock ].freeze, 'update' => %w[ with_gemfile_lock with_gemfile_lock_with_added_gem with_gemfile_lock_with_removed_gem with_gemfile_lock_with_two_primary_sources with_gemfile_lock_with_two_sources without_gemfile_lock ].freeze }.freeze
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#path ⇒ Object
readonly
Returns the value of attribute path.
Instance Method Summary collapse
-
#bundler_version_string ⇒ String
Build bundler version string.
-
#clean ⇒ Object
Clean isolated instance of a repository.
-
#file_path(file_name) ⇒ String
Build the path to a specified file within the repository.
-
#global_file_path(file_name) ⇒ String
Build global path.
-
#initialize(command, name) ⇒ Repository
constructor
A new instance of Repository.
-
#isolate {|path| ... } ⇒ Object
Execute tasks in an isolated instance of a repository.
-
#orig_path ⇒ String
Build repository path.
-
#setup ⇒ Object
Setup an isolated instance of a repository.
Constructor Details
#initialize(command, name) ⇒ Repository
Returns a new instance of Repository.
43 44 45 46 47 |
# File 'lib/diffend/repository.rb', line 43 def initialize(command, name) @command = command @name = name @path = File.join(Dir.tmpdir, SecureRandom.uuid) end |
Instance Attribute Details
#name ⇒ Object (readonly)
Returns the value of attribute name.
39 40 41 |
# File 'lib/diffend/repository.rb', line 39 def name @name end |
#path ⇒ Object (readonly)
Returns the value of attribute path.
39 40 41 |
# File 'lib/diffend/repository.rb', line 39 def path @path end |
Instance Method Details
#bundler_version_string ⇒ String
Build bundler version string
105 106 107 |
# File 'lib/diffend/repository.rb', line 105 def bundler_version_string @bundler_version_string ||= "bundler_#{Bundler::VERSION.tr('.', '_')}" end |
#clean ⇒ Object
Clean isolated instance of a repository
67 68 69 |
# File 'lib/diffend/repository.rb', line 67 def clean FileUtils.rm_rf(path) end |
#file_path(file_name) ⇒ String
Build the path to a specified file within the repository
83 84 85 86 87 88 |
# File 'lib/diffend/repository.rb', line 83 def file_path(file_name) File.join( path, file_name ) end |
#global_file_path(file_name) ⇒ String
Build global path
95 96 97 98 99 100 |
# File 'lib/diffend/repository.rb', line 95 def global_file_path(file_name) File.join( REPOSITORIES_PATH, file_name ) end |
#isolate {|path| ... } ⇒ Object
Execute tasks in an isolated instance of a repository
72 73 74 75 76 |
# File 'lib/diffend/repository.rb', line 72 def isolate setup yield(path) clean end |
#orig_path ⇒ String
Build repository path
52 53 54 55 56 57 58 59 |
# File 'lib/diffend/repository.rb', line 52 def orig_path @orig_path ||= global_file_path( File.join( bundler_version_string, "#{@command}_#{name}" ) ) end |
#setup ⇒ Object
Setup an isolated instance of a repository
62 63 64 |
# File 'lib/diffend/repository.rb', line 62 def setup FileUtils.cp_r(orig_path, path) end |