Class: Raykit::Console

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

Class Method Summary collapse

Class Method Details

.import(hash) ⇒ Object



75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
# File 'lib/raykit/console.rb', line 75

def self.import(hash)
    puts 'scanning...'
    scanned_remotes = Raykit::Git::scan_remote_urls
    remotes = Raykit::Git::remote_urls
    count = 0
    scanned_remotes.each{|remote|
        if(!remotes.include?(remote))
            puts "imported " + Rainbow(remote).yellow.bright
            remotes.insert(0,remote)
            count = count + 1
        end
    }
    if(count > 0)
        puts 'updating Raykit::Git::remote_urls'
        Raykit::Git::remote_urls = remotes
    end
end

.list(hash) ⇒ Object



63
64
65
66
67
68
69
70
71
72
73
# File 'lib/raykit/console.rb', line 63

def self.list(hash)
    pattern=nil
    if(hash.include?(:pattern))
        pattern=hash[:pattern]
    end
    Raykit::Git::remote_urls.each{|url| 
        if(pattern.nil? || url.include?(pattern))
            puts Rainbow(url).yellow.bright
        end
    }
end

.rake(hash) ⇒ Object



93
94
95
96
97
98
99
100
101
102
103
104
105
106
# File 'lib/raykit/console.rb', line 93

def self.rake(hash)
    cmd = Raykit::Rake::run(hash[:remote],'master')
    elapsed_str = Timer.get_elapsed_str(cmd.elapsed)
    if(cmd.exitstatus == 0)
        puts elapsed_str + " " +  Rainbow(cmd.command).yellow.bright + " (#{cmd.directory})"
        return elapsed_str + " " + cmd.command
    else
        puts "\r\n" + cmd.command + "\r\n"
        puts "\r\n" + cmd.output + "\r\n"
        puts "\r\n" + cmd.error + "\r\n"
        puts ''
        abort Rainbow(elapsed_str).red.bright + " " +  Rainbow(cmd.command).white
    end
end

.runObject



42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
# File 'lib/raykit/console.rb', line 42

def self.run
    if(ARGV.length == 0)
        Parser.parse %w[--help]
        0
    else
        hash = Parser.parse ARGV
        #puts "hash: #{hash.to_s}"

        if(hash.include?(:verb))
            verb = hash[:verb]
            case verb
            when 'list'
                list(hash)
            when 'import'
                import(hash)
            when 'rake'
                rake(hash)
            end
        end
    end
end