Module: Ken
- Defined in:
- lib/ken/view.rb,
lib/ken.rb,
lib/ken/type.rb,
lib/ken/util.rb,
lib/ken/logger.rb,
lib/ken/session.rb,
lib/ken/version.rb,
lib/ken/property.rb,
lib/ken/resource.rb,
lib/ken/attribute.rb,
lib/ken/collection.rb
Overview
Public Ken Logger API
Logger taken from Merb/Datamapper :)
To replace an existing logger with a new one:
Ken.logger.set_log(log{String, IO},level{Symbol, String})
Available logging levels are:
:off, :fatal, :error, :warn, :info, :debug
Logging via:
Ken.logger.fatal(<String>)
Ken.logger.error(<String>)
Ken.logger.warn(<String>)
Ken.logger.info(<String>)
Ken.logger.debug(<String>)
Flush the buffer to
Ken.logger.flush
Remove the current log object
Ken.logger.close
Private Ken Logger API
To initialize the logger you create a new object, proxies to set_log.
ken::Logger.new(log{String, IO}, level{Symbol, String})
Logger will not create the file until something is actually logged This avoids file creation on Ken init when it creates the default logger.
Defined Under Namespace
Modules: Util Classes: Attribute, Collection, Logger, Property, ReadError, Resource, Session, Type, View
Constant Summary collapse
- VERSION =
'0.0.2'
Class Attribute Summary collapse
-
.logger ⇒ Object
Returns the value of attribute logger.
-
.session ⇒ Object
Returns the value of attribute session.
Class Method Summary collapse
- .all(options = {}) ⇒ Object
-
.get(id) ⇒ Object
Executes an Mql Query against the Freebase API and returns the result wrapped in a
Resource
Object.
Class Attribute Details
.logger ⇒ Object
Returns the value of attribute logger.
37 38 39 |
# File 'lib/ken/logger.rb', line 37 def logger @logger end |
.session ⇒ Object
Returns the value of attribute session.
3 4 5 |
# File 'lib/ken/session.rb', line 3 def session @session end |
Class Method Details
.all(options = {}) ⇒ Object
28 29 30 31 |
# File 'lib/ken.rb', line 28 def self.all( = {}) # raise ArgumentError.new("must be a hash") unless options.is_a(::Hash) raise NotImplementedError end |
.get(id) ⇒ Object
Executes an Mql Query against the Freebase API and returns the result wrapped in a Resource
Object.
Examples
Ken.get('/en/the_police') => #<Resource id="/en/the_police" name="The Police">
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 |
# File 'lib/ken.rb', line 40 def self.get(id) # TODO check if it has a correct /type/object/id syntax raise ArgumentError.new("must be a string") unless id.is_a?(::String) query = { :id => id, :name => nil, :type => [{ :id => nil, :name => nil, :properties => [{ :id => nil, :name => nil, :expected_type => nil, :unique => nil, :reverse_property => nil, :master_property => nil, }] }] } result = Ken.session.mqlread(query) return Ken::Resource.new(result) end |