nothing_magical 0.0.1

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/.gitignore ADDED
@@ -0,0 +1,17 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
data/CHANGELOG ADDED
@@ -0,0 +1,3 @@
1
+ = 0.0.1 (June 27, 2013)
2
+
3
+ * Initial release
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in nothing_magical.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2013 Richard Lee
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,22 @@
1
+ # NothingMagical
2
+
3
+ > A simple utility to remove all magic encoding comments on Ruby source code files.
4
+
5
+ In [Ruby 2.0](http://www.ruby-lang.org/en/news/2013/02/24/ruby-2-0-0-p0-is-released/), one of the major change is that UTF-8 becomes the default encoding of Ruby source code files, which makes many magic comments omissible.
6
+
7
+ ## Usage
8
+
9
+ Currently this gem removes comments from Ruby, Rake and Haml source files.
10
+
11
+ ```bash
12
+ gem i nothing_magical
13
+ nothing_magical .
14
+ ```
15
+
16
+ ## Credits
17
+
18
+ NothingMagical was inspired by Manuel Ryan's [magic_encoding](https://github.com/m-ryan/magic_encoding) gem, which adds magic comments for Ruby source code files.
19
+
20
+ ## License
21
+
22
+ NothingMagical is available under the MIT license. See the LICENSE file for more info.
data/Rakefile ADDED
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env ruby
2
+ require 'nothing_magical'
3
+
4
+ if ARGV.empty?
5
+ abort "usage: nothing_magical directory"
6
+ end
7
+
8
+ NothingMagical.process(ARGV)
@@ -0,0 +1,26 @@
1
+ require "nothing_magical/version"
2
+
3
+ module NothingMagical
4
+ def self.process(directory)
5
+ extensions = ['rb', 'rake', 'haml']
6
+
7
+ count = 0
8
+ extensions.each do |ext|
9
+ rbfiles = File.join(directory ,'**', '*.' + ext)
10
+ Dir.glob(rbfiles).each do |filename|
11
+ lines = File.readlines(filename)
12
+
13
+ # remove current encoding comment(s)
14
+ while lines[0].match(/^-?# ?(-\*-)? ?(en)?coding/)
15
+ lines.shift
16
+ count += 1
17
+ end
18
+
19
+ File.write(filename, lines.join)
20
+ end
21
+ end
22
+
23
+ puts "Magic comments removed for #{count} source files"
24
+ end
25
+ end
26
+
@@ -0,0 +1,3 @@
1
+ module NothingMagical
2
+ VERSION = "0.0.1"
3
+ end
@@ -0,0 +1,24 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'nothing_magical/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "nothing_magical"
8
+ spec.version = NothingMagical::VERSION
9
+ spec.authors = ["Richard Lee"]
10
+ spec.email = ["dlackty@gmail.com"]
11
+ spec.description = "Easily remove all magic encoding comments for Ruby source files."
12
+ spec.summary = spec.description
13
+ spec.homepage = "https://github.com/dlackty/nothing_magical"
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files`.split($/)
17
+ spec.executables =["nothing_magical"]
18
+ spec.require_paths = ["lib"]
19
+ spec.has_rdoc = false
20
+
21
+ spec.default_executable = %q{nothing_magical}
22
+
23
+ spec.add_development_dependency 'rake'
24
+ end
metadata ADDED
@@ -0,0 +1,79 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: nothing_magical
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Richard Lee
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2013-07-26 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: rake
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: '0'
22
+ type: :development
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ! '>='
28
+ - !ruby/object:Gem::Version
29
+ version: '0'
30
+ description: Easily remove all magic encoding comments for Ruby source files.
31
+ email:
32
+ - dlackty@gmail.com
33
+ executables:
34
+ - nothing_magical
35
+ extensions: []
36
+ extra_rdoc_files: []
37
+ files:
38
+ - .gitignore
39
+ - CHANGELOG
40
+ - Gemfile
41
+ - LICENSE.txt
42
+ - README.md
43
+ - Rakefile
44
+ - bin/nothing_magical
45
+ - lib/nothing_magical.rb
46
+ - lib/nothing_magical/version.rb
47
+ - nothing_magical.gemspec
48
+ homepage: https://github.com/dlackty/nothing_magical
49
+ licenses:
50
+ - MIT
51
+ post_install_message:
52
+ rdoc_options: []
53
+ require_paths:
54
+ - lib
55
+ required_ruby_version: !ruby/object:Gem::Requirement
56
+ none: false
57
+ requirements:
58
+ - - ! '>='
59
+ - !ruby/object:Gem::Version
60
+ version: '0'
61
+ segments:
62
+ - 0
63
+ hash: 331393839490331547
64
+ required_rubygems_version: !ruby/object:Gem::Requirement
65
+ none: false
66
+ requirements:
67
+ - - ! '>='
68
+ - !ruby/object:Gem::Version
69
+ version: '0'
70
+ segments:
71
+ - 0
72
+ hash: 331393839490331547
73
+ requirements: []
74
+ rubyforge_project:
75
+ rubygems_version: 1.8.23
76
+ signing_key:
77
+ specification_version: 3
78
+ summary: Easily remove all magic encoding comments for Ruby source files.
79
+ test_files: []