webhook_stopwatch_client 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore ADDED
@@ -0,0 +1,17 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --color
2
+ --format progress
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in webhook_stopwatch_client.gemspec
4
+ gemspec
data/Guardfile ADDED
@@ -0,0 +1,5 @@
1
+ guard 'rspec' do
2
+ watch(%r{^spec/.+_spec\.rb$})
3
+ watch(%r{^lib/(.+)\.rb$}) { |m| "spec/lib/#{m[1]}_spec.rb" }
4
+ watch('spec/spec_helper.rb') { "spec" }
5
+ end
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2013 Donald Plummer
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,29 @@
1
+ # WebhookStopwatchClient
2
+
3
+ TODO: Write a gem description
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ gem 'webhook_stopwatch_client'
10
+
11
+ And then execute:
12
+
13
+ $ bundle
14
+
15
+ Or install it yourself as:
16
+
17
+ $ gem install webhook_stopwatch_client
18
+
19
+ ## Usage
20
+
21
+ TODO: Write usage instructions here
22
+
23
+ ## Contributing
24
+
25
+ 1. Fork it
26
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
27
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
28
+ 4. Push to the branch (`git push origin my-new-feature`)
29
+ 5. Create new Pull Request
data/Rakefile ADDED
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
@@ -0,0 +1,27 @@
1
+ require 'faraday'
2
+
3
+ module WebhookStopwatch
4
+ class Client
5
+ attr_reader :base_url
6
+
7
+ def initialize(base_url)
8
+ @base_url = base_url
9
+ end
10
+
11
+ def start(message_id, timestamp)
12
+ connection.post("/messages/#{message_id}/start", "timestamp" => timestamp).
13
+ success?
14
+ end
15
+
16
+ def stop(message_id, timestamp)
17
+ connection.post("/messages/#{message_id}/stop", "timestamp" => timestamp).
18
+ success?
19
+ end
20
+
21
+ private
22
+
23
+ def connection
24
+ Faraday.new(:url => base_url)
25
+ end
26
+ end
27
+ end
@@ -0,0 +1 @@
1
+ require "#{File.dirname(__FILE__)}/webhook_stopwatch/client"
@@ -0,0 +1,59 @@
1
+ require 'spec_helper'
2
+
3
+ describe WebhookStopwatch::Client do
4
+ let(:base_url) { "http://0.0.0.0:9292" }
5
+
6
+ subject { WebhookStopwatch::Client.new(base_url) }
7
+
8
+ before(:each) do
9
+ stub_request(:post, /#{base_url}/)
10
+ end
11
+
12
+ describe "#start" do
13
+ it "POSTs to start" do
14
+ subject.start(123, 1000000)
15
+
16
+ a_request(:post, "http://0.0.0.0:9292/messages/123/start").
17
+ with(:body => {"timestamp" => "1000000"}).
18
+ should have_been_made
19
+ end
20
+
21
+ it "returns true" do
22
+ subject.start(123, 1000000).should == true
23
+ end
24
+
25
+ context "all hell breaks loose" do
26
+ before(:each) do
27
+ stub_request(:post, /#{base_url}/).to_return(:status => 500)
28
+ end
29
+
30
+ it "returns false" do
31
+ subject.start(123, 1000000).should == false
32
+ end
33
+ end
34
+ end
35
+
36
+ describe "#stop" do
37
+ it "POSTs to stop" do
38
+ subject.stop(123, 1000000)
39
+
40
+ a_request(:post, "http://0.0.0.0:9292/messages/123/stop").
41
+ with(:body => {"timestamp" => "1000000"}).
42
+ should have_been_made
43
+ end
44
+
45
+ it "returns true" do
46
+ subject.stop(123, 1000000).should == true
47
+ end
48
+
49
+ context "all hell breaks loose" do
50
+ before(:each) do
51
+ stub_request(:post, /#{base_url}/).to_return(:status => 500)
52
+ end
53
+
54
+ it "returns false" do
55
+ subject.stop(123, 1000000).should == false
56
+ end
57
+ end
58
+ end
59
+ end
@@ -0,0 +1,10 @@
1
+ require "#{File.dirname(__FILE__)}/../lib/webhook_stopwatch_client"
2
+ require 'webmock/rspec'
3
+
4
+ RSpec.configure do |config|
5
+ config.treat_symbols_as_metadata_keys_with_true_values = true
6
+ config.run_all_when_everything_filtered = true
7
+ config.filter_run :focus
8
+
9
+ config.order = 'random'
10
+ end
@@ -0,0 +1,25 @@
1
+ # coding: utf-8
2
+
3
+ Gem::Specification.new do |spec|
4
+ spec.name = "webhook_stopwatch_client"
5
+ spec.version = "0.0.1"
6
+ spec.authors = ["Donald Plummer", "Michael Xavier"]
7
+ spec.email = ["donald@crystalcommerce.com", "xavier@crystalcommerce.com"]
8
+ spec.description = %q{Client for sending events to webhook stopwatch}
9
+ spec.summary = %q{Client for sending events to webhook stopwatch}
10
+ spec.homepage = ""
11
+ spec.license = "MIT"
12
+
13
+ spec.files = `git ls-files`.split($/)
14
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
15
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
16
+ spec.require_paths = ["lib"]
17
+
18
+ spec.add_dependency "faraday"
19
+
20
+ spec.add_development_dependency "bundler", "~> 1.3"
21
+ spec.add_development_dependency "rake"
22
+ spec.add_development_dependency "guard-rspec"
23
+ spec.add_development_dependency "rspec"
24
+ spec.add_development_dependency "webmock"
25
+ end
metadata ADDED
@@ -0,0 +1,159 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: webhook_stopwatch_client
3
+ version: !ruby/object:Gem::Version
4
+ prerelease:
5
+ version: 0.0.1
6
+ platform: ruby
7
+ authors:
8
+ - Donald Plummer
9
+ - Michael Xavier
10
+ autorequire:
11
+ bindir: bin
12
+ cert_chain: []
13
+ date: 2013-03-15 00:00:00.000000000 Z
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ prerelease: false
17
+ type: :runtime
18
+ name: faraday
19
+ version_requirements: !ruby/object:Gem::Requirement
20
+ none: false
21
+ requirements:
22
+ - - ! '>='
23
+ - !ruby/object:Gem::Version
24
+ version: '0'
25
+ requirement: !ruby/object:Gem::Requirement
26
+ none: false
27
+ requirements:
28
+ - - ! '>='
29
+ - !ruby/object:Gem::Version
30
+ version: '0'
31
+ - !ruby/object:Gem::Dependency
32
+ prerelease: false
33
+ type: :development
34
+ name: bundler
35
+ version_requirements: !ruby/object:Gem::Requirement
36
+ none: false
37
+ requirements:
38
+ - - ~>
39
+ - !ruby/object:Gem::Version
40
+ version: '1.3'
41
+ requirement: !ruby/object:Gem::Requirement
42
+ none: false
43
+ requirements:
44
+ - - ~>
45
+ - !ruby/object:Gem::Version
46
+ version: '1.3'
47
+ - !ruby/object:Gem::Dependency
48
+ prerelease: false
49
+ type: :development
50
+ name: rake
51
+ version_requirements: !ruby/object:Gem::Requirement
52
+ none: false
53
+ requirements:
54
+ - - ! '>='
55
+ - !ruby/object:Gem::Version
56
+ version: '0'
57
+ requirement: !ruby/object:Gem::Requirement
58
+ none: false
59
+ requirements:
60
+ - - ! '>='
61
+ - !ruby/object:Gem::Version
62
+ version: '0'
63
+ - !ruby/object:Gem::Dependency
64
+ prerelease: false
65
+ type: :development
66
+ name: guard-rspec
67
+ version_requirements: !ruby/object:Gem::Requirement
68
+ none: false
69
+ requirements:
70
+ - - ! '>='
71
+ - !ruby/object:Gem::Version
72
+ version: '0'
73
+ requirement: !ruby/object:Gem::Requirement
74
+ none: false
75
+ requirements:
76
+ - - ! '>='
77
+ - !ruby/object:Gem::Version
78
+ version: '0'
79
+ - !ruby/object:Gem::Dependency
80
+ prerelease: false
81
+ type: :development
82
+ name: rspec
83
+ version_requirements: !ruby/object:Gem::Requirement
84
+ none: false
85
+ requirements:
86
+ - - ! '>='
87
+ - !ruby/object:Gem::Version
88
+ version: '0'
89
+ requirement: !ruby/object:Gem::Requirement
90
+ none: false
91
+ requirements:
92
+ - - ! '>='
93
+ - !ruby/object:Gem::Version
94
+ version: '0'
95
+ - !ruby/object:Gem::Dependency
96
+ prerelease: false
97
+ type: :development
98
+ name: webmock
99
+ version_requirements: !ruby/object:Gem::Requirement
100
+ none: false
101
+ requirements:
102
+ - - ! '>='
103
+ - !ruby/object:Gem::Version
104
+ version: '0'
105
+ requirement: !ruby/object:Gem::Requirement
106
+ none: false
107
+ requirements:
108
+ - - ! '>='
109
+ - !ruby/object:Gem::Version
110
+ version: '0'
111
+ description: Client for sending events to webhook stopwatch
112
+ email:
113
+ - donald@crystalcommerce.com
114
+ - xavier@crystalcommerce.com
115
+ executables: []
116
+ extensions: []
117
+ extra_rdoc_files: []
118
+ files:
119
+ - .gitignore
120
+ - .rspec
121
+ - Gemfile
122
+ - Guardfile
123
+ - LICENSE.txt
124
+ - README.md
125
+ - Rakefile
126
+ - lib/webhook_stopwatch/client.rb
127
+ - lib/webhook_stopwatch_client.rb
128
+ - spec/lib/webhook_stopwatch/client_spec.rb
129
+ - spec/spec_helper.rb
130
+ - webhook_stopwatch_client.gemspec
131
+ homepage: ''
132
+ licenses:
133
+ - MIT
134
+ post_install_message:
135
+ rdoc_options: []
136
+ require_paths:
137
+ - lib
138
+ required_ruby_version: !ruby/object:Gem::Requirement
139
+ none: false
140
+ requirements:
141
+ - - ! '>='
142
+ - !ruby/object:Gem::Version
143
+ version: '0'
144
+ required_rubygems_version: !ruby/object:Gem::Requirement
145
+ none: false
146
+ requirements:
147
+ - - ! '>='
148
+ - !ruby/object:Gem::Version
149
+ version: '0'
150
+ requirements: []
151
+ rubyforge_project:
152
+ rubygems_version: 1.8.25
153
+ signing_key:
154
+ specification_version: 3
155
+ summary: Client for sending events to webhook stopwatch
156
+ test_files:
157
+ - spec/lib/webhook_stopwatch/client_spec.rb
158
+ - spec/spec_helper.rb
159
+ has_rdoc: