Class: DataMgr::DSL
- Inherits:
-
Object
- Object
- DataMgr::DSL
- Includes:
- Singleton
- Defined in:
- lib/DataMgr/DSL/dsl.rb
Instance Method Summary collapse
- #cmd(opts) ⇒ Object
- #connect(id) ⇒ Object
-
#initialize ⇒ DSL
constructor
A new instance of DSL.
- #loadData(_f) ⇒ Object
-
#loadDB(_f) ⇒ Object
Ex.
Constructor Details
#initialize ⇒ DSL
Returns a new instance of DSL.
9 10 11 |
# File 'lib/DataMgr/DSL/dsl.rb', line 9 def initialize() end |
Instance Method Details
#cmd(opts) ⇒ Object
19 20 21 22 23 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 |
# File 'lib/DataMgr/DSL/dsl.rb', line 19 def cmd(opts) # puts "cmd => #{opts}" rc=false _cmd=nil if opts.has_key?(:cmd) _cmd=opts[:cmd] else return false end if _cmd.match(/^\s*loaddb\s*\(.*\)\s*$/i) dbName = _cmd.match(/^\s*loaddb\s*\((.*)\)\s*$/i)[1].to_s rc=DataMgr::DB.instance.load(dbName) elsif opts.has_key?(:cmd) && opts[:cmd].match(/^\s*connect\s*\((.*)\)\s*$/) _connectID = opts[:cmd].match(/^\s*connect\s*\((.*)\)\s*$/i)[1].to_s rc=DataMgr::DB.instance.connect(_connectID) elsif _cmd.match(/^\s*getDB\s*\(.*\)\.get\(.*\)\s*$/) db = _cmd.match(/^\s*getDB\s*\(\s*(.*)\s*\)\.get\(.*\)\s*$/)[1].to_s # puts "db => #{db}" # rc = queries.getDataElement(hit) else STDERR.puts " Unknown command: #{opts}" end rc end |
#connect(id) ⇒ Object
51 52 53 |
# File 'lib/DataMgr/DSL/dsl.rb', line 51 def connect(id) DataMgr::DB.instance.connect(id) end |
#loadData(_f) ⇒ Object
56 57 58 |
# File 'lib/DataMgr/DSL/dsl.rb', line 56 def loadData(_f) DataMgr::DataModel.new(_f) end |
#loadDB(_f) ⇒ Object
Ex. ‘./spec/fixtures/connect.yml’
15 16 17 |
# File 'lib/DataMgr/DSL/dsl.rb', line 15 def loadDB(_f) DataMgr::DB.instance.load(_f) end |