File tree Expand file tree Collapse file tree 2 files changed +40
-1
lines changed Expand file tree Collapse file tree 2 files changed +40
-1
lines changed Original file line number Diff line number Diff line change @@ -5,13 +5,20 @@ class ExtractSnippet
5
5
initialize_with :code , :language
6
6
7
7
def call
8
+ processed_lines [ 0 ...10 ] . join
9
+ end
10
+
11
+ private
12
+ def processed_lines
8
13
lines . drop_while do |line |
9
14
naked_line = line . strip
10
15
next true if naked_line . empty?
11
16
next true if ignore_list . any? { |ignore | naked_line . start_with? ( ignore ) }
12
17
13
18
false
14
- end [ 0 ...10 ] . join
19
+ end
20
+ rescue Errno ::ENOENT
21
+ lines
15
22
end
16
23
17
24
def lines
Original file line number Diff line number Diff line change 3
3
module SnippetExtractor
4
4
module Languages
5
5
class RubyTest < Minitest ::Test
6
+ def test_returns_first_10_loc_on_missing_language
7
+ code = <<~CODE
8
+ Loc 1
9
+ Loc 2
10
+ Loc 3
11
+ Loc 4
12
+ Loc 5
13
+ Loc 6
14
+ Loc 6
15
+ Loc 8
16
+ Loc 9
17
+ Loc 10
18
+ Loc 11
19
+ Loc 12
20
+ CODE
21
+
22
+ expected = <<~CODE
23
+ Loc 1
24
+ Loc 2
25
+ Loc 3
26
+ Loc 4
27
+ Loc 5
28
+ Loc 6
29
+ Loc 6
30
+ Loc 8
31
+ Loc 9
32
+ Loc 10
33
+ CODE
34
+
35
+ assert_equal expected , ExtractSnippet . ( code , :foobar )
36
+ end
37
+
6
38
def test_strips_correctly
7
39
code = <<~CODE
8
40
# This is a file
You can’t perform that action at this time.
0 commit comments