Class: Ki::TestVersion

Inherits:
Object show all
Defined in:
lib/cmd/version_cmd.rb

Overview

Tests version from repository or metadata file

See Also:

Instance Method Summary collapse

Instance Method Details

#execute(ctx, args) ⇒ Object



114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
# File 'lib/cmd/version_cmd.rb', line 114

def execute(ctx, args)
  @tester = VersionTester.new.recursive(false).print(true)
  ver_strs = opts.parse(args)
  if ver_strs.size > 0 || @tester.recursive
    @tester.ki_home(ctx.ki_home)
    versions = ver_strs.map { |v| ctx.ki_home.version(v) }
  else
    versions = []
  end
  if @file
    versions.unshift Version.create_version(@file, @input_dir)
  end
  all_ok = true
  versions.each do |v|
    all_ok = all_ok && @tester.test_version(v)
  end
  if all_ok
    puts "All files ok."
  end
end

#helpObject



158
159
160
161
162
163
164
165
166
167
168
169
170
# File 'lib/cmd/version_cmd.rb', line 158

def help
  <<EOF
"#{shell_command}" tests versions, their files and their dependencies. Can also test version that has not been imported yet.

### Examples

#{shell_command} -r my/product other/product
#{shell_command} -f ki-version.json -i file-directory

### Parameters
#{opts}
EOF
end

#optsObject



135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
# File 'lib/cmd/version_cmd.rb', line 135

def opts
  OptionParser.new do |opts|
    opts.banner = ""
    opts.on("-f", "--file FILE", "Version source file. By default uses file's directory as source for binary files.'") do |v|
      if @input_dir.nil?
        dir = File.dirname(v)
        @input_dir = dir != "." ? dir : Dir.pwd
      end
      @file = v
    end
    opts.on("-i", "--input-directory INPUT-DIR", "Binary file input directory") do |v|
      @input_dir = v
    end
    opts.on("-r", "--recursive", "Tests version's dependencies also.'") do |v|
      @tester.recursive = true
    end
  end
end

#summaryObject



154
155
156
# File 'lib/cmd/version_cmd.rb', line 154

def summary
  "Tests versions and their dependencies"
end