Class: SiSU_Info_Db::InfoDb
Overview
Constant Summary
collapse
- @@rc =
nil
Instance Attribute Summary
#base_markup_dir_stub, #env, #etc, #filename, #flv, #fnb, #fnn, #fnt, #home, #hostname, #processing, #processing_git, #rc, #stub_pwd, #stub_src, #sys, #webserv_host_cgi, #webserv_path, #webserv_port_cgi, #www, #yamlrc_dir
#ad, #fnb, #fnn, #fnt, #fnv, #fnz, #rc
Instance Method Summary
collapse
#ao, #arch, #asciidoc_ocn?, #bin, #build, #cgi, #cgi_sample_search_form_name, #cjk, #cjk_ja, #cjk_ko, #cjk_zh, #composite_file, #concord_max, #console_web_browser, #console_www_browser, #current_document, #defaults, #digest, #digest_conf?, #dir_url, #docbook_viewer, #encoding, #epub, #epub_bld, #epub_cp_images, #epub_viewer, #feed, #feed_home, #fictionbook_viewer, #file_encoding, #font, #git, #html, #html_minitoc?, #html_navigation?, #html_navigation_bar?, #html_quick_ref?, #html_right_pane?, #html_scroll_1, #html_scroll_2, #html_search_form?, #html_seg_1, #html_seg_2, #html_seg_title_banner?, #html_top_band?, #i18n, #image_external, #image_source, #image_source_include, #image_source_include_local, #image_source_include_remote, #image_source_sisu_includes, #images, #images_epub, #images_external, #images_local, #landscape, #lang_filename, #language, #language_default_set, #length, #links_to_manifest?, #listed?, #local, #locale, #localhost, #lout, #main, #make, #man, #manifest?, #manifest_minitoc?, #manpage, #manpage_generator, #manpage_viewer, #markdown_ocn?, #markup_emphasis, #metadata?, #minitoc?, #mono, #ocn?, #odf, #odf_pth, #odf_viewer, #odt, #odt_bld, #odt_ocn?, #omit_list, #orgmode_ocn?, #output, #output_tell, #papersize, #path, #path_rel_links, #paths, #pattern, #pdf, #pdf_viewer, #pdflatex, #php, #plaintext_ocn?, #plaintext_wrap, #po, #portrait, #postgresql, #pot, #processing_base_tmp, #processing_path, #processing_sisupod, #program, #promo?, #pwd, #rbver, #read_source_file, #read_source_file_array, #read_source_file_string, #remote, #rexml, #rmagick, #root, #root_dir, #rst_ocn?, #sample_data, #sample_search_form_title, #sans, #scripts, #search?, #search_action, #search_fixed?, #search_form, #search_form?, #search_form_static, #segsubtoc?, #serif, #share, #sisupod_gen, #sisupod_gen_v2, #sisupod_gen_v3, #sisupod_v2, #sisupod_v3, #sisupod_v4, #sisurc_path, #sitearch, #size, #source_file_path, #source_file_processing_array, #source_file_with_path, #sql, #src_pod, #src_txt, #stub_dir, #stub_dir_orig, #stub_epub, #stub_md_harvest, #stub_pod, #style, #tex, #texi, #texinfo, #texpdf, #texpdf_hyperlinks, #text_editor, #textile_ocn?, #tidy, #tmp_root_dir, #toc?, #tune, #txt, #type, #url, #usr_dir?, #wc, #web_browser, #webrick, #webrick_port, #webserv, #webserv_base, #webserv_base_cgi, #webserv_cgi, #webserv_dir, #webserv_files_from_db, #webserv_host_base, #webserv_image, #webserv_map_pwd, #webserv_stub_ensure, #widget, #widget_static, #www_browser, #xml_docbook_ocn?, #xml_editor, #xml_fictionbook_ocn?, #xml_scaffold_ocn?, #xml_viewer, #yamlrc
#by?, #by_filename?, #by_filetype?, #by_language_code?, #default_language?, #document_language_versions_found, #dump?, #filename, #lang, #mono_multi_lingual?, #multilingual?, #output_dir_structure, #published_manifests?, #redirect?
Constructor Details
#initialize ⇒ InfoDb
Returns a new instance of InfoDb.
Instance Method Details
#conn_dbi ⇒ Object
131
132
133
|
# File 'lib/sisu/se_db.rb', line 131
def conn_dbi
DBI.connect(psql.dbi,psql.user,psql.db)
end
|
#conn_pg ⇒ Object
134
135
136
137
138
139
140
141
142
|
# File 'lib/sisu/se_db.rb', line 134
def conn_pg
begin
require 'pg'
rescue LoadError
SiSU_Utils::CodeMarker.new(__LINE__,__FILE__,:fuchsia).
error('pg NOT FOUND (LoadError)')
end
PG::Connection.new(dbname: psql.db, port: psql.port)
end
|
#conn_sqlite3 ⇒ Object
161
162
163
|
# File 'lib/sisu/se_db.rb', line 161
def conn_sqlite3
SQLite3::Database.new(sqlite.sqlite3)
end
|
#db ⇒ Object
101
102
103
|
# File 'lib/sisu/se_db.rb', line 101
def db "#{Db[:name_prefix]}#{@pwd_stub}"
end
|
#db_discrete(md) ⇒ Object
149
150
151
|
# File 'lib/sisu/se_db.rb', line 149
def db_discrete(md)
end
|
#dbi ⇒ Object
“#SiSU_Info_Db::InfoDb.@[email protected]@env.path.webserv/#@pwd_stub/sisu_sqlite.db”
152
153
154
|
# File 'lib/sisu/se_db.rb', line 152
def dbi
PG::Connection.open(:dbname => psql.db)
end
|
#dbi_ ⇒ Object
126
127
128
129
130
|
# File 'lib/sisu/se_db.rb', line 126
def dbi_
(psql.host =~/(?:\S{1,3}\.){3}\S{1,3}|\S+?\.\S+/) \
? "DBI:Pg:database=#{psql.db};host=#{psql.host};port=#{psql.port}"
: "DBI:Pg:database=#{psql.db};port=#{psql.port}"
end
|
#default ⇒ Object
78
79
80
81
82
83
|
# File 'lib/sisu/se_db.rb', line 78
def default
((defined? @rc['db']['engine']['default']) \
&& @rc['db']['engine']['default']=~/postgresql|sqlite/) \
? @rc['db']['engine']['default']
: 'sqlite'
end
|
#engine ⇒ Object
77
78
79
80
81
82
83
84
85
|
# File 'lib/sisu/se_db.rb', line 77
def engine
def default
((defined? @rc['db']['engine']['default']) \
&& @rc['db']['engine']['default']=~/postgresql|sqlite/) \
? @rc['db']['engine']['default']
: 'sqlite'
end
self
end
|
#host ⇒ Object
117
118
119
120
121
122
|
# File 'lib/sisu/se_db.rb', line 117
def host
((defined? @rc['db']['postgresql']['host']) \
&& @rc['db']['postgresql']['host']=~/(?:\S{1,3}\.){3}\S{1,3}|\S+?\.\S+/) \
? @rc['db']['postgresql']['host']
: ''
end
|
#password ⇒ Object
111
112
113
114
115
116
|
# File 'lib/sisu/se_db.rb', line 111
def password
((defined? @rc['db']['postgresql']['password']) \
&& @rc['db']['postgresql']['password']=~/\S+/) \
? @rc['db']['postgresql']['password']
: ''
end
|
#port ⇒ Object
104
105
106
107
108
109
110
|
# File 'lib/sisu/se_db.rb', line 104
def port ((defined? @rc['db']['postgresql']['port']) \
&& ( @rc['db']['postgresql']['port'] =~/\d+/ \
|| @rc['db']['postgresql']['port'].is_a?(Fixnum))) \
? @rc['db']['postgresql']['port']
: (@defaults[:postgresql_port])
end
|
#psql ⇒ Object
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
|
# File 'lib/sisu/se_db.rb', line 86
def psql
def user(opt=nil)
if opt \
and opt.selections.str =~/--db-user[=-]["']?(\S+)["']+/
$1
elsif opt \
and opt.selections.str =~/--webserv[=-]webrick/
@env.user
else
((defined? @rc['db']['postgresql']['user']) \
&& @rc['db']['postgresql']['user']=~/\S+/) \
? @rc['db']['postgresql']['user']
: @env.user
end
end
def db "#{Db[:name_prefix]}#{@pwd_stub}"
end
def port ((defined? @rc['db']['postgresql']['port']) \
&& ( @rc['db']['postgresql']['port'] =~/\d+/ \
|| @rc['db']['postgresql']['port'].is_a?(Fixnum))) \
? @rc['db']['postgresql']['port']
: (@defaults[:postgresql_port])
end
def password
((defined? @rc['db']['postgresql']['password']) \
&& @rc['db']['postgresql']['password']=~/\S+/) \
? @rc['db']['postgresql']['password']
: ''
end
def host
((defined? @rc['db']['postgresql']['host']) \
&& @rc['db']['postgresql']['host']=~/(?:\S{1,3}\.){3}\S{1,3}|\S+?\.\S+/) \
? @rc['db']['postgresql']['host']
: ''
end
def dbi
PG::Connection.open(:dbname => psql.db)
end
def dbi_
(psql.host =~/(?:\S{1,3}\.){3}\S{1,3}|\S+?\.\S+/) \
? "DBI:Pg:database=#{psql.db};host=#{psql.host};port=#{psql.port}"
: "DBI:Pg:database=#{psql.db};port=#{psql.port}"
end
def conn_dbi
DBI.connect(psql.dbi,psql.user,psql.db)
end
def conn_pg
begin
require 'pg'
rescue LoadError
SiSU_Utils::CodeMarker.new(__LINE__,__FILE__,:fuchsia).
error('pg NOT FOUND (LoadError)')
end
PG::Connection.new(dbname: psql.db, port: psql.port)
end
self
end
|
#share_source? ⇒ Boolean
71
72
73
74
75
76
|
# File 'lib/sisu/se_db.rb', line 71
def share_source?
((defined? @rc['db']['share_source']) \
&& @rc['db']['share_source']==true) \
? @rc['db']['share_source']
: false
end
|
#sqlite ⇒ Object
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
|
# File 'lib/sisu/se_db.rb', line 145
def sqlite
def db
"#{@env.path.webserv}/#{@pwd_stub}/sisu_sqlite.db"
end
def db_discrete(md)
end
def dbi
"DBI:SQLite3:#{sqlite.db}" end
def sqlite3
sqlite.db end
def conn_dbi
DBI.connect(sqlite.dbi)
end
def conn_sqlite3
SQLite3::Database.new(sqlite.sqlite3)
end
self
end
|
#sqlite3 ⇒ Object
155
156
157
|
# File 'lib/sisu/se_db.rb', line 155
def sqlite3
sqlite.db end
|
#user(opt = nil) ⇒ Object
87
88
89
90
91
92
93
94
95
96
97
98
99
100
|
# File 'lib/sisu/se_db.rb', line 87
def user(opt=nil)
if opt \
and opt.selections.str =~/--db-user[=-]["']?(\S+)["']+/
$1
elsif opt \
and opt.selections.str =~/--webserv[=-]webrick/
@env.user
else
((defined? @rc['db']['postgresql']['user']) \
&& @rc['db']['postgresql']['user']=~/\S+/) \
? @rc['db']['postgresql']['user']
: @env.user
end
end
|