canvas_link_migrator 0.1.0 → 0.1.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
  SHA256:
3
- metadata.gz: 993c3428360b15aea7b4eca2ee43652342f4a700e23837794ffe913e1572dea1
4
- data.tar.gz: 5081c3aa602c6cf78fc3bd1e152a4c8e12f419fc6853ab72a9d09f86ba42498e
3
+ metadata.gz: 814327ff4502ff2b1187f0b817659cff573bb272ee7e85ae32685297f985ce55
4
+ data.tar.gz: e8fa4255d9200988f052ddc9b6a4087b72709ce5443c9bbff4558279be38c4c6
5
5
  SHA512:
6
- metadata.gz: d8d3068542e30d89ddffb809c95b59ba1a2665a515a65d8f6359ec3c1f7fd204560794a3d016fc861490561215e82aad126fdb1ff0ef0f9cd8d20c6ebc12c7bb
7
- data.tar.gz: b18abcf3c0b4e325cca73e10a905fea2d09c0f444230766eae955f842f8bde394765254cc9c9626ee7d6510251069e0aeed9061c81eb2c93df6b52e485aa5212
6
+ metadata.gz: fc23256c7587decc42dfe9b5677f6299c7ba31cc4aa14e2bda8aca60233ba5ffdc143b205419f4d9fd101b13a52e54a2de896dbd1f038a3d25a44e7d631f54cf
7
+ data.tar.gz: fd8ac04adf9829f958297818be79bff39910259cb9e8bb233689b117deb22cbce21df0c875c8d756e9dfa5c4dafb1ab4b5aaba717cfb10aa1a22d8b9574b52a5
@@ -32,7 +32,7 @@ module CanvasLinkMigrator
32
32
  end
33
33
 
34
34
  def resources
35
- migration_data["resource_mapping"]
35
+ migration_data["resource_mapping"] || {}
36
36
  end
37
37
 
38
38
  ### Overwritable methods
@@ -74,7 +74,14 @@ module CanvasLinkMigrator
74
74
 
75
75
  # looks up a discussion topic
76
76
  def convert_discussion_topic_migration_id(migration_id)
77
- resources.dig("discussion_topics", migration_id, "destination", "id")
77
+ dt_id = resources.dig("discussion_topics", migration_id, "destination", "id")
78
+ # the /discusson_topic url scheme is used for annnouncments as well.
79
+ # we'll check both here
80
+ dt_id || convert_announcement_migration_id(migration_id)
81
+ end
82
+
83
+ def convert_announcement_migration_id(migration_id)
84
+ resources.dig("announcements", migration_id, "destination", "id")
78
85
  end
79
86
 
80
87
  def convert_context_module_tag_migration_id(migration_id)
@@ -84,5 +91,16 @@ module CanvasLinkMigrator
84
91
  def convert_attachment_migration_id(migration_id)
85
92
  resources.dig("files", migration_id, "destination", "id")
86
93
  end
94
+
95
+ def convert_migration_id(type, migration_id)
96
+ type = "modules" if type == "context_modules"
97
+ id = if CanvasLinkMigrator::LinkParser::KNOWN_REFERENCE_TYPES.include? type
98
+ resources.dig(type, migration_id, "destination", "id")
99
+ end
100
+ return id if id.present?
101
+ # the /discusson_topic url scheme is used for annnouncments as well.
102
+ # we'll check both here
103
+ convert_announcement_migration_id(migration_id) if type == "discussion_topics"
104
+ end
87
105
  end
88
106
  end
@@ -62,5 +62,23 @@ describe CanvasLinkMigrator::LinkResolver do
62
62
  resolver.resolve_link!(link)
63
63
  expect(link[:new_value]).to eq("/courses/2/discussion_topics/7?foo=bar")
64
64
  end
65
+
66
+ it "converts announcement links" do
67
+ link = { link_type: :discussion_topic, migration_id: "H", query: "?foo=bar" }
68
+ resolver.resolve_link!(link)
69
+ expect(link[:new_value]).to eq("/courses/2/discussion_topics/10?foo=bar")
70
+ end
71
+
72
+ it "converts module links" do
73
+ link = { link_type: :object, type: "modules", migration_id: "J", query: "?foo=bar" }
74
+ resolver.resolve_link!(link)
75
+ expect(link[:new_value]).to eq("/courses/2/modules/36?foo=bar")
76
+ end
77
+
78
+ it "converters other links" do
79
+ link = { link_type: :object, type: "assignments", migration_id: "I", query: "#fie" }
80
+ resolver.resolve_link!(link)
81
+ expect(link[:new_value]).to eq("/courses/2/assignments/12#fie")
82
+ end
65
83
  end
66
84
  end
@@ -7,6 +7,26 @@
7
7
  ],
8
8
  "destination_root_folder": "course files/",
9
9
  "resource_mapping": {
10
+ "announcements": {
11
+ "H": {
12
+ "source": {
13
+ "id": "9"
14
+ },
15
+ "destination": {
16
+ "id": "10"
17
+ }
18
+ }
19
+ },
20
+ "assignments": {
21
+ "I": {
22
+ "source": {
23
+ "id": "11"
24
+ },
25
+ "destination": {
26
+ "id": "12"
27
+ }
28
+ }
29
+ },
10
30
  "discussion_topics": {
11
31
  "G": {
12
32
  "destination": {
@@ -49,6 +69,16 @@
49
69
  }
50
70
  }
51
71
  },
72
+ "modules": {
73
+ "J": {
74
+ "destination": {
75
+ "id": "36"
76
+ },
77
+ "source": {
78
+ "id": "22"
79
+ }
80
+ }
81
+ },
52
82
  "wiki_pages": {
53
83
  "A": {
54
84
  "destination": {
metadata CHANGED
@@ -1,14 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: canvas_link_migrator
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mysti Lilla
8
+ - James Logan
8
9
  autorequire:
9
10
  bindir: bin
10
11
  cert_chain: []
11
- date: 2023-07-20 00:00:00.000000000 Z
12
+ date: 2023-07-31 00:00:00.000000000 Z
12
13
  dependencies:
13
14
  - !ruby/object:Gem::Dependency
14
15
  name: activesupport
@@ -97,6 +98,7 @@ dependencies:
97
98
  description:
98
99
  email:
99
100
  - mysti@instructure.com
101
+ - james.logan@instructure.com
100
102
  executables: []
101
103
  extensions: []
102
104
  extra_rdoc_files: []