mo 0.0.3 → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/mo.rb +1 -2
- data/lib/mo/railtie.rb +1 -50
- data/lib/mo/tasks.rake +56 -0
- data/lib/mo/version.rb +1 -1
- metadata +5 -3
data/lib/mo.rb
CHANGED
data/lib/mo/railtie.rb
CHANGED
@@ -2,56 +2,7 @@
|
|
2
2
|
module Mo
|
3
3
|
class Railtie < Rails::Railtie
|
4
4
|
rake_tasks do
|
5
|
-
|
6
|
-
|
7
|
-
namespace :mo do
|
8
|
-
|
9
|
-
desc "Clean-up trailing whitespaces."
|
10
|
-
task :whitespace do
|
11
|
-
globs = %w[ app/**/*.rb app/**/*.haml app/**/*.js app/**/*.coffee lib/**/*.rb spec/**/*.rb lib/**/*.rake Gemfile config/**/*.rb config/**/*.yml]
|
12
|
-
globs.map { |glob| Dir[glob] }.flatten.each do |file|
|
13
|
-
puts file
|
14
|
-
system "sed -e 's/[ \t]*$//' -i #{file}"
|
15
|
-
end
|
16
|
-
end
|
17
|
-
|
18
|
-
desc "Convert ruby hashes to 1.9 style."
|
19
|
-
task :rocketless do
|
20
|
-
Dir['**/*.rb'].each do |file|
|
21
|
-
source = File.open(file).read
|
22
|
-
regexp = /(?<!return)(?<!:)(?<!\w)(\s+):(\w+)\s*=>/
|
23
|
-
next if source.scan(regexp).size.zero?
|
24
|
-
source.gsub!(regexp, '\1\2:')
|
25
|
-
open(file, 'w') { |b| b << source }
|
26
|
-
end
|
27
|
-
end
|
28
|
-
|
29
|
-
# Courtesy of changa.
|
30
|
-
desc "Add utf-8 encoding on files that don't have it"
|
31
|
-
task :encoding do
|
32
|
-
require 'find'
|
33
|
-
files_to_convert = []
|
34
|
-
|
35
|
-
Find.find Rails.root.to_s do |f|
|
36
|
-
if File.file?(f) && f =~ /\.(rb|feature|rake)$/ && `head -n 1 #{f}|grep '# encoding'`.empty?
|
37
|
-
files_to_convert << f
|
38
|
-
end
|
39
|
-
end
|
40
|
-
|
41
|
-
print "Converting #{files_to_convert.size} files"
|
42
|
-
puts if verbose
|
43
|
-
files_to_convert.each do |f|
|
44
|
-
system "sed -i -r '1 s/^(.*)$/# encoding: utf-8\\n\\1/g' #{f}"
|
45
|
-
if verbose
|
46
|
-
puts " * #{f}"
|
47
|
-
else
|
48
|
-
print '.'
|
49
|
-
end
|
50
|
-
end
|
51
|
-
puts unless verbose
|
52
|
-
|
53
|
-
end
|
54
|
-
end
|
5
|
+
load File.dirname(__FILE__) + '/tasks.rake'
|
55
6
|
end
|
56
7
|
end
|
57
8
|
end
|
data/lib/mo/tasks.rake
ADDED
@@ -0,0 +1,56 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
module Mo
|
3
|
+
module Tasks
|
4
|
+
require 'rake'
|
5
|
+
extend Rake::DSL
|
6
|
+
|
7
|
+
namespace :mo do
|
8
|
+
|
9
|
+
desc "Clean-up trailing whitespaces."
|
10
|
+
task :whitespace do
|
11
|
+
globs = %w[ app/**/*.rb app/**/*.haml app/**/*.js app/**/*.coffee lib/**/*.rb spec/**/*.rb lib/**/*.rake Gemfile config/**/*.rb config/**/*.yml]
|
12
|
+
globs.map { |glob| Dir[glob] }.flatten.each do |file|
|
13
|
+
puts file
|
14
|
+
system "sed -e 's/[ \t]*$//' -i #{file}"
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
desc "Convert ruby hashes to 1.9 style."
|
19
|
+
task :rocketless do
|
20
|
+
Dir['**/*.rb'].each do |file|
|
21
|
+
source = File.open(file).read
|
22
|
+
regexp = /(?<!return)(?<!:)(?<!\w)(\s+):(\w+)\s*=>/
|
23
|
+
next if source.scan(regexp).size.zero?
|
24
|
+
source.gsub!(regexp, '\1\2:')
|
25
|
+
open(file, 'w') { |b| b << source }
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
# Courtesy of changa.
|
30
|
+
desc "Add utf-8 encoding on files that don't have it"
|
31
|
+
task :encoding do
|
32
|
+
require 'find'
|
33
|
+
files_to_convert = []
|
34
|
+
|
35
|
+
Find.find Dir.pwd.to_s do |f|
|
36
|
+
if File.file?(f) && f =~ /\.(rb|feature|rake)$/ && `head -n 1 #{f}|grep '# encoding'`.empty?
|
37
|
+
files_to_convert << f
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
print "Converting #{files_to_convert.size} files"
|
42
|
+
puts if verbose
|
43
|
+
files_to_convert.each do |f|
|
44
|
+
system "sed -i -r '1 s/^(.*)$/# encoding: utf-8\\n\\1/g' #{f}"
|
45
|
+
if verbose
|
46
|
+
puts " * #{f}"
|
47
|
+
else
|
48
|
+
print '.'
|
49
|
+
end
|
50
|
+
end
|
51
|
+
puts unless verbose
|
52
|
+
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
data/lib/mo/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mo
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 0.1.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-
|
12
|
+
date: 2012-07-04 00:00:00.000000000 Z
|
13
13
|
dependencies: []
|
14
14
|
description: Mo helps you keep your rails project clean.
|
15
15
|
email: jboyer@af83.com
|
@@ -19,6 +19,7 @@ extra_rdoc_files: []
|
|
19
19
|
files:
|
20
20
|
- lib/mo.rb
|
21
21
|
- lib/mo/railtie.rb
|
22
|
+
- lib/mo/tasks.rake
|
22
23
|
- lib/mo/version.rb
|
23
24
|
homepage: https://github.com/chatgris/mo
|
24
25
|
licenses: []
|
@@ -40,8 +41,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
40
41
|
version: '0'
|
41
42
|
requirements: []
|
42
43
|
rubyforge_project:
|
43
|
-
rubygems_version: 1.8.
|
44
|
+
rubygems_version: 1.8.21
|
44
45
|
signing_key:
|
45
46
|
specification_version: 3
|
46
47
|
summary: Mo helps you keep your rails project clean.
|
47
48
|
test_files: []
|
49
|
+
has_rdoc:
|