canvas_link_migrator 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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 993c3428360b15aea7b4eca2ee43652342f4a700e23837794ffe913e1572dea1
4
- data.tar.gz: 5081c3aa602c6cf78fc3bd1e152a4c8e12f419fc6853ab72a9d09f86ba42498e
3
+ metadata.gz: 5e4d3a30191584ee3b4bc14c83f21edecbad0652562590eee989047f99e1d050
4
+ data.tar.gz: fb9825fc75bb255068dfb1f5d2f285e332612657690f6bc08933c99ae4d948bb
5
5
  SHA512:
6
- metadata.gz: d8d3068542e30d89ddffb809c95b59ba1a2665a515a65d8f6359ec3c1f7fd204560794a3d016fc861490561215e82aad126fdb1ff0ef0f9cd8d20c6ebc12c7bb
7
- data.tar.gz: b18abcf3c0b4e325cca73e10a905fea2d09c0f444230766eae955f842f8bde394765254cc9c9626ee7d6510251069e0aeed9061c81eb2c93df6b52e485aa5212
6
+ metadata.gz: 5847f829a7938282cfd2399fe3067dc72a5d248b95c2c38d35716d58ea12a019fff94e5b6cc0b34d09ff0bb4efae0dcc4ebef98baf771f999d9a73c865e9fba5
7
+ data.tar.gz: 25e4c872ded3277e7980bd99a7cbfc961d44a1a984840c8bfe8efb24052b0c36e0ac3c6c8e72f10a74072c14072ba89bd96f81305f2261abc0da0a5d67dbc389
@@ -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,15 @@ 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
+ id = if CanvasLinkMigrator::LinkParser::KNOWN_REFERENCE_TYPES.include? type
97
+ resources.dig(type, migration_id, "destination", "id")
98
+ end
99
+ return id if id.present?
100
+ # the /discusson_topic url scheme is used for annnouncments as well.
101
+ # we'll check both here
102
+ convert_announcement_migration_id(migration_id) if type == "discussion_topics"
103
+ end
87
104
  end
88
105
  end
@@ -62,5 +62,17 @@ 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 "converters other links" do
73
+ link = { link_type: :object, type: "assignments", migration_id: "I", query: "#fie" }
74
+ resolver.resolve_link!(link)
75
+ expect(link[:new_value]).to eq("/courses/2/assignments/12#fie")
76
+ end
65
77
  end
66
78
  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": {
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.1
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-25 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: []