Class: Raykit::Console

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

Overview

The implementation for the raykit console application

Class Method Summary collapse

Class Method Details

.import(hash) ⇒ Object



90
91
92
93
94
95
96
97
98
# File 'lib/raykit/console.rb', line 90

def self.import(hash)
    pattern=''
    pattern=hash["pattern"] if(hash.include?("pattern"))
    puts 'scanning...'
    count=REPOSITORIES.length
    REPOSITORIES.import(pattern)
    new_count=REPOSITORIES.length-count
    puts "imported #{new_count} git repositories"
end

.list(hash) ⇒ Object



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

def self.list(hash)
    pattern=''
    if(hash.include?(:pattern))
        pattern=hash["pattern"]
    end
    pattern='' if(pattern.nil?)

    REPOSITORIES.each{|url|
        if(url.include?(pattern))
            puts Rainbow(url).yellow.bright
        end
    }
end

.rake(hash) ⇒ Object



100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
# File 'lib/raykit/console.rb', line 100

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

.runObject



54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
# File 'lib/raykit/console.rb', line 54

def self.run
    if(ARGV.length == 0)
        Parser.parse %w[--help]
        0
    else
        hash = Parser.parse ARGV
        if(hash.include?(:verb))
            verb = hash[:verb]
            case verb
            when 'list'
                list(hash)
            when 'import'
                import(hash)
            when 'rake'
                rake(hash)
            when 'work'
                work(hash)
            end
        end
    end
end

.work(hash) ⇒ Object



123
124
125
126
127
128
129
130
131
132
133
134
135
# File 'lib/raykit/console.rb', line 123

def self.work(hash)
    REPOSITORIES.each{|remote|
        if(remote.include?(hash[:pattern]))
            puts "remote: #{remote}"
            repo=Raykit::Git::Repository.new(remote)
            work=Raykit::Git::Directory.new(repo.get_dev_dir('work'))
            if(!Dir.exist?(work.directory))
                Raykit::run("git clone #{remote} #{work.directory}")
            end
            work.rake('default')
        end
    }
end