gemfiler 0.1.2 → 0.1.3

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: f966ab4ecc6fe450eba87b92d89ce39bd25b0386
4
+ data.tar.gz: 53314f72465bde315985d4f904f1f2f1190c295d
5
+ SHA512:
6
+ metadata.gz: 4ec8ee14b68dafefb322a10cd4917b503cb5f191f8e0aa2427b9e3904473c6500c9ddf1f7870bdd867a91c426e96dd9f8641e8e34b25b3000507f1329de95aea
7
+ data.tar.gz: b12ca4fabc9ebfeef18577caa5fd96fe0a780bf1bcda69d80e69efe70317ec26e89e7c4f23e1191d6ed0b54666c27b575b5c11a531741c292441b4621a2b8d03
data/Gemfile CHANGED
@@ -1,5 +1,2 @@
1
1
  source 'https://rubygems.org'
2
-
3
- # Specify your gem's dependencies in Gemfiler.gemspec
4
2
  gemspec
5
-
data/Gemfiler.gemspec CHANGED
@@ -19,5 +19,6 @@ Gem::Specification.new do |gem|
19
19
  gem.add_runtime_dependency('thor', '~> 0.16')
20
20
 
21
21
  gem.add_development_dependency('rspec', '~> 2.11')
22
+ gem.add_development_dependency('rake')
22
23
  gem.add_development_dependency('awesome_print')
23
24
  end
data/README.md CHANGED
@@ -1,24 +1,70 @@
1
+
1
2
  # Gemfiler
2
3
 
3
- TODO: Write a gem description
4
+ Gemfiler will take your Gemfile and make it nice. It will alphabetize and group everything correctly. It can also turn hash syntax into Ruby's 1.9 hash syntax, and align versions / options nicely.
4
5
 
5
6
  ## Installation
6
7
 
7
- Add this line to your application's Gemfile:
8
+ ```gem install gemfiler```
9
+
8
10
 
9
- gem 'Gemfiler'
11
+ ## Usage
10
12
 
11
- And then execute:
13
+ Once you've installed gemfiler, you'll get the ```gemfiler``` executable.
12
14
 
