Module: RemoteTable::Format::Textual
- Included in:
- Delimited, FixedWidth, HTML
- Defined in:
- lib/remote_table/format/mixins/textual.rb
Constant Summary collapse
- USELESS_CHARACTERS =
[ '\xef\xbb\xbf', # UTF-8 byte order mark '\xc2\xad' # soft hyphen, often inserted by MS Office (html: ­) ]
Instance Method Summary collapse
- #convert_file_to_utf8! ⇒ Object
- #crop_rows! ⇒ Object
- #cut_columns! ⇒ Object
- #remove_useless_characters! ⇒ Object
- #skip_rows! ⇒ Object
Instance Method Details
#convert_file_to_utf8! ⇒ Object
6 7 8 |
# File 'lib/remote_table/format/mixins/textual.rb', line 6 def convert_file_to_utf8! ::RemoteTable.executor.bang t.local_file.path, "iconv -c -f #{::Escape.shell_single_word t.properties.encoding} -t UTF-8" end |
#crop_rows! ⇒ Object
23 24 25 26 |
# File 'lib/remote_table/format/mixins/textual.rb', line 23 def crop_rows! return unless t.properties.crop ::RemoteTable.executor.bang t.local_file.path, "tail -n +#{::Escape.shell_single_word t.properties.crop.first.to_s} | head -n #{t.properties.crop.last - t.properties.crop.first + 1}" end |
#cut_columns! ⇒ Object
28 29 30 31 |
# File 'lib/remote_table/format/mixins/textual.rb', line 28 def cut_columns! return unless t.properties.cut ::RemoteTable.executor.bang t.local_file.path, "cut -c #{::Escape.shell_single_word t.properties.cut.to_s}" end |
#remove_useless_characters! ⇒ Object
14 15 16 |
# File 'lib/remote_table/format/mixins/textual.rb', line 14 def remove_useless_characters! ::RemoteTable.executor.bang t.local_file.path, "perl -pe 's/#{USELESS_CHARACTERS.join '//g; s/'}//g'" end |
#skip_rows! ⇒ Object
18 19 20 21 |
# File 'lib/remote_table/format/mixins/textual.rb', line 18 def skip_rows! return unless t.properties.skip > 0 ::RemoteTable.executor.bang t.local_file.path, "tail -n +#{t.properties.skip + 1}" end |