axlsx_rad 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 834382ebf19e94d28b67e1b8fdf27036cef2c31e
4
- data.tar.gz: 4deb68fde5206dd7292903386aa30e8d8c61689d
3
+ metadata.gz: 627f2ae10a0ddb5ea335613a53a674527aa6e6e0
4
+ data.tar.gz: 88a2da224cc8ca4878989e8668a3d19be02c3b0f
5
5
  SHA512:
6
- metadata.gz: c8d48310cb59052aab604e80bc6b56efc499b9fea63eb16792e64f0c647adc10a4689543565cbc2c8465ad983c8839bc3f4cd8004a966cb04fde5079e1c6eacf
7
- data.tar.gz: e328b22d9cc7f3431717d7a70cc33bf510a7caafbdf9ce469c23c8d742718c582f619ce68e7090cff9b6b8d997f7e53c5870fa30f8ebf412da9f5d8f31c1f97b
6
+ metadata.gz: 79e3021bf478184d7a1988af7ee04f1d10db7a975ddce9d1f981269f09de221a8b99ae0709683aed3a6ca8f7ce26a4c1e73057f05207735efe28c23e6863bdd6
7
+ data.tar.gz: 73299d0193a018e5a83180ef47203dc224c8c5204ee6067b9a8d7a4db91ac3ff34125d5a75738a701d0b69ead828d6d8f195128d38f30ad187b3005095b48964
@@ -1,5 +1,7 @@
1
1
  CHANGELOG
2
2
  ---------
3
3
 
4
+ - **2014-03-23**: 0.0.2
5
+ - Add ability to filter / remove duplicate documents
4
6
  - **2014-03-21**: 0.0.1
5
7
  - Initial release
data/README.md CHANGED
@@ -59,22 +59,25 @@ Download and install axlsx_rad with the following:
59
59
  :head => { :bg_color => '00FFFF', :b => true}
60
60
  }
61
61
 
62
- # Subclass AxlsxRad::Config object. This object has attributes: oColumns
63
- # and dStylesCfg. It doesn't matter how they are set but they should be
64
- # set before instantiating a AxlsxRad::Worksheet object. Additionally,
65
- # the #getStylesForHeader() and #getStylesForDocument( document ) methods
66
- # should be overridden to return a style hash as shown below:
62
+ # Subclass AxlsxRad::Config object. This object has accepts the columns,
63
+ # styles and unique key initialization parameters, setting them to the
64
+ # aColumns, dStylesCfg and xxKeyUnique attributes. It doesn't matter how
65
+ # they are set but they should be set before instantiating a
66
+ # AxlsxRad::Worksheet object. Additionally, the #getStylesForHeader() and
67
+ # #getStylesForDocument( document ) methods should be overridden to return
68
+ # a style hash as shown below.
67
69
  #
68
- # The contract contains: @aColumns, @dStylesCfg, #getStylesForHeader, and
69
- # #getStylesForDocument( JsonDoc::Document ).
70
+ # The contract contains the #getStylesForHeader and
71
+ # #getStylesForDocument( JsonDoc::Document ) methods.
70
72
  #
71
73
  # The style names used in the reponse hash should correspond to the style
72
74
  # keys used in the styles configuration hash above.
73
75
 
74
76
  class MyWorksheetConfig < AxlsxRad::Config
75
- def initialize(columns=[],styles={})
76
- @aColumns = columns
77
- @dStylesCfg = styles
77
+ def initialize(columns=[],styles={},unique_key=nil)
78
+ @aColumns = columns
79
+ @dStylesCfg = styles
80
+ @xxKeyUnique = unique_key
78
81
  end
79
82
  def getStylesForHeader()
80
83
  return { :bgstyle => :head }
@@ -110,6 +113,9 @@ Download and install axlsx_rad with the following:
110
113
  end
111
114
 
112
115
  # Write XLSX spreadsheet
116
+ workbook.serialize('example_users.xlsx')
117
+
118
+ # Write XLSX spreadsheet by accessing the Axlsx::Package object
113
119
  workbook.oAxlsx.serialize('example_users.xlsx')
114
120
 
115
121
  #Documentation
