eefgilm 1.1.2 → 1.2.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.
- checksums.yaml +4 -4
- data/Gemfile +0 -3
- data/README.md +9 -8
- data/Rakefile +3 -4
- data/eefgilm.gemspec +11 -11
- data/lib/eefgilm.rb +2 -4
- data/lib/eefgilm/gemfile.rb +16 -16
- data/lib/eefgilm/version.rb +1 -1
- data/test/features/gemfile_test.rb +17 -17
- data/test/test_helper.rb +2 -2
- metadata +5 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: dea236f60c15b0d31886ee8ed1748ce45ae2c6f6
|
4
|
+
data.tar.gz: b3c533a459503b0ea581a3edb91e5bd714c0b1ab
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: af0e0241a7cd8998f97b25df18fb67ab1795319573970373f2efb9e276d9e5129199492892027b1d41dad727e63db335c9aea1344d4f731132b969f4d9431cc1
|
7
|
+
data.tar.gz: 882cdd72937a7cd6f9beab52e9972b4d55b2eb75b94fb9bbeed662cdd98e243ac60e66039b3485acfc04da95a98d2c1726b2882bfba6795d0c15060ae98bab13
|
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -39,14 +39,6 @@ and then run
|
|
39
39
|
|
40
40
|
bundle install
|
41
41
|
|
42
|
-
---
|
43
|
-
|
44
|
-
## Demo
|
45
|
-
|
46
|
-
A gif of 2 versions of Gemfile i.e before using the gem and after using the gem.
|
47
|
-
|
48
|
-

|
49
|
-
|
50
42
|
---
|
51
43
|
## Usage
|
52
44
|
|
@@ -59,6 +51,15 @@ Currently it will not ask you for any confirmation before making modifications,
|
|
59
51
|
cp Gemfile Gemfilebackup
|
60
52
|
|
61
53
|
---
|
54
|
+
|
55
|
+
## Demo
|
56
|
+
|
57
|
+
A gif showing a gemfile before and after running Eefgilm.
|
58
|
+
|
59
|
+

