Module: Ziya
- Defined in:
- lib/ziya.rb,
lib/ziya/utils/logger.rb,
lib/ziya/html_helpers/base.rb,
lib/ziya/yaml_helpers/base.rb,
lib/ziya/yaml_helpers/charts.rb
Defined Under Namespace
Modules: Charts, Gauges, HtmlHelpers, Maps, YamlHelpers Classes: Logger
Constant Summary collapse
- LIBPATH =
:stopdoc:
::File.(::File.dirname(__FILE__)) + ::File::SEPARATOR
- PATH =
::File.dirname(LIBPATH) + ::File::SEPARATOR
Class Method Summary collapse
-
.config ⇒ Object
ZiYa configuration.
- .default_configuration ⇒ Object
-
.designs_dir ⇒ Object
the gauges designs root directory location.
-
.dump ⇒ Object
Debug.
-
.helpers_dir ⇒ Object
directory location for ziya stylesheet custom helpers.
-
.initialize(opts = {}) ⇒ Object
:startdoc:.
-
.libpath(*args, &block) ⇒ Object
Returns the library path for the module.
-
.logger ⇒ Object
fetch the framework logger.
-
.map_themes_dir ⇒ Object
the map themes root directory location.
-
.path(*args, &block) ⇒ Object
Returns the lpath for the module.
-
.require_all_libs_relative_to(fname, dir = nil) ⇒ Object
Utility method used to require all files ending in .rb that lie in the directory below this file that has the same name as the filename passed in.
-
.themes_dir ⇒ Object
the themes root directory location.
-
.version ⇒ Object
Returns the version string for the library.
Class Method Details
.config ⇒ Object
ZiYa configuration
48 49 50 |
# File 'lib/ziya.rb', line 48 def self.config @config end |
.default_configuration ⇒ Object
39 40 41 42 43 44 45 |
# File 'lib/ziya.rb', line 39 def self.default_configuration { :themes_dir => File.join( File.dirname(__FILE__), %w[.. charts themes] ), :log_file => $stdout, :log_level => :info } end |
.designs_dir ⇒ Object
the gauges designs root directory location
68 69 70 |
# File 'lib/ziya.rb', line 68 def self.designs_dir config[:designs_dir] end |
.dump ⇒ Object
Debug
73 74 75 76 77 78 79 80 81 |
# File 'lib/ziya.rb', line 73 def self.dump #:nodoc: puts "" puts "ZiYa Configuration Landscape" config.keys.sort{ |a,b| a.to_s <=> b.to_s }.each do |k| key = k.to_s.rjust(20) value = config[k].to_s.rjust(97,".") puts "#{key} : #{value}" end end |
.helpers_dir ⇒ Object
directory location for ziya stylesheet custom helpers
53 54 55 |
# File 'lib/ziya.rb', line 53 def self.helpers_dir config[:helpers_dir] end |
.initialize(opts = {}) ⇒ Object
:startdoc:
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/ziya.rb', line 7 def self.initialize( opts={} ) if opts[:log_level] == :debug puts ">>> No logger specified. Using ZiYa default logger" unless opts[:logger] puts ">>> No themes_dir specified. Using ZiYa default themes" unless opts[:themes_dir] end @config = default_configuration.merge( opts ) @logger = opts[:logger] if opts[:logger] # Verify existence of themes, designs and helper dirs if any if themes_dir raise "Unable to find themes directory `#{themes_dir}" unless File.exists?( themes_dir ) end if map_themes_dir raise "Unable to find map themes directory `#{map_themes_dir}" unless File.exists?( map_themes_dir ) end if designs_dir raise "Unable to find designs directory `#{designs_dir}" unless File.exists?( designs_dir ) end if helpers_dir raise "Unable to find helper directory `#{helpers_dir}" unless File.exists?( helpers_dir ) end # Add the ziya/lib to the ruby path... $: << libpath Ziya.require_all_libs_relative_to __FILE__ dump if config[:log_level] == :debug end |
.libpath(*args, &block) ⇒ Object
Returns the library path for the module. If any arguments are given, they will be joined to the end of the libray path using File.join.
102 103 104 105 106 107 108 109 110 111 112 113 |
# File 'lib/ziya.rb', line 102 def self.libpath( *args, &block ) rv = args.empty? ? LIBPATH : ::File.join(LIBPATH, args.flatten) if block begin $LOAD_PATH.unshift LIBPATH rv = block.call ensure $LOAD_PATH.shift end end return rv end |
.logger ⇒ Object
fetch the framework logger
84 85 86 87 88 89 90 |
# File 'lib/ziya.rb', line 84 def self.logger # get a hold of a logger. @logger ||= ::Ziya::Logger.new( { :log_file => config[:log_file], :logger_name => "ZiYa", :log_level => config[:log_level], :additive => false } ) end |
.map_themes_dir ⇒ Object
the map themes root directory location
63 64 65 |
# File 'lib/ziya.rb', line 63 def self.map_themes_dir config[:map_themes_dir] end |
.path(*args, &block) ⇒ Object
Returns the lpath for the module. If any arguments are given, they will be joined to the end of the path using File.join.
119 120 121 122 123 124 125 126 127 128 129 130 |
# File 'lib/ziya.rb', line 119 def self.path( *args, &block ) rv = args.empty? ? PATH : ::File.join(PATH, args.flatten) if block begin $LOAD_PATH.unshift PATH rv = block.call ensure $LOAD_PATH.shift end end return rv end |
.require_all_libs_relative_to(fname, dir = nil) ⇒ Object
Utility method used to require all files ending in .rb that lie in the directory below this file that has the same name as the filename passed in. Optionally, a specific directory name can be passed in such that the filename does not have to be equivalent to the directory.
137 138 139 140 141 142 143 |
# File 'lib/ziya.rb', line 137 def self.require_all_libs_relative_to( fname, dir = nil ) dir ||= ::File.basename(fname, '.*') search_me = ::File.( ::File.join(::File.dirname(fname), dir, '**', '*.rb')) Dir.glob(search_me).sort.each {|rb| require rb} end |
.themes_dir ⇒ Object
the themes root directory location
58 59 60 |
# File 'lib/ziya.rb', line 58 def self.themes_dir config[:themes_dir] end |
.version ⇒ Object
Returns the version string for the library.
94 95 96 |
# File 'lib/ziya.rb', line 94 def self.version @version ||= File.read(path('version.txt')).strip end |