Skip to content

Commit ab2da78

Browse files
committed
Configurable encoding.
1 parent 355406f commit ab2da78

File tree

2 files changed

+16
-11
lines changed

2 files changed

+16
-11
lines changed

lib/nanoc/github.rb

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ def client
2727
end
2828

2929
def decode(content)
30-
content = Base64.decode64(content).force_encoding(Encoding::UTF_8)
30+
content = Base64.decode64(content).force_encoding(encoding)
3131
matchdata = content.match(REGEX)
3232
metadata = matchdata ? YAML.safe_load(matchdata[:metadata], permitted_classes: [Time]) : {}
3333

@@ -48,6 +48,10 @@ def repository_items
4848
[]
4949
end
5050

51+
def encoding
52+
@config[:encoding] || "utf-8"
53+
end
54+
5155
def concurrency
5256
@config[:concurrency] || 5
5357
end

test/source_test.rb

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9,30 +9,31 @@ def site_config
99

1010
def source_with_posts
1111
Source.new(site_config, nil, nil, {
12-
repository: "pawelpacana/test-source",
13-
path: "posts",
14-
concurrency: 1
12+
repository: "pawelpacana/test-source",
13+
path: "posts",
14+
encoding: "utf-8",
15+
concurrency: 1,
1516
})
1617
end
1718

1819
def empty_source
1920
Source.new(site_config, nil, nil, {
20-
repository: "pawelpacana/test-empty",
21-
concurrency: 1
21+
repository: "pawelpacana/test-empty",
22+
concurrency: 1,
2223
})
2324
end
2425

2526
def empty_source_by_path
2627
Source.new(site_config, nil, nil, {
27-
repository: "pawelpacana/test-source",
28-
path: "dummy",
29-
concurrency: 1
28+
repository: "pawelpacana/test-source",
29+
path: "dummy",
30+
concurrency: 1,
3031
})
3132
end
3233

3334
def flat_source
3435
Source.new(site_config, nil, nil, {
35-
repository: "pawelpacana/test-source",
36+
repository: "pawelpacana/test-source",
3637
concurrency: 1
3738
})
3839
end
@@ -42,7 +43,7 @@ def source_with_token
4243
repository: "pawelpacana/test-source",
4344
path: "posts",
4445
access_token: "secret123",
45-
concurrency: 1
46+
concurrency: 1,
4647
})
4748
end
4849

0 commit comments

Comments
 (0)