|
60
|
+
|
61
|
+
---
|
62
|
+
|
62
63
|
## Contributing
|
63
64
|
We welcome contributions! If you want to help out you have many options:
|
64
65
|
|
data/Rakefile
CHANGED
data/eefgilm.gemspec
CHANGED
@@ -4,21 +4,21 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
4
4
|
require 'eefgilm/version'
|
5
5
|
|
6
6
|
Gem::Specification.new do |spec|
|
7
|
-
spec.name =
|
7
|
+
spec.name = 'eefgilm'
|
8
8
|
spec.version = Eefgilm::VERSION
|
9
|
-
spec.authors = [
|
10
|
-
spec.email = [
|
11
|
-
spec.summary =
|
12
|
-
spec.description =
|
13
|
-
spec.homepage =
|
14
|
-
spec.license =
|
9
|
+
spec.authors = ['Erik Nilsen', 'Marco Lindsay']
|
10
|
+
spec.email = ['enilsen16@live.com', 'lindsay_marco@hotmail.com']
|
11
|
+
spec.summary = 'A gem to keep your Gemfile in best practice .'
|
12
|
+
spec.description = 'Eefgilm is a gem that is written to help keep your gemfile in order. It will alphabetize your gems, remove comments, and remove unnecessary whitespace.'
|
13
|
+
spec.homepage = 'http://enilsen16.github.io/Eefgilm/'
|
14
|
+
spec.license = 'MIT'
|
15
15
|
|
16
16
|
spec.files = `git ls-files -z`.split("\x0")
|
17
17
|
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
18
|
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
-
spec.require_paths = [
|
19
|
+
spec.require_paths = ['lib']
|
20
20
|
|
21
|
-
spec.add_development_dependency
|
22
|
-
spec.add_development_dependency
|
23
|
-
spec.add_development_dependency
|
21
|
+
spec.add_development_dependency 'minitest'
|
22
|
+
spec.add_development_dependency 'bundler', '~> 1.6'
|
23
|
+
spec.add_development_dependency 'rake'
|
24
24
|
end
|
data/lib/eefgilm.rb
CHANGED
data/lib/eefgilm/gemfile.rb
CHANGED
@@ -2,13 +2,13 @@ module Eefgilm
|
|
2
2
|
class Gemfile
|
3
3
|
attr_accessor :path, :source, :groups, :rubyversion
|
4
4
|
|
5
|
-
def initialize(path =
|
6
|
-
@path
|
7
|
-
@groups ={}
|
5
|
+
def initialize(path = '.', options = {})
|
6
|
+
@path = path
|
7
|
+
@groups = {}
|
8
8
|
@options = {
|
9
|
-
:
|
10
|
-
:
|
11
|
-
:
|
9
|
+
alphabetize: true,
|
10
|
+
delete_whitespace: true,
|
11
|
+
delete_comments: true
|
12
12
|
}.merge(options)
|
13
13
|
end
|
14
14
|
|
@@ -29,14 +29,14 @@ module Eefgilm
|
|
29
29
|
private
|
30
30
|
|
31
31
|
def extract_to_array_of_lines
|
32
|
-
gemfile = File.open("#{@path}/Gemfile",
|
32
|
+
gemfile = File.open("#{@path}/Gemfile", 'r+')
|
33
33
|
group_block = :all
|
34
34
|
file_lines = gemfile.readlines
|
35
35
|
|
36
36
|
file_lines.each do |line|
|
37
37
|
self.source = line if line.match(/^source/)
|
38
38
|
|
39
|
-
if
|
39
|
+
if source == "source 'http://rubygems.org'\n"
|
40
40
|
self.source = "source 'https://rubygems.org'\n"
|
41
41
|
end
|
42
42
|
|
@@ -49,10 +49,10 @@ module Eefgilm
|
|
49
49
|
end
|
50
50
|
|
51
51
|
if line.match(/^\s*gem/)
|
52
|
-
if
|
53
|
-
|
52
|
+
if groups[group_block].nil?
|
53
|
+
groups[group_block] = [line]
|
54
54
|
else
|
55
|
-
|
55
|
+
groups[group_block] << line
|
56
56
|
end
|
57
57
|
end
|
58
58
|
end
|
@@ -61,7 +61,7 @@ module Eefgilm
|
|
61
61
|
def change_double_qoutes_to_single
|
62
62
|
@groups.each do |group, gems|
|
63
63
|
@groups[group] = gems.map do |g|
|
64
|
-
g.
|
64
|
+
g.tr("\"", "'")
|
65
65
|
end
|
66
66
|
end
|
67
67
|
end
|
@@ -69,13 +69,13 @@ module Eefgilm
|
|
69
69
|
def delete_comments!
|
70
70
|
@groups.each do |group, gems|
|
71
71
|
@groups[group] = gems.map do |g|
|
72
|
-
g.gsub(/#(.*)$/,
|
72
|
+
g.gsub(/#(.*)$/, '')
|
73
73
|
end
|
74
74
|
end
|
75
75
|
end
|
76
76
|
|
77
77
|
def recreate_file
|
78
|
-
output = File.open(
|
78
|
+
output = File.open("#{@path}/Gemfile", 'w+')
|
79
79
|
output.puts [@source, @rubyversion].compact
|
80
80
|
output.puts
|
81
81
|
|
@@ -91,7 +91,7 @@ module Eefgilm
|
|
91
91
|
gems.each do |g|
|
92
92
|
output.puts " #{g}"
|
93
93
|
end
|
94
|
-
output.puts
|
94
|
+
output.puts 'end'
|
95
95
|
end
|
96
96
|
end
|
97
97
|
|
@@ -107,7 +107,7 @@ module Eefgilm
|
|
107
107
|
def delete_whitespace!
|
108
108
|
@groups.each do |group, gems|
|
109
109
|
@groups[group] = gems.map do |g|
|
110
|
-
g.gsub(/(?<=^|\[)\s+|\s+(?=$|\])|(?<=\s)\s+/,
|
110
|
+
g.gsub(/(?<=^|\[)\s+|\s+(?=$|\])|(?<=\s)\s+/, '')
|
111
111
|
end
|
112
112
|
end
|
113
113
|
end
|
data/lib/eefgilm/version.rb
CHANGED
@@ -1,26 +1,26 @@
|
|
1
|
-
require
|
1
|
+
require 'test_helper'
|
2
2
|
|
3
|
-
describe
|
4
|
-
it
|
5
|
-
gemfile = Eefgilm::Gemfile.new(
|
3
|
+
describe 'Gemfile' do
|
4
|
+
it 'will raise an exception if methods are called without a specified Gemfile' do
|
5
|
+
gemfile = Eefgilm::Gemfile.new('../data/sources/')
|
6
6
|
proc { gemfile.clean! }.must_raise(Errno::ENOENT)
|
7
7
|
end
|
8
8
|
|
9
|
-
describe
|
9
|
+
describe 'Comment Proccessing' do
|
10
10
|
before do
|
11
|
-
@file =
|
12
|
-
@file2 =
|
13
|
-
FileUtils.copy
|
14
|
-
FileUtils.copy
|
15
|
-
@worker = Eefgilm::Gemfile.new(
|
16
|
-
@worker2 = Eefgilm::Gemfile.new(
|
11
|
+
@file = 'test/data/sources/dummy/Gemfile'
|
12
|
+
@file2 = 'test/data/sources/expected/Gemfile'
|
13
|
+
FileUtils.copy 'test/data/sources/original/groupgems', @file2
|
14
|
+
FileUtils.copy 'test/data/sources/original/railsgem', @file
|
15
|
+
@worker = Eefgilm::Gemfile.new('test/data/sources/dummy')
|
16
|
+
@worker2 = Eefgilm::Gemfile.new('test/data/sources/expected')
|
17
17
|
end
|
18
18
|
|
19
|
-
it
|
20
|
-
@worker.clean!.wont_match
|
19
|
+
it 'must remove a files comments' do
|
20
|
+
@worker.clean!.wont_match(/.../)
|
21
21
|
end
|
22
22
|
|
23
|
-
it
|
23
|
+
it 'should remove unnecessary whitespace' do
|
24
24
|
regex = /(?<=^|\[)\s+|(?<=\s)\s+/
|
25
25
|
count = 0
|
26
26
|
@worker.clean!
|
@@ -30,12 +30,12 @@ describe "Gemfile" do
|
|
30
30
|
count.must_equal 9
|
31
31
|
end
|
32
32
|
|
33
|
-
it
|
33
|
+
it 'should alphabetize groups' do
|
34
34
|
@worker.clean!
|
35
35
|
@worker.groups[:all].must_equal @worker.groups[:all].sort
|
36
36
|
end
|
37
37
|
|
38
|
-
it
|
38
|
+
it 'should keep the ruby version' do
|
39
39
|
@worker.clean!
|
40
40
|
@worker.rubyversion.must_include 'ruby "2.0.0"'
|
41
41
|
end
|
@@ -45,7 +45,7 @@ describe "Gemfile" do
|
|
45
45
|
@worker.source.must_include 'https://rubygems.org'
|
46
46
|
end
|
47
47
|
|
48
|
-
it
|
48
|
+
it 'without a specified ruby version, it should not have an extra line' do
|
49
49
|
regex = /^[\s]*$\n/
|
50
50
|
count = 0
|
51
51
|
@worker2.clean!
|
data/test/test_helper.rb
CHANGED
@@ -1,2 +1,2 @@
|
|
1
|
-
require
|
2
|
-
require
|
1
|
+
require 'minitest/autorun'
|
2
|
+
require 'eefgilm'
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: eefgilm
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Erik Nilsen
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2015-08-27 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: minitest
|
@@ -53,8 +53,8 @@ dependencies:
|
|
53
53
|
- - ">="
|
54
54
|
- !ruby/object:Gem::Version
|
55
55
|
version: '0'
|
56
|
-
description:
|
57
|
-
It will alphabetize your gems, remove comments, and remove unnecessary whitespace.
|
56
|
+
description: Eefgilm is a gem that is written to help keep your gemfile in order.
|
57
|
+
It will alphabetize your gems, remove comments, and remove unnecessary whitespace.
|
58
58
|
email:
|
59
59
|
- enilsen16@live.com
|
60
60
|
- lindsay_marco@hotmail.com
|
@@ -99,7 +99,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
99
99
|
version: '0'
|
100
100
|
requirements: []
|
101
101
|
rubyforge_project:
|
102
|
-
rubygems_version: 2.
|
102
|
+
rubygems_version: 2.4.5.1
|
103
103
|
signing_key:
|
104
104
|
specification_version: 4
|
105
105
|
summary: A gem to keep your Gemfile in best practice .
|