@@ -120,10 +126,19 @@ This gem is 100% documented with YARD, an exceptional documentation library. To
120
126
  $ gem install yard
121
127
  $ yard server -g
122
128
 
129
+ Notes
130
+ -----
131
+
132
+ 1. Removing duplicate documents
133
+ - If the unique_key parameter is set in the AxlsxRad::Config object, that key will be checked to retain or discard added documents which can streamline the adding process. Not setting this value or setting this value to nil will disable checking and add all documents.
134
+
123
135
  #Change Log
124
136
  -----------
125
137
 
126
- - **2014-03-20**: 0.0.1
138
+ - **2014-03-23**: 0.0.2
139
+ - Add ability to filter duplicate documents
140
+ - Add AxlsxRad::Workbook::serialize shortcut
141
+ - **2014-03-21**: 0.0.1
127
142
  - Initial release
128
143
 
129
144
  #Links
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.1
1
+ 0.0.2
@@ -2,9 +2,11 @@ module AxlsxRad
2
2
  class Config
3
3
  attr_accessor :aColumns
4
4
  attr_accessor :dStylesCfg
5
- def initialize(aColumns=[],dStylesCfg={})
6
- @aColumns = aColumns
7
- @dStylesCfg = dStylesCfg
5
+ attr_accessor :xxKeyUnique
6
+ def initialize(aColumns=[],dStylesCfg={},xxKeyUnique=nil)
7
+ @aColumns = aColumns
8
+ @dStylesCfg = dStylesCfg
9
+ @xxKeyUnique = nil
8
10
  end
9
11
  # Override this method with rules to return style key
10
12
  def getStylesForHeader()
@@ -27,6 +27,10 @@ module AxlsxRad
27
27
  @dWorksheets[ sWorksheetName ].addDocument( oJsondoc )
28
28
  end
29
29
 
30
+ def serialize(sPath=nil)
31
+ @oAxlsx.serialize(sPath)
32
+ end
33
+
30
34
  end
31
35
  end
32
36
 
@@ -44,6 +48,7 @@ module AxlsxRad
44
48
  @oWsConfig = oWsConfig
45
49
  self.loadWsConfig( oWsConfig )
46
50
  @bHasHead = false
51
+ @dKeysUnique = {}
47
52
  end
48
53
 
49
54
  def loadWsConfig(oWsConfig=nil)
@@ -64,10 +69,18 @@ module AxlsxRad
64
69
  end
65
70
  @bHasHead = true
66
71
  end
72
+ unless @oWsConfig.xxKeyUnique.nil?
73
+ xxKeyUniqueValue = oJsondoc.getProp( @oWsConfig.xxKeyUnique )
74
+ if @dKeysUnique.has_key?( xxKeyUniqueValue )
75
+ return
76
+ else
77
+ @dKeysUnique[ xxKeyUniqueValue ] = 1
78
+ end
79
+ end
67
80
  aValues = oJsondoc.getValArrayForProperties( @aColumns )
68
81
  aStyles = getStylesForDocument( oJsondoc )
69
82
  if aStyles.is_a?(Fixnum) || aStyles.is_a?(Array)
70
- @oAxlsxWorksheet.add_row aValues, :style => aStyles
83
+ @oAxlsxWorksheet.add_row aValues, :style => aStyles
71
84
  else
72
85
  @oAxlsxWorksheet.add_row aValues
73
86
  end
@@ -121,6 +134,11 @@ module AxlsxRad
121
134
  end
122
135
 
123
136
  def getStylesArrayForHash(dStyles={})
137
+ if dStyles.is_a?(Hash) && dStyles.keys.length == 0
138
+ return nil
139
+ elsif ! dStyles.is_a?(Hash)
140
+ return nil
141
+ end
124
142
  yStyleBg = dStyles.has_key?(:bgstyle) ? dStyles[:bgstyle] : nil
125
143
  yStyleBg = yStyleBg.to_sym if yStyleBg.is_a?(String)
126
144
  aStyles = []
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: axlsx_rad
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - John Wang
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-03-20 00:00:00.000000000 Z
11
+ date: 2014-03-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: axlsx