freydis 0.0.2 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
data/lib/freydis/init.rb DELETED
@@ -1,78 +0,0 @@
1
- # lib/init.rb
2
-
3
- module Freydis
4
- module Init
5
-
6
- puts "===> Starting Init"
7
-
8
- def self.run(options)
9
- loop do
10
- puts %q{Please select an option:
11
-
12
- 1. Choose a disk (plug on)
13
- 2. Add more paths
14
- 3. Reset paths
15
- 4. Show options
16
- 5. Save & Quit}
17
-
18
- case gets.chomp
19
- when '1'
20
- select_disk(options)
21
- when '2'
22
- puts "Add a path..."
23
- add_path(options)
24
- when '3'
25
- puts "Reseting paths..."
26
- options[:paths] = []
27
- when '4'
28
- show_options(options)
29
- else
30
- puts "Quit."
31
- return
32
- end
33
- end
34
- end
35
-
36
- private
37
-
38
- def self.select_disk(options)
39
- disks_list = Dir.glob("/dev/sd?")
40
- puts "Available disks: (only type sdX)"
41
- disks_list.each { |d|
42
- your_disk = Freydis::Disk.new(d)
43
- puts "+ " + your_disk.complete_info
44
- }
45
- print "> "
46
- answer = $stdin.gets
47
- disk = answer.chomp
48
- if File.exist? "/dev/#{disk}"
49
- options[:disk] = disk
50
- puts "Disk #{disk} added."
51
- else
52
- puts "No disk #{disk} found."
53
- end
54
- end
55
-
56
- def self.add_path(options)
57
- print "> "
58
- answer = $stdin.gets
59
- new_path = answer.chomp if answer
60
- if Dir.exists? new_path
61
- options[:paths] << new_path
62
- puts "Path '#{new_path}' added"
63
- display_path(options)
64
- else
65
- puts "#{new_path} no found"
66
- end
67
- end
68
-
69
- def self.display_path(options)
70
- puts "Current paths:"
71
- options[:paths].each { |p| puts "+ #{p}" }
72
- end
73
-
74
- def self.show_options(options)
75
- puts options
76
- end
77
- end
78
- end