Class: CiCache::CLI
- Inherits:
-
Object
- Object
- CiCache::CLI
- Defined in:
- lib/ci-cache/cli.rb
Constant Summary collapse
- VALID_COMMANDS =
['get', 'set']
Instance Attribute Summary collapse
-
#argv ⇒ Object
readonly
Returns the value of attribute argv.
-
#command ⇒ Object
Returns the value of attribute command.
-
#fold_count ⇒ Object
Returns the value of attribute fold_count.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
Class Method Summary collapse
Instance Method Summary collapse
- #archive_path ⇒ Object
- #cache_archive_name ⇒ Object
- #cache_hash_file_name ⇒ Object
- #content ⇒ Object
- #fold(message) ⇒ Object
- #hash_file ⇒ Object
-
#initialize(argv = nil) ⇒ CLI
constructor
A new instance of CLI.
- #log(message) ⇒ Object
- #name ⇒ Object
- #old_hash_file ⇒ Object
- #output_path ⇒ Object
- #run ⇒ Object
- #tmp_folder ⇒ Object
Constructor Details
#initialize(argv = nil) ⇒ CLI
Returns a new instance of CLI.
16 17 18 19 20 |
# File 'lib/ci-cache/cli.rb', line 16 def initialize(argv = nil) @argv = argv || ARGV = {} self.fold_count = 0 end |
Instance Attribute Details
#argv ⇒ Object (readonly)
Returns the value of attribute argv.
11 12 13 |
# File 'lib/ci-cache/cli.rb', line 11 def argv @argv end |
#command ⇒ Object
Returns the value of attribute command.
12 13 14 |
# File 'lib/ci-cache/cli.rb', line 12 def command @command end |
#fold_count ⇒ Object
Returns the value of attribute fold_count.
12 13 14 |
# File 'lib/ci-cache/cli.rb', line 12 def fold_count @fold_count end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
11 12 13 |
# File 'lib/ci-cache/cli.rb', line 11 def end |
Class Method Details
.run(argv) ⇒ Object
7 8 9 |
# File 'lib/ci-cache/cli.rb', line 7 def self.run(argv) new(argv).run end |
Instance Method Details
#archive_path ⇒ Object
70 71 72 |
# File 'lib/ci-cache/cli.rb', line 70 def archive_path Pathname("#{tmp_folder}/#{cache_archive_name}") end |
#cache_archive_name ⇒ Object
58 59 60 |
# File 'lib/ci-cache/cli.rb', line 58 def cache_archive_name "#{name}.tar.gz" end |
#cache_hash_file_name ⇒ Object
62 63 64 |
# File 'lib/ci-cache/cli.rb', line 62 def cache_hash_file_name "#{name}.sha2" end |
#content ⇒ Object
43 44 45 46 |
# File 'lib/ci-cache/cli.rb', line 43 def content error("No valid content provided") unless [:content] Pathname([:content]) end |
#fold(message) ⇒ Object
29 30 31 32 33 34 35 36 |
# File 'lib/ci-cache/cli.rb', line 29 def fold() self.fold_count += 1 print "travis_fold:start:ci-cache.#{fold_count}\r" if [:fold] puts "\e[33m#{message}\e[0m" yield ensure print "\ntravis_fold:end:ci-cache.#{fold_count}\r" if [:fold] end |
#hash_file ⇒ Object
48 49 50 51 |
# File 'lib/ci-cache/cli.rb', line 48 def hash_file error("No hash file provided") unless [:hash_file] Pathname([:hash_file]). end |
#log(message) ⇒ Object
78 79 80 |
# File 'lib/ci-cache/cli.rb', line 78 def log() $stderr.puts() end |
#name ⇒ Object
38 39 40 41 |
# File 'lib/ci-cache/cli.rb', line 38 def name error("No valid name provided") unless [:name] [:name] end |
#old_hash_file ⇒ Object
74 75 76 |
# File 'lib/ci-cache/cli.rb', line 74 def old_hash_file Pathname("#{tmp_folder}/#{cache_hash_file_name}") end |
#output_path ⇒ Object
53 54 55 56 |
# File 'lib/ci-cache/cli.rb', line 53 def output_path error("No output path provided") unless [:output_path] Pathname([:output_path]). end |
#run ⇒ Object
22 23 24 25 26 27 |
# File 'lib/ci-cache/cli.rb', line 22 def run parse! execute_command rescue Error => error [:debug] ? raise(error) : die(error.) end |
#tmp_folder ⇒ Object
66 67 68 |
# File 'lib/ci-cache/cli.rb', line 66 def tmp_folder Pathname("~"). end |