Class: Suspenders::Cleanup::OrganizeGemfile
- Inherits:
-
Object
- Object
- Suspenders::Cleanup::OrganizeGemfile
- Defined in:
- lib/suspenders/cleanup/organize_gemfile.rb
Instance Attribute Summary collapse
-
#current_group ⇒ Object
readonly
Returns the value of attribute current_group.
-
#current_lines ⇒ Object
readonly
Returns the value of attribute current_lines.
-
#gem_groups ⇒ Object
readonly
Returns the value of attribute gem_groups.
-
#gemfile ⇒ Object
readonly
Returns the value of attribute gemfile.
-
#new_line_markers ⇒ Object
readonly
Returns the value of attribute new_line_markers.
-
#new_lines ⇒ Object
readonly
Returns the value of attribute new_lines.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(gemfile) ⇒ OrganizeGemfile
constructor
A new instance of OrganizeGemfile.
- #perform ⇒ Object
Constructor Details
#initialize(gemfile) ⇒ OrganizeGemfile
Returns a new instance of OrganizeGemfile.
11 12 13 14 15 16 17 18 19 20 |
# File 'lib/suspenders/cleanup/organize_gemfile.rb', line 11 def initialize(gemfile) @gemfile = gemfile @current_lines = File.read(gemfile).lines @new_lines = [] @new_line_markers = [] @current_group = nil @gem_groups = {} end |
Instance Attribute Details
#current_group ⇒ Object (readonly)
Returns the value of attribute current_group.
8 9 10 |
# File 'lib/suspenders/cleanup/organize_gemfile.rb', line 8 def current_group @current_group end |
#current_lines ⇒ Object (readonly)
Returns the value of attribute current_lines.
8 9 10 |
# File 'lib/suspenders/cleanup/organize_gemfile.rb', line 8 def current_lines @current_lines end |
#gem_groups ⇒ Object (readonly)
Returns the value of attribute gem_groups.
8 9 10 |
# File 'lib/suspenders/cleanup/organize_gemfile.rb', line 8 def gem_groups @gem_groups end |
#gemfile ⇒ Object (readonly)
Returns the value of attribute gemfile.
8 9 10 |
# File 'lib/suspenders/cleanup/organize_gemfile.rb', line 8 def gemfile @gemfile end |
#new_line_markers ⇒ Object (readonly)
Returns the value of attribute new_line_markers.
8 9 10 |
# File 'lib/suspenders/cleanup/organize_gemfile.rb', line 8 def new_line_markers @new_line_markers end |
#new_lines ⇒ Object (readonly)
Returns the value of attribute new_lines.
8 9 10 |
# File 'lib/suspenders/cleanup/organize_gemfile.rb', line 8 def new_lines @new_lines end |
Class Method Details
.perform(gemfile) ⇒ Object
4 5 6 |
# File 'lib/suspenders/cleanup/organize_gemfile.rb', line 4 def self.perform(gemfile) new(gemfile).perform end |
Instance Method Details
#perform ⇒ Object
22 23 24 25 26 27 28 29 30 |
# File 'lib/suspenders/cleanup/organize_gemfile.rb', line 22 def perform remove_line_breaks sort_gems_and_groups add_gem_groups_to_gemfile add_line_breaks cleanup File.open(gemfile, "w+") { _1.write new_lines.join } end |