blaze 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -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 documentation
data/.rvmrc ADDED
@@ -0,0 +1 @@
1
+ rvm 1.9.3@blaze
@@ -0,0 +1,12 @@
1
+ language: ruby
2
+ rvm:
3
+ - 1.8.7
4
+ - 1.9.2
5
+ - 1.9.3
6
+ - jruby-18mode
7
+ - jruby-19mode
8
+ - rbx-18mode
9
+ - rbx-19mode
10
+ - ruby-head
11
+ - jruby-head
12
+ - ree
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in blaze.gemspec
4
+ gemspec
data/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2012 iain
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.
@@ -0,0 +1,65 @@
1
+ # Blaze
2
+
3
+ [![Build Status](https://secure.travis-ci.org/iain/blaze.png?branch=master)](http://travis-ci.org/iain/blaze)
4
+
5
+ Just a tiny simple gem which lets you speak on Campfire. No runtime dependencies!
6
+
7
+ ## Installation
8
+
9
+ Add this line to your application's Gemfile:
10
+
11
+ gem 'blaze'
12
+
13
+ And then execute:
14
+
15
+ $ bundle
16
+
17
+ Or install it yourself as:
18
+
19
+ $ gem install blaze
20
+
21
+ ## Usage
22
+
23
+ Configure blaze:
24
+
25
+ ``` ruby
26
+ require 'blaze'
27
+
28
+ Blaze.configure do |config|
29
+ config.account = "your-subdomain"
30
+ config.room_id = 12345
31
+ config.token = "abcd"
32
+ config.ssl = true
33
+ end
34
+ ```
35
+
36
+ And speak:
37
+
38
+ ``` ruby
39
+ Blaze.speak "hello there!"
40
+ ```
41
+
42
+ ## Coming up in v1.0
43
+
44
+ A way to allow you to spam more rooms in one Ruby process.
45
+
46
+ This would probably look something like:
47
+
48
+ ``` ruby
49
+ client = Blaze::Client.new do |client|
50
+ client.account = "your-subdomain"
51
+ client.room_id = 12345
52
+ client.token = "abcd"
53
+ client.ssl = true
54
+ end
55
+
56
+ client.speak "Hello"
57
+ ```
58
+
59
+ ## Contributing
60
+
61
+ 1. Fork it
62
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
63
+ 3. Commit your changes (`git commit -am 'Added some feature'`)
64
+ 4. Push to the branch (`git push origin my-new-feature`)
65
+ 5. Create new Pull Request
@@ -0,0 +1,6 @@
1
+ #!/usr/bin/env rake
2
+ require "bundler/gem_tasks"
3
+
4
+ require 'rspec/core/rake_task'
5
+ RSpec::Core::RakeTask.new(:spec)
6
+ task :default => :spec
@@ -0,0 +1,21 @@
1
+ # -*- encoding: utf-8 -*-
2
+ require File.expand_path('../lib/blaze/version', __FILE__)
3
+
4
+ Gem::Specification.new do |gem|
5
+ gem.authors = ["iain"]
6
+ gem.email = ["iain@iain.nl"]
7
+ gem.description = %q{Very simple Campfire notification gem}
8
+ gem.summary = %q{Very simple Campfire notification gem}
9
+ gem.homepage = "https://github.com/iain/blaze"
10
+
11
+ gem.files = `git ls-files`.split($\)
12
+ gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
13
+ gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
14
+ gem.name = "blaze"
15
+ gem.require_paths = ["lib"]
16
+ gem.version = Blaze::VERSION
17
+
18
+ gem.add_development_dependency 'rspec'
19
+ gem.add_development_dependency 'webmock'
20
+
21
+ end
@@ -0,0 +1,40 @@
1
+ require 'blaze/version'
2
+ require 'blaze/configuration'
3
+ require 'net/http'
4
+ require 'json'
5
+
6
+ module Blaze
7
+ extend self
8
+
9
+ def configure
10
+ yield configuration
11
+ end
12
+
13
+ def configuration
14
+ @configuration ||= Configuration.new
15
+ end
16
+
17
+ def speak(message)
18
+ configuration.validate!
19
+ port = configuration.ssl ? 443 : 80
20
+
21
+ req = Net::HTTP::Post.new("/room/#{configuration.room_id}/speak.json")
22
+ req.basic_auth configuration.token, 'X'
23
+ req.body = { :message => { :body => message } }.to_json
24
+ req.content_type = "application/json"
25
+ req["User-Agent"] = "Blaze"
26
+
27
+ res = Net::HTTP.start("#{configuration.account}.campfirenow.com", port, :use_ssl => configuration.ssl) do |http|
28
+ http.request(req)
29
+ end
30
+
31
+ if res.is_a?(Net::HTTPSuccess)
32
+ warn "Campfire message sent!"
33
+ else
34
+ warn "Campfire communication failed!"
35
+ warn res.inspect
36
+ warn res.body.inspect
37
+ end
38
+ end
39
+
40
+ end
@@ -0,0 +1,36 @@
1
+ module Blaze
2
+
3
+ class Configuration
4
+
5
+ attr_accessor :account, :room_id, :token, :ssl
6
+
7
+ def []=(option, value)
8
+ send "#{option}=", value
9
+ end
10
+
11
+ def [](option)
12
+ send option
13
+ end
14
+
15
+ def validate!
16
+ %w(account room_id token).each do |option|
17
+ if send(option).nil?
18
+ fail MissingOption.new(option)
19
+ end
20
+ end
21
+ end
22
+
23
+ class MissingOption < RuntimeError
24
+
25
+ def initialize(option)
26
+ @option = option
27
+ end
28
+
29
+ def to_s
30
+ "Please specify the #{@option} option"
31
+ end
32
+
33
+ end
34
+ end
35
+
36
+ end
@@ -0,0 +1,3 @@
1
+ module Blaze
2
+ VERSION = "0.0.1"
3
+ end
@@ -0,0 +1,33 @@
1
+ require 'blaze'
2
+ require 'webmock'
3
+
4
+ describe Blaze do
5
+ include WebMock::API
6
+
7
+ around do |example|
8
+ $stderr = StringIO.new
9
+ example.run
10
+ $stderr = STDERR
11
+ end
12
+
13
+ it "can speak" do
14
+ token = "abc"
15
+ room_id = 1234
16
+ account = "abcd"
17
+
18
+ stub_request(:post, "http://#{token}:X@#{account}.campfirenow.com/room/#{room_id}/speak.json").
19
+ with(:body => "{\"message\":{\"body\":\"Ik ben een gem aan het maken\"}}",
20
+ :headers => {'Accept'=>'*/*', 'Content-Type'=>'application/json', 'User-Agent'=>'Blaze'}).
21
+ to_return(:status => 200, :body => "", :headers => {})
22
+
23
+ subject.configure do |config|
24
+ config.account = account
25
+ config.room_id = room_id
26
+ config.token = token
27
+ config.ssl = false
28
+ end
29
+
30
+ subject.speak "Ik ben een gem aan het maken"
31
+ end
32
+
33
+ end
@@ -0,0 +1,20 @@
1
+ require 'blaze/configuration'
2
+
3
+ describe Blaze::Configuration do
4
+
5
+ REQUIRED = %W(account room_id token)
6
+
7
+ before do
8
+ REQUIRED.each do |option|
9
+ subject[option] = "foo"
10
+ end
11
+ end
12
+
13
+ REQUIRED.each do |option|
14
+ it "requires #{option} to be set" do
15
+ subject[option] = nil
16
+ expect { subject.validate! }.to raise_error("Please specify the #{option} option")
17
+ end
18
+ end
19
+
20
+ end
metadata ADDED
@@ -0,0 +1,93 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: blaze
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - iain
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2012-06-14 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: rspec
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: '0'
22
+ type: :development
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ! '>='
28
+ - !ruby/object:Gem::Version
29
+ version: '0'
30
+ - !ruby/object:Gem::Dependency
31
+ name: webmock
32
+ requirement: !ruby/object:Gem::Requirement
33
+ none: false
34
+ requirements:
35
+ - - ! '>='
36
+ - !ruby/object:Gem::Version
37
+ version: '0'
38
+ type: :development
39
+ prerelease: false
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ! '>='
44
+ - !ruby/object:Gem::Version
45
+ version: '0'
46
+ description: Very simple Campfire notification gem
47
+ email:
48
+ - iain@iain.nl
49
+ executables: []
50
+ extensions: []
51
+ extra_rdoc_files: []
52
+ files:
53
+ - .gitignore
54
+ - .rspec
55
+ - .rvmrc
56
+ - .travis.yml
57
+ - Gemfile
58
+ - LICENSE
59
+ - README.md
60
+ - Rakefile
61
+ - blaze.gemspec
62
+ - lib/blaze.rb
63
+ - lib/blaze/configuration.rb
64
+ - lib/blaze/version.rb
65
+ - spec/blaze/blaze_spec.rb
66
+ - spec/blaze/configuration_spec.rb
67
+ homepage: https://github.com/iain/blaze
68
+ licenses: []
69
+ post_install_message:
70
+ rdoc_options: []
71
+ require_paths:
72
+ - lib
73
+ required_ruby_version: !ruby/object:Gem::Requirement
74
+ none: false
75
+ requirements:
76
+ - - ! '>='
77
+ - !ruby/object:Gem::Version
78
+ version: '0'
79
+ required_rubygems_version: !ruby/object:Gem::Requirement
80
+ none: false
81
+ requirements:
82
+ - - ! '>='
83
+ - !ruby/object:Gem::Version
84
+ version: '0'
85
+ requirements: []
86
+ rubyforge_project:
87
+ rubygems_version: 1.8.24
88
+ signing_key:
89
+ specification_version: 3
90
+ summary: Very simple Campfire notification gem
91
+ test_files:
92
+ - spec/blaze/blaze_spec.rb
93
+ - spec/blaze/configuration_spec.rb