informix_rails 0.1.0

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.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 583469060d3769d64c4142a18ffb7dc5dcaab1d9e5fe73644653ced2b4d004b2
4
+ data.tar.gz: d2e11d5efecef1d96b524f11c68528a1e1f9552255d6f682c5b3820694fc0109
5
+ SHA512:
6
+ metadata.gz: 64a43d81e056a666c3269d61e13b614ccaab86ba7d762544a4c8e3817e98730e7aefb0b2e29d18faa7fa6a0020f4f03dbdecbc5754d231eed0dfd718a5b6716d
7
+ data.tar.gz: ab55ee8a06c846e86f8b16c4f0d7e3e361f9f2c1cea011a459e826ac08439b4fdcb56d823f824030f7ddca97855ef4cbf140b30c8148db00070849ea8799e667
data/.rubocop.yml ADDED
@@ -0,0 +1,13 @@
1
+ AllCops:
2
+ TargetRubyVersion: 2.5
3
+
4
+ Style/StringLiterals:
5
+ Enabled: true
6
+ EnforcedStyle: double_quotes
7
+
8
+ Style/StringLiteralsInInterpolation:
9
+ Enabled: true
10
+ EnforcedStyle: double_quotes
11
+
12
+ Layout/LineLength:
13
+ Max: 120
data/CHANGELOG.md ADDED
@@ -0,0 +1,5 @@
1
+ ## [Unreleased]
2
+
3
+ ## [0.1.0] - 2022-02-15
4
+
5
+ - Initial release
data/Gemfile ADDED
@@ -0,0 +1,10 @@
1
+ # frozen_string_literal: true
2
+
3
+ source "https://rubygems.org"
4
+
5
+ # Specify your gem's dependencies in informix_rails.gemspec
6
+ gemspec
7
+
8
+ gem "rake", "~> 13.0"
9
+
10
+ gem "rubocop", "~> 1.7"
data/Gemfile.lock ADDED
@@ -0,0 +1,58 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ informix_rails (0.1.0)
5
+ rake
6
+ rspec
7
+ thor (~> 1.2.1)
8
+
9
+ GEM
10
+ remote: https://rubygems.org/
11
+ specs:
12
+ ast (2.4.2)
13
+ diff-lcs (1.5.0)
14
+ parallel (1.21.0)
15
+ parser (3.1.0.0)
16
+ ast (~> 2.4.1)
17
+ rainbow (3.1.1)
18
+ rake (13.0.6)
19
+ regexp_parser (2.2.1)
20
+ rexml (3.2.5)
21
+ rspec (3.11.0)
22
+ rspec-core (~> 3.11.0)
23
+ rspec-expectations (~> 3.11.0)
24
+ rspec-mocks (~> 3.11.0)
25
+ rspec-core (3.11.0)
26
+ rspec-support (~> 3.11.0)
27
+ rspec-expectations (3.11.0)
28
+ diff-lcs (>= 1.2.0, < 2.0)
29
+ rspec-support (~> 3.11.0)
30
+ rspec-mocks (3.11.0)
31
+ diff-lcs (>= 1.2.0, < 2.0)
32
+ rspec-support (~> 3.11.0)
33
+ rspec-support (3.11.0)
34
+ rubocop (1.25.1)
35
+ parallel (~> 1.10)
36
+ parser (>= 3.1.0.0)
37
+ rainbow (>= 2.2.2, < 4.0)
38
+ regexp_parser (>= 1.8, < 3.0)
39
+ rexml
40
+ rubocop-ast (>= 1.15.1, < 2.0)
41
+ ruby-progressbar (~> 1.7)
42
+ unicode-display_width (>= 1.4.0, < 3.0)
43
+ rubocop-ast (1.15.2)
44
+ parser (>= 3.0.1.1)
45
+ ruby-progressbar (1.11.0)
46
+ thor (1.2.1)
47
+ unicode-display_width (2.1.0)
48
+
49
+ PLATFORMS
50
+ x86_64-linux
51
+
52
+ DEPENDENCIES
53
+ informix_rails!
54
+ rake (~> 13.0)
55
+ rubocop (~> 1.7)
56
+
57
+ BUNDLED WITH
58
+ 2.2.28
data/Rakefile ADDED
@@ -0,0 +1,12 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "bundler/gem_tasks"
4
+ require "rubocop/rake_task"
5
+
6
+ RuboCop::RakeTask.new
7
+
8
+ #task default: :rubocop
9
+
10
+ require 'rspec/core/rake_task'
11
+ RSpec::Core::RakeTask.new(:spec)
12
+ task :default => :spec
data/bin/console ADDED
@@ -0,0 +1,15 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ require "bundler/setup"
5
+ require "informix_rails"
6
+
7
+ # You can add fixtures and/or initialization code here to make experimenting
8
+ # with your gem easier. You can also use a different console, if you like.
9
+
10
+ # (If you use this, don't forget to add pry to your Gemfile!)
11
+ # require "pry"
12
+ # Pry.start
13
+
14
+ require "irb"
15
+ IRB.start(__FILE__)
data/bin/setup ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,4 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "informix_rails"
4
+ InformixRails::Per2Erb.start(ARGV)
@@ -0,0 +1,41 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "lib/informix_rails/version"
4
+
5
+ Gem::Specification.new do |spec|
6
+ spec.name = "informix_rails"
7
+ spec.version = InformixRails::VERSION
8
+ spec.authors = ["Michael Pope"]
9
+ spec.email = ["michael@dtcorp.com.au"]
10
+
11
+ spec.summary = "Convert Informix to Rails"
12
+ spec.description = "Convert Informix 7.x forms (per files) to Rails views (erb files)."
13
+ spec.homepage = "https://github.com/map7/informix_rails"
14
+ spec.required_ruby_version = ">= 2.5.0"
15
+
16
+ # spec.metadata["allowed_push_host"] = "TODO: Set to your gem server 'https://example.com'"
17
+
18
+ spec.metadata["homepage_uri"] = spec.homepage
19
+ spec.metadata["source_code_uri"] = "https://github.com/map7/informix_rails"
20
+ spec.metadata["changelog_uri"] = "https://github.com/map7/informix_rails/changelog.md"
21
+
22
+ # Specify which files should be added to the gem when it is released.
23
+ # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
24
+ spec.files = Dir.chdir(File.expand_path(__dir__)) do
25
+ `git ls-files -z`.split("\x0").reject do |f|
26
+ (f == __FILE__) || f.match(%r{\A(?:(?:test|spec|features)/|\.(?:git|travis|circleci)|appveyor)})
27
+ end
28
+ end
29
+ spec.bindir = "exe"
30
+ spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
31
+ spec.require_paths = ["lib"]
32
+
33
+ # Uncomment to register a new dependency of your gem
34
+ # spec.add_dependency "example-gem", "~> 1.0"
35
+ spec.add_dependency "thor", "~> 1.2.1"
36
+ spec.add_dependency "rspec"
37
+ spec.add_dependency "rake"
38
+
39
+ # For more information and examples about making a new gem, checkout our
40
+ # guide at: https://bundler.io/guides/creating_gem.html
41
+ end
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ module InformixRails
4
+ VERSION = "0.1.0"
5
+ end
@@ -0,0 +1,130 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "informix_rails/version"
4
+ require "thor"
5
+
6
+ module InformixRails
7
+ class Error < StandardError; end
8
+
9
+ class Per2Erb < Thor
10
+
11
+ desc "convert [file]", "Convert per to erb"
12
+ def convert(file)
13
+ puts build_erb(file)
14
+ end
15
+
16
+ no_commands{
17
+
18
+ def build_erb(file)
19
+ output = read(file)
20
+
21
+ content = ""
22
+ output.each do |line|
23
+ content += convert_line(line) unless line.strip.empty?
24
+ end
25
+ content
26
+ end
27
+
28
+ def read(file)
29
+ output = File.read(file).split("\n")
30
+ output = crop("{","}",output)
31
+ output.reject!(&:empty?)
32
+ output
33
+ end
34
+
35
+ def crop(before,after,items)
36
+ items = remove_before("{",items)
37
+ items = remove_after("}",items)
38
+ items
39
+ end
40
+
41
+ def remove_before(token,items)
42
+ remove(token,items) {|found| !found}
43
+ end
44
+
45
+ def remove_after(token,items)
46
+ remove(token,items) {|found| found}
47
+ end
48
+
49
+ def remove(token,items)
50
+ found = false
51
+ items.delete_if {|x|
52
+ found = true if x == token
53
+ yield(found) || x == token
54
+ }
55
+ end
56
+
57
+ def wrap_content(content)
58
+ "<div class='flex-container'>\n#{content}\n</div>\n\n"
59
+ end
60
+
61
+ def convert_line(line)
62
+ content = split_items(line).map{ |item|
63
+ convert_item(item)}.join("\n")
64
+ wrap_content(content)
65
+ end
66
+
67
+ def split_items(line)
68
+ results = []
69
+ skip = 0
70
+ items = (line.split(/([\[\]])/).reject{|c| c.strip.empty?})
71
+ items.each_with_index do |item,i|
72
+
73
+ if item == '['
74
+ skip = 2
75
+ results << items[i] + items[i+1] + items[i+2]
76
+
77
+ elsif skip > 0
78
+ skip -= 1
79
+ next
80
+
81
+ else
82
+ results << item
83
+ end
84
+ end
85
+ return results
86
+
87
+ end
88
+
89
+ def convert_item(item)
90
+ if item[0..1] == '[l'
91
+ size = detect_label_size(item)
92
+ name = item.split(/([\[\]])/)[2].strip
93
+ return " <%= form.label :#{name}, '#{name}', class: '#{size}' %>"
94
+ elsif item[0] == '['
95
+ size = detect_field_size(item)
96
+ name = item.split(/([\[\]])/)[2].strip
97
+ return " <%= form.text_field :#{name}, class: '#{size}', disabled: @show %>"
98
+ else
99
+ return " #{item.strip}"
100
+ end
101
+ end
102
+
103
+ def detect_label_size(item)
104
+ if item.size < 10
105
+ size=""
106
+ elsif item.size < 14
107
+ size="-m"
108
+ elsif item.size < 18
109
+ size="-l"
110
+ end
111
+
112
+ "flex-label#{size}"
113
+ end
114
+
115
+ def detect_field_size(item)
116
+ if item.size < 10
117
+ size="-s"
118
+ elsif item.size < 14
119
+ size="-m"
120
+ elsif item.size < 18
121
+ size="-l"
122
+ else
123
+ size="-l-g"
124
+ end
125
+
126
+ "flex#{size}"
127
+ end
128
+ }
129
+ end
130
+ end
data/readme.org ADDED
@@ -0,0 +1,34 @@
1
+ * InformixRails
2
+
3
+ Convert Informix 7.x forms (per files) to Rails views (erb files).
4
+
5
+ There are
6
+
7
+ ** Installation
8
+
9
+ Or install it yourself as:
10
+
11
+ $ gem install informix_rails
12
+
13
+ ** Usage
14
+
15
+ From within your Informix development directory where you have your .per form files you can convert to erb with the following;
16
+ : informix_rails convert ftele00a.per
17
+
18
+ ** Development
19
+
20
+ Testing with sample_files
21
+ : be exe/informix_rails convert sample_files/ftele00a.per
22
+
23
+ ** Contributing
24
+
25
+ Bug reports and pull requests are welcome on GitHub at https://github.com/map7/informix_rails.
26
+
27
+ ** Ideas
28
+
29
+ Further features which could be added would be;
30
+
31
+ 1. Detect number & date fields and set them in the form
32
+ 2. Improve the field names by using the bottom table in per files instead
33
+ 3. Convert Informix SQL to migration files for Rails to create the same tables
34
+ 4. Convert 4gl files to business logic in Rails (plain class)
@@ -0,0 +1,68 @@
1
+ database pais
2
+ screen size 24 by 80
3
+ {
4
+ [l001 ][f013 ][f123 ]
5
+ [l099 ][f9][f99 ]
6
+ [l100 ][f100 ][f101 ]
7
+ [t ]
8
+ [l003 ][f015 ][l002 ][f014 ]ActionDt[dr ]time[tr ]
9
+ [l004 ][f016 ] byStaff[bs ]
10
+
11
+ [l006 ][f017 ]
12
+ [f17 ]
13
+ [l005 ][a1][f021 ]
14
+
15
+
16
+
17
+
18
+
19
+
20
+
21
+
22
+ }
23
+ end
24
+ tables
25
+ tele,
26
+ teac
27
+ attributes
28
+ f9=formonly.ccode_tele type CHAR,noentry;
29
+ f99=formonly.name_firm type CHAR,noentry;
30
+ f100=formonly.client_tele type CHAR,autonext;
31
+ f101=formonly.name_sur_clfi type CHAR,noentry;
32
+ f013=formonly.staff_tele type CHAR,autonext;
33
+ f123=formonly.name_sur_staf type CHAR,noentry;
34
+ f014=formonly.ext_tele type INTEGER,format="##########",noentry;
35
+ f015=formonly.date_tele type DATE,picture = "##/##/####",autonext;
36
+ dr=formonly.datereplied_tele type DATE,picture = "##/##/####",noentry,autonext;
37
+ f016=formonly.time_tele type datetime hour to minute,picture="##:##",autonext;
38
+ tr=formonly.timereply_tele type datetime hour to minute,picture="##:##",noentry,autonext;
39
+ t=formonly.trustcompany,noentry,autonext;
40
+ bs=formonly.staffactioned type char,noentry,autonext;
41
+ a1=formonly.type_tele_1 type char,autonext;
42
+ f017=formonly.comments_tele type CHAR,autonext;
43
+ f17=formonly.com2_tele type CHAR,autonext;
44
+ f021=formonly.comments_teac type CHAR,noentry;
45
+ ---f023=formonly.name_sur_clfi_1 type CHAR,noentry;
46
+ ---f024=formonly.client_tele_1 type CHAR,noentry;
47
+ ---f018=formonly.time_tele_1 type datetime hour to minute;
48
+ ---f2=formonly.type_tele type SMALLINT,format="##",noentry;
49
+ ---f22=formonly.comments_teac_1 type CHAR;
50
+ ---f020=formonly.comments_tele_1 type CHAR,noentry;
51
+ ---f019=formonly.staff_mess_tele type CHAR,noentry;
52
+ l099=formonly.ccode_tele_l,noentry;
53
+ l100=formonly.client_tele_l,noentry;
54
+ l006=formonly.comments_tele_l,noentry;
55
+ ---l012=formonly.comments_tele_1_l,noentry;
56
+ l003=formonly.date_tele_l,noentry;
57
+ l002=formonly.ext_tele_l,noentry;
58
+ l001=formonly.staff_tele_l,noentry;
59
+ ---l011=formonly.staff_mess_tele_l,noentry;
60
+ ---l008=formonly.time_tele_l,noentry;
61
+ l004=formonly.time_tele_1_l,noentry;
62
+ ---l009=formonly.type_tele_l,noentry;
63
+ l005=formonly.type_tele_1_l,noentry;
64
+ end
65
+ instructions
66
+ delimiters " "
67
+ end
68
+
@@ -0,0 +1,67 @@
1
+ database pais
2
+ screen size 24 by 80
3
+ {
4
+ [l001 ]
5
+
6
+
7
+
8
+
9
+
10
+
11
+
12
+
13
+
14
+
15
+
16
+
17
+
18
+
19
+
20
+
21
+
22
+ }
23
+ end
24
+ tables
25
+ tele,
26
+ teac
27
+ attributes
28
+ f9=formonly.ccode_tele type CHAR,noentry;
29
+ f99=formonly.name_firm type CHAR,noentry;
30
+ f100=formonly.client_tele type CHAR,autonext;
31
+ f101=formonly.name_sur_clfi type CHAR,noentry;
32
+ f013=formonly.staff_tele type CHAR,autonext;
33
+ f123=formonly.name_sur_staf type CHAR,noentry;
34
+ f014=formonly.ext_tele type INTEGER,format="##########",noentry;
35
+ f015=formonly.date_tele type DATE,picture = "##/##/####",autonext;
36
+ dr=formonly.datereplied_tele type DATE,picture = "##/##/####",noentry,autonext;
37
+ f016=formonly.time_tele type datetime hour to minute,picture="##:##",autonext;
38
+ tr=formonly.timereply_tele type datetime hour to minute,picture="##:##",noentry,autonext;
39
+ t=formonly.trustcompany,noentry,autonext;
40
+ bs=formonly.staffactioned type char,noentry,autonext;
41
+ a1=formonly.type_tele_1 type char,autonext;
42
+ f017=formonly.comments_tele type CHAR,autonext;
43
+ f17=formonly.com2_tele type CHAR,autonext;
44
+ f021=formonly.comments_teac type CHAR,noentry;
45
+ ---f023=formonly.name_sur_clfi_1 type CHAR,noentry;
46
+ ---f024=formonly.client_tele_1 type CHAR,noentry;
47
+ ---f018=formonly.time_tele_1 type datetime hour to minute;
48
+ ---f2=formonly.type_tele type SMALLINT,format="##",noentry;
49
+ ---f22=formonly.comments_teac_1 type CHAR;
50
+ ---f020=formonly.comments_tele_1 type CHAR,noentry;
51
+ ---f019=formonly.staff_mess_tele type CHAR,noentry;
52
+ l099=formonly.ccode_tele_l,noentry;
53
+ l100=formonly.client_tele_l,noentry;
54
+ l006=formonly.comments_tele_l,noentry;
55
+ ---l012=formonly.comments_tele_1_l,noentry;
56
+ l003=formonly.date_tele_l,noentry;
57
+ l002=formonly.ext_tele_l,noentry;
58
+ l001=formonly.staff_tele_l,noentry;
59
+ ---l011=formonly.staff_mess_tele_l,noentry;
60
+ ---l008=formonly.time_tele_l,noentry;
61
+ l004=formonly.time_tele_1_l,noentry;
62
+ ---l009=formonly.type_tele_l,noentry;
63
+ l005=formonly.type_tele_1_l,noentry;
64
+ end
65
+ instructions
66
+ delimiters " "
67
+ end
metadata ADDED
@@ -0,0 +1,102 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: informix_rails
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Michael Pope
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2022-02-16 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: thor
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: 1.2.1
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: 1.2.1
27
+ - !ruby/object:Gem::Dependency
28
+ name: rspec
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rake
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ description: Convert Informix 7.x forms (per files) to Rails views (erb files).
56
+ email:
57
+ - michael@dtcorp.com.au
58
+ executables:
59
+ - informix_rails
60
+ extensions: []
61
+ extra_rdoc_files: []
62
+ files:
63
+ - ".rubocop.yml"
64
+ - CHANGELOG.md
65
+ - Gemfile
66
+ - Gemfile.lock
67
+ - Rakefile
68
+ - bin/console
69
+ - bin/setup
70
+ - exe/informix_rails
71
+ - informix_rails.gemspec
72
+ - lib/informix_rails.rb
73
+ - lib/informix_rails/version.rb
74
+ - readme.org
75
+ - sample_files/ftele00a.per
76
+ - sample_files/simple.per
77
+ homepage: https://github.com/map7/informix_rails
78
+ licenses: []
79
+ metadata:
80
+ homepage_uri: https://github.com/map7/informix_rails
81
+ source_code_uri: https://github.com/map7/informix_rails
82
+ changelog_uri: https://github.com/map7/informix_rails/changelog.md
83
+ post_install_message:
84
+ rdoc_options: []
85
+ require_paths:
86
+ - lib
87
+ required_ruby_version: !ruby/object:Gem::Requirement
88
+ requirements:
89
+ - - ">="
90
+ - !ruby/object:Gem::Version
91
+ version: 2.5.0
92
+ required_rubygems_version: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
97
+ requirements: []
98
+ rubygems_version: 3.2.22
99
+ signing_key:
100
+ specification_version: 4
101
+ summary: Convert Informix to Rails
102
+ test_files: []