modernize-hashes 1.0.0 → 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: dab7b27b657bb6ffed01cdf6f46c5da0808cd55a
4
+ data.tar.gz: 70a492372386ca83df21bc11e5547450b52f67ca
5
+ SHA512:
6
+ metadata.gz: bf974b8ebeed390779958af4f9cbf1a2d49bf9e099046f534addc62b8ee7fba0473177aa4e13f710c5b68e6d62d05667e6ed6e15c79a700582f4da7660224ea2
7
+ data.tar.gz: 3942154a56042a96bb146f970d018da47594372fde99fbfae857d02ae84f64b50f34ab5075b7d3a477301503fc724bacaaa83c9807c4a882d8575cdd3b07782d
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # Modernize::Hashes
2
2
 
3
- TODO: Write a gem description
3
+ A command line tool that converts all your hashes from `:really_old => 'style'` to `the_new: 'hotness'`!!!
4
4
 
5
5
  ## Installation
6
6
 
@@ -18,7 +18,10 @@ Or install it yourself as:
18
18
 
19
19
  ## Usage
20
20
 
21
- TODO: Write usage instructions here
21
+ Just run it:
22
+ ```sh
23
+ $ modernize-hashes
24
+ ```
22
25
 
23
26
  ## Contributing
24
27
 
@@ -3,13 +3,26 @@ require "modernize-hashes/version"
3
3
  module ModernizeHashes
4
4
  extend self
5
5
 
6
+ SUPPORTED_EXTENSIONS = %w{
7
+ rb
8
+ haml
9
+ erb
10
+ slim
11
+ }
12
+
6
13
  def run!
7
- Dir["**/*.rb"].each do |file|
8
- replacements = File.open(file).read.gsub /:([a-z_]+)(\s+)?=>(\s+)?/, '\1: '
9
- File.open file, 'w' do |f|
10
- f.write replacements
11
- end
12
- end
14
+ Dir["**/*"].select { |file| supported_extension? file }.each { |file| replace_hashes_in_file file }
15
+ end
16
+
17
+ def replace_hashes_in_file(file)
18
+ replacements = File.open(file).read.gsub /:([a-z_]+)(\s+)?=>(\s+)?/, '\1: '
19
+ File.open(file, 'w') { |f| f.write replacements }
20
+ rescue => e
21
+ raise e.class, "#{e.message} in #{file}"
22
+ end
23
+
24
+ def supported_extension?(file)
25
+ SUPPORTED_EXTENSIONS.map { |e| ".#{e}" }.include? File.extname(file)
13
26
  end
14
27
 
15
28
  end
@@ -1,5 +1,5 @@
1
1
  module Modernize
2
2
  module Hashes
3
- VERSION = "1.0.0"
3
+ VERSION = "1.1.0"
4
4
  end
5
5
  end
@@ -8,7 +8,7 @@ Gem::Specification.new do |spec|
8
8
  spec.version = Modernize::Hashes::VERSION
9
9
  spec.authors = ["Jason Waldrip"]
10
10
  spec.email = ["jason@waldrip.net"]
11
- spec.description = "Modernizes all hashes to be Ruby > 1.9 style hashes"
11
+ spec.description = "Modernizes all the hashes"
12
12
  spec.summary = "Modernizes all hashes to be Ruby > 1.9 style hashes"
13
13
  spec.homepage = "https://github.com/jwaldrip/modernize-hashes"
14
14
  spec.license = "MIT"
@@ -19,5 +19,5 @@ Gem::Specification.new do |spec|
19
19
  spec.require_paths = ["lib"]
20
20
 
21
21
  spec.add_development_dependency "bundler", "~> 1.3"
22
- spec.add_development_dependency "rake"
23
- end
22
+ spec.add_development_dependency "rake", "~> 10.3"
23
+ end
metadata CHANGED
@@ -1,49 +1,44 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: modernize-hashes
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
5
- prerelease:
4
+ version: 1.1.0
6
5
  platform: ruby
7
6
  authors:
8
7
  - Jason Waldrip
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2013-08-07 00:00:00.000000000 Z
11
+ date: 2014-11-19 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
14
  name: bundler
16
15
  requirement: !ruby/object:Gem::Requirement
17
- none: false
18
16
  requirements:
19
- - - ~>
17
+ - - "~>"
20
18
  - !ruby/object:Gem::Version
21
19
  version: '1.3'
22
20
  type: :development
23
21
  prerelease: false
24
22
  version_requirements: !ruby/object:Gem::Requirement
25
- none: false
26
23
  requirements:
27
- - - ~>
24
+ - - "~>"
28
25
  - !ruby/object:Gem::Version
29
26
  version: '1.3'
30
27
  - !ruby/object:Gem::Dependency
31
28
  name: rake
32
29
  requirement: !ruby/object:Gem::Requirement
33
- none: false
34
30
  requirements:
35
- - - ! '>='
31
+ - - "~>"
36
32
  - !ruby/object:Gem::Version
37
- version: '0'
33
+ version: '10.3'
38
34
  type: :development
39
35
  prerelease: false
40
36
  version_requirements: !ruby/object:Gem::Requirement
41
- none: false
42
37
  requirements:
43
- - - ! '>='
38
+ - - "~>"
44
39
  - !ruby/object:Gem::Version
45
- version: '0'
46
- description: Modernizes all hashes to be Ruby > 1.9 style hashes
40
+ version: '10.3'
41
+ description: Modernizes all the hashes
47
42
  email:
48
43
  - jason@waldrip.net
49
44
  executables:
@@ -51,39 +46,37 @@ executables:
51
46
  extensions: []
52
47
  extra_rdoc_files: []
53
48
  files:
54
- - .gitignore
49
+ - ".gitignore"
55
50
  - Gemfile
56
51
  - LICENSE.txt
57
52
  - README.md
58
53
  - Rakefile
59
54
  - bin/modernize-hashes
60
55
  - lib/modernize-hashes.rb
61
- - lib/modernize-hashes/hashes.rb
62
56
  - lib/modernize-hashes/version.rb
63
57
  - modernize-hashes.gemspec
64
58
  homepage: https://github.com/jwaldrip/modernize-hashes
65
59
  licenses:
66
60
  - MIT
61
+ metadata: {}
67
62
  post_install_message:
68
63
  rdoc_options: []
69
64
  require_paths:
70
65
  - lib
71
66
  required_ruby_version: !ruby/object:Gem::Requirement
72
- none: false
73
67
  requirements:
74
- - - ! '>='
68
+ - - ">="
75
69
  - !ruby/object:Gem::Version
76
70
  version: '0'
77
71
  required_rubygems_version: !ruby/object:Gem::Requirement
78
- none: false
79
72
  requirements:
80
- - - ! '>='
73
+ - - ">="
81
74
  - !ruby/object:Gem::Version
82
75
  version: '0'
83
76
  requirements: []
84
77
  rubyforge_project:
85
- rubygems_version: 1.8.23
78
+ rubygems_version: 2.2.2
86
79
  signing_key:
87
- specification_version: 3
80
+ specification_version: 4
88
81
  summary: Modernizes all hashes to be Ruby > 1.9 style hashes
89
82
  test_files: []
@@ -1,5 +0,0 @@
1
- require "modernize-hashes/version"
2
-
3
- module ModernizeHashes
4
-
5
- end