sushi_counter 0.1.0 → 0.1.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.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/sushi_counter.rb +21 -16
  3. metadata +3 -3
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 0d6e5e173e88c45200a3f4966060ce1153f93d6a
4
- data.tar.gz: 30817939966490cbcd1667cdeed0778b722cb555
3
+ metadata.gz: 95f7c943d58b5485c950efb26143cab845f4db07
4
+ data.tar.gz: df21c32e8eef3fee4e76dfeb3b74124ac48b18ae
5
5
  SHA512:
6
- metadata.gz: 5c7fa75cf5156ffb4b97f6cf065cea398874007eecd57ca20519dc584707ceaf7a128a48f01af5626465acdc4a495c7573c12ed27994a3428eadb9875eca4996
7
- data.tar.gz: 6f0366b9ea9c058a58a5e5ddccf54ac1528b8778ef0b5914fc39ceb04dd0ce7a8ab98e844103d2aa33ee41e498c01d7b8cced2b7c4c35311380de7f6767f6886
6
+ metadata.gz: 2e9fe70c44aa5e5f0d92cee13bf487784b24353f1327f01dda3870d9661a4d137e3589bd36250de4942fa2265101571706776f0951439c718c3cd003572d0c1b
7
+ data.tar.gz: 6273352d2ed6a3c4303ff5c3e8749dbd419d58e8389c7e5c43eaa4f934a455798c2117fe6a718e5bedfa365a265ab60d3ce8b9f5a325dd0d4b771976fa571bab
@@ -161,7 +161,7 @@ define_method :sushi_call do
161
161
  },
162
162
  } )
163
163
  puts "Fetching report..."
164
- begin
164
+ #begin
165
165
 
166
166
  xml = response.doc
167
167
  #Need to replace below xml file with a dynamically generated name based on vendor/year.
@@ -212,6 +212,8 @@ define_method :sushi_call do
212
212
  html_holder = []
213
213
  month_holder = []
214
214
  count_holder = []
215
+ total_holder = []
216
+ all_stats = []
215
217
  count_hash = Hash[month_array.map{|x| [x.to_sym] }]
216
218
  month_iterator = nil
217
219
  total_iterator = nil
@@ -225,8 +227,7 @@ define_method :sushi_call do
225
227
  total_all = nil
226
228
  i = 0
227
229
  platform = nil
228
- total_integer = nil
229
- #total_months = []
230
+
230
231
 
231
232
 
232
233
  noko_doc.xpath('//ReportItems').each do |item|
@@ -255,7 +256,6 @@ define_method :sushi_call do
255
256
 
256
257
 
257
258
  n = 0
258
- m = 0
259
259
 
260
260
 
261
261
  #Match months supplied by user to months in month_holder array
@@ -264,7 +264,6 @@ define_method :sushi_call do
264
264
  if month_holder.include? month_array[n]
265
265
  month_key = month_array[n]
266
266
  count = count_hash[month_key.to_sym]
267
- m += 1
268
267
  total_stats << count
269
268
  if n < count_var
270
269
  n += 1
@@ -291,18 +290,17 @@ define_method :sushi_call do
291
290
  #Refine code below? Currently working, but could probably be DRYer
292
291
  total_stats.each_slice(months_var).each do |slice|
293
292
  iterator = slice.join(",")
294
- total_integer = slice.map(&:to_i).inject(0, :+)
295
293
  end
296
294
  #Could probably just add up html_stats array and output in CSV row below.
297
295
  html_stats.each_slice(months_var).each do |slice|
298
296
  html_holder = slice
299
297
  html_integer = html_holder.map(&:to_i)
300
- html_iterator = html_integer.inject(0, :+)
298
+ html_iterator = html_integer.reduce(0, :+)
301
299
  end
302
300
  pdf_stats.each_slice(months_var).each do |slice|
303
301
  pdf_holder = slice
304
302
  pdf_integer = pdf_holder.map(&:to_i)
305
- pdf_iterator = pdf_integer.inject(0, :+)
303
+ pdf_iterator = pdf_integer.reduce(0, :+)
306
304
  end
307
305
  total_iterator = pdf_iterator + html_iterator
308
306
 
@@ -316,6 +314,13 @@ define_method :sushi_call do
316
314
  total_html = html_stats.map(&:to_i).reduce(:+)
317
315
  total_all = total_html + total_pdf
318
316
 
317
+ #Need to use with_index to divide index, not value
318
+ #z = 1
319
+ #months_var.times do
320
+ # all_stats << total_stats.select {|x| x % z == 0}
321
+ # z += 1
322
+ #end
323
+
319
324
  ##Output Nokogiri Doc into csv
320
325
  CSV.open(output_file, 'wb') do |row|
321
326
  row << ["#{doc_version}", "Release: #{doc_release}"]
@@ -328,22 +333,22 @@ define_method :sushi_call do
328
333
  #Prints all headers
329
334
  row << ["Journal", "Publisher", "Platform", "Journal DOI", "Proprietary Identifier", "Print ISSN", "Online ISSN", "Reporting Period Total", "Reporting Period HTML", "Reporting Period PDF", month_array]
330
335
  #Prints totals of all data - need to add more totals.
331
- row << ["Total for all Journals", "", platform, "","","","", total_all, total_html, total_pdf, total_integer]
336
+ row << ["Total for all Journals", "", platform, "","","","", total_all, total_html, total_pdf, all_stats]
332
337
 
333
338
  #Code below iterates through array, printing each item to a row
334
339
  report_data.each do |data|
335
340
  row << data
336
341
  end
337
342
  end
338
- rescue
339
- puts Rainbow("There was an error running the script. Double check the values you are passing to the script and try adding '--log' to your command
340
- to see what went wrong.").bright.red
341
- else
343
+ #rescue
344
+ #puts Rainbow("There was an error running the script. Double check the values you are passing to the script and try adding '--log' to your command
345
+ #to see what went wrong.").bright.red
346
+ #else
342
347
  #Rewrite XML filename to something more useful (e.g. vendor name)?
343
348
  #Add statements to check if files actually created.
344
- puts "The XML file is in the" + Rainbow(" 'raw_xml/'").green.bright + " folder and the filename is" + Rainbow(" '#{options[:customer]}-#{Time.now.strftime("%Y%m%d")}.xml'").green.bright
345
- puts "Your COUNTER report is in the file" + Rainbow(" '#{ARGV[0]}'").green.bright
346
- end
349
+ #puts "The XML file is in the" + Rainbow(" 'raw_xml/'").green.bright + " folder and the filename is" + Rainbow(" '#{options[:customer]}-#{Time.now.strftime("%Y%m%d")}.xml'").green.bright
350
+ #puts "Your COUNTER report is in the file" + Rainbow(" '#{ARGV[0]}'").green.bright
351
+ #end
347
352
  end
348
353
 
349
354
  sushi_call()
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sushi_counter
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Max King
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-10-30 00:00:00.000000000 Z
11
+ date: 2017-10-31 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: savon
@@ -90,7 +90,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
90
90
  requirements:
91
91
  - - ">="
92
92
  - !ruby/object:Gem::Version
93
- version: '0'
93
+ version: 2.2.2
94
94
  required_rubygems_version: !ruby/object:Gem::Requirement
95
95
  requirements:
96
96
  - - ">="