-
-
Notifications
You must be signed in to change notification settings - Fork 49
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #88 from DavidS/add-v
Add -x to skip specified repositories
- Loading branch information
Showing
11 changed files
with
175 additions
and
58 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
--color | ||
--format=documentation |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
|
||
module ModuleSync | ||
# Encapsulate a configs for a module, providing easy access to its parts | ||
class Settings | ||
attr_reader :global_defaults, :defaults, :module_defaults, :module_configs, :additional_settings | ||
|
||
def initialize(global_defaults, defaults, module_defaults, module_configs, additional_settings) | ||
@global_defaults = global_defaults | ||
@defaults = defaults | ||
@module_defaults = module_defaults | ||
@module_configs = module_configs | ||
@additional_settings = additional_settings | ||
end | ||
|
||
def build_file_configs(filename) | ||
global_defaults.merge(defaults[filename] || {}).merge(module_defaults).merge(module_configs[filename] || {}).merge(additional_settings) | ||
end | ||
|
||
def managed?(filename) | ||
Pathname.new(filename).ascend do |v| | ||
configs = build_file_configs(v.to_s) | ||
return false if configs['unmanaged'] | ||
end | ||
true | ||
end | ||
|
||
# given a list of existing files in the repo, return everything that we might want to act on | ||
def managed_files(file_list) | ||
(file_list | defaults.keys | module_configs.keys).select do |f| | ||
managed?(f) && (f != ModuleSync::GLOBAL_DEFAULTS_KEY) | ||
end | ||
end | ||
|
||
# returns a list of files that should not be touched | ||
def unmanaged_files(file_list) | ||
(file_list | defaults.keys | module_configs.keys).select do |f| | ||
!managed?(f) && (f != ModuleSync::GLOBAL_DEFAULTS_KEY) | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
require 'modulesync' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
require 'spec_helper' | ||
|
||
describe ModuleSync::Settings do | ||
subject do | ||
ModuleSync::Settings.new( | ||
{}, | ||
{}, | ||
{}, | ||
{ 'Rakefile' => { 'unmanaged' => true }, | ||
'Gemfile' => { 'key' => 'value' }, }, | ||
{} | ||
) | ||
end | ||
|
||
it { is_expected.not_to eq nil } | ||
it { expect(subject.managed?('Rakefile')).to eq false } | ||
it { expect(subject.managed?('Rakefile/foo')).to eq false } | ||
it { expect(subject.managed?('Gemfile')).to eq true } | ||
it { expect(subject.managed?('Gemfile/foo')).to eq true } | ||
it { expect(subject.managed_files([])).to eq ['Gemfile'] } | ||
it { expect(subject.managed_files(%w(Rakefile Gemfile other_file))).to eq %w(Gemfile other_file) } | ||
it { expect(subject.unmanaged_files([])).to eq ['Rakefile'] } | ||
it { expect(subject.unmanaged_files(%w(Rakefile Gemfile other_file))).to eq ['Rakefile'] } | ||
end |