Class: Githack::Repository
- Inherits:
-
Object
- Object
- Githack::Repository
- Defined in:
- lib/githack/repository.rb
Direct Known Subclasses
Githack::Repositories::CakePHP::V2, Githack::Repositories::CakePHP::V3, Githack::Repositories::Laravel::V5, Githack::Repositories::Rails::V5, Githack::Repositories::Symfony::V1, Githack::Repositories::Symfony::V2, Githack::Repositories::Symfony::V3, Githack::Repositories::Symfony::V4
Constant Summary collapse
- SECRET_PATH =
Represent the path to secrets files
[].freeze
- DATABASE_PATH =
Represent the path to database configuration files
[].freeze
Instance Attribute Summary collapse
-
#git ⇒ Object
readonly
Returns the value of attribute git.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#path ⇒ Object
readonly
Returns the value of attribute path.
-
#remote ⇒ Object
readonly
Returns the value of attribute remote.
Instance Method Summary collapse
-
#databases ⇒ Array<Githack::Leak>
Get all changements for config/database.yml file (who contains database configuration for Ruby on Rails Framework).
-
#initialize(remote) ⇒ Repository
constructor
A new instance of Repository.
-
#secrets ⇒ Array<Githack::Leak>
Get all changements for config/secrets.yml file (who contains some API keys).
Constructor Details
#initialize(remote) ⇒ Repository
Returns a new instance of Repository.
15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/githack/repository.rb', line 15 def initialize(remote) @remote = remote @name = remote.gsub /[^0-9A-Z]/i, '_' @path = File.join(Dir.tmpdir, name) @git = if File.directory? @path Git.open @path else Git.clone @remote, @name, path: Dir.tmpdir end end |
Instance Attribute Details
#git ⇒ Object (readonly)
Returns the value of attribute git.
8 9 10 |
# File 'lib/githack/repository.rb', line 8 def git @git end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
8 9 10 |
# File 'lib/githack/repository.rb', line 8 def name @name end |
#path ⇒ Object (readonly)
Returns the value of attribute path.
8 9 10 |
# File 'lib/githack/repository.rb', line 8 def path @path end |
#remote ⇒ Object (readonly)
Returns the value of attribute remote.
8 9 10 |
# File 'lib/githack/repository.rb', line 8 def remote @remote end |
Instance Method Details
#databases ⇒ Array<Githack::Leak>
Get all changements for config/database.yml file (who contains database configuration for Ruby on Rails Framework)
44 45 46 47 48 49 50 51 52 53 |
# File 'lib/githack/repository.rb', line 44 def databases leaks = [] files = self.class::DATABASE_PATHS.map { |f| File.join(@path, f) } get_leaks(*files).each do |leak| leaks << leak yield lead if block_given? end leaks end |
#secrets ⇒ Array<Githack::Leak>
Get all changements for config/secrets.yml file (who contains some API keys)
30 31 32 33 34 35 36 37 38 39 |
# File 'lib/githack/repository.rb', line 30 def secrets leaks = [] files = self.class::SECRET_PATHS.map { |f| File.join(@path, f) } get_leaks(*files).each do |leak| leaks << leak yield lead if block_given? end leaks end |