Class: Stool::Command::Lib

Inherits:
Stool::Command show all
Defined in:
lib/stool/Command/Lib.rb,
lib/stool/Command/Lib/VersionAdd.rb

Direct Known Subclasses

VersionAdd

Defined Under Namespace

Classes: VersionAdd

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Stool::Command

#checkConfigFile, options, #pp

Constructor Details

#initialize(argv) ⇒ Lib

Returns a new instance of Lib.



23
24
25
26
27
28
# File 'lib/stool/Command/Lib.rb', line 23

def initialize(argv)
  # @info = LibInfo.new()
  @name = argv.shift_argument
  # @progress = argv.flag?('progress')
  super
end

Instance Attribute Details

#infoObject

查询结果lib信息



21
22
23
# File 'lib/stool/Command/Lib.rb', line 21

def info
  @info
end

#nameObject

要查询的lib名字



19
20
21
# File 'lib/stool/Command/Lib.rb', line 19

def name
  @name
end

Instance Method Details

#existAtPools?Boolean

Returns:

  • (Boolean)


47
48
49
50
51
52
53
54
55
56
57
58
59
# File 'lib/stool/Command/Lib.rb', line 47

def existAtPools?
  #在libPool中查找lib
  arrayPools = LibPool::List::pools_from_config
  arrayPools.each {|pool|
    Dir.new(pool.path).each{|file|
      if @name.eql?(file)
        path = pool.path + "/#{file}"
        @info = LibInfo::loadFromPath(path)
      end
    }
  }
  @info
end

#runObject



41
42
43
44
45
# File 'lib/stool/Command/Lib.rb', line 41

def run
  if @info
    @info.info_tos
  end
end

#validate!Object



30
31
32
33
34
35
36
37
38
39
# File 'lib/stool/Command/Lib.rb', line 30

def validate!
  super
  unless @name
    help! 'need the lib `NAME`.'
  end

  unless existAtPools?
    help! "the lib named #{@name} did not find."
  end
end