Class: Lynx::DSL

Inherits:
Object
  • Object
show all
Defined in:
lib/lynx/d_s_l.rb

Instance Method Summary collapse

Constructor Details

#initialize(config) ⇒ DSL

Returns a new instance of DSL.



6
7
8
# File 'lib/lynx/d_s_l.rb', line 6

def initialize(config)
  @config = Lynx::Config.new(config)
end

Instance Method Details

#basicObject



10
11
12
13
14
15
# File 'lib/lynx/d_s_l.rb', line 10

def basic
  Command::Basic.new(@config)
    .mysql
    .authorize
    .with_database
end

#create_databaseObject



17
18
19
20
21
22
# File 'lib/lynx/d_s_l.rb', line 17

def create_database
  Command::Basic.new(@config)
    .mysql
    .authorize
    .sql("create database #{@config.database}")
end

#dataObject



41
42
43
# File 'lib/lynx/d_s_l.rb', line 41

def data
  dump.no_create_info
end

#drop_databaseObject



24
25
26
27
28
29
# File 'lib/lynx/d_s_l.rb', line 24

def drop_database
  Command::Basic.new(@config)
    .mysql
    .authorize
    .sql("drop database #{@config.database}")
end

#dumpObject



31
32
33
34
35
36
37
38
39
# File 'lib/lynx/d_s_l.rb', line 31

def dump
  Command::Dump.new(@config)
    .authorize
    .with_database
    .skip_quote_names
    .compress
    .compact
    .no_create_db
end

#selectObject



49
50
51
52
53
54
# File 'lib/lynx/d_s_l.rb', line 49

def select
  basic
    .batch
    .no_names
    .compress
end

#structureObject



45
46
47
# File 'lib/lynx/d_s_l.rb', line 45

def structure
  dump.no_data
end