alphabetize 0.1.2 → 0.1.3

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: 9c89540521fb0f8944440b9473d503c9e1e1dc21
4
+ data.tar.gz: f6c3e3e272baf68cb07b212837dc6ed81887c642
5
+ SHA512:
6
+ metadata.gz: 9294388a860d1dd71c4d9d0aab57fea9813988b29b9fff85155f12fde8353cb1267e22bf79d155137747f34466e52bab78a65555aeafb75efcc1a7c9fa654396
7
+ data.tar.gz: 97b8fa3b95305a4f9ef42c0ebedf7ddb7ecefa6e70f222e1f93b12918bcd21ea332c75cd53138f719d54fc92fa9783b2f011689503f09d4660472487b107d76e
@@ -1,3 +1,3 @@
1
1
  #!/usr/bin/env ruby
2
2
  require 'alphabetize'
3
- puts Alphabetize.alphabetize_file()
3
+ puts Alphabetize.alphabetize_file
metadata CHANGED
@@ -1,17 +1,16 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: alphabetize
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
5
- prerelease:
4
+ version: 0.1.3
6
5
  platform: ruby
7
6
  authors:
8
7
  - Vidur Murali
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2012-07-02 00:00:00.000000000Z
11
+ date: 2014-12-28 00:00:00.000000000 Z
13
12
  dependencies: []
14
- description: Alphabetizes your gemfile
13
+ description: Alphabetizes your Gemfile
15
14
  email:
16
15
  - vidur.murali@gmail.com
17
16
  executables:
@@ -19,53 +18,30 @@ executables:
19
18
  extensions: []
20
19
  extra_rdoc_files: []
21
20
  files:
22
- - Gemfile
23
- - LICENSE
24
- - README.md
25
- - Rakefile
26
- - alphabetize.gemspec
27
21
  - bin/alphabetize
28
- - lib/alphabetize.rb
29
- - test/helper.rb
30
- - test/sample_Gemfiles/mixed_Gemfile
31
- - test/sample_Gemfiles/out_regular_chunks_Gemfile
32
- - test/sample_Gemfiles/out_static_chunks_Gemfile
33
- - test/sample_Gemfiles/regular_chunks_Gemfile
34
- - test/sample_Gemfiles/simple_Gemfile
35
- - test/sample_Gemfiles/static_chunks_Gemfile
36
- - test/test_alphabetize.rb
37
22
  homepage: https://github.com/vyder/alphabetize
38
- licenses: []
23
+ licenses:
24
+ - MIT
25
+ metadata: {}
39
26
  post_install_message:
40
27
  rdoc_options: []
41
28
  require_paths:
42
29
  - lib
43
30
  required_ruby_version: !ruby/object:Gem::Requirement
44
- none: false
45
31
  requirements:
46
- - - ! '>='
32
+ - - ">="
47
33
  - !ruby/object:Gem::Version
48
34
  version: '0'
49
35
  required_rubygems_version: !ruby/object:Gem::Requirement
50
- none: false
51
36
  requirements:
52
- - - ! '>='
37
+ - - ">="
53
38
  - !ruby/object:Gem::Version
54
39
  version: '0'
55
40
  requirements: []
56
41
  rubyforge_project:
57
- rubygems_version: 1.8.10
42
+ rubygems_version: 2.0.3
58
43
  signing_key:
59
- specification_version: 3
44
+ specification_version: 4
60
45
  summary: Please check how far I've got with the file parsing before you use this gem.
