Class: VpsbClient::Builders::Trial

Inherits:
Object
  • Object
show all
Defined in:
lib/vpsb_client/builders/trial.rb

Instance Method Summary collapse

Constructor Details

#initialize(config, hoster_id = nil, application_id = nil, plan_id = nil) ⇒ Trial

Returns a new instance of Trial.



4
5
6
7
8
9
# File 'lib/vpsb_client/builders/trial.rb', line 4

def initialize(config, hoster_id=nil, application_id=nil, plan_id=nil)
  @config = config
  @hoster_id = hoster_id
  @application_id = application_id
  @plan_id = plan_id
end

Instance Method Details

#create_paramsObject



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
# File 'lib/vpsb_client/builders/trial.rb', line 17

def create_params
  trial_params = {}
  trial_params[:started_at] = Time.now
  trial_params[:hoster_id] = @hoster_id if @hoster_id
  trial_params[:application_id] = @application_id if @application_id
  trial_params[:plan_id] = @plan_id if @plan_id

  trial_params[:comment] = @config['comment']

  cpuinfo_parser = Builders::CpuinfoParser.new
  cpuinfo_parser.parse
  trial_params[:cpu_type] = cpuinfo_parser.model
  trial_params[:num_cores] = cpuinfo_parser.num
  trial_params[:cpu_mhz] = cpuinfo_parser.mhz

  issue_parser = Builders::IssueParser.new
  issue_parser.parse
  trial_params[:os] = issue_parser.os

  memory_parser = Builders::MemoryParser.new
  memory_parser.parse
  trial_params[:free_memory_mb] = memory_parser.free

  uname_parser = Builders::UnameParser.new
  uname_parser.parse
  trial_params[:kernel] = uname_parser.kernel

  trial_params[:client_hostname] = @config['client_hostname']
  trial_params[:ruby_version] = RUBY_VERSION
  trial_params[:rails_version] = defined?(Rails) ? Rails.version : nil

  trial_params[:datacenter] = @config['datacenter']

  trial_params
end

#lookup_paramsObject



11
12
13
14
15
# File 'lib/vpsb_client/builders/trial.rb', line 11

def lookup_params
  trial_params = {}
  trial_params[:client_hostname] = @config['client_hostname']
  trial_params
end