Class: Jets::Gems::Agree
- Inherits:
-
Object
- Object
- Jets::Gems::Agree
- Defined in:
- lib/jets/gems/agree.rb
Instance Method Summary collapse
-
#bypass_prompt ⇒ Object
Allow user to bypass prompt with JETS_AGREE=1 JETS_AGREE=yes etc Useful for CI/CD pipelines.
-
#initialize ⇒ Agree
constructor
A new instance of Agree.
- #no! ⇒ Object
- #no? ⇒ Boolean
-
#prompt ⇒ Object
Only prompts if hasnt prompted before and saved a ~/.jets/agree file.
- #write_file(content) ⇒ Object
- #yes! ⇒ Object
- #yes? ⇒ Boolean
Constructor Details
#initialize ⇒ Agree
Returns a new instance of Agree.
3 4 5 |
# File 'lib/jets/gems/agree.rb', line 3 def initialize @agree_file = "#{ENV['HOME']}/.jets/agree" end |
Instance Method Details
#bypass_prompt ⇒ Object
Allow user to bypass prompt with JETS_AGREE=1 JETS_AGREE=yes etc Useful for CI/CD pipelines.
26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/jets/gems/agree.rb', line 26 def bypass_prompt agree = ENV['JETS_AGREE'] return false unless agree if %w[1 yes true].include?(agree.downcase) write_file('yes') else write_file('no') end true end |
#no! ⇒ Object
51 52 53 |
# File 'lib/jets/gems/agree.rb', line 51 def no! write_file("no") end |
#no? ⇒ Boolean
43 44 45 |
# File 'lib/jets/gems/agree.rb', line 43 def no? File.exist?(@agree_file) && IO.read(@agree_file).strip == 'no' end |
#prompt ⇒ Object
Only prompts if hasnt prompted before and saved a ~/.jets/agree file
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/jets/gems/agree.rb', line 8 def prompt return if bypass_prompt return if File.exist?(@agree_file) puts <<~EOL Jets sends data about your gems to your specified lambda build service **lambdagems.com** so that it can compile and generate the necessary Lambda layers. Lambdagems only collects anonymous non-identifiable data. Is it okay to send your gem data to Lambdagems? (Y/n)? EOL answer = $stdin.gets.strip value = answer =~ /y/i ? 'yes' : 'no' write_file(value) end |
#write_file(content) ⇒ Object
55 56 57 58 |
# File 'lib/jets/gems/agree.rb', line 55 def write_file(content) FileUtils.mkdir_p(File.dirname(@agree_file)) IO.write(@agree_file, content) end |
#yes! ⇒ Object
47 48 49 |
# File 'lib/jets/gems/agree.rb', line 47 def yes! write_file("yes") end |
#yes? ⇒ Boolean
39 40 41 |
# File 'lib/jets/gems/agree.rb', line 39 def yes? File.exist?(@agree_file) && IO.read(@agree_file).strip == 'yes' end |