fluent-plugin-github-activities 0.6.1 → 0.7.0

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.
@@ -1,46 +0,0 @@
1
- # -*- coding: utf-8 -*-
2
- #
3
- # This file is part of fluent-plugin-github-activities.
4
- #
5
- # fluent-plugin-github-activities is free software: you can
6
- # redistribute it and/or modify it under the terms of the GNU Lesser
7
- # General Public License as published by the Free Software
8
- # Foundation, either version 3 of the License, or (at your option)
9
- # any later version.
10
- #
11
- # fluent-plugin-github-activities is distributed in the hope that
12
- # it will be useful, but WITHOUT ANY WARRANTY; without even the
13
- # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
14
- # PURPOSE. See the GNU Lesser General Public License for more details.
15
- #
16
- # You should have received a copy of the GNU Lesser General Public
17
- # License along with fluent-plugin-github-activities. If not, see
18
- # <http://www.gnu.org/licenses/>.
19
-
20
- require "pathname"
21
- require "fileutils"
22
- require "tempfile"
23
-
24
- module Fluent
25
- module GithubActivities
26
- class SafeFileWriter
27
- class << self
28
- def write(path, contents=nil)
29
- # Don't output the file directly to prevent loading of incomplete file!
30
- path = Pathname(path).expand_path
31
- FileUtils.mkdir_p(path.dirname.to_s)
32
- Tempfile.open(path.basename.to_s, path.dirname.to_s) do |output|
33
- if block_given?
34
- yield(output, output.path)
35
- else
36
- output.write(contents)
37
- end
38
- output.flush
39
- File.rename(output.path, path.to_s)
40
- end
41
- end
42
- end
43
- end
44
- end
45
- end
46
-