Class: Clean::Idea::Manager

Inherits:
Object
  • Object
show all
Defined in:
lib/idea.rb

Instance Method Summary collapse

Constructor Details

#initialize(arguments) ⇒ Manager

Returns a new instance of Manager.



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/idea.rb', line 7

def initialize(arguments)
  puts "Let the wipe begin....".yellow

  if !is_android_project?
    puts "but.. but... this isn't even an android project!".red
    exit
  end

  ideas = get_all_idea_folders
  imls = get_all_imls

  if ideas.empty? && imls.empty?
    puts "You have nothing to clean, cool!!".green
    exit
  end

  # wipe them all
  delete_them_all ideas
  delete_them_all imls

end

Instance Method Details

#delete(item) ⇒ Object



38
39
40
41
42
# File 'lib/idea.rb', line 38

def delete(item)
  puts "Deleting: #{item.green}"
  FileUtils.rm_f(item) if File.exist?(item)
  FileUtils.remove_dir(item) if File.directory?(item)
end

#delete_them_all(array) ⇒ Object



30
31
32
33
34
35
36
# File 'lib/idea.rb', line 30

def delete_them_all array
  return nil if !array

  array.each do |item|
    delete item
  end
end

#get_all_idea_foldersObject



44
45
46
# File 'lib/idea.rb', line 44

def get_all_idea_folders
  Dir.glob("#{Dir.pwd}/**/.idea/")
end

#get_all_imlsObject



48
49
50
# File 'lib/idea.rb', line 48

def get_all_imls
  Dir.glob("#{Dir.pwd}/**/*.iml")
end

#is_android_project?Boolean

Returns:

  • (Boolean)


52
53
54
# File 'lib/idea.rb', line 52

def is_android_project?
  File.exists?("#{Dir.pwd}/settings.gradle")
end