Module: RestAssuredCLI

Defined in:
lib/restassured_cli.rb,
lib/restassured_cli/version.rb

Constant Summary collapse

VERSION =
"0.1.2"

Class Method Summary collapse

Class Method Details

.process(firstArg, secondArg, options) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
# File 'lib/restassured_cli.rb', line 7

def self.process(firstArg, secondArg, options)
  # checking required first argument for null
  if firstArg.nil?
    puts "Error: Base package name cannot be null\n\n"
    Display.help
    return
  end
  # checking required second argument for null
  if secondArg.nil?
    puts "Error: Service name cannot be null\n\n"
    Display.help
    return
  end

  # setting default values
  if options.nil?
    options[:jdkVersion] = "1.7"
    options[:projectVersion] = "1.0.0"
    options[:full] = false
  end
  if options[:jdkVersion].nil?
    options[:jdkVersion] = "1.7"
  end
  if options[:projectVersion].nil?
    options[:projectVersion] = "1.0.0"
  end
  if options[:full].nil?
    options[:full] = false
  end

  $baseJavaPackage = firstArg

  # servicename = test module name
  $serviceName = secondArg

  # projectName = project root and can contain dashes
  $projectName = $serviceName

  # groupId = java test package names cannot contain dashes
  baseJavaPackageDashesRemoved = $baseJavaPackage.gsub(/-/, '')
  serviceNameDashesRemoved = $serviceName.gsub(/-/, '')
  $groupId = baseJavaPackageDashesRemoved + "." + serviceNameDashesRemoved

  # packageName = test directory path replaces . with /
  $packageName = baseJavaPackageDashesRemoved.gsub(/\./,'/') + '/' + serviceNameDashesRemoved

  filegen = CreateController.new("#{$projectName}", "#{$groupId}", "#{$serviceName}", "#{$packageName}")
  filegen.setJdkVersion(options[:jdkVersion])
  filegen.setProjectVersion(options[:projectVersion])
  files = FileNames.new("#{$serviceName}", "#{$packageName}")
  baseCopyToDir = "#{$projectName}/testing"

  # Create common directories
  filegen.mkdir_common
  filegen.mkdir_service_default
  if options[:full]
    filegen.mkdir_service_full
    files.full.each do |filename|
      filegen.copyFilesWithoutOverwriting "#{filename[0]}", "#{baseCopyToDir}/#{filename[1]}"
    end
  end
  # Default option
  files.default.each do |filename|
    filegen.copyFilesWithoutOverwriting "#{filename[0]}", "#{baseCopyToDir}/#{filename[1]}"
  end
  files.testRunner.each do |filename|
    filegen.copyFilesWithoutOverwriting "#{filename[0]}", "#{baseCopyToDir}/#{filename[1]}"
  end
  Display.results
end