@@ -17,7 +17,7 @@ impl ChallengeConverter {
1717
1818 pub fn convert_chunk_to_challenge ( & self , chunk : CodeChunk ) -> Challenge {
1919 let id = Uuid :: new_v4 ( ) . to_string ( ) ;
20- let language = self . language_to_string ( & chunk. language ) ;
20+ let language = chunk. language . to_string ( ) ;
2121 let file_path = chunk. file_path . to_string_lossy ( ) . to_string ( ) ;
2222
2323 Challenge :: new ( id, chunk. content )
@@ -84,7 +84,7 @@ impl ChallengeConverter {
8484 for file_path in file_paths {
8585 if let Ok ( content) = std:: fs:: read_to_string ( & file_path) {
8686 let id = Uuid :: new_v4 ( ) . to_string ( ) ;
87- let language = self . detect_language_from_path ( & file_path) ;
87+ let language = super :: Language :: detect_from_path ( & file_path) ;
8888 let file_path_str = file_path. to_string_lossy ( ) . to_string ( ) ;
8989
9090 let line_count = content. lines ( ) . count ( ) ;
@@ -100,18 +100,6 @@ impl ChallengeConverter {
100100 challenges
101101 }
102102
103- fn detect_language_from_path ( & self , path : & std:: path:: Path ) -> String {
104- match path. extension ( ) . and_then ( |ext| ext. to_str ( ) ) {
105- Some ( "rs" ) => "rust" . to_string ( ) ,
106- Some ( "ts" ) | Some ( "tsx" ) => "typescript" . to_string ( ) ,
107- Some ( "py" ) => "python" . to_string ( ) ,
108- Some ( "go" ) => "go" . to_string ( ) ,
109- Some ( "rb" ) => "ruby" . to_string ( ) ,
110- Some ( "js" ) | Some ( "jsx" ) => "javascript" . to_string ( ) ,
111- _ => "text" . to_string ( ) ,
112- }
113- }
114-
115103 fn split_chunk_by_difficulty (
116104 & self ,
117105 chunk : & CodeChunk ,
@@ -177,7 +165,7 @@ impl ChallengeConverter {
177165 // Only create challenge if it meets minimum size for this difficulty
178166 if truncated_code_chars >= min_chars {
179167 let id = Uuid :: new_v4 ( ) . to_string ( ) ;
180- let language = self . language_to_string ( & chunk. language ) ;
168+ let language = chunk. language . to_string ( ) ;
181169 let file_path = chunk. file_path . to_string_lossy ( ) . to_string ( ) ;
182170
183171 let challenge = Challenge :: new ( id, truncated_content. to_string ( ) )
@@ -326,7 +314,7 @@ impl ChallengeConverter {
326314 for file_path in file_paths {
327315 if let Ok ( content) = std:: fs:: read_to_string ( & file_path) {
328316 let id = uuid:: Uuid :: new_v4 ( ) . to_string ( ) ;
329- let language = self . detect_language_from_path ( & file_path) ;
317+ let language = super :: Language :: detect_from_path ( & file_path) ;
330318 let file_path_str = file_path. to_string_lossy ( ) . to_string ( ) ;
331319
332320 let line_count = content. lines ( ) . count ( ) ;
@@ -341,16 +329,4 @@ impl ChallengeConverter {
341329
342330 zen_challenges
343331 }
344-
345- fn language_to_string ( & self , language : & super :: Language ) -> String {
346- match language {
347- super :: Language :: Rust => "rust" . to_string ( ) ,
348- super :: Language :: TypeScript => "typescript" . to_string ( ) ,
349- super :: Language :: Python => "python" . to_string ( ) ,
350- super :: Language :: Ruby => "ruby" . to_string ( ) ,
351- super :: Language :: Go => "go" . to_string ( ) ,
352- super :: Language :: Swift => "swift" . to_string ( ) ,
353- super :: Language :: Kotlin => "kotlin" . to_string ( ) ,
354- }
355- }
356332}
0 commit comments