Class: Avmtrf1::Tools::Runner::Oracle::SourceGet

Inherits:
Object
  • Object
show all
Defined in:
lib/avmtrf1/tools/runner/oracle/source_get.rb

Constant Summary collapse

TABLE =
'all_source'

Instance Method Summary collapse

Instance Method Details

#found_countObject


35
36
37
# File 'lib/avmtrf1/tools/runner/oracle/source_get.rb', line 35

def found_count
  connection.unique_value(sql(true)).to_i
end

#nameObject


17
18
19
# File 'lib/avmtrf1/tools/runner/oracle/source_get.rb', line 17

def name
  parsed.name
end

#runObject


25
26
27
28
29
30
31
32
33
# File 'lib/avmtrf1/tools/runner/oracle/source_get.rb', line 25

def run
  infov('Name', name)
  infov('Type', type)
  infov('Found', found_count)
  infov('Enconding', OCI8.encoding)
  connection.query(sql(false)) do |row|
    out(row['TEXT'].encode('UTF-8').to_s)
  end
end

#sql(count) ⇒ Object


39
40
41
42
43
44
# File 'lib/avmtrf1/tools/runner/oracle/source_get.rb', line 39

def sql(count)
  projection = count ? 'count(*)' : '*'
  selection = "lower(name) = lower('#{name}')"
  selection += " and lower(type) = lower('#{type}')" if type.present?
  "select #{projection} from #{TABLE} where #{selection} order by line"
end

#typeObject


21
22
23
# File 'lib/avmtrf1/tools/runner/oracle/source_get.rb', line 21

def type
  parsed.type
end