eefgilm 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: abdc770670127c4ed4d395646b7a2aaf66c2aac3
4
+ data.tar.gz: c45efc0325db4ca8dd242c149b8af900f0239427
5
+ SHA512:
6
+ metadata.gz: 7e1689039ea7fbe045da169e1d7a9864f99f0240b1466d2a81a93b9cdd6ad459631135cf8893a39734dbf692975404085501314ca2ccb342de225b4c22887d4b
7
+ data.tar.gz: 71344dd2bc04f3f6d644e0843c04eab22e42c98482ddb09996897365c8252db2df644fe4354144a16adabf85b2dd683fc6811711bcb83897c0c2f88158881784
data/.gitignore ADDED
@@ -0,0 +1,23 @@
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
18
+ *.bundle
19
+ *.so
20
+ *.o
21
+ *.a
22
+ mkmf.log
23
+ test/data/sources/dummy/Gemfile
data/Gemfile ADDED
@@ -0,0 +1,5 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gemspec
4
+ gem "pry"
5
+ gem "pry-nav"
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2014 Erik Nilsen
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,32 @@
1
+ [![Stories in Ready](https://badge.waffle.io/enilsen16/eefgilm.png?label=ready&title=Ready)](https://waffle.io/enilsen16/eefgilm)
2
+ #Eefgilm: A gem for cleaning up your Gemfile
3
+
4
+ #Description:
5
+ This gem automatically sorts the Gemfile alphabetically and removes comments, per Best Practice. Grouped gems are only sorted within their group.
6
+
7
+
8
+ ## Installation
9
+
10
+ Add this line to your application's Gemfile:
11
+
12
+ gem 'eefgilm'
13
+
14
+ And then execute:
15
+
16
+ $ bundle
17
+
18
+ Or install it yourself as:
19
+
20
+ $ gem install eefgilm
21
+
22
+ ## Usage
23
+
24
+ TODO: Write usage instructions here
25
+
26
+ ## Contributing
27
+
28
+ 1. Fork it ( https://github.com/enilsen16/eefgilm/fork )
29
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
30
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
31
+ 4. Push to the branch (`git push origin my-new-feature`)
32
+ 5. Create a new Pull Request
data/Rakefile ADDED
@@ -0,0 +1,10 @@
1
+ require "bundler/gem_tasks"
2
+ require 'rake/testtask'
3
+
4
+ task default: 'test'
5
+
6
+ Rake::TestTask.new do |t|
7
+ t.libs << "test"
8
+ t.pattern = "test/**/*_test.rb"
9
+ end
10
+
data/bin/eefgilm ADDED
@@ -0,0 +1,6 @@
1
+ #!/usr/bin/env ruby
2
+ require 'eefgilm'
3
+ gemfile = Eefgilm::Gemfile.new
4
+ gemfile.clean!
5
+
6
+
data/eefgilm.gemspec ADDED
@@ -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 'eefgilm/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "eefgilm"
8
+ spec.version = Eefgilm::VERSION
9
+ spec.authors = ["Erik Nilsen", "Marco Lindsay"]
10
+ spec.email = ["enilsen16@live.com", "lindsay_marco@hotmail.com"]
11
+ spec.summary = %q{A gem to keep your Gemfile in best practice .}
12
+ spec.description = %q{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 = "https://github.com/enilsen16/eefgilm"
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files -z`.split("\x0")
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.add_development_dependency "minitest"
22
+ spec.add_development_dependency "bundler", "~> 1.6"
23
+ spec.add_development_dependency "rake"
24
+ end
@@ -0,0 +1,71 @@
1
+ module Eefgilm
2
+ class Gemfile
3
+ attr_accessor :path, :lines, :source, :group
4
+
5
+ def initialize(path = ".", options = {})
6
+ @path = path
7
+ @lines = []
8
+ @options = {
9
+ :alphabetize => true,
10
+ :delete_whitespace => true,
11
+ :delete_comments => true
12
+ }.merge(options)
13
+ end
14
+
15
+ def clean!
16
+ # Extract:
17
+ extract_to_array_of_lines
18
+
19
+ # Transform:
20
+ delete_comments! if @options[:delete_comments]
21
+ delete_whitespace! if @options[:delete_whitespace]
22
+ alphabetize_gems! if @options[:alphabetize]
23
+
24
+ # Load:
25
+ recreate_file
26
+ end
27
+
28
+ private
29
+
30
+ def extract_to_array_of_lines
31
+ gemfile = File.open("#{@path}/Gemfile", "r+")
32
+
33
+ file_lines = gemfile.readlines
34
+ file_lines.each do |line|
35
+ self.source = line if line.match(/^source/)
36
+ group = line.match(//) if line.match(/^\s*group/)
37
+ self.lines << line if line.match(/^\s*gem/)
38
+ end
39
+ end
40
+
41
+ def delete_comments!
42
+ @lines.each do |string|
43
+ string.gsub!(/#(.*)$/, "")
44
+ end
45
+ end
46
+
47
+ def recreate_file
48
+ output = File.open( "#{@path}/Gemfile", "w+" )
49
+ output.puts @source
50
+ output.puts
51
+
52
+ @lines.each do |line|
53
+ unless line.empty?
54
+ output.puts line
55
+ end
56
+ end
57
+
58
+ output.close
59
+ end
60
+
61
+ def alphabetize_gems!
62
+ @lines.sort!
63
+ end
64
+
65
+ def delete_whitespace!
66
+ @lines.each do |line|
67
+ line.gsub!(/(?<=^|\[)\s+|\s+(?=$|\])|(?<=\s)\s+/, "")
68
+ end
69
+ end
70
+ end
71
+ end
@@ -0,0 +1,3 @@
1
+ module Eefgilm
2
+ VERSION = "0.0.1"
3
+ end
data/lib/eefgilm.rb ADDED
@@ -0,0 +1,7 @@
1
+ require "eefgilm/version"
2
+ require "eefgilm/gemfile"
3
+
4
+ module Eefgilm
5
+
6
+ end
7
+
@@ -0,0 +1,13 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gem 'coffee-rails', '~> 4.0.0'
4
+ gem 'jbuilder', '~> 2.0'
5
+ gem 'jquery-rails'
6
+ gem 'rails', '4.1.1'
7
+ gem 'sass-rails', '~> 4.0.3'
8
+ gem 'sdoc', '~> 0.4.0'
9
+ gem 'spring'
10
+ gem 'sqlite3'
11
+ gem 'this gem', '4.1.1'
12
+ gem 'turbolinks'
13
+ gem 'uglifier', '>= 1.3.0'
File without changes
@@ -0,0 +1,42 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
4
+ gem 'rails', '4.1.1'
5
+ gem 'this gem', '4.1.1'
6
+ # Use sqlite3 as the database for Active Record
7
+ gem 'sqlite3'
8
+ # Use SCSS for stylesheets
9
+ gem 'sass-rails', '~> 4.0.3'
10
+ # Use Uglifier as compressor for JavaScript assets
11
+ gem 'uglifier', '>= 1.3.0'
12
+ # Use CoffeeScript for .js.coffee assets and views
13
+ gem 'coffee-rails', '~> 4.0.0'
14
+ # See https://github.com/sstephenson/execjs#readme for more supported runtimes
15
+ # gem 'therubyracer', platforms: :ruby
16
+
17
+ # Use jquery as the JavaScript library
18
+ gem 'jquery-rails'
19
+ # Turbolinks makes following links in your web application faster. Read more: https://github.com/rails/turbolinks
20
+ gem 'turbolinks'
21
+ # Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
22
+ gem 'jbuilder', '~> 2.0'
23
+ # bundle exec rake doc:rails generates the API under doc/api.
24
+ gem 'sdoc', '~> 0.4.0'
25
+
26
+ # Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring
27
+ gem 'spring'
28
+
29
+ # Use ActiveModel has_secure_password
30
+ # gem 'bcrypt', '~> 3.1.7'
31
+
32
+ # Use unicorn as the app server
33
+ # gem 'unicorn'
34
+
35
+ # Use Capistrano for deployment
36
+ # gem 'capistrano-rails'
37
+
38
+ # Use debugger
39
+ # gem 'debugger'
40
+
41
+
42
+
@@ -0,0 +1,36 @@
1
+ require "test_helper"
2
+
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
+ proc { gemfile.clean! }.must_raise(Errno::ENOENT)
7
+ end
8
+
9
+ describe "Comment Proccessing" do
10
+ before do
11
+ @file = "test/data/sources/dummy/Gemfile"
12
+ FileUtils.copy "test/data/sources/original/railsgem", @file
13
+ @worker = Eefgilm::Gemfile.new("test/data/sources/dummy")
14
+ end
15
+
16
+ it "must remove a files comments" do
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
+ end
25
+
26
+ it "should remove unnecessary whitespace" do
27
+ regex = /(?<=^|\[)\s+|(?<=\s)\s+/
28
+ count = 0
29
+ @worker.clean!
30
+ File.read(@file).each_line do |line|
31
+ count += 1 if regex.match(line)
32
+ end
33
+ count.must_equal 1
34
+ end
35
+ end
36
+ end
@@ -0,0 +1,5 @@
1
+ require "minitest/autorun"
2
+ require "eefgilm"
3
+ require "pry"
4
+ require "pry-nav"
5
+
metadata ADDED
@@ -0,0 +1,110 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: eefgilm
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Erik Nilsen
8
+ - Marco Lindsay
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2014-05-29 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: minitest
16
+ requirement: !ruby/object:Gem::Requirement
17
+ requirements:
18
+ - - ">="
19
+ - !ruby/object:Gem::Version
20
+ version: '0'
21
+ type: :development
22
+ prerelease: false
23
+ version_requirements: !ruby/object:Gem::Requirement
24
+ requirements:
25
+ - - ">="
26
+ - !ruby/object:Gem::Version
27
+ version: '0'
28
+ - !ruby/object:Gem::Dependency
29
+ name: bundler
30
+ requirement: !ruby/object:Gem::Requirement
31
+ requirements:
32
+ - - "~>"
33
+ - !ruby/object:Gem::Version
34
+ version: '1.6'
35
+ type: :development
36
+ prerelease: false
37
+ version_requirements: !ruby/object:Gem::Requirement
38
+ requirements:
39
+ - - "~>"
40
+ - !ruby/object:Gem::Version
41
+ version: '1.6'
42
+ - !ruby/object:Gem::Dependency
43
+ name: rake
44
+ requirement: !ruby/object:Gem::Requirement
45
+ requirements:
46
+ - - ">="
47
+ - !ruby/object:Gem::Version
48
+ version: '0'
49
+ type: :development
50
+ prerelease: false
51
+ version_requirements: !ruby/object:Gem::Requirement
52
+ requirements:
53
+ - - ">="
54
+ - !ruby/object:Gem::Version
55
+ version: '0'
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
+ email:
59
+ - enilsen16@live.com
60
+ - lindsay_marco@hotmail.com
61
+ executables:
62
+ - eefgilm
63
+ extensions: []
64
+ extra_rdoc_files: []
65
+ files:
66
+ - ".gitignore"
67
+ - Gemfile
68
+ - LICENSE.txt
69
+ - README.md
70
+ - Rakefile
71
+ - bin/eefgilm
72
+ - eefgilm.gemspec
73
+ - lib/eefgilm.rb
74
+ - lib/eefgilm/gemfile.rb
75
+ - lib/eefgilm/version.rb
76
+ - test/data/sources/dummy/Gemfile
77
+ - test/data/sources/expected/Gemfile
78
+ - test/data/sources/original/railsgem
79
+ - test/features/gemfile_test.rb
80
+ - test/test_helper.rb
81
+ homepage: https://github.com/enilsen16/eefgilm
82
+ licenses:
83
+ - MIT
84
+ metadata: {}
85
+ post_install_message:
86
+ rdoc_options: []
87
+ require_paths:
88
+ - lib
89
+ required_ruby_version: !ruby/object:Gem::Requirement
90
+ requirements:
91
+ - - ">="
92
+ - !ruby/object:Gem::Version
93
+ version: '0'
94
+ required_rubygems_version: !ruby/object:Gem::Requirement
95
+ requirements:
96
+ - - ">="
97
+ - !ruby/object:Gem::Version
98
+ version: '0'
99
+ requirements: []
100
+ rubyforge_project:
101
+ rubygems_version: 2.2.2
102
+ signing_key:
103
+ specification_version: 4
104
+ summary: A gem to keep your Gemfile in best practice .
105
+ test_files:
106
+ - test/data/sources/dummy/Gemfile
107
+ - test/data/sources/expected/Gemfile
108
+ - test/data/sources/original/railsgem
109
+ - test/features/gemfile_test.rb
110
+ - test/test_helper.rb