magic-commenter 0.0.1 → 0.0.3
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.
- data/Gemfile.lock +1 -1
- data/lib/magic-commenter.rb +23 -15
- data/lib/magic-commenter/version.rb +1 -1
- metadata +8 -24
data/Gemfile.lock
CHANGED
data/lib/magic-commenter.rb
CHANGED
@@ -8,25 +8,33 @@ module Magic
|
|
8
8
|
include Open3
|
9
9
|
|
10
10
|
def initialize(files)
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
11
|
+
files.sort!
|
12
|
+
|
13
|
+
threads = []
|
14
|
+
|
15
|
+
2.times do |i|
|
16
|
+
threads << Thread.new do
|
17
|
+
while(file = files.shift)
|
18
|
+
puts "Thread-#{i}: checking #{file}"
|
19
|
+
firstline = File.readlines(file).first
|
20
|
+
if firstline && !firstline.include?("encoding: utf-8")
|
21
|
+
stdin, stdout, stderr = popen3("ruby -c #{file}")
|
22
|
+
errors = stderr.read
|
16
23
|
|
17
|
-
|
18
|
-
|
19
|
-
|
24
|
+
if errors && errors.include?("invalid multibyte char")
|
25
|
+
puts ">> Fixing #{file}"
|
26
|
+
contents = "# -*- encoding: utf-8 -*-\n" + File.read(file)
|
27
|
+
File.open(file,"w") do |f|
|
28
|
+
f.write contents
|
29
|
+
f.close
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
20
34
|
end
|
21
35
|
end
|
22
|
-
end
|
23
36
|
|
24
|
-
|
25
|
-
contents = "# -*- encoding: utf-8 -*-\n" + File.read(file)
|
26
|
-
File.open(file,"w") do |f|
|
27
|
-
f.write contents
|
28
|
-
f.close
|
29
|
-
end
|
37
|
+
threads.each(&:join)
|
30
38
|
end
|
31
39
|
|
32
40
|
end
|
metadata
CHANGED
@@ -1,12 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: magic-commenter
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
|
5
|
-
segments:
|
6
|
-
- 0
|
7
|
-
- 0
|
8
|
-
- 1
|
9
|
-
version: 0.0.1
|
4
|
+
version: 0.0.3
|
10
5
|
platform: ruby
|
11
6
|
authors:
|
12
7
|
- Albert llop
|
@@ -19,19 +14,14 @@ default_executable:
|
|
19
14
|
dependencies:
|
20
15
|
- !ruby/object:Gem::Dependency
|
21
16
|
name: bundler
|
22
|
-
|
23
|
-
|
24
|
-
|
17
|
+
type: :development
|
18
|
+
version_requirement:
|
19
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
20
|
requirements:
|
26
21
|
- - ">="
|
27
22
|
- !ruby/object:Gem::Version
|
28
|
-
segments:
|
29
|
-
- 1
|
30
|
-
- 0
|
31
|
-
- 0
|
32
23
|
version: 1.0.0
|
33
|
-
|
34
|
-
version_requirements: *id001
|
24
|
+
version:
|
35
25
|
description:
|
36
26
|
email:
|
37
27
|
- mrsimo@gmail.com
|
@@ -61,27 +51,21 @@ rdoc_options: []
|
|
61
51
|
require_paths:
|
62
52
|
- lib
|
63
53
|
required_ruby_version: !ruby/object:Gem::Requirement
|
64
|
-
none: false
|
65
54
|
requirements:
|
66
55
|
- - ">="
|
67
56
|
- !ruby/object:Gem::Version
|
68
|
-
segments:
|
69
|
-
- 0
|
70
57
|
version: "0"
|
58
|
+
version:
|
71
59
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
72
|
-
none: false
|
73
60
|
requirements:
|
74
61
|
- - ">="
|
75
62
|
- !ruby/object:Gem::Version
|
76
|
-
segments:
|
77
|
-
- 1
|
78
|
-
- 3
|
79
|
-
- 6
|
80
63
|
version: 1.3.6
|
64
|
+
version:
|
81
65
|
requirements: []
|
82
66
|
|
83
67
|
rubyforge_project: magic-commenter
|
84
|
-
rubygems_version: 1.3.
|
68
|
+
rubygems_version: 1.3.5
|
85
69
|
signing_key:
|
86
70
|
specification_version: 3
|
87
71
|
summary: Add magic comments to your ruby files
|