class Origen::Client

Client for communicating with the Origen server

Constants

DEV_PORT
USE_DEV_SERVER

include HTTParty

Public Instance Methods

get(path, options = {}) click to toggle source
# File lib/origen/client.rb, line 21
def get(path, options = {})
  self.class.get("#{url}/#{path}", options)
end
latest_development() click to toggle source

Returns the latest developmen Origen version

# File lib/origen/client.rb, line 95
def latest_development
  Origen::VersionString.new(origen[:latest_version_dev])
end
latest_production() click to toggle source

Returns the latest production Origen version

# File lib/origen/client.rb, line 90
def latest_production
  Origen::VersionString.new(origen[:latest_version_prod])
end
origen() click to toggle source

Returns a data packet for Origen core

# File lib/origen/client.rb, line 68
def origen
  @origen ||= begin
    response = get('plugins/origen_core')
    JSON.parse(response.body, symbolize_names: true)[:plugin]
  end
end
Also aliased as: origen_core
origen_core()
Alias for: origen
plugin(name) click to toggle source
# File lib/origen/client.rb, line 62
def plugin(name)
  response = get("plugins/#{name}")
  JSON.parse(response.body, symbolize_names: true)[:plugin]
end
plugins() click to toggle source

Returns an array of data packets for all plugins

# File lib/origen/client.rb, line 55
def plugins
  return @plugins if @plugins

  response = get('plugins')
  @plugins = JSON.parse(response.body, symbolize_names: true)[:plugins]
end
port() click to toggle source
# File lib/origen/client.rb, line 33
def port
  USE_DEV_SERVER ? DEV_PORT : 80
end
post(path, options = {}) click to toggle source
# File lib/origen/client.rb, line 14
def post(path, options = {})
  options[:port] = port
  invocation_url = URI.parse("#{url}/#{path}")
  http = Net::HTTP.new(invocation_url.host, invocation_url.port)
  http.post(invocation_url, JSON.dump(options[:body]), 'Content-type' => 'application/vnd.api+json', 'Accept' => 'text/json, application/vnd.api+json')
end
record_invocation(command) click to toggle source
# File lib/origen/client.rb, line 37
def record_invocation(command)
  content = {
    data: {
      type:       'applications',
      attributes: {
        user:             Origen.current_user.core_id,
        application:      Origen.app.config.initials,
        "app-version":    Origen.app.version,
        "origen-version": Origen.version,
        command:          command,
        platform:         Origen.running_on_windows? ? 'windows' : 'linux'
      }
    }
  }
  post('applications', body: content)
end
release!() click to toggle source

This will be called by the Origen release process to post the latest app version information to the server

# File lib/origen/client.rb, line 78
def release!
  version = Origen.app.version
  body = { version: version.to_s }
  if version.production?
    body[:type] = :production
  else
    body[:type] = :development
  end
  post("plugins/#{Origen.app.name}/release", body: body)
end
url() click to toggle source
# File lib/origen/client.rb, line 25
def url
  if Origen.site_config.invocation_url.nil?
    'http://localhost:3000'
  else
    Origen.site_config.invocation_url
  end
end