magic-commenter 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +3 -0
- data/Gemfile +4 -0
- data/Gemfile.lock +15 -0
- data/README.md +9 -0
- data/Rakefile +2 -0
- data/bin/magic-commenter +6 -0
- data/lib/magic-commenter.rb +33 -0
- data/lib/magic-commenter/version.rb +5 -0
- data/magic-commenter.gemspec +20 -0
- metadata +89 -0
data/.gitignore
ADDED
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
data/README.md
ADDED
data/Rakefile
ADDED
data/bin/magic-commenter
ADDED
@@ -0,0 +1,33 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
require 'stringio'
|
3
|
+
require 'open3'
|
4
|
+
|
5
|
+
module Magic
|
6
|
+
class Commenter
|
7
|
+
|
8
|
+
include Open3
|
9
|
+
|
10
|
+
def initialize(files)
|
11
|
+
for file in files
|
12
|
+
errors = []
|
13
|
+
popen3("ruby -c #{file}") do |stdin, stdout, stderr|
|
14
|
+
errors = stderr.read.split("\n")
|
15
|
+
end
|
16
|
+
|
17
|
+
if errors.any?{|error| error.include?("invalid multibyte char")}
|
18
|
+
puts ">> Fixing #{file}"
|
19
|
+
add_magic_comment(file)
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
def add_magic_comment(file)
|
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
|
30
|
+
end
|
31
|
+
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
require File.expand_path("../lib/magic-commenter/version", __FILE__)
|
3
|
+
|
4
|
+
Gem::Specification.new do |s|
|
5
|
+
s.name = "magic-commenter"
|
6
|
+
s.version = Magic::Commenter::VERSION
|
7
|
+
s.platform = Gem::Platform::RUBY
|
8
|
+
s.authors = ["Albert llop"]
|
9
|
+
s.email = ["mrsimo@gmail.com"]
|
10
|
+
s.summary = "Add magic comments to your ruby files"
|
11
|
+
|
12
|
+
s.required_rubygems_version = ">= 1.3.6"
|
13
|
+
s.rubyforge_project = "magic-commenter"
|
14
|
+
|
15
|
+
s.add_development_dependency "bundler", ">= 1.0.0"
|
16
|
+
|
17
|
+
s.files = `git ls-files`.split("\n")
|
18
|
+
s.executables = ["magic-commenter"]
|
19
|
+
s.require_path = 'lib'
|
20
|
+
end
|
metadata
ADDED
@@ -0,0 +1,89 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: magic-commenter
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
prerelease: false
|
5
|
+
segments:
|
6
|
+
- 0
|
7
|
+
- 0
|
8
|
+
- 1
|
9
|
+
version: 0.0.1
|
10
|
+
platform: ruby
|
11
|
+
authors:
|
12
|
+
- Albert llop
|
13
|
+
autorequire:
|
14
|
+
bindir: bin
|
15
|
+
cert_chain: []
|
16
|
+
|
17
|
+
date: 2010-09-15 00:00:00 +02:00
|
18
|
+
default_executable:
|
19
|
+
dependencies:
|
20
|
+
- !ruby/object:Gem::Dependency
|
21
|
+
name: bundler
|
22
|
+
prerelease: false
|
23
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
24
|
+
none: false
|
25
|
+
requirements:
|
26
|
+
- - ">="
|
27
|
+
- !ruby/object:Gem::Version
|
28
|
+
segments:
|
29
|
+
- 1
|
30
|
+
- 0
|
31
|
+
- 0
|
32
|
+
version: 1.0.0
|
33
|
+
type: :development
|
34
|
+
version_requirements: *id001
|
35
|
+
description:
|
36
|
+
email:
|
37
|
+
- mrsimo@gmail.com
|
38
|
+
executables:
|
39
|
+
- magic-commenter
|
40
|
+
extensions: []
|
41
|
+
|
42
|
+
extra_rdoc_files: []
|
43
|
+
|
44
|
+
files:
|
45
|
+
- .gitignore
|
46
|
+
- Gemfile
|
47
|
+
- Gemfile.lock
|
48
|
+
- README.md
|
49
|
+
- Rakefile
|
50
|
+
- bin/magic-commenter
|
51
|
+
- lib/magic-commenter.rb
|
52
|
+
- lib/magic-commenter/version.rb
|
53
|
+
- magic-commenter.gemspec
|
54
|
+
has_rdoc: true
|
55
|
+
homepage:
|
56
|
+
licenses: []
|
57
|
+
|
58
|
+
post_install_message:
|
59
|
+
rdoc_options: []
|
60
|
+
|
61
|
+
require_paths:
|
62
|
+
- lib
|
63
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
64
|
+
none: false
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
segments:
|
69
|
+
- 0
|
70
|
+
version: "0"
|
71
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
72
|
+
none: false
|
73
|
+
requirements:
|
74
|
+
- - ">="
|
75
|
+
- !ruby/object:Gem::Version
|
76
|
+
segments:
|
77
|
+
- 1
|
78
|
+
- 3
|
79
|
+
- 6
|
80
|
+
version: 1.3.6
|
81
|
+
requirements: []
|
82
|
+
|
83
|
+
rubyforge_project: magic-commenter
|
84
|
+
rubygems_version: 1.3.7
|
85
|
+
signing_key:
|
86
|
+
specification_version: 3
|
87
|
+
summary: Add magic comments to your ruby files
|
88
|
+
test_files: []
|
89
|
+
|