Module: Kielce
- Defined in:
- lib/kielce.rb,
lib/kielce/kielce.rb,
lib/kielce/kielce_data.rb,
lib/kielce/kielce_loader.rb
Overview
KielceData
An object representing the data loaded from the various Kielce data files. The files return a Hash: a set of key-value pairs. KielceData allows users to access the data using the more convenient method syntax (i.e., $d.itemName instead of $d or $d) KielceData is a child of BasicObject instead of Object so that there aren’t conflicts with methods defined on Object and Kernel (freeze, method, trust, etc. )
For convenience, KielceData does provide a few key methods including is_a and inspect
© 2020 Zachary Kurmas
Defined Under Namespace
Classes: IncompleteRenderError, InvalidKeyError, Kielce, KielceData, KielceDataAnalyzer, KielceLoader, LoadingError, NoKeyError
Constant Summary collapse
- VERSION =
"2.0.8"- INVALID_KEYS =
[:root, :method_missing, :inspect]
Class Method Summary collapse
-
.run ⇒ Object
Changelog.
Class Method Details
.run ⇒ Object
Changelog
2.0.8: Changed how missing schedule items are reported. 2.0.4: Added a “target” option to “link”, and made the timeline links open in a new tab.
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 |
# File 'lib/kielce.rb', line 24 def self.run # TODO: #idea: If 1 param: Assume input and stdout # If 2 params and 2nd param is file, assume input and output # If 2+ params and 2nd param is dir, then process all files. Place in output dir. remove.erb from filename. = { quiet: false, } OptionParser.new do |opts| opts. = "Usage: kielce [options]" opts.on("-q", "--[no-]quiet", "Run quietly") do |q| [:quiet] = q end end.parse! $stderr.puts "KielceRB (version #{VERSION})" unless [:quiet] if ARGV.length == 0 $stderr.puts "Usage: kielce file_to_process" exit end # # Get to work # file = ARGV[0] $stderr.puts "Processing #{file}" unless [:quiet] # We use global variables $d and $k to make the data and +Kielce+ objects available to the # ERB template engine. There was a bit of debate about this decision. The most popular # alternative was to create a class named +DataContext+ with +data+ and +kielce+ accessors. # # Advantages to using global variables: # (1) The resulting names were short (two characters) and eye-catching (because the first # character is '$') # (2) It keeps the design simpler by eliminating the need for an additional +DataContext+ class. # (3) Users can create a custom class to use as a context without worring about conforiming to # any specific interface # # Advantages to using a special +DataContext+ class: # (1) Avoids polluting the global namespace. begin context = Object.new $d = KielceLoader.load(file, context: context) $k = Kielce.new(context) result = $k.render(file) puts result if $k.error_count == 0 rescue LoadingError => e $stderr.puts e. exit 1 rescue IncompleteRenderError => e2 part2 = e2.source_file.nil? ? "" : "(included from #{e2.source_file})" $stderr.puts "ERROR: Unable to read #{e2.file_name} #{part2}" $stderr.puts "\t(#{e2.source_exception})" exit 1 end exit $k.error_count == 0 ? 0 : 1 end |