Class: Commands::MakeSample

Inherits:
Object
  • Object
show all
Defined in:
lib/commands/make_sample.rb

Instance Method Summary collapse

Instance Method Details

#optionsObject

holds the options that were passed you can set any initial defaults here



13
14
15
16
# File 'lib/commands/make_sample.rb', line 13

def options
  @options ||= {
  }
end

#register(opts, global_options) ⇒ Object



25
26
27
28
29
30
31
32
33
# File 'lib/commands/make_sample.rb', line 25

def register(opts, global_options)
  opts.banner = "Usage: make_sample [options]"
  opts.description = "Make a sample config file"

  opts.on('-c', "--config name", "Required - Name of the config we are making.") do |v|
    options[:config] = v
  end

end

#required_optionsObject

required options



19
20
21
22
23
# File 'lib/commands/make_sample.rb', line 19

def required_options
  @required_options ||= Set.new [
      :config,
  ]
end

#run(global_options) ⇒ Object



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
77
78
79
80
81
82
83
# File 'lib/commands/make_sample.rb', line 36

def run(global_options)

  # create a sample config file in the current directory - we append the .config suffix
  # the file will be in JSON format
  config_name = options[:config]

  config_path = "#{config_name}#{EbmSharedLib::CONFIG_SUFFIX}"

  begin
    sample = {
        :repos => [
            {
              :branch => "iphone_3.1",
              :create_dev_branch => true,
              :git_path => "[email protected]:eBayMobile/ios_iphone_core.git",
              :taggable => true,
            },
            {
              :branch => "nautilus_3.1",
              :create_dev_branch => true,
              :git_path => "[email protected]:eBayMobile/ios_nautilus.git",
              :taggable => true,
            },
            {
              :tag => "2.2.9",
              :git_path => "[email protected]:ios-mobile-framework/CoreFramework.git",
              :parent_path => "Framework",
            },
            {
              :tag => "2.0.10",
              :git_path => "[email protected]:ios-mobile-framework/ImagePickerModule.git",
              :parent_path => "Framework/Modules",
            },
            {
              :tag => "11fb35782f647a13552ccbd620ca4e88b75a8977",
              :git_path => "[email protected]:cfry/RegistrationModule.git",
              :parent_path => "Framework/Modules",
            },
        ],
    }

    json = JSON.pretty_generate(sample)

    File.open(config_path, 'w') { |file| file.write(json) }
  rescue
    raise "Error creating config file JSON: #{config_path}"
  end
end