Class: Origen::Client
Overview
Client for communicating with the Origen server
Constant Summary collapse
- USE_DEV_SERVER =
include HTTParty
false
- DEV_PORT =
3000
Instance Method Summary collapse
- #get(path, options = {}) ⇒ Object
-
#latest_development ⇒ Object
Returns the latest developmen Origen version.
-
#latest_production ⇒ Object
Returns the latest production Origen version.
-
#origen ⇒ Object
(also: #origen_core)
Returns a data packet for Origen core.
- #plugin(name) ⇒ Object
-
#plugins ⇒ Object
Returns an array of data packets for all plugins.
- #port ⇒ Object
- #post(path, options = {}) ⇒ Object
- #record_invocation(command) ⇒ Object
-
#release! ⇒ Object
This will be called by the Origen release process to post the latest app version information to the server.
- #url ⇒ Object
Instance Method Details
#get(path, options = {}) ⇒ Object
21 22 23 |
# File 'lib/origen/client.rb', line 21 def get(path, = {}) self.class.get("#{url}/#{path}", ) end |
#latest_development ⇒ Object
Returns the latest developmen Origen version
95 96 97 |
# File 'lib/origen/client.rb', line 95 def latest_development Origen::VersionString.new(origen[:latest_version_dev]) end |
#latest_production ⇒ Object
Returns the latest production Origen version
90 91 92 |
# File 'lib/origen/client.rb', line 90 def latest_production Origen::VersionString.new(origen[:latest_version_prod]) end |
#origen ⇒ Object Also known as: origen_core
Returns a data packet for Origen core
68 69 70 71 72 73 |
# 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 |
#plugin(name) ⇒ Object
62 63 64 65 |
# File 'lib/origen/client.rb', line 62 def plugin(name) response = get("plugins/#{name}") JSON.parse(response.body, symbolize_names: true)[:plugin] end |
#plugins ⇒ Object
Returns an array of data packets for all plugins
55 56 57 58 59 60 |
# 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 ⇒ Object
33 34 35 |
# File 'lib/origen/client.rb', line 33 def port USE_DEV_SERVER ? DEV_PORT : 80 end |
#post(path, options = {}) ⇒ Object
14 15 16 17 18 19 |
# File 'lib/origen/client.rb', line 14 def post(path, = {}) [:port] = port invocation_url = URI.parse("#{url}/#{path}") http = Net::HTTP.new(invocation_url.host, invocation_url.port) http.post(invocation_url, JSON.dump([:body]), 'Content-type' => 'application/vnd.api+json', 'Accept' => 'text/json, application/vnd.api+json') end |
#record_invocation(command) ⇒ Object
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
# 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! ⇒ Object
This will be called by the Origen release process to post the latest app version information to the server
78 79 80 81 82 83 84 85 86 87 |
# 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 ⇒ Object
25 26 27 28 29 30 31 |
# 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 |