13
- $ bundle
15
+ * cd into the project with the gemfile you'd like to prettify.
16
+ * type ```gemfiler file``` (If you'd like to specify a Gemfile, type ```gemfiler file OtherGemfile```)
17
+ * Voila!
14
18
 
15
- Or install it yourself as:
19
+ To see a list of options, type ```gemfiler help file```
16
20
 
17
- $ gem install Gemfiler
21
+ ## Additional Options
18
22
 
19
- ## Usage
23
+ ```gemfiler file --ruby19_hashes``` Will use the 1.9 hash syntax
24
+
25
+ ```gemfiler file --nice_spaces``` Will align all versions / options
26
+
27
+ ## Before / After
28
+
29
+ ### Before
30
+
31
+ ```ruby
32
+ source 'http://rubygems.org'
33
+
34
+ gem 'state_machine'
35
+ gem 'validates_timeliness', '~> 3.0.2'
36
+ gem 'gmaps4rails'
37
+ gem 'chronic'
38
+ gem 'paper_trail'
39
+ gem 'no_peeping_toms', :git => 'git://github.com/patmaddox/no-peeping-toms.git'
40
+ gem "tire", :git => 'git@github.com:bobbytables/tire.git', :ref => '543f4b410f6c7b4ce62b4b866fb45a2339642b16'
41
+ gem 'draper', '~> 0.9'
42
+
43
+ ```
44
+
45
+ ### After
46
+
47
+ ```ruby
48
+ source :rubygems
49
+
50
+ gem 'chronic'
51
+ gem 'draper', '~> 0.9'
52
+ gem 'gmaps4rails'
53
+ gem 'no_peeping_toms', git: 'git://github.com/patmaddox/no-peeping-toms.git'
54
+ gem 'paper_trail'
55
+ gem 'state_machine'
56
+ gem 'tire', git: 'git@github.com:bobbytables/tire.git', ref: '543f4b410f6c7b4ce62b4b866fb45a2339642b16'
57
+ gem 'validates_timeliness', '~> 3.0.2'
58
+
59
+ ```
60
+
61
+
62
+ ## Gotchas
63
+ Gemfiler works by acting like Bundler, it executes the Gemfile under a shim, and passes all of the gems as objects around Gemfiler.
64
+
65
+ * Comments go away (Working on this)
66
+ * Statements will go away, if you have any if statements, or anything other than bundler commands, it will either fail or remove the statement.
20
67
 
21
- TODO: Write usage instructions here
22
68
 
23
69
  ## Contributing
24
70
 
data/Rakefile CHANGED
@@ -1,2 +1,7 @@
1
1
  #!/usr/bin/env rake
2
2
  require "bundler/gem_tasks"
3
+ require "rspec/core/rake_task"
4
+
5
+ RSpec::Core::RakeTask.new(:spec)
6
+
7
+ task :default => :spec
@@ -11,7 +11,7 @@ module Gemfiler
11
11
  end
12
12
 
13
13
  def gather(source)
14
- source = source.gsub /source[\s]+\:([\w_]+)/, 'source(:\\1)'
14
+ source = source.gsub /source[\s]+\:([\w_]+)/, "source(:\\1)"
15
15
  instance_eval(source)
16
16
  end
17
17
 
File without changes
@@ -1,11 +1,11 @@
1
- require 'awesome_print'
1
+ require "awesome_print"
2
2
 
3
3
  module Gemfiler
4
4
  class CLI < Thor
5
5
 
6
- desc 'file', 'Organizes your Gemfile.'
7
- method_options nice_spaces: :boolean, ruby19_hashes: :boolean
8
- def file(gemfile='Gemfile')
6
+ desc "file", "Organizes your Gemfile."
7
+ method_options nice_spaces: :boolean, ruby19_hashes: :boolean, annotate: :boolean
8
+ def file(gemfile="Gemfile")
9
9
  gemfile = "#{Dir.pwd}/#{gemfile}"
10
10
 
11
11
  cabinet = Gemfiler::Cabinet.new(gemfile)
File without changes
@@ -1,4 +1,6 @@
1
- require 'erb'
1
+ require "erb"
2
+ require "json"
3
+ require "net/http"
2
4
 
3
5
  module Gemfiler
4
6
  class Output
@@ -10,13 +12,13 @@ module Gemfiler
10
12
  end
11
13
 
12
14
  def write(gemfile)
13
- File.open(gemfile, 'w') do |file|
15
+ File.open(gemfile, "w") do |file|
14
16
  file.write(content)
15
17
  end
16
18
  end
17
19
 
18
20
  def content
19
- erb = ERB.new(File.read(File.expand_path('../templates/gemfile.erb', __FILE__)), nil, '<>')
21
+ erb = ERB.new(File.read(File.expand_path("../templates/gemfile.erb", __FILE__)), nil, "<>")
20
22
  erb.result(binding)
21
23
  end
22
24
 
@@ -28,7 +30,7 @@ module Gemfiler
28
30
  end
29
31
 
30
32
  def gemspec
31
- filer.shim.gemspec? ? 'gemspec' : ''
33
+ filer.shim.gemspec? ? "gemspec" : ""
32
34
  end
33
35
 
34
36
  def ruby
@@ -39,7 +41,7 @@ module Gemfiler
39
41
  parts << hash_keyvalue(:engine_version, version_info[:engine_version]) if version_info[:engine_version]
40
42
  end
41
43
 
42
- parts.join(', ')
44
+ parts.join(", ")
43
45
  end
44
46
 
45
47
  def uncategorized_gems
@@ -60,7 +62,7 @@ module Gemfiler
60
62
  end
61
63
 
62
64
  def spacer
63
- ' '
65
+ " "
64
66
  end
65
67
 
66
68
  def type_value(value)
@@ -90,18 +92,30 @@ module Gemfiler
90
92
  space_between = @options[:nice_spaces] ? longest_gem_name(groups) - gem_name.length : 0
91
93
 
92
94
  if g[:version]
93
- line << (' ' * space_between) + "'#{g[:version]}'"
95
+ line << (" " * space_between) + "'#{g[:version]}'"
94
96
  elsif (g.length - 1) > 0
95
- line << (' ' * space_between) + g.inject([]) do |options, (key, value)|
97
+ line << (" " * space_between) + g.inject([]) do |options, (key, value)|
96
98
  if key != :name
97
99
  options << hash_keyvalue(key, value)
98
100
  end
99
101
 
100
102
  options
101
- end.join(', ')
103
+ end.join(", ")
102
104
  end
103
105
 
104
- line.join(', ')
106
+ annotation = ""
107
+
108
+ if @options[:annotate]
109
+ puts "-- Annotating #{gem_name}"
110
+ uri = URI.parse("https://rubygems.org/api/v1/gems/#{gem_name}.json")
111
+ response = Net::HTTP.get_response(uri)
112
+ parsed = JSON.load(response.body)
113
+ info = parsed['info']
114
+
115
+ annotation = " # #{info}"
116
+ end
117
+
118
+ line.join(", ") + annotation
105
119
  end
106
120
  end
107
121
  end
@@ -1,3 +1,3 @@
1
1
  module Gemfiler
2
- VERSION = "0.1.2"
2
+ VERSION = "0.1.3"
3
3
  end
data/lib/gemfiler.rb ADDED
@@ -0,0 +1,9 @@
1
+ require_relative "gemfiler/version"
2
+
3
+ module Gemfiler
4
+ autoload :Cabinet, "gemfiler/cabinet"
5
+ autoload :BundlerShim, "gemfiler/bundler_shim"
6
+ autoload :Filer, "gemfiler/filer"
7
+ autoload :Output, "gemfiler/output"
8
+ autoload :CLI, "gemfiler/cli"
9
+ end
metadata CHANGED
@@ -1,62 +1,69 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gemfiler
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
  - Robert Ross
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2012-08-22 00:00:00.000000000 Z
11
+ date: 2015-03-31 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
14
  name: thor
16
15
  requirement: !ruby/object:Gem::Requirement
17
- none: false
18
16
  requirements:
19
- - - ~>
17
+ - - "~>"
20
18
  - !ruby/object:Gem::Version
21
19
  version: '0.16'
22
20
  type: :runtime
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: '0.16'
30
27
  - !ruby/object:Gem::Dependency
31
28
  name: rspec
32
29
  requirement: !ruby/object:Gem::Requirement
33
- none: false
34
30
  requirements:
35
- - - ~>
31
+ - - "~>"
36
32
  - !ruby/object:Gem::Version
37
33
  version: '2.11'
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
40
  version: '2.11'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rake
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
46
55
  - !ruby/object:Gem::Dependency
47
56
  name: awesome_print
48
57
  requirement: !ruby/object:Gem::Requirement
49
- none: false
50
58
  requirements:
51
- - - ! '>='
59
+ - - ">="
52
60
  - !ruby/object:Gem::Version
53
61
  version: '0'
54
62
  type: :development
55
63
  prerelease: false
56
64
  version_requirements: !ruby/object:Gem::Requirement
57
- none: false
58
65
  requirements:
59
- - - ! '>='
66
+ - - ">="
60
67
  - !ruby/object:Gem::Version
61
68
  version: '0'
62
69
  description: Gemfiler makes your Gemfile pretty.
@@ -67,22 +74,22 @@ executables:
67
74
  extensions: []
68
75
  extra_rdoc_files: []
69
76
  files:
70
- - .gitignore
71
- - .rspec
77
+ - ".gitignore"
78
+ - ".rspec"
72
79
  - Gemfile
73
80
  - Gemfiler.gemspec
74
81
  - LICENSE
75
82
  - README.md
76
83
  - Rakefile
77
84
  - bin/gemfiler
78
- - lib/Gemfiler.rb
79
- - lib/Gemfiler/bundler_shim.rb
80
- - lib/Gemfiler/cabinet.rb
81
- - lib/Gemfiler/cli.rb
82
- - lib/Gemfiler/filer.rb
83
- - lib/Gemfiler/output.rb
84
- - lib/Gemfiler/version.rb
85
+ - lib/gemfiler.rb
86
+ - lib/gemfiler/bundler_shim.rb
87
+ - lib/gemfiler/cabinet.rb
88
+ - lib/gemfiler/cli.rb
89
+ - lib/gemfiler/filer.rb
90
+ - lib/gemfiler/output.rb
85
91
  - lib/gemfiler/templates/gemfile.erb
92
+ - lib/gemfiler/version.rb
86
93
  - spec/bundler_shim_spec.rb
87
94
  - spec/cabinet_spec.rb
88
95
  - spec/filer_spec.rb
@@ -94,27 +101,26 @@ files:
94
101
  - spec/support/gemfiles/SampleGemfileForOutput
95
102
  homepage: ''
96
103
  licenses: []
104
+ metadata: {}
97
105
  post_install_message:
98
106
  rdoc_options: []
99
107
  require_paths:
100
108
  - lib
101
109
  required_ruby_version: !ruby/object:Gem::Requirement
102
- none: false
103
110
  requirements:
104
- - - ! '>='
111
+ - - ">="
105
112
  - !ruby/object:Gem::Version
106
113
  version: '0'
107
114
  required_rubygems_version: !ruby/object:Gem::Requirement
108
- none: false
109
115
  requirements:
110
- - - ! '>='
116
+ - - ">="
111
117
  - !ruby/object:Gem::Version
112
118
  version: '0'
113
119
  requirements: []
114
120
  rubyforge_project:
115
- rubygems_version: 1.8.23
121
+ rubygems_version: 2.2.2
116
122
  signing_key:
117
- specification_version: 3
123
+ specification_version: 4
118
124
  summary: Gemfiler knows how to make Gemfiles organized and reader friendly.
119
125
  test_files:
120
126
  - spec/bundler_shim_spec.rb
data/lib/Gemfiler.rb DELETED
@@ -1,9 +0,0 @@
1
- require_relative "gemfiler/version"
2
-
3
- module Gemfiler
4
- autoload :Cabinet, 'gemfiler/cabinet'
5
- autoload :BundlerShim, 'gemfiler/bundler_shim'
6
- autoload :Filer, 'gemfiler/filer'
7
- autoload :Output, 'gemfiler/output'
8
- autoload :CLI, 'gemfiler/cli'
9
- end