Class: LicenseFinder::Configuration
- Inherits:
-
Object
- Object
- LicenseFinder::Configuration
- Defined in:
- lib/license_finder/configuration.rb
Defined Under Namespace
Modules: Persistence Classes: Artifacts
Instance Attribute Summary collapse
-
#artifacts ⇒ Object
Returns the value of attribute artifacts.
-
#ignore_groups ⇒ Object
Returns the value of attribute ignore_groups.
-
#project_name ⇒ Object
Returns the value of attribute project_name.
-
#whitelist ⇒ Object
Returns the value of attribute whitelist.
Class Method Summary collapse
- .ensure_default ⇒ Object
- .move! ⇒ Object
-
.prepare(config) ⇒ Object
It’s nice to keep destructive file system manipulation out of the initializer.
Instance Method Summary collapse
-
#initialize(config) ⇒ Configuration
constructor
A new instance of Configuration.
- #save ⇒ Object
- #whitelisted?(license_name) ⇒ Boolean
Constructor Details
#initialize(config) ⇒ Configuration
Returns a new instance of Configuration.
29 30 31 32 33 34 |
# File 'lib/license_finder/configuration.rb', line 29 def initialize(config) @whitelist = Array(config['whitelist']) @ignore_groups = Array(config["ignore_groups"]) @artifacts = Artifacts.new(Pathname(config['dependencies_file_dir'] || './doc/')) @project_name = config['project_name'] || determine_project_name end |
Instance Attribute Details
#artifacts ⇒ Object
Returns the value of attribute artifacts.
27 28 29 |
# File 'lib/license_finder/configuration.rb', line 27 def artifacts @artifacts end |
#ignore_groups ⇒ Object
Returns the value of attribute ignore_groups.
27 28 29 |
# File 'lib/license_finder/configuration.rb', line 27 def ignore_groups @ignore_groups end |
#project_name ⇒ Object
Returns the value of attribute project_name.
27 28 29 |
# File 'lib/license_finder/configuration.rb', line 27 def project_name @project_name end |
#whitelist ⇒ Object
Returns the value of attribute whitelist.
27 28 29 |
# File 'lib/license_finder/configuration.rb', line 27 def whitelist @whitelist end |
Class Method Details
.ensure_default ⇒ Object
5 6 7 8 |
# File 'lib/license_finder/configuration.rb', line 5 def self.ensure_default Persistence.init prepare(Persistence.get) end |
.move! ⇒ Object
10 11 12 13 14 15 |
# File 'lib/license_finder/configuration.rb', line 10 def self.move! config = prepare(Persistence.get.merge('dependencies_file_dir' => './doc/')) config.save FileUtils.mv(Dir["dependencies*"], config.artifacts.dir) end |
.prepare(config) ⇒ Object
It’s nice to keep destructive file system manipulation out of the initializer. That reduces test polution, but is slightly inconvenient for methods like Configuration.ensure_default and Configuration.move!, which need a working artifacts directory. This helper is a compromise.
21 22 23 24 25 |
# File 'lib/license_finder/configuration.rb', line 21 def self.prepare(config) result = new(config) result.artifacts.init result end |
Instance Method Details
#save ⇒ Object
41 42 43 |
# File 'lib/license_finder/configuration.rb', line 41 def save Persistence.set(to_hash) end |
#whitelisted?(license_name) ⇒ Boolean
36 37 38 39 |
# File 'lib/license_finder/configuration.rb', line 36 def whitelisted?(license_name) license = License.find_by_name(license_name) whitelisted_licenses.include? license end |