ibe2txt 0.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. checksums.yaml +7 -0
  2. data/bin/ibe2txt.rb +57 -0
  3. metadata +58 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 0ac1add4658cc4f7988ea3b3b28a28db818096c7381e5b3394bc16bfacc93db2
4
+ data.tar.gz: aeba56b1a380d591e5450617e3994c0fc4bdc85e16c3819ccdaa0000644c93d9
5
+ SHA512:
6
+ metadata.gz: 8bee43ab8cca0f12976be4c465e9236dabbbb026a63efe65e0859efb3417589d7ccfcf2d2ceb181db49368f941ced23cf5f5d49587f4b7a2aff941aca0944f1f
7
+ data.tar.gz: de068b664a29aff7afd24301f9fb7f876e9b639f0a967c228b143d6bd5b3bccb4d3d256bf49cb6c96fcedf0d41fd1aaae5fe709385d14c71ac6a0b4902dff38f
data/bin/ibe2txt.rb ADDED
@@ -0,0 +1,57 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'base64'
4
+ require 'nokogiri'
5
+
6
+ class IBE2Txt
7
+ USAGE = 'Usage: ibe2txt.rb file.xml'.freeze
8
+
9
+ private
10
+
11
+ attr_accessor :path, :doc, :captions, :sources
12
+
13
+ def initialize(path)
14
+ @path = path
15
+ @captions = []
16
+ @sources = []
17
+ @doc = File.open(@path, 'r') { |f| Nokogiri::XML(f) }
18
+ parse
19
+ write_back
20
+ end
21
+
22
+ def parse
23
+ @captions = @doc.xpath('/ibe_sql_queries/queryset/query/caption').map { |x| Base64.decode64(x.content) }
24
+ @sources = @doc.xpath('/ibe_sql_queries/queryset/query/source').map { |x| Base64.decode64(x.content) }
25
+ # puts @sources, @captions
26
+ end
27
+
28
+ def write_back
29
+ File.open("#{File.join(File.dirname(@path), File.basename(@path, '.xml'))}.txt", 'w') do |f|
30
+ @captions.zip(@sources).each do |c, s|
31
+ line = "#{c}\n#{s}\n"
32
+ f << line.encode(line.encoding, universal_newline: true)
33
+ end
34
+ end
35
+ end
36
+ end
37
+
38
+ begin
39
+ if ARGV.size > 1
40
+ if File.exist?(ARGV[0])
41
+ if File.extname(ARGV[0]) == '.xml'
42
+ IBE2Txt.new(ARGV[0])
43
+ else
44
+ puts 'Not an xml file'
45
+ puts IBE2Txt::USAGE
46
+ end
47
+ else
48
+ puts 'No such file'
49
+ puts IBE2Txt::USAGE
50
+ end
51
+ else
52
+ puts IBE2Txt::USAGE
53
+ end
54
+ rescue StandardError => e
55
+ puts e
56
+ puts IBE2Txt::USAGE
57
+ end
metadata ADDED
@@ -0,0 +1,58 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: ibe2txt
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.2
5
+ platform: ruby
6
+ authors:
7
+ - Ivan Ignatenko
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2021-09-19 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: nokogiri
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: 1.12.4
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: 1.12.4
27
+ description:
28
+ email: iignatenko@sfedu.ru
29
+ executables:
30
+ - ibe2txt.rb
31
+ extensions: []
32
+ extra_rdoc_files: []
33
+ files:
34
+ - bin/ibe2txt.rb
35
+ homepage: https://gist.github.com/COOLIRON2311/3d0dee2c63a4c1e8db4785888e26cf14
36
+ licenses:
37
+ - GPL-3.0
38
+ metadata: {}
39
+ post_install_message:
40
+ rdoc_options: []
41
+ require_paths:
42
+ - lib
43
+ required_ruby_version: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ required_rubygems_version: !ruby/object:Gem::Requirement
49
+ requirements:
50
+ - - ">="
51
+ - !ruby/object:Gem::Version
52
+ version: '0'
53
+ requirements: []
54
+ rubygems_version: 3.2.22
55
+ signing_key:
56
+ specification_version: 4
57
+ summary: Small IBExpert query set converter written in Ruby
58
+ test_files: []