mo 0.1.0 → 1.0.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.
data/bin/mo ADDED
@@ -0,0 +1,5 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'mo'
4
+
5
+ Mo::Runner.start
data/lib/mo.rb CHANGED
@@ -1,5 +1,59 @@
1
1
  # encoding: utf-8
2
- require 'mo/railtie' if defined?(Rails)
2
+ require 'boson/runner'
3
3
 
4
4
  module Mo
5
+ class Runner < Boson::Runner
6
+ RUBY_FILES = %w[**/*.haml **/*.ru **/*.rake Gemfile **/*.rb]
7
+ JS_FILES = %w[**/*.js **/*.coffee]
8
+ DOC_FILES = %w[**/*.md **/*.txt **/*.textile]
9
+ ALL_FILES = RUBY_FILES + JS_FILES + DOC_FILES
10
+
11
+ desc "Clean-up trailing whitespaces."
12
+ def whitespace
13
+ (RUBY_FILES + JS_FILES).map { |glob| Dir[glob] }.flatten.each do |file|
14
+ wsps = false
15
+ File.open(file).each_line do |line|
16
+ break if wsps = line.match(/( |\t)*$/).captures.compact.any?
17
+ end
18
+ if wsps
19
+ system "sed -e 's/[ \t]*$//' -i #{file}"
20
+ puts " * #{file}"
21
+ end
22
+ end
23
+ end
24
+
25
+ desc "Print files with more than 80 columns"
26
+ def eighty_column
27
+ ALL_FILES.map { |glob| Dir[glob] }.flatten.each do |file|
28
+ output = `grep -n '.\\{80,\\}' #{file}`
29
+ unless output.empty?
30
+ puts file
31
+ puts output
32
+ end
33
+ end
34
+ end
35
+
36
+ desc "Convert ruby hashes to 1.9 style."
37
+ def rocketless
38
+ RUBY_FILES.map { |glob| Dir[glob] }.flatten.each do |file|
39
+ source = File.open(file).read
40
+ regexp = /(?<!return)(?<!:)(?<!\w)(\s+):(\w+)\s*=>/
41
+ next if source.scan(regexp).any?
42
+ source.gsub!(regexp, '\1\2:')
43
+ open(file, 'w') { |b| b << source }
44
+ puts " * #{file}"
45
+ end
46
+ end
47
+
48
+ # Courtesy of changa.
49
+ desc "Add utf-8 encoding on files that don't have it"
50
+ def encoding
51
+ RUBY_FILES.map { |glob| Dir[glob] }.flatten.each do |file|
52
+ if `head -n 1 #{file}|grep '# encoding'`.empty?
53
+ system "sed -i -r '1 s/^(.*)$/# encoding: utf-8\\n\\1/g' #{file}"
54
+ puts " * #{file}"
55
+ end
56
+ end
57
+ end
58
+ end
5
59
  end
data/lib/mo/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # encoding: utf-8
2
2
 
3
3
  module Mo
4
- VERSION = "0.1.0"
4
+ VERSION = "1.0.0"
5
5
  end
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.1.0
4
+ version: 1.0.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,17 +9,33 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-07-04 00:00:00.000000000 Z
13
- dependencies: []
12
+ date: 2012-09-05 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: boson
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: '0'
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ! '>='
28
+ - !ruby/object:Gem::Version
29
+ version: '0'
14
30
  description: Mo helps you keep your rails project clean.
15
31
  email: jboyer@af83.com
16
- executables: []
32
+ executables:
33
+ - mo
17
34
  extensions: []
18
35
  extra_rdoc_files: []
19
36
  files:
37
+ - bin/mo
20
38
  - lib/mo.rb
21
- - lib/mo/railtie.rb
22
- - lib/mo/tasks.rake
23
39
  - lib/mo/version.rb
24
40
  homepage: https://github.com/chatgris/mo
25
41
  licenses: []
@@ -41,9 +57,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
41
57
  version: '0'
42
58
  requirements: []
43
59
  rubyforge_project:
44
- rubygems_version: 1.8.21
60
+ rubygems_version: 1.8.24
45
61
  signing_key:
46
62
  specification_version: 3
47
63
  summary: Mo helps you keep your rails project clean.
48
64
  test_files: []
49
- has_rdoc:
data/lib/mo/railtie.rb DELETED
@@ -1,8 +0,0 @@
1
- # encoding: utf-8
2
- module Mo
3
- class Railtie < Rails::Railtie
4
- rake_tasks do
5
- load File.dirname(__FILE__) + '/tasks.rake'
6
- end
7
- end
8
- end
data/lib/mo/tasks.rake DELETED
@@ -1,56 +0,0 @@
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