twb 1.9.1 → 2.2.1

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.
@@ -0,0 +1,70 @@
1
+ # Copyright (C) 2014, 2018 Chris Gerrard
2
+ #
3
+ # This program is free software: you can redistribute it and/or modify
4
+ # it under the terms of the GNU General Public License as published by
5
+ # the Free Software Foundation, either version 3 of the License, or
6
+ # (at your option) any later version.
7
+ #
8
+ # This program is distributed in the hope that it will be useful,
9
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
10
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11
+ # GNU General Public License for more details.
12
+ #
13
+ # You should have received a copy of the GNU General Public License
14
+ # along with this program. If not, see <http://www.gnu.org/licenses/>.
15
+
16
+ require 'nokogiri'
17
+
18
+ module Twb
19
+
20
+ class DbField
21
+
22
+ include Comparable
23
+
24
+ attr_reader :node
25
+ attr_reader :properties
26
+ attr_reader :name, :uiname
27
+ attr_reader :dbname, :dbtable
28
+
29
+ def initialize dataSource, node, nodeType, table=nil
30
+ @node = node
31
+ @nodeType = nodeType
32
+ case @nodeType
33
+ when :map
34
+ @uiname = @node.attribute('key').text.gsub(/^\[|\]$/,'')
35
+ @name = @uiname
36
+ fldRef = @node.attribute('value').text.gsub(/^\[|\]$/,'')
37
+ parts = fldRef.split('].[')
38
+ @dbtable = parts[0]
39
+ @dbname = parts[1]
40
+ when :tableColumn
41
+ @uiname = @node.attribute('name').text
42
+ @name = @uiname
43
+ @dbtable = table
44
+ else
45
+ raise ArgumentError.new("ERROR in DbField creation: invalid Node type, is #{nodeType} \n ")
46
+ end
47
+ @id = "#{dataSource}::#{dbname}::#{dbtable}::#{uiname}"
48
+ end
49
+
50
+ def properties
51
+ @properties ||= loadProperties
52
+ end
53
+
54
+ def loadProperties
55
+ @properties = {:name=>@name,:uiname=>@uiname, :dbtable=>@dbtable}
56
+ @properties[:dbname] = @dbname if :map == @nodeType
57
+ return @properties
58
+ end
59
+
60
+ def to_s
61
+ @id
62
+ end
63
+
64
+ def <=>(other)
65
+ @id <=> other.id
66
+ end
67
+
68
+ end # class ColumnField
69
+
70
+ end
@@ -27,7 +27,7 @@ module Twb
27
27
  attr_reader :formulaResolved
28
28
  attr_reader :formulaFlat
29
29
  attr_reader :formulaFlatResolved
30
- attr_reader :formulaLines
30
+ attr_reader :formulaLines, :formulaResolvedLines
31
31
  attr_reader :is_tableCalc
32
32
  attr_reader :is_lod, :lodCodePos
33
33
  attr_reader :class, :scopeIsolation
@@ -121,7 +121,7 @@ module Twb
121
121
  stripBck = stripFrt.gsub( /\][^\]]+$/ , ']' )
122
122
  stripMid = stripBck.gsub( /\][^\]]{2,}\[/ , ']]..[[' )
123
123
  stripCom = stripMid.gsub( /\][ ]*,[ ]*\[/ , ']]..[[' )
124
- stripFns = stripMid.gsub( /\][ ]*[\*\/+\-,=][ ]*\[/ , ']]..[[' )
124
+ stripFns = stripMid.gsub( /\][ ]*[\*\/+\-><,=][ ]*\[/ , ']]..[[' )
125
125
  fields = stripFns.split(']..[')
126
126
  fields.each { |field| @fields.add field.gsub(/^\[|\]$/, '')}
127
127
  fields.each do |field|
@@ -149,6 +149,13 @@ module Twb
149
149
  return formula
150
150
  end
151
151
 
152
+ def formulaResolvedLines
153
+ formulaResolved.split(/\n|\r\n/)
154
+ end
155
+
156
+ def enlineResolvedFormula
157
+ end
158
+
152
159
  def formulaFlatResolved
153
160
  @formulaFlatResolved ||= flattenResolvedFormula
154
161
  end
@@ -21,20 +21,21 @@ module Twb
21
21
 
22
22
  class LocalField
23
23
 
