moodle2cc 0.1.3 → 0.1.4
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/moodle2cc/cc/web_link.rb +5 -1
- data/lib/moodle2cc/version.rb +1 -1
- data/test/unit/cc/web_link_test.rb +20 -0
- metadata +4 -4
@@ -22,7 +22,11 @@ module Moodle2CC::CC
|
|
22
22
|
end
|
23
23
|
|
24
24
|
def self.external_link?(mod)
|
25
|
-
|
25
|
+
begin
|
26
|
+
!!URI.parse(mod.reference.to_s.strip.gsub(/\s/, '+')).scheme
|
27
|
+
rescue URI::InvalidURIError
|
28
|
+
!!mod.reference.strip.match(/^https?\:\/\//)
|
29
|
+
end
|
26
30
|
end
|
27
31
|
|
28
32
|
def create_resource_node(resources_node)
|
data/lib/moodle2cc/version.rb
CHANGED
@@ -53,6 +53,26 @@ class TestUnitCCWebLink < MiniTest::Unit::TestCase
|
|
53
53
|
assert_equal false, web_link.external_link
|
54
54
|
end
|
55
55
|
|
56
|
+
def test_it_converts_external_link_with_spaces_in_the_url
|
57
|
+
@mod.reference = "http://en.wikipedia.org/wiki/Einstein with a Space"
|
58
|
+
web_link = Moodle2CC::CC::WebLink.new @mod
|
59
|
+
assert_equal true, web_link.external_link
|
60
|
+
|
61
|
+
@mod.reference = "files/my file.txt"
|
62
|
+
web_link = Moodle2CC::CC::WebLink.new @mod
|
63
|
+
assert_equal false, web_link.external_link
|
64
|
+
end
|
65
|
+
|
66
|
+
def test_it_converts_external_link_with_completely_invalid_url
|
67
|
+
@mod.reference = 'http://!@#$%^&*'
|
68
|
+
web_link = Moodle2CC::CC::WebLink.new @mod
|
69
|
+
assert_equal true, web_link.external_link
|
70
|
+
|
71
|
+
@mod.reference = 'files/!@#$%^&*.txt'
|
72
|
+
web_link = Moodle2CC::CC::WebLink.new @mod
|
73
|
+
assert_equal false, web_link.external_link
|
74
|
+
end
|
75
|
+
|
56
76
|
def test_if_converts_href
|
57
77
|
@mod.reference = "http://en.wikipedia.org/wiki/Einstein"
|
58
78
|
web_link = Moodle2CC::CC::WebLink.new @mod
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: moodle2cc
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 19
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 1
|
9
|
-
-
|
10
|
-
version: 0.1.
|
9
|
+
- 4
|
10
|
+
version: 0.1.4
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Christopher Durtschi
|
@@ -17,7 +17,7 @@ autorequire:
|
|
17
17
|
bindir: bin
|
18
18
|
cert_chain: []
|
19
19
|
|
20
|
-
date: 2012-08-
|
20
|
+
date: 2012-08-15 00:00:00 Z
|
21
21
|
dependencies:
|
22
22
|
- !ruby/object:Gem::Dependency
|
23
23
|
name: rubyzip
|