Skip to content

Commit a1cfc8e

Browse files
committed
remove duplicated methods and incorrect private
1 parent 8792a78 commit a1cfc8e

File tree

2 files changed

+9
-30
lines changed

2 files changed

+9
-30
lines changed

app/controllers/textbooks_controller.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ def create
2626
lms_course_num: 9999999
2727
)
2828

29-
cloned_book = inst_book.get_clone(current_user)
29+
cloned_book = inst_book.clone(current_user)
3030

3131
if course_offering.save!
3232
cloned_book.course_offering_id = course_offering.id
@@ -56,4 +56,4 @@ def create
5656
end
5757
end
5858

59-
end
59+
end

app/models/inst_book.rb

Lines changed: 7 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -136,9 +136,9 @@ def validate_configuration
136136
def extract_av_data_from_rst
137137
av_data = {}
138138
parsed_options = parse_json_options(self.options)
139-
lang = parsed_options['lang'] || 'en'
139+
lang = parsed_options['lang'] || 'en'
140140
rst_folder = File.join('public', 'OpenDSA', 'RST', lang)
141-
141+
142142
# Check if rst_folder to prevent Dir.glob from failing
143143
return av_data unless Dir.exist?(rst_folder)
144144

@@ -166,29 +166,8 @@ def extract_av_data_from_rst
166166
av_data
167167
end
168168

169-
def get_clone(currentUser)
170-
return clone(currentUser)
171-
end
172-
private
173-
174-
def extract_metadata_from_line(line)
175-
key, value = line.strip.split(': ', 2)
176-
[key[1..].to_sym, value] if key && value
177-
end
178-
179-
def extract_inlineav_name_from_line(line)
180-
match = line.match(/\.\. inlineav:: (\w+)/)
181-
match[1] if match # Returns the inlineav short name or nil if no match
182-
end
183-
184-
def extract_avembed_data_from_line(line)
185-
match = line.match(/\.\. avembed:: Exercises\/\w+\/(\w+)\.html/)
186-
match[1] if match # Returns the 3rd level word or nil if no match
187-
end
188-
189-
190169

191-
# --------------------------------------------------------------------------------
170+
# --------------------------------------------------------------------------------
192171
# FIXME: shouldn't this method be removed? It appears to be out-dated?
193172
# FIXME: the real code is now in views/inst_books/show.json.builder
194173
def to_builder
@@ -330,20 +309,20 @@ def extract_metadata_from_line(line)
330309

331310
def extract_inlineav_name_from_line(line)
332311
match = line.match(/\.\. inlineav:: (\w+)/)
333-
match[1] if match
312+
match[1] if match
334313
end
335314

336315
def extract_avembed_data_from_line(line)
337316
match = line.match(/\.\. avembed:: Exercises\/\w+\/(\w+)\.html/)
338-
match[1] if match
317+
match[1] if match
339318
end
340319

341320
# helper method for extract_av_data_from_rst(), safely attempts to parse a JSON string, returning an empty hash as fallback
342321
def parse_json_options(json_str)
343322
return {} if json_str.nil? # Ensures nil input returns an empty hash
344-
JSON.parse(json_str || '{}')
323+
JSON.parse(json_str || '{}')
345324
rescue JSON::ParserError
346-
{}
325+
{}
347326
end
348327

349328
end

0 commit comments

Comments
 (0)