icersplicer 0.6.0 → 0.6.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.
- checksums.yaml +4 -4
- data/bin/icersplicer +7 -8
- data/examples/files/example_data.sql +200 -0
- data/examples/files/voc_dump.sql +29335 -0
- data/lib/icersplicer.rb +28 -18
- metadata +4 -2
data/lib/icersplicer.rb
CHANGED
@@ -14,14 +14,15 @@ module Icersplicer
|
|
14
14
|
module VERSION #:nodoc:
|
15
15
|
MAJOR = 0
|
16
16
|
MINOR = 6
|
17
|
-
TINY =
|
18
|
-
CODENAME = "
|
17
|
+
TINY = 2
|
18
|
+
CODENAME = "Ice Pick !"
|
19
19
|
STRING = [MAJOR, MINOR, TINY].join('.')
|
20
20
|
end
|
21
21
|
|
22
22
|
@@nfile = 0
|
23
23
|
@@exp = nil
|
24
24
|
@@keywordsfile = "keywords.ice"
|
25
|
+
@@debug = false
|
25
26
|
|
26
27
|
COLOURS = {"black" => 0,
|
27
28
|
"red" => 1,
|
@@ -33,14 +34,17 @@ module Icersplicer
|
|
33
34
|
"white" => 7}
|
34
35
|
|
35
36
|
def load_keywords(file)
|
36
|
-
keys =
|
37
|
+
keys = Hash.new
|
38
|
+
linenum = 0
|
37
39
|
unless Dir.exists?("#{Dir.home}/.icersplicer")
|
38
40
|
Dir.mkdir("#{Dir.home}/.icersplicer")
|
39
41
|
end
|
40
42
|
if File.exists?("#{Dir.home}/.icersplicer/#{file}")
|
41
43
|
File.open("#{Dir.home}/.icersplicer/#{file}") {|n|
|
42
44
|
n.each_line {|l|
|
43
|
-
keys
|
45
|
+
keys.update({linenum => "#{l.strip}"}) unless l.strip == ""
|
46
|
+
puts "L: #{l.strip}" if @@debug == true
|
47
|
+
linenum += 1
|
44
48
|
}
|
45
49
|
}
|
46
50
|
return keys
|
@@ -61,21 +65,25 @@ module Icersplicer
|
|
61
65
|
def text_highlighter(text)
|
62
66
|
@keys ||= load_keywords("#{@@keywordsfile}")
|
63
67
|
if @keys == false
|
64
|
-
@keys =
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
68
|
+
@keys = {0 => "Ln:",
|
69
|
+
1 => "SELECT",
|
70
|
+
2 => "CREATE TABLE",
|
71
|
+
3 => "UPDATE",
|
72
|
+
4 => "DELETE",
|
73
|
+
5 => "INSERT"}
|
69
74
|
end
|
70
75
|
cpicker = [2,3,4,1,7,5,6] # Just a selection of colours
|
71
76
|
@keys.each {|n|
|
72
|
-
if n.split("##")[1] == nil
|
73
|
-
text.gsub!("#{n}", "\e[4;3#{cpicker[rand(cpicker.size)]}m#{n}\e[0m\ \e[0;32m"
|
77
|
+
if n[1].split("##")[1] == nil
|
78
|
+
text.gsub!("#{n[1]}", "\e[4;3#{cpicker[rand(cpicker.size)]}m#{n[1]}\e[0m\ \e[0;32m")
|
74
79
|
else
|
75
|
-
name = n.split("##")[1].split("=")[1]
|
80
|
+
name = n[1].split("##")[1].split("=")[1]
|
81
|
+
puts "Name: #{name}" if @@debug == true
|
76
82
|
cnum = COLOURS[name].to_i
|
77
|
-
|
78
|
-
|
83
|
+
puts "Colour Number: #{cnum}" if @@debug == true
|
84
|
+
nval = n[1].split("##")[0]
|
85
|
+
puts "Value: #{nval}" if @@debug == true
|
86
|
+
text.gsub!("#{nval}", "\e[4;3#{cnum}m#{nval}\e[0m\ \e[0;32m")
|
79
87
|
end
|
80
88
|
text.gsub!(" \e[0;32m", "\e[0;32m")
|
81
89
|
}
|
@@ -85,7 +93,7 @@ module Icersplicer
|
|
85
93
|
def countlines(inputfile)
|
86
94
|
lines = 0
|
87
95
|
unless inputfile == nil
|
88
|
-
if File.
|
96
|
+
if File.exist?(inputfile)
|
89
97
|
File.open(inputfile) {|n|
|
90
98
|
n.each_line {
|
91
99
|
lines += 1
|
@@ -122,9 +130,11 @@ module Icersplicer
|
|
122
130
|
|
123
131
|
def skip(line)
|
124
132
|
begin
|
125
|
-
|
126
|
-
|
127
|
-
|
133
|
+
if instance_variable_defined?("@skip_lines")
|
134
|
+
line_element = @skip_lines.index(line)
|
135
|
+
if line_element != nil
|
136
|
+
skiper = @skip_lines[line_element]
|
137
|
+
end
|
128
138
|
end
|
129
139
|
rescue NoMethodError
|
130
140
|
return nil
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: icersplicer
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.6.
|
4
|
+
version: 0.6.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Brian Hood
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-01-
|
11
|
+
date: 2016-01-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: walltime
|
@@ -32,6 +32,8 @@ extensions: []
|
|
32
32
|
extra_rdoc_files: []
|
33
33
|
files:
|
34
34
|
- bin/icersplicer
|
35
|
+
- examples/files/example_data.sql
|
36
|
+
- examples/files/voc_dump.sql
|
35
37
|
- examples/keywords.ice
|
36
38
|
- lib/icersplicer.rb
|
37
39
|
homepage: https://github.com/puppetpies/icersplicer
|