Module: Prepd
- Defined in:
- lib/prepd.rb,
lib/prepd/models.rb,
lib/prepd/version.rb,
lib/prepd/cli/commands.rb
Defined Under Namespace
Modules: Cli
Classes: Application, Client, Project
Constant Summary
collapse
- VERSION =
'0.1.1'
Class Method Summary
collapse
Class Method Details
.clients ⇒ Object
20
|
# File 'lib/prepd/cli/commands.rb', line 20
def self.clients; Client.pluck(:name); end
|
.commands ⇒ Object
7
8
9
|
# File 'lib/prepd/cli/commands.rb', line 7
def self.commands
puts (methods(false) - %i(:options= :options :commands default_settings)).join("\n")
end
|
.config ⇒ Object
13
|
# File 'lib/prepd.rb', line 13
def self.config; "#{work_dir}/config"; end
|
.current_client ⇒ Object
24
25
26
|
# File 'lib/prepd/cli/commands.rb', line 24
def self.current_client
@client
end
|
.current_client=(client) ⇒ Object
28
29
30
31
32
33
34
35
36
|
# File 'lib/prepd/cli/commands.rb', line 28
def self.current_client=(client)
STDOUT.puts 'duh'
@client = client
Dir.chdir(client.path) do
Pry.start(client, prompt: [proc { "prepd(#{client.name}) > " }])
end
STDOUT.puts 'duh2'
nil
end
|
.data_dir ⇒ Object
9
|
# File 'lib/prepd.rb', line 9
def self.data_dir; ENV['DATA_DIR']; end
|
.default_settings ⇒ Object
15
16
17
18
19
20
21
|
# File 'lib/prepd.rb', line 15
def self.default_settings
{
'VERSION' => '1',
'DATA_DIR' => "#{Dir.home}/prepd",
'VAGRANT_BASE_BOX' => 'debian/contrib-jessie64'
}
end
|
.files ⇒ Object
11
|
# File 'lib/prepd.rb', line 11
def self.files; Dir.glob("#{work_dir}/*"); end
|
.new(name) ⇒ Object
11
12
13
|
# File 'lib/prepd/cli/commands.rb', line 11
def self.new(name)
Client.create(name: name)
end
|
.options ⇒ Object
5
|
# File 'lib/prepd/cli/commands.rb', line 5
def self.options; @options; end
|
.options=(options) ⇒ Object
2
3
4
|
# File 'lib/prepd/cli/commands.rb', line 2
def self.options=(options)
@options = options
end
|
.projects ⇒ Object
22
|
# File 'lib/prepd/cli/commands.rb', line 22
def self.projects; Project.pluck(:name); end
|
.rm ⇒ Object
15
16
17
18
|
# File 'lib/prepd/cli/commands.rb', line 15
def self.rm
FileUtils.rm_rf(work_dir)
FileUtils.rm_rf(data_dir)
end
|
.scan ⇒ Object
Create records for exisitng directories in the DATA_DIR
24
25
26
27
28
29
30
31
32
33
|
# File 'lib/prepd.rb', line 24
def self.scan
clients = Dir.entries(ENV['DATA_DIR'])
clients.select { |entry| !entry.starts_with?('.') }.each do |client_name|
c = Client.find_or_create_by(name: client_name)
projects = Dir.entries("#{ENV['DATA_DIR']}/#{client_name}")
projects.select { |entry| !entry.starts_with?('.') }.each do |project_name|
c.projects.find_or_create_by(name: project_name)
end
end
end
|
.work_dir ⇒ Object
8
|
# File 'lib/prepd.rb', line 8
def self.work_dir; "#{Dir.home}/.prepd"; end
|