Class: MoveToGo::Sources

Inherits:
Object
  • Object
show all
Defined in:
lib/move-to-go/source.rb

Instance Method Summary collapse

Constructor Details

#initialize(path) ⇒ Sources

Returns a new instance of Sources.



6
7
8
# File 'lib/move-to-go/source.rb', line 6

def initialize(path)
    @path = path
end

Instance Method Details

#about_source(source_name) ⇒ Object



39
40
41
42
43
44
45
46
# File 'lib/move-to-go/source.rb', line 39

def about_source(source_name)
    if !source_exists?(source_name)
        puts "The source '#{source_name}' doesnt exist."
        return false
    end
    
    print_about_file_for_source(source_name)
end

#create_project_from_source(project_name, source_name) ⇒ Object



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/move-to-go/source.rb', line 16

def create_project_from_source(project_name, source_name)
    if !source_exists?(source_name)
        puts "The source '#{source_name}' doesnt exist."
        return false
    end

    if project_exists?(project_name)
        puts "A project named '#{project_name}' already exists"
        return false
    end

    begin
        copy_source_to_folder(source_name, project_name)

        install_gems_for_project(project_name)
        return true
    rescue
        puts "Something when wrong (errors should have been printed above)..."
        FileUtils.remove_dir(project_name, true)
        return false
    end
end

#listObject



10
11
12
13
14
# File 'lib/move-to-go/source.rb', line 10

def list()
    Dir.entries(@path).select {
        |f| f != '.' && f != '..'
    }
end