Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Scm #2

Open
wants to merge 18 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
language: ruby
rvm:
- 2.0.0
- 2.1.5
- 2.1.10
- 2.2.1
- 2.2.5
- 2.3.1
4 changes: 2 additions & 2 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@ source "http://rubygems.org"
gem 'oj', '~> 2.1'
gem 'httparty', '~> 0.13'
gem 'paint', '~> 1.0'
gem 'rake', '~> 10.1'
gem 'rake', '~> 11.1'

# Add dependencies to develop your gem here.
# Include everything needed to run rake, tests, features, etc.
group :development do
gem 'jeweler', '~> 2.0'
gem 'rake-version', '~> 0.4'
gem 'rake-version', '~> 1.0'
gem 'simplecov', '~> 0.10', require: false
gem 'fakefs', '~> 0.6', require: 'fakefs/safe'
gem 'rspec', '~> 3.1'
Expand Down
10 changes: 9 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,20 +8,26 @@
[![Coverage Status](https://coveralls.io/repos/probedock/probedock-ruby/badge.svg)](https://coveralls.io/r/probedock/probedock-ruby?branch=master)
[![License](https://img.shields.io/github/license/probedock/probedock-ruby.svg)](LICENSE.txt)



## Requirements

* Ruby 2+



## Installation

Add it to your Gemfile:

```rb
gem 'probedock-ruby', '~> 0.1.5'
gem 'probedock-ruby', '~> 0.2.0'
```

Run `bundle install`.



## Contributing

* [Fork](https://help.github.com/articles/fork-a-repo)
Expand All @@ -31,6 +37,8 @@ Run `bundle install`.

Please add a [changelog](CHANGELOG.md) entry with your name for new features and bug fixes.



## License

Probe Dock RSpec is licensed under the [MIT License](http://opensource.org/licenses/MIT).
2 changes: 1 addition & 1 deletion Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ Jeweler::RubygemsDotOrgTasks.new
require 'rake-version'
RakeVersion::Tasks.new do |v|
v.copy 'README.md'
v.copy 'lib/probe_dock_ruby.rb'
v.copy 'lib/probedock_ruby.rb'
end

require 'rspec/core/rake_task'
Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.1.5
0.2.0
9 changes: 0 additions & 9 deletions lib/probe_dock_ruby.rb

This file was deleted.

180 changes: 0 additions & 180 deletions lib/probe_dock_ruby/config.rb

This file was deleted.

30 changes: 0 additions & 30 deletions lib/probe_dock_ruby/project.rb

This file was deleted.

2 changes: 1 addition & 1 deletion lib/probedock-ruby.rb
Original file line number Diff line number Diff line change
@@ -1 +1 @@
require 'probe_dock_ruby'
require 'probedock_ruby'
9 changes: 9 additions & 0 deletions lib/probedock_ruby.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# encoding: UTF-8
module ProbeDockProbe
VERSION = '0.2.0'

class Error < StandardError; end
class PayloadError < Error; end
end

Dir[File.join(File.dirname(__FILE__), File.basename(__FILE__, '.*'), '*.rb')].each{ |lib| require lib }
File renamed without changes.
32 changes: 14 additions & 18 deletions lib/probe_dock_ruby/client.rb → lib/probedock_ruby/client.rb
Original file line number Diff line number Diff line change
@@ -1,28 +1,24 @@
require 'paint'

module ProbeDockProbe

class Client

def initialize server, options = {}

@server = server
@publish, @local_mode, @workspace = options[:publish], options[:local_mode], options[:workspace]
@print_payload, @save_payload = options[:print_payload], options[:save_payload]

@uid = UID.new workspace: @workspace
def initialize config
@config = config
raise "A configuration is required" unless @config
end

def process test_run

return fail "No server to publish results to" if !@server
return fail "No server to publish results to" if !@config.server

test_run.uid = @uid.load_uid
uid = UID.new workspace: @config.workspace
test_run.uid = uid.load_uid

payload_options = {}
return false unless payload = build_payload(test_run, payload_options)

published = if !@publish
published = if !@config.publish
puts Paint["Probe Dock - Publishing disabled", :yellow]
false
elsif publish_payload payload
Expand All @@ -31,8 +27,8 @@ def process test_run
false
end

save_payload payload if @save_payload
print_payload payload if @print_payload
save_payload payload if @config.save_payload
print_payload payload if @config.print_payload

puts

Expand Down Expand Up @@ -66,26 +62,26 @@ def print_payload payload

def save_payload payload

missing = { "workspace" => @workspace, "server" => @server }.inject([]){ |memo,(k,v)| !v ? memo << k : memo }
missing = { "workspace" => @config.workspace, "server" => @config.server }.inject([]){ |memo,(k,v)| !v ? memo << k : memo }
return fail "Cannot save payload without a #{missing.join ' and '}" if missing.any?

FileUtils.mkdir_p File.dirname(payload_file)
File.open(payload_file, 'w'){ |f| f.write Oj.dump(payload, mode: :strict) }
end

def payload_file
@payload_file ||= File.join(@workspace, 'rspec', 'servers', @server.name, 'payload.json')
@payload_file ||= File.join(@config.workspace, 'rspec', 'servers', @config.server.name, 'payload.json')
end

def publish_payload payload

puts Paint["Probe Dock - Sending payload to #{@server.api_url}...", :magenta]
puts Paint["Probe Dock - Sending payload to #{@config.server.api_url}...", :magenta]

begin
if @local_mode
if @config.local_mode
puts Paint['Probe Dock - LOCAL MODE: not actually sending payload.', :yellow]
else
@server.upload payload
@config.server.upload payload
end
puts Paint["Probe Dock - Done!", :green]
true
Expand Down
Loading