eefgilm 0.0.5 → 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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: a2447a7e9a09a8dc48abb413b05dcb1ea345679f
4
- data.tar.gz: d903402a832491fe0e4ccfbb0f687ac386d1d92a
3
+ metadata.gz: 213bba7090ed949e3691e4d491d2b5c7000f9e09
4
+ data.tar.gz: c0a82a26ba9f22e5b3d6f81486e2f3aef194534c
5
5
  SHA512:
6
- metadata.gz: f6613e016d425e82070563cf952bb2b4678d6c7e68f15caf9a2ffd535ef7243cf646c664d6805f7ae6981f76ed96e03370f92bc494e5f06b14f324372641fc14
7
- data.tar.gz: aef3129bfd0520e8de8fc9cf30cca8146700cac813089a71732c0c1e0c3050b1ac11b3456adb78cea12c67b31332f30f1c2cfb943282542482aa98631667c206
6
+ metadata.gz: b9938207fb7f954a211ca40172efb29f4df497ccd4231880d487f810c0b67de8890f8afe03e40328c8fdaab0710be240b57cd70e32fceebad84240c56bfc5acb
7
+ data.tar.gz: 13c950cf7e793782f2b9ddfc4cc80af71a93a02269c8ba2d6551962fdfca8060699b0007c99e7393434189df282935b9b47ea29b85a4aff8a4195a788bbf988f
data/README.md CHANGED
@@ -1,32 +1,91 @@
1
+ [![Build Status](https://travis-ci.org/enilsen16/Eefgilm.svg?branch=master)](https://travis-ci.org/enilsen16/Eefgilm)
2
+ [![Gem Version](https://badge.fury.io/rb/eefgilm.svg)](http://badge.fury.io/rb/eefgilm)
1
3
  [![Stories in Ready](https://badge.waffle.io/enilsen16/eefgilm.png?label=ready&title=Ready)](https://waffle.io/enilsen16/eefgilm)
2
4
  #Eefgilm: A gem for cleaning up your Gemfile
3
5
 
4
6
  #Description:
5
- This gem automatically sorts the Gemfile alphabetically and removes comments, per Best Practice. Grouped gems are only sorted within their group.
7
+ **Important, currently does not support group blocks. If you have groups they will not included in the revised gemfile!**
6
8
 
9
+ This gem automatically modifies a ruby gemfile to make them a little easier to read, it does this by alphabetizing the gems, removing all comments, and removing all whitespace including leading and trailing.
7
10
 
8
- ## Installation
11
+ ---
9
12
 
10
- Add this line to your application's Gemfile:
13
+ ## Installation
14
+ The simplest way to install Eefgilm is to
15
+ Run this command:
11
16
 
12
- gem 'eefgilm'
17
+ gem install eefgilm
13
18
 
14
- And then execute:
19
+ Alternatively you can include it in a gem file with:
15
20
 
16
- $ bundle
21
+ gem 'eefgilm'
17
22
 
18
- Or install it yourself as:
23
+ and then run
19
24
 
20
- $ gem install eefgilm
25
+ bundle install
21
26
 
27
+ ---
22
28
  ## Usage
23
29
 
24
- TODO: Write usage instructions here
30
+ Once you have installed eefgilm on your system or in a project directory its quite simple to use. In the directory who's gemfile you would like to modify run:
31
+
32
+ eefglim
33
+
34
+ Currently it will not ask you for any confirmation before making modifications, nor will it create a backup so please be careful when using eefgilm. It may be a good idea to backup your gemfile beforehand hand this can be done with:
35
+
36
+ cp Gemfile Gemfilebackup
25
37
 
38
+ ---
26
39
  ## Contributing
40
+ We welcome contributions! If you want to help out you have many options:
27
41
 
28
42
  1. Fork it ( https://github.com/enilsen16/eefgilm/fork )
29
43
  2. Create your feature branch (`git checkout -b my-new-feature`)
30
44
  3. Commit your changes (`git commit -am 'Add some feature'`)
31
45
  4. Push to the branch (`git push origin my-new-feature`)
32
46
  5. Create a new Pull Request
47
+
48
+ ---
49
+ ##Issues
50
+ If you find a bug or have a suggestion, please create a new issue and we will look into it. Thank You.
51
+ [Create a new issue](https://github.com/enilsen16/Eefgilm/issues/new)
52
+
53
+ ---
54
+ ##Contact
55
+
56
+
57
+ ---
58
+
59
+ ##Thanks
60
+ The following people have helped with development or project design in one form or another:
61
+ [Steve Buckley](https://github.com/buckleys78)
62
+ [Brook Riggio](https://github.com/brookr)
63
+ [Cheri](https://github.com/cherimarie)
64
+ [David](https://github.com/dbalatero)
65
+
66
+ ---
67
+ ##License
68
+
69
+ And now for the fun part...
70
+
71
+ The MIT License (MIT)
72
+
73
+ Copyright (c) <2014> <Marco Lindsay & Erik Nilsen>
74
+
75
+ Permission is hereby granted, free of charge, to any person obtaining a copy
76
+ of this software and associated documentation files (the "Software"), to deal
77
+ in the Software without restriction, including without limitation the rights
78
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
79
+ copies of the Software, and to permit persons to whom the Software is
80
+ furnished to do so, subject to the following conditions:
81
+
82
+ The above copyright notice and this permission notice shall be included in
83
+ all copies or substantial portions of the Software.
84
+
85
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
86
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
87
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
88
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
89
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
90
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
91
+ THE SOFTWARE.
@@ -1,10 +1,10 @@
1
1
  module Eefgilm
2
2
  class Gemfile
3
- attr_accessor :path, :lines, :source, :group
3
+ attr_accessor :path, :source, :groups
4
4
 
5
5
  def initialize(path = ".", options = {})
6
6
  @path = path
7
- @lines = []
7
+ @groups ={}
8
8
  @options = {
9
9
  :alphabetize => true,
10
10
  :delete_whitespace => true,
@@ -30,24 +30,41 @@ module Eefgilm
30
30
 
31
31
  def extract_to_array_of_lines
32
32
  gemfile = File.open("#{@path}/Gemfile", "r+")
33
-
33
+ group_block = :all
34
34
  file_lines = gemfile.readlines
35
+
35
36
  file_lines.each do |line|
36
37
  self.source = line if line.match(/^source/)
37
- group = line.match(//) if line.match(/^\s*group/)
38
- self.lines << line if line.match(/^\s*gem/)
38
+
39
+ if line.match(/^\s*group/)
40
+ group_block = line.match(/^group (:.*)[,|\s]/)[1]
41
+ elsif line.match(/^\s*end/)
42
+ group_block = :all
43
+ end
44
+
45
+ if line.match(/^\s*gem/)
46
+ if self.groups[group_block].nil?
47
+ self.groups[group_block] = [line]
48
+ else
49
+ self.groups[group_block] << line
50
+ end
51
+ end
39
52
  end
40
53
  end
41
54
 
42
55
  def change_double_qoutes_to_single
43
- @lines.each do |line|
44
- line.gsub!('"',"'")
56
+ @groups.each do |group, gems|
57
+ @groups[group] = gems.map do |g|
58
+ g.gsub('"',"'")
59
+ end
45
60
  end
46
61
  end
47
62
 
48
63
  def delete_comments!
49
- @lines.each do |string|
50
- string.gsub!(/#(.*)$/, "")
64
+ @groups.each do |group, gems|
65
+ @groups[group] = gems.map do |g|
66
+ g.gsub(/#(.*)$/, "")
67
+ end
51
68
  end
52
69
  end
53
70
 
@@ -56,9 +73,19 @@ module Eefgilm
56
73
  output.puts @source
57
74
  output.puts
58
75
 
59
- @lines.each do |line|
60
- unless line.empty?
61
- output.puts line
76
+ @groups.each do |group, gems|
77
+ if group == :all
78
+ gems.each do |g|
79
+ output.puts g
80
+ end
81
+ else
82
+ output.puts
83
+ output.puts "group #{group}"
84
+
85
+ gems.each do |g|
86
+ output.puts " #{g}"
87
+ end
88
+ output.puts "end"
62
89
  end
63
90
  end
64
91
 
@@ -66,12 +93,16 @@ module Eefgilm
66
93
  end
67
94
 
68
95
  def alphabetize_gems!
69
- @lines.sort!
96
+ @groups.each do |group, gems|
97
+ @groups[group] = gems.sort
98
+ end
70
99
  end
71
100
 
72
101
  def delete_whitespace!
73
- @lines.each do |line|
74
- line.gsub!(/(?<=^|\[)\s+|\s+(?=$|\])|(?<=\s)\s+/, "")
102
+ @groups.each do |group, gems|
103
+ @groups[group] = gems.map do |g|
104
+ g.gsub(/(?<=^|\[)\s+|\s+(?=$|\])|(?<=\s)\s+/, "")
105
+ end
75
106
  end
76
107
  end
77
108
  end
@@ -1,3 +1,3 @@
1
1
  module Eefgilm
2
- VERSION = "0.0.5"
2
+ VERSION = "1.0.0"
3
3
  end
@@ -0,0 +1,32 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gem 'devise'
4
+ gem 'foundation-rails'
5
+ gem 'rails', '4.1.1'
6
+ gem 'sass-rails', '~> 4.0.3'
7
+ gem 'uglifier', '>= 1.3.0'
8
+ gem 'coffee-rails', '~> 4.0.0'
9
+
10
+ group :development do
11
+ gem "sqlite3"
12
+ end
13
+
14
+ gem "minitest-rails"
15
+ gem 'jquery-rails'
16
+ gem 'turbolinks'
17
+ gem 'jbuilder', '~> 2.0'
18
+ gem 'sdoc', '~> 0.4.0', group: :doc
19
+ gem 'spring', group: :development
20
+
21
+ group :test do
22
+ gem "minitest-rails-capybara"
23
+ gem "launchy"
24
+ end
25
+ group :development do
26
+ gem 'rails_layout'
27
+ end
28
+
29
+ group :production do
30
+ gem 'pg'
31
+ gem 'rails_12factor'
32
+ end
@@ -39,4 +39,19 @@ gem 'spring'
39
39
  # gem 'debugger'
40
40
 
41
41
 
42
+ group :test do
43
+ gem "minitest-rails-capybara"
44
+ gem "launchy"
45
+ end
46
+ group :development, :test do
47
+ gem 'rails_layout'
48
+ end
49
+
50
+ group :production do
51
+ gem 'pg'
52
+ gem 'rails_12factor'
53
+ end
54
+
55
+
56
+
42
57
 
@@ -15,12 +15,6 @@ describe "Gemfile" do
15
15
 
16
16
  it "must remove a files comments" do
17
17
  @worker.clean!.wont_match /.../
18
- #File.read(@file) {|f| f.read }.wont_match /#(.*)$/
19
- end
20
-
21
- it "should Alphabetize each gem in your gemfile" do
22
- @worker.clean!
23
- @worker.lines.must_equal @worker.lines.sort
24
18
  end
25
19
 
26
20
  it "should remove unnecessary whitespace" do
@@ -30,7 +24,17 @@ describe "Gemfile" do
30
24
  File.read(@file).each_line do |line|
31
25
  count += 1 if regex.match(line)
32
26
  end
33
- count.must_equal 1
27
+ count.must_equal 9
34
28
  end
29
+
30
+ it "should alphabetize groups" do
31
+ @worker.clean!
32
+ @worker.groups[:all].must_equal @worker.groups[:all].sort
33
+ end
34
+
35
+ # it "should alphabetize gems within a group" do
36
+
37
+ # end
38
+
35
39
  end
36
40
  end
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: 0.0.5
4
+ version: 1.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Erik Nilsen
@@ -75,6 +75,7 @@ files:
75
75
  - lib/eefgilm/version.rb
76
76
  - test/data/sources/dummy/Gemfile
77
77
  - test/data/sources/expected/Gemfile
78
+ - test/data/sources/original/groupgems
78
79
  - test/data/sources/original/railsgem
79
80
  - test/features/gemfile_test.rb
80
81
  - test/test_helper.rb
@@ -105,6 +106,7 @@ summary: A gem to keep your Gemfile in best practice .
105
106
  test_files:
106
107
  - test/data/sources/dummy/Gemfile
107
108
  - test/data/sources/expected/Gemfile
109
+ - test/data/sources/original/groupgems
108
110
  - test/data/sources/original/railsgem
109
111
  - test/features/gemfile_test.rb
110
112
  - test/test_helper.rb