class RBT::RegisteredTags
Public Class Methods
[]()
click to toggle source
new( optional_commandline_arguments = ARGV, run_already = true )
click to toggle source
#¶ ↑
initialize¶ ↑
#¶ ↑
Calls superclass method
RBT::Base::new
# File lib/rbt/registered/registered_tags.rb, line 66 def initialize( optional_commandline_arguments = ARGV, run_already = true ) super() reset menu(optional_commandline_arguments) if optional_commandline_arguments run if run_already end
Public Instance Methods
available_cookbooks?()
click to toggle source
reset()
click to toggle source
#¶ ↑
reset¶ ↑
#¶ ↑
Calls superclass method
RBT::Base#reset
# File lib/rbt/registered/registered_tags.rb, line 79 def reset super() infer_the_namespace # ======================================================================= # # === @hash_available_tags # ======================================================================= # @hash_available_tags = {} end
run()
click to toggle source
#¶ ↑
run¶ ↑
#¶ ↑
# File lib/rbt/registered/registered_tags.rb, line 196 def run available_cookbooks?.each {|program| dataset = RBT::Cookbooks::SanitizeCookbook.new(program) { :fast } tags = dataset.tags? if tags if tags.empty? opne "#{crimson('Notice')}: The program `#{sfancy(program)}` has "\ "no registered tags." else # else add it to the Hash. @hash_available_tags[program] = tags end else opne "No tags for `#{sfancy(program.to_s)}`." end } # ======================================================================= # # Note that at this point, the hash is not correct yet. # It will have entries such as: # "thor"=>["ruby"] # but it should be the other way around. # ======================================================================= # inverted_hash = {} tags?.each_pair {|name_of_the_program, value| unless value.is_a? Array e 'Must be an Array, but is a `'+sfancy(value.class.to_s)+'`.' e 'This is not allowed - correct the entry please.' e 'Exiting now as a consequence.' exit end value.each {|program_type| unless inverted_hash.has_key? program_type inverted_hash[program_type] = [] end inverted_hash[program_type] << name_of_the_program } } set_hash(inverted_hash) store_main_hash end
set_hash(i)
click to toggle source
show_help( shall_we_exit_afterwards = false )
click to toggle source
#¶ ↑
show_help
¶ ↑
To invoke this method from the commandline, do:
registered_tags --help
#¶ ↑
# File lib/rbt/registered/registered_tags.rb, line 113 def show_help( shall_we_exit_afterwards = false ) case shall_we_exit_afterwards when :then_exit shall_we_exit_afterwards = true end opne 'This class will simply register all available tags into the file' opne " #{sfile(store_where?)}" exit if shall_we_exit_afterwards end
store_main_hash()
click to toggle source
#¶ ↑
store_main_hash
¶ ↑
Write the hash into a file.
#¶ ↑
# File lib/rbt/registered/registered_tags.rb, line 154 def store_main_hash _ = store_where? e sfancy('Storing yaml dataset in ') e " #{sfile(_)}" # ======================================================================= # # Purge the old file first before adding new data to it. # ======================================================================= # remove_file(_) if File.exist? _ tags = tags? if tags File.open(_,'w+') { |file| YAML.dump(tags, file) } end # ======================================================================= # # Also store in the right file on my home system. # # cat $RSRC/rbt/lib/rbt/yaml/registered_tags.yml # # ======================================================================= # if is_on_roebe? _ = RUBY_SRC_DIR_AT_HOME+'rbt/lib/rbt/yaml/'\ 'registered_tags/registered_tags.yml' File.delete(_) if File.exist? _ e sfancy('Also storing into ') e " #{sfile(_)}" File.open(_,'w+') { |file| YAML.dump(tags?, file) } end end