24
- attr_reader :node, :type, :datatype, :name, :ordinal
24
+ attr_reader :node, :type, :datatype, :name, :uiname, :hidden, :ordinal, :properties
25
25
 
26
26
  def initialize fieldNode
27
- puts "lf:: #{fieldNode}"
28
27
  @node = fieldNode
29
28
  @type = 'local'
30
29
  @datatype = @node.attr('datatype')
31
30
  @name = @node.attr('name')
31
+ @uiname = @name
32
32
  @ordinal = @node.attr('ordinal')
33
+ # @properties = @node.attributes
33
34
  # @dbname = @node.attr('name').gsub(/^\[/,'').gsub(/\]$/,'')
34
35
  # @datatype = @node.attr('datatype')
35
36
  # @role = @node.attr('role')
36
37
  # @type = @node.attr('type')
37
- # @hidden = @node.attr('hidden')
38
+ @hidden = @node.attr('hidden')
38
39
  # @caption = @node.attr('caption')
39
40
  # @aggregation = @node.attr('aggregation')
40
41
  # @calculation = getCalculation
@@ -43,26 +44,19 @@ module Twb
43
44
  # return self
44
45
  end
45
46
 
46
- # def getCalculation
47
- # calcNode = @node.at_xpath("./calculation")
48
- # FieldCalculation.new(calcNode) unless calcNode.nil?
49
- # end
50
-
51
- # def getComments
52
- # comments = ''
53
- # runs = node.xpath('./desc/formatted-text/run')
54
- # runs.each do |run|
55
- # unless run.nil?
56
- # comments += run.text
57
- # end
58
- # end
59
- # return comments
60
- # end
47
+ def properties
48
+ @properties ||= loadProperties
49
+ end
61
50
 
62
- # def remove_attribute attribute
63
- # @node.remove_attribute(attribute)
64
- # end
51
+ def loadProperties
52
+ @properties= {}
53
+ @node.attributes.each do |name,attr|
54
+ @properties[name] = attr.value
55
+ end
56
+ @properties[:uiname] = @name
57
+ return @properties
58
+ end
65
59
 
66
- end
60
+ end # class LocalField
67
61
 
68
- end
62
+ end # module twb
@@ -0,0 +1,62 @@
1
+ # Copyright (C) 2014, 2018 Chris Gerrard
2
+ #
3
+ # This program is free software: you can redistribute it and/or modify
4
+ # it under the terms of the GNU General Public License as published by
5
+ # the Free Software Foundation, either version 3 of the License, or
6
+ # (at your option) any later version.
7
+ #
8
+ # This program is distributed in the hope that it will be useful,
9
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
10
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11
+ # GNU General Public License for more details.
12
+ #
13
+ # You should have received a copy of the GNU General Public License
14
+ # along with this program. If not, see <http://www.gnu.org/licenses/>.
15
+
16
+ require 'nokogiri'
17
+
18
+ module Twb
19
+
20
+ class DbField
21
+
22
+ include Comparable
23
+
24
+ attr_reader :node,
25
+ attr_reader :properties
26
+ attr_reader :name, :uiname, :dbname
27
+ attr_reader :dbtable
28
+
29
+ def initialize dataSource, fieldNode
30
+ @node = fieldNode
31
+ @uiname = @node.attribute('key').text.gsub(/^\[|\]$/,'')
32
+ @name = @uiname
33
+ fldRef = @node.attribute('value').text.gsub(/^\[|\]$/,'')
34
+ parts = fldRef.split('].[')
35
+ @dbtable = parts[0]
36
+ @dbname = parts[1]
37
+ @id = "#{dataSource}::#{dbname}::#{dbtable}::#{uiname}"
38
+ end
39
+
40
+ def properties
41
+ @properties ||= loadProperties
42
+ end
43
+
44
+ def loadProperties
45
+ @properties= {}
46
+ @node.attributes.each do |attr|
47
+ @properties[attr.name] = attr.text
48
+ end
49
+ @properties[:uiname] = @name
50
+ end
51
+
52
+ def to_s
53
+ @id
54
+ end
55
+
56
+ def <=>(other)
57
+ @id <=> other.id
58
+ end
59
+
60
+ end # class ColumnField
61
+
62
+ end
@@ -21,11 +21,13 @@ module Twb
21
21
 
22
22
  include Comparable
23
23
 
24
- attr_reader :node, :class
24
+ attr_reader :node, :properties
25
+ attr_reader :twbClass
25
26
  attr_accessor :source
