lib/license_acceptance/acceptor.rb in license-acceptance-0.2.6 vs lib/license_acceptance/acceptor.rb in license-acceptance-0.2.8
- old
+ new
@@ -36,31 +36,31 @@
output.puts "#{product_name} cannot execute without accepting the license"
exit 172
end
def check_and_persist(product_name, version)
- if env_acceptance.check_no_persist(ENV) || arg_acceptance.check_no_persist(ARGV)
+ if accepted_no_persist?
logger.debug("Chef License accepted with no persistence")
return true
end
product_reader.read
product_relationship = product_reader.lookup(product_name, version)
- missing_licenses = file_acceptance.check(product_relationship)
+ missing_licenses = file_acceptance.accepted?(product_relationship)
# They have already accepted all licenses and stored their acceptance in the persistent files
if missing_licenses.empty?
logger.debug("All licenses present")
return true
end
- if env_acceptance.check(ENV) || arg_acceptance.check(ARGV)
+ if accepted? || accepted_silent?
if config.persist
errs = file_acceptance.persist(product_relationship, missing_licenses)
if errs.empty?
- output_num_persisted(missing_licenses.size)
+ output_num_persisted(missing_licenses.size) unless accepted_silent?
else
output_persist_failed(errs)
end
end
return true
@@ -81,9 +81,23 @@
new(opts).check_and_persist!(product_name, version)
end
def self.check_and_persist(product_name, version, opts={})
new(opts).check_and_persist(product_name, version)
+ end
+
+ def accepted?
+ env_acceptance.accepted?(ENV) || arg_acceptance.accepted?(ARGV)
+ end
+
+ # no-persist is silent too
+ def accepted_no_persist?
+ env_acceptance.no_persist?(ENV) || arg_acceptance.no_persist?(ARGV)
+ end
+
+ # persist but be silent like no-persist
+ def accepted_silent?
+ env_acceptance.silent?(ENV) || arg_acceptance.silent?(ARGV)
end
# In the case where users accept with a command line argument or environment variable
# we still want to output the fact that the filesystem was changed.
def output_num_persisted(count)