Class: Classroom::Commands::Clone

Inherits:
Object
  • Object
show all
Defined in:
lib/classroom/commands/clone.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options) ⇒ Clone

Returns a new instance of Clone.



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/classroom/commands/clone.rb', line 6

def initialize options

    # TODO: make file an option, and give error if file does not exist

    projects = YAML.load_file('projects.yml')['projects']
    puts projects.inspect if options[:verbose]

    puts "Clonin projects..."
    projects.each do |url|
        # student_name = url[/github.com\/(.*)\//, 1]

        # # puts student_name

    
        # url_path = url[/github.com\/(.*)/, 1] + ".git"

        # ssh_url = "[email protected]:" + url_path

    
        clone_project url
    end
    puts "done!"
end

Class Method Details

.optsparserObject



30
31
32
33
34
35
36
37
38
# File 'lib/classroom/commands/clone.rb', line 30

def self.optsparser
    OptionParser.new do |opts|
        opts.banner = "Usage: classroom foo [options]"
        
        opts.on("-v", "--[no-]verbose", "Run verbosely") do |v|
            options[:verbose] = v
        end
    end
end

Instance Method Details

#clone_project(url, project_name = nil) ⇒ Object



25
26
27
28
# File 'lib/classroom/commands/clone.rb', line 25

def clone_project url, project_name = nil
    # TODO: enable to choose projectname 

    system("git clone #{url}")
end