26
27
  attr_reader :parentName, :table # parentName is the Db table
27
- attr_reader :name, :caption, :family
28
- attr_reader :localName, :localType
28
+ attr_reader :localName, :name
29
+ attr_reader :caption, :uiname
30
+ attr_reader :localType, :family
29
31
  attr_reader :remoteName, :remoteAlias
30
32
  attr_reader :remoteType, :aggregation
31
33
  attr_reader :containsNull, :ordinal
@@ -54,8 +56,8 @@ module Twb
54
56
 
55
57
 
56
58
  def initialize fieldNode
57
- @class = fieldNode.attribute('class').text
58
59
  @node = fieldNode
60
+ @twbClass = @node.attribute('class').text
59
61
  @parentName = load 'parent-name'
60
62
  @family = load 'family'
61
63
  @table = @family.nil? ? @parentName : @family
@@ -64,7 +66,8 @@ module Twb
64
66
  @remoteType = load 'remote-type'
65
67
  @caption = load 'caption'
66
68
  @localName = load 'local-name'
67
- @name = @caption.nil? ? @localName : @caption
69
+ @name = @localName
70
+ @uiname = @caption.nil? ? @localName : @caption
68
71
  @aggregation = load 'aggregation'
69
72
  @containsNull = load 'contains-null'
70
73
  @localType = load 'local-type'
@@ -73,7 +76,23 @@ module Twb
73
76
  @scale = load 'scale'
74
77
  @width = load 'width'
75
78
  @id = "'%s::%s' " % [@table,@remoteName]
76
- # return self
79
+ end
80
+
81
+ def properties
82
+ @properties ||= loadProperties
83
+ end
84
+
85
+ def loadProperties
86
+ @properties = {}
87
+ children = @node.xpath('child::node()')
88
+ children.each do |child|
89
+ @properties[child.name] = child.text unless 'attributes'.eql? child.name
90
+ end
91
+ @properties[:uiname] = @uiname
92
+ @node.attributes.each do |name,attr|
93
+ @properties[name] = attr.value
94
+ end
95
+ return @properties
77
96
  end
78
97
 
79
98
  def load nodeName
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: twb
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.9.1
4
+ version: 2.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Chris Gerrard
@@ -20,20 +20,24 @@ files:
20
20
  - LICENSE.md
21
21
  - LICENSE.txt
22
22
  - README.md
23
- - bin/twb.rb
24
23
  - lib/twb.rb
25
24
  - lib/twb/TwbTest.rb
26
25
  - lib/twb/action.rb
26
+ - lib/twb/analysis/AnnotatedFieldsCSVEmitter.rb
27
27
  - lib/twb/analysis/CalculatedFields/CSVEmitter.rb
28
28
  - lib/twb/analysis/CalculatedFields/CalculatedFieldsAnalyzer.rb
29
29
  - lib/twb/analysis/CalculatedFields/MarkdownEmitter.rb
30
+ - lib/twb/analysis/DataSources/DataSourceFieldsCSVEmitter.rb
30
31
  - lib/twb/analysis/DataSources/DataSourceTableFieldsCSVEmitter.rb
32
+ - lib/twb/analysis/DocumentedFieldsCSVEmitter.rb
33
+ - lib/twb/analysis/DocumentedFieldsMarkdownEmitter.rb
31
34
  - lib/twb/analysis/Sheets/WorksheetDataStructureCSVEmitter.rb
32
35
  - lib/twb/calculatedfield.rb
33
36
  - lib/twb/columnfield.rb
34
37
  - lib/twb/dashboard.rb
35
38
  - lib/twb/dashboard.txt
36
39
  - lib/twb/datasource.rb
40
+ - lib/twb/dbfield.rb
37
41
  - lib/twb/docdashboard.rb
38
42
  - lib/twb/docdashboardimagevert.rb
39
43
  - lib/twb/docdashboardwebvert.rb
@@ -47,6 +51,7 @@ files:
47
51
  - lib/twb/htmllistcollapsible.rb
48
52
  - lib/twb/identifyFields.rb
49
53
  - lib/twb/localfield.rb
54
+ - lib/twb/mappedfield.rb
50
55
  - lib/twb/metadatafield.rb
51
56
  - lib/twb/storyboard.rb
52
57
  - lib/twb/there.rb
data/bin/twb.rb DELETED
@@ -1 +0,0 @@
1
- puts "\n TWB gem here. \n"