61
- It does create a backup of your gemfile in case things go seriously wrong.'
62
- test_files:
63
- - test/helper.rb
64
- - test/sample_Gemfiles/mixed_Gemfile
65
- - test/sample_Gemfiles/out_regular_chunks_Gemfile
66
- - test/sample_Gemfiles/out_static_chunks_Gemfile
67
- - test/sample_Gemfiles/regular_chunks_Gemfile
68
- - test/sample_Gemfiles/simple_Gemfile
69
- - test/sample_Gemfiles/static_chunks_Gemfile
70
- - test/test_alphabetize.rb
71
- has_rdoc:
46
+ It does create a backup of your Gemfile in case things go seriously wrong.'
47
+ test_files: []
data/Gemfile DELETED
@@ -1,4 +0,0 @@
1
- source 'https://rubygems.org'
2
-
3
- # Specify your gem's dependencies in alphabetize.gemspec
4
- gemspec
data/LICENSE DELETED
@@ -1,22 +0,0 @@
1
- Copyright (c) 2012 Vidur Murali
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 DELETED
@@ -1,31 +0,0 @@
1
- # Alphabetize
2
-
3
- Ruby gem to soothe your OCDs by alphabetizing your Gemfile
4
-
5
- ## Installation
6
-
7
- Add this line to your application's Gemfile:
8
-
9
- gem 'alphabetize'
10
-
11
- And then execute:
12
-
13
- $ bundle
14
-
15
- Or install it yourself as:
16
-
17
- $ gem install alphabetize
18
-
19
- ## Usage
20
-
21
- Go to root level of your rails app and run
22
-
23
- $ alphabetize
24
-
25
- ## Contributing
26
-
27
- 1. Fork it
28
- 2. Create your feature branch (`git checkout -b my-new-feature`)
29
- 3. Commit your changes (`git commit -am 'Added some feature'`)
30
- 4. Push to the branch (`git push origin my-new-feature`)
31
- 5. Create new Pull Request
data/Rakefile DELETED
@@ -1,94 +0,0 @@
1
- #!/usr/bin/env rake
2
- require "bundler/gem_tasks"
3
-
4
- # Most of these rake tasks were obtained from jekyll's Rakefile: #src TODO
5
-
6
- $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), *%w[lib]))
7
-
8
- #############################################################################
9
- #
10
- # Helper functions
11
- #
12
- #############################################################################
13
-
14
- def name
15
- @name ||= Dir['*.gemspec'].first.split('.').first
16
- end
17
-
18
- def version
19
- line = File.read("lib/#{name}.rb")[/^\s*VERSION\s*=\s*.*/]
20
- puts "Line read: #{line}"
21
- line.match(/.*VERSION\s*=\s*['"](.*)['"]/)[1]
22
- end
23
-
24
- def date
25
- Date.today.to_s
26
- end
27
-
28
- def rubyforge_project
29
- name
30
- end
31
-
32
- def gemspec_file
33
- "#{name}.gemspec"
34
- end
35
-
36
- def gem_file
37
- "#{name}-#{version}.gem"
38
- end
39
-
40
- def replace_header(head, header_name)
41
- head.sub!(/(\.#{header_name}\s*= ').*'/) { "#{$1}#{send(header_name)}'"}
42
- end
43
-
44
- #############################################################################
45
- #
46
- # Packaging tasks
47
- #
48
- #############################################################################
49
-
50
- task :release => :build do
51
- unless `git branch` =~ /^\* master$/
52
- puts "You must be on the master branch to release!"
53
- exit!
54
- end
55
- sh "git commit --allow-empty -m 'Release #{version}'"
56
- sh "git tag v#{version}"
57
- sh "git push origin master"
58
- sh "git push origin v#{version}"
59
- sh "gem push pkg/#{name}-#{version}.gem"
60
- end
61
-
62
- task :build => :gemspec do
63
- sh "mkdir -p pkg"
64
- sh "gem build #{gemspec_file}"
65
- sh "mv #{gem_file} pkg"
66
- end
67
-
68
- task :gemspec do
69
- # read spec file and split out manifest section
70
- spec = File.read(gemspec_file)
71
- head, manifest, tail = spec.split(" # = MANIFEST =\n")
72
-
73
- # replace name version and date
74
- replace_header(head, :name)
75
- replace_header(head, :version)
76
- replace_header(head, :date)
77
- #comment this out if your rubyforge_project has a different name
78
- replace_header(head, :rubyforge_project)
79
-
80
- # determine file list from git ls-files
81
- files = `git ls-files`.
82
- split("\n").
83
- sort.
84
- reject { |file| file =~ /^\./ }.
85
- reject { |file| file =~ /^(rdoc|pkg|coverage)/ }.
86
- map { |file| " #{file}" }.
87
- join("\n")
88
-
89
- # piece file back together and write
90
- manifest = " gem.files = %w[\n#{files}\n ]\n"
91
- spec = [head, manifest, tail].join(" # = MANIFEST =\n")
92
- File.open(gemspec_file, 'w') { |io| io.write(spec) }
93
- puts "Updated #{gemspec_file}"
94
- end
@@ -1,40 +0,0 @@
1
- # -*- encoding: utf-8 -*-
2
- $:.unshift File.dirname(__FILE__)
3
-
4
- require 'lib/alphabetize'
5
-
6
- Gem::Specification.new do |gem|
7
- gem.authors = ["Vidur Murali"]
8
- gem.email = ["vidur.murali@gmail.com"]
9
- gem.description = %q{Alphabetizes your gemfile}
10
- gem.summary = %q{Please check how far I've got with the file parsing before you use this gem. It does create a backup of your gemfile in case things go seriously wrong.'}
11
- gem.homepage = "https://github.com/vyder/alphabetize"
12
-
13
- gem.files = `git ls-files`.split($\)
14
- gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
15
- gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
16
- gem.name = "alphabetize"
17
- gem.require_paths = ["lib"]
18
- gem.version = Alphabetize::VERSION
19
-
20
- # = MANIFEST =
21
- gem.files = %w[
22
- Gemfile
23
- LICENSE
24
- README.md
25
- Rakefile
26
- alphabetize.gemspec
27
- bin/alphabetize
28
- lib/alphabetize.rb
29
- test/helper.rb
30
- test/sample_Gemfiles/mixed_Gemfile
31
- test/sample_Gemfiles/out_regular_chunks_Gemfile
32
- test/sample_Gemfiles/out_static_chunks_Gemfile
33
- test/sample_Gemfiles/regular_chunks_Gemfile
34
- test/sample_Gemfiles/simple_Gemfile
35
- test/sample_Gemfiles/static_chunks_Gemfile
36
- test/test_alphabetize.rb
37
- ]
38
- # = MANIFEST =
39
-
40
- end
@@ -1,144 +0,0 @@
1
- $:.unshift File.dirname(__FILE__) # For use/testing when no gem is installed
2
-
3
- # The Gemfile is parsed into file_chunks array
4
- # Each chunk has the following attributes:
5
- # :type - :static (don't sort them), :regular, :group (official group, use the header, end correctly)
6
- # :header - the line that prepends the chunk
7
- # :gem_hash - the hash of gems that belong to this chunk
8
- #
9
-
10
- module Alphabetize
11
- VERSION = "0.1.2"
12
-
13
- def self.alphabetize_file
14
- filename = "Gemfile"
15
- file = File.new(filename)
16
-
17
- lines = file.readlines
18
- puts "File Lines: #{lines.inspect}"
19
- file_chunks = make_chunky(lines)
20
-
21
- puts "Chunks: #{file_chunks.inspect}"
22
-
23
- backupFilename = "old_#{filename}"
24
- %x( mv #{filename} #{backupFilename})
25
-
26
- file = File.open(filename, 'w')
27
- # file.truncate(0) # clear the file
28
-
29
- file_chunks.each do |chunk|
30
- if chunk[:type] == :static
31
- print_gem_hash(file, chunk[:gem_hash])
32
- elsif chunk[:type] == :group
33
- file.puts(chunk[:header])
34
- print_gem_hash(file, chunk[:gem_hash])
35
- file.puts("end")
36
- elsif chunk[:type] == :regular
37
- print_gem_hash(file, chunk[:gem_hash])
38
- else
39
- raise "This chunk has some wierd type!"
40
- end
41
-
42
-
43
- # chunk.keys.sort.each do |gem|
44
- # line = chunk[gem]
45
- # file.puts(line)
46
- # end
47
- file.puts("")
48
- end
49
-
50
- file.close
51
-
52
- end
53
-
54
- private
55
- def self.make_chunky(lines)
56
- chunks = []
57
-
58
- chunk = {}
59
- chunk_gem_lines = []
60
- lines.each do |line|
61
- puts "* Processing line: #{line}"
62
- if line != "\n"
63
- if line.match(/##/) # static chunk
64
- chunk[:type] = :static
65
- puts "Thinks its static"
66
- chunk[:gem_hash] = gem_hash([line])
67
- chunks << chunk
68
- chunk = {}
69
- chunk_gem_lines = []
70
-
71
- elsif line.match(/do/) # official start of a group
72
- chunk[:type] = :group
73
- chunk[:header] = line
74
-
75
- elsif line.match(/^end/) # official end of a group
76
- puts "Thinks its a group"
77
- chunk[:gem_hash] = gem_hash(chunk_gem_lines)
78
- chunks << chunk
79
- chunk = {}
80
- chunk_gem_lines = []
81
-
82
- else # regular gem line
83
- chunk[:type] = :regular if chunk == {} # start of a regualr chunk
84
- chunk_gem_lines << line
85
- end
86
-
87
- elsif line == "\n" and chunk != {} # this is the end of some regular chunk
88
- puts "Thinks its regular"
89
- chunk[:gem_hash] = gem_hash(chunk_gem_lines)
90
- chunks << chunk
91
- chunk = {}
92
- chunk_gem_lines = []
93
-
94
- else # two new line characters in a row
95
- puts "**** Skipping line: #{line}"
96
- # do nothing
97
- end
98
-
99
-
100
- # if line contains '##'
101
- # mark chunk as :static
102
- # if line contains 'do'
103
- # mark chunk as :group
104
- #
105
- # if line == "\n" and !chunk_gem_lines.empty?
106
- # chunk[:gem_hash] = gem_hash(chunk_gem_lines)
107
- # chunks << chunk
108
- # chunk_gem_lines = [] # reset chunk lines
109
- # else
110
- # chunk_gem_lines << line if line != "\n"
111
- # end
112
- end
113
-
114
- if chunk != {}
115
- chunk[:gem_hash] = gem_hash(chunk_gem_lines)
116
- chunks << chunk
117
- end
118
-
119
- chunks
120
- end
121
-
122
- def self.gem_hash(lines)
123
- hash = {}
124
- puts "-------- Inspecting lines: #{lines.inspect}"
125
- lines.each do |line|
126
- puts "Line: #{line}"
127
- match_data = line.scan(/(\"([^"]*)\")|(\'([^']*)\')/)
128
- # The gem is either the second element or the 4th element of the array
129
- gem ||= match_data[0][1]
130
- gem ||= match_data[0].last
131
- puts "Found gem: #{gem}"
132
- hash[gem] = line
133
- end
134
-
135
- hash
136
- end
137
-
138
- def self.print_gem_hash(out, hash)
139
- hash.keys.sort.each do |gem|
140
- line = hash[gem]
141
- out.puts(line)
142
- end
143
- end
144
- end
@@ -1,11 +0,0 @@
1
- require 'rubygems'
2
-
3
- require 'shoulda'
4
-
5
- class Test::Unit::TestCase
6
-
7
- # def some_helper_function(args)
8
- # # ...
9
- # end
10
-
11
- end
@@ -1,46 +0,0 @@
1
- gem 'rails', '3.1.3'
2
- gem 'pg'
3
- gem 'jquery-rails'
4
- gem "zurbfoundation"
5
- gem 'devise'
6
- gem 'icalendar'
7
- gem 'omniauth-facebook'
8
- gem 'cancan'
9
- gem 'nested_form', :git => 'https://github.com/jweslley/nested_form.git'
10
- gem 'datejsrails'
11
-
12
- group :assets do
13
- gem 'sass-rails', '~> 3.1.5'
14
- gem 'coffee-rails', '~> 3.1.1'
15
- gem 'uglifier', '>= 1.0.3'
16
- end
17
-
18
- group :development do
19
- gem 'kumade', '~> 0.8.1'
20
- gem 'letter_opener'
21
- gem 'ruby-debug19', :platforms => :ruby_19#, :require => 'ruby-debug'
22
- end
23
-
24
- group :development, :test do
25
- gem 'factory_girl_rails'
26
- gem 'rspec-rails', '~> 2.7'
27
- gem 'shoulda-matchers'
28
- gem 'email_spec'
29
- gem 'guard-livereload'
30
- gem 'yajl-ruby' # speed up LiveReload JSON
31
- gem 'rb-notifu', :platforms => :mingw
32
- gem 'rb-fchange', :platforms => :mingw
33
- gem 'eventmachine', '>= 1.0.0.beta.4', :platforms => :mingw
34
- end
35
-
36
- group :test do
37
- gem "capybara", '~> 1.1.2' # for spec/requests
38
- gem 'launchy' # for save_and_open_page
39
- gem 'spork'
40
- gem 'guard-spork'
41
- gem 'rb-fsevent'
42
- gem 'guard-rspec'
43
- gem 'simplecov', '~> 0.5.4'
44
- gem 'shoulda', '~> 2.11.3'
45
- gem 'factory_girl_rails'
46
- end
@@ -1,21 +0,0 @@
1
- gem 'fixed-gem', '3.2.1' ## Don't want this to move from line 1
2
- gem 'bcrypt-ruby', '3.0.1'
3
- gem 'jquery-rails', '2.0.2'
4
-
5
- gem 'fixed-gem', '3.2.1' ## Don't want this to move from line 5
6
- gem 'pg', '0.13.2'
7
- gem 'uglifier', '1.0.3'
8
-
9
- group :development do
10
- gem 'private_pub'
11
- gem 'sass-rails', '3.2.3'
12
- gem 'rails', '3.2.3'
13
- gem 'js-routes'
14
- gem 'rails-erd'
15
- gem 'growl'
16
- end
17
-
18
- gem 'shoulda-matchers'
19
- gem 'spork'
20
- gem 'faker'
21
- gem 'simplecov', :require => false
@@ -1,4 +0,0 @@
1
- require './alphabetize/lib/alphabetize'
2
-
3
- %x(cp test_Gemfile Gemfile)
4
- Alphabetize::alphabetize_file