From 94599c654385b8bfc7b73111f48d5345fe5ed9cd Mon Sep 17 00:00:00 2001 From: Andrew Colchagoff Date: Wed, 16 Sep 2015 16:43:23 -0400 Subject: [PATCH 01/10] Fixes issue with missing slash in resource path --- .gitignore | 1 + lib/scorm.rb | 4 ++-- lib/scorm/resource.rb | 10 ++++++++-- 3 files changed, 11 insertions(+), 4 deletions(-) create mode 100644 .gitignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..485dee6 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +.idea diff --git a/lib/scorm.rb b/lib/scorm.rb index 1bd9be1..b712f80 100644 --- a/lib/scorm.rb +++ b/lib/scorm.rb @@ -1,5 +1,5 @@ module Scorm - VERSION = '1.0.2' + VERSION = '1.0.3' end -require 'scorm/package' \ No newline at end of file +require 'scorm/package' diff --git a/lib/scorm/resource.rb b/lib/scorm/resource.rb index 3626a72..1b624ac 100644 --- a/lib/scorm/resource.rb +++ b/lib/scorm/resource.rb @@ -35,12 +35,18 @@ def self.from_xml(element) REXML::XPath.each(element, 'dependency') do |dep_el| dependencies << dep_el.attribute('identifierref').to_s end - + + path = element.attribute('xml:base').to_s + unless path.end_with?('/') + path += '/' + end + path += element.attribute('href').to_s + res = self.new( element.attribute('identifier'), element.attribute('type'), element.attribute('scormType', 'adlcp') || element.attribute('scormtype', 'adlcp'), - element.attribute('xml:base').to_s + element.attribute('href').to_s, + path, metadata, files, dependencies) From 0af1370ef9959e1c2729018892c9c421c7c20aae Mon Sep 17 00:00:00 2001 From: Andrew Colchagoff Date: Wed, 16 Sep 2015 16:56:46 -0400 Subject: [PATCH 02/10] Fixes issue with files path --- lib/scorm/resource.rb | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/lib/scorm/resource.rb b/lib/scorm/resource.rb index 1b624ac..fafe38a 100644 --- a/lib/scorm/resource.rb +++ b/lib/scorm/resource.rb @@ -28,25 +28,24 @@ def initialize(id, type, scorm_type, href = nil, metadata = nil, files = nil, de def self.from_xml(element) metadata = nil files = [] + xml_base = element.attribute('xml:base').to_s + unless xml_base.end_with?('/') + xml_base += '/' + end + REXML::XPath.each(element, 'file') do |file_el| - files << element.attribute('xml:base').to_s + file_el.attribute('href').to_s + files << xml_base + file_el.attribute('href').to_s end dependencies = [] REXML::XPath.each(element, 'dependency') do |dep_el| dependencies << dep_el.attribute('identifierref').to_s end - path = element.attribute('xml:base').to_s - unless path.end_with?('/') - path += '/' - end - path += element.attribute('href').to_s - res = self.new( element.attribute('identifier'), element.attribute('type'), element.attribute('scormType', 'adlcp') || element.attribute('scormtype', 'adlcp'), - path, + xml_base + element.attribute('href').to_s, metadata, files, dependencies) From 33f9a6644e3ead1defbf1442c355dff8758c67f9 Mon Sep 17 00:00:00 2001 From: Andrew Colchagoff Date: Wed, 16 Sep 2015 16:57:34 -0400 Subject: [PATCH 03/10] mend --- lib/scorm.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/scorm.rb b/lib/scorm.rb index b712f80..a8496d5 100644 --- a/lib/scorm.rb +++ b/lib/scorm.rb @@ -1,5 +1,5 @@ module Scorm - VERSION = '1.0.3' + VERSION = '1.0.4' end require 'scorm/package' From bcd7b3bd558e9dae96375347f5e679ead8508157 Mon Sep 17 00:00:00 2001 From: Andrew Colchagoff Date: Fri, 18 Sep 2015 14:16:21 -0400 Subject: [PATCH 04/10] Fixes issue with '//' occuring in file paths --- lib/scorm/resource.rb | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/lib/scorm/resource.rb b/lib/scorm/resource.rb index fafe38a..cc37b86 100644 --- a/lib/scorm/resource.rb +++ b/lib/scorm/resource.rb @@ -29,18 +29,22 @@ def self.from_xml(element) metadata = nil files = [] xml_base = element.attribute('xml:base').to_s - unless xml_base.end_with?('/') - xml_base += '/' - end REXML::XPath.each(element, 'file') do |file_el| - files << xml_base + file_el.attribute('href').to_s + file = file_el.attribute('href').to_s + if xml_base.end_with?('/') || file.start_with?('/') + files << xml_base + file + else + files << xml_base + '/' + file + end end dependencies = [] REXML::XPath.each(element, 'dependency') do |dep_el| dependencies << dep_el.attribute('identifierref').to_s end + + res = self.new( element.attribute('identifier'), element.attribute('type'), From 4298642ed130ee86c65d18521278fb35d1894677 Mon Sep 17 00:00:00 2001 From: Andrew Colchagoff Date: Tue, 3 Jul 2018 09:54:19 -0400 Subject: [PATCH 05/10] Adds method to turn time interval back into scorm strings --- lib/scorm/datatypes.rb | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/lib/scorm/datatypes.rb b/lib/scorm/datatypes.rb index 5bf3196..65ee536 100644 --- a/lib/scorm/datatypes.rb +++ b/lib/scorm/datatypes.rb @@ -51,6 +51,15 @@ def to_s sec -= min*60 return "#{hours}:#{min}:#{sec}" end + + def to_scorm_s + sec = self.to_f + hours = (sec/60/60).to_i + sec -= hours*60*60 + min = (sec/60).to_i + sec -= min*60 + return "PT#{hours}H#{min}M#{sec}S" + end end end From d37f81c4fbad899f1a098c5147561212fa27bf17 Mon Sep 17 00:00:00 2001 From: Andrew Colchagoff Date: Tue, 3 Jul 2018 10:00:02 -0400 Subject: [PATCH 06/10] Fixes float issue --- lib/scorm/datatypes.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/scorm/datatypes.rb b/lib/scorm/datatypes.rb index 65ee536..9a9eafd 100644 --- a/lib/scorm/datatypes.rb +++ b/lib/scorm/datatypes.rb @@ -58,6 +58,7 @@ def to_scorm_s sec -= hours*60*60 min = (sec/60).to_i sec -= min*60 + sec = (sec*100).ceil/100.0 return "PT#{hours}H#{min}M#{sec}S" end end From 243c0a66235ca5bf852e6bf713dabe28d7689681 Mon Sep 17 00:00:00 2001 From: Andrew Colchagoff Date: Tue, 3 Jul 2018 10:01:54 -0400 Subject: [PATCH 07/10] round rather than ciel for true number --- lib/scorm/datatypes.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/scorm/datatypes.rb b/lib/scorm/datatypes.rb index 9a9eafd..7085aa0 100644 --- a/lib/scorm/datatypes.rb +++ b/lib/scorm/datatypes.rb @@ -58,7 +58,7 @@ def to_scorm_s sec -= hours*60*60 min = (sec/60).to_i sec -= min*60 - sec = (sec*100).ceil/100.0 + sec = (sec*100).round/100.0 return "PT#{hours}H#{min}M#{sec}S" end end From ed7d4da5c802ce5252e82590bf30225b530084c0 Mon Sep 17 00:00:00 2001 From: Andrew Colchagoff Date: Tue, 3 Jul 2018 10:12:05 -0400 Subject: [PATCH 08/10] Omit minuntes and hours when not relevant --- lib/scorm/datatypes.rb | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/lib/scorm/datatypes.rb b/lib/scorm/datatypes.rb index 7085aa0..1695470 100644 --- a/lib/scorm/datatypes.rb +++ b/lib/scorm/datatypes.rb @@ -59,7 +59,15 @@ def to_scorm_s min = (sec/60).to_i sec -= min*60 sec = (sec*100).round/100.0 - return "PT#{hours}H#{min}M#{sec}S" + + rtn_str = "PT" + if hours + rtn_str += "#{hours}H" + end + if min + rtn_str += "#{min}M" + end + rtn_str += "#{sec}S" end end From 5613a086bd359c9f3ba592abe1bb549b65e6f852 Mon Sep 17 00:00:00 2001 From: Andrew Colchagoff Date: Tue, 3 Jul 2018 10:15:06 -0400 Subject: [PATCH 09/10] fixes issue where hours are printed when they are zero --- lib/scorm/datatypes.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/scorm/datatypes.rb b/lib/scorm/datatypes.rb index 1695470..17fdfce 100644 --- a/lib/scorm/datatypes.rb +++ b/lib/scorm/datatypes.rb @@ -61,10 +61,10 @@ def to_scorm_s sec = (sec*100).round/100.0 rtn_str = "PT" - if hours + if hours > 0 rtn_str += "#{hours}H" end - if min + if min > 0 rtn_str += "#{min}M" end rtn_str += "#{sec}S" From 0aaff4e96785e583713e45561110dd79c99e2ddb Mon Sep 17 00:00:00 2001 From: Andrew Colchagoff Date: Tue, 11 Jun 2019 20:09:25 -0400 Subject: [PATCH 10/10] Update scorm.gemspec --- scorm.gemspec | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scorm.gemspec b/scorm.gemspec index dd86e97..5c02864 100644 --- a/scorm.gemspec +++ b/scorm.gemspec @@ -15,5 +15,5 @@ Gem::Specification.new do |s| s.executables = ['scorm'] s.default_executable = 'scorm' - s.add_dependency('rubyzip', '~> 0.9.4') -end \ No newline at end of file + s.add_dependency('rubyzip', '~> 1.0.0') +end