Class: Avmtrf1::Tools::Runner::Oracle::SourceGet
- Inherits:
-
EacRubyUtils::Console::DocoptRunner
- Object
- EacRubyUtils::Console::DocoptRunner
- Avmtrf1::Tools::Runner::Oracle::SourceGet
- Includes:
- EacRubyUtils::Console::Speaker
- Defined in:
- lib/avmtrf1/tools/runner/oracle/source_get.rb
Constant Summary collapse
- DOC =
<<~DOCOPT Usage: __PROGRAM__ [options] <name> <type> __PROGRAM__ -h | --help Options: -h --help Show this screen DOCOPT
- TABLE =
'all_source'
Instance Method Summary collapse
Instance Method Details
#found_count ⇒ Object
42 43 44 |
# File 'lib/avmtrf1/tools/runner/oracle/source_get.rb', line 42 def found_count context(:connection).unique_value(sql(true)).to_i end |
#name ⇒ Object
24 25 26 |
# File 'lib/avmtrf1/tools/runner/oracle/source_get.rb', line 24 def name .fetch('<name>') end |
#run ⇒ Object
32 33 34 35 36 37 38 39 40 |
# File 'lib/avmtrf1/tools/runner/oracle/source_get.rb', line 32 def run infov('Name', name) infov('Type', type) infov('Found', found_count) infov('Enconding', OCI8.encoding) context(:connection).query(sql(false)) do |row| out(row['TEXT'].encode('UTF-8').to_s) end end |
#sql(count) ⇒ Object
46 47 48 49 50 51 |
# File 'lib/avmtrf1/tools/runner/oracle/source_get.rb', line 46 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 |
#type ⇒ Object
28 29 30 |
# File 'lib/avmtrf1/tools/runner/oracle/source_get.rb', line 28 def type .fetch('<type>') end |