Class: Checkson::APIClient
- Inherits:
-
Object
- Object
- Checkson::APIClient
- Defined in:
- lib/checkson/apiclient.rb
Instance Attribute Summary collapse
-
#apiaddr ⇒ Object
readonly
Returns the value of attribute apiaddr.
-
#outfile ⇒ Object
readonly
Returns the value of attribute outfile.
Instance Method Summary collapse
- #getchecks ⇒ Object
-
#initialize(apiaddr, outfile) ⇒ APIClient
constructor
A new instance of APIClient.
- #writechecks ⇒ Object
Constructor Details
#initialize(apiaddr, outfile) ⇒ APIClient
Returns a new instance of APIClient.
15 16 17 18 |
# File 'lib/checkson/apiclient.rb', line 15 def initialize(apiaddr, outfile) @apiaddr = apiaddr @outfile = outfile end |
Instance Attribute Details
#apiaddr ⇒ Object (readonly)
Returns the value of attribute apiaddr.
13 14 15 |
# File 'lib/checkson/apiclient.rb', line 13 def apiaddr @apiaddr end |
#outfile ⇒ Object (readonly)
Returns the value of attribute outfile.
13 14 15 |
# File 'lib/checkson/apiclient.rb', line 13 def outfile @outfile end |
Instance Method Details
#getchecks ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/checkson/apiclient.rb', line 20 def getchecks template = " <%@checks.each do |check| %>\n check '<%=check[\"description\"]%>' do\n using <%=check[\"check\"]%>\n <%check[\"sets\"].each do |key,value| %>\n set :<%=key%>, \"<%=value%>\"\n <%end%>\n <%unless check[\"helps\"].eql?(nil)%>\n <%check[\"helps\"].each do |help| %>\n help '<%= help %>'\n <%end%>\n <%end%>\n end\n <% end %>\n TEMPLATE\n querydata = get\n @checks = querydata['checks'] if querydata['status'].eql? 'ok'\n begin\n remove_empty_lines(ERB.new(template).result(binding))\n rescue StandardError\n die querydata['error']\n end\nend\n" |
#writechecks ⇒ Object
45 46 47 48 49 |
# File 'lib/checkson/apiclient.rb', line 45 def writechecks File.open(@outfile, 'w') do |f| f.write(getchecks) end end |