campy 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,3 +1,14 @@
1
+ ## 0.1.2 (unreleased)
2
+
3
+
4
+ ## 0.1.1 (April 5, 2012)
5
+
6
+ ### New features
7
+
8
+ * Add Campy::Room#paste message type. ([@fnichol][])
9
+ * Allow message to be read from STDIN in bin/campy. ([@fnichol][])
10
+
11
+
1
12
  ## 0.1.0 (April 4, 2012)
2
13
 
3
14
  The initial release.
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
- # <a name="title"></a> Campy [![Build Status](https://secure.travis-ci.org/fnichol/campy.png)](http://travis-ci.org/fnichol/campy)
1
+ # <a name="title"></a> Campy [![Build Status](https://secure.travis-ci.org/fnichol/campy.png)](http://travis-ci.org/fnichol/campy) [![Dependency Status](https://gemnasium.com/fnichol/campy.png)](https://gemnasium.com/fnichol/campy)
2
2
 
3
- Tiny Campfire client so you can get on with it. It's implemented on top of
3
+ Tiny Campfire Ruby client so you can get on with it. It's implemented on top of
4
4
  `Net::HTTP` and only requires the `multi_json` gem for Ruby compatibilities.
5
5
 
6
6
  ## <a name="installation"></a> Installation
@@ -42,9 +42,18 @@ command line:
42
42
 
43
43
  ```bash
44
44
  $ campy speak "Campy says yello"
45
+ $ campy paste "Long pastes are long"
45
46
  $ campy play ohmy
46
47
  ```
47
48
 
49
+ Or pipe in your message:
50
+
51
+ ```bash
52
+ $ echo "Campy tries to honor unix conventions" | campy speak
53
+ $ cat ~/stackdump.log | campy paste
54
+ $ echo ohmy | campy play
55
+ ```
56
+
48
57
  ### <a name="usage-ruby"></a> Ruby Library
49
58
 
50
59
  There's not much to the API; create a `Campy::Room` and go:
@@ -52,9 +61,10 @@ There's not much to the API; create a `Campy::Room` and go:
52
61
  ```ruby
53
62
  require 'campy'
54
63
 
55
- campy = Campy::Room.new(:account => "mysubdomain", :token => "mytoken123",
56
- :room => "House of Hubot")
64
+ campy = Campy::Room.new(:account => "mysubdomain",
65
+ :token => "mytoken123", :room => "House of Hubot")
57
66
  campy.speak "Campy says yello"
67
+ campy.paste "Long pastes are long"
58
68
  campy.play "ohmy"
59
69
  ```
60
70
 
@@ -64,8 +74,10 @@ Why not use the `campfire.yml` config? Let's do that:
64
74
  require 'campy'
65
75
  require 'yaml'
66
76
 
67
- campy = Campy::Room.new(YAML.load_file(File.expand_path("~/.campfire.yml")))
77
+ campy = Campy::Room.new(YAML.load_file(
78
+ File.expand_path("~/.campfire.yml")))
68
79
  campy.speak "Campy says yello"
80
+ campy.paste "Long pastes are long"
69
81
  campy.play "ohmy"
70
82
  ```
71
83
 
data/bin/campy CHANGED
@@ -4,14 +4,6 @@ $:.unshift File.join(File.dirname(__FILE__), '..', 'lib')
4
4
  require 'campy'
5
5
  require 'yaml'
6
6
 
7
- def options
8
- yaml_file = File.expand_path(ENV['CAMPFIRE_YAML_FILE'] || '~/.campfire.yml')
9
- if !File.exists?(yaml_file)
10
- abort "File '#{yaml_file}' does not exist with campfire configuration."
11
- end
12
- YAML.load_file(yaml_file)
13
- end
14
-
15
7
  def usage
16
8
  <<-USAGE.gsub(/^ {4}/, '')
17
9
 
@@ -28,11 +20,37 @@ def usage
28
20
  USAGE
29
21
  end
30
22
 
31
- if ARGV.first == "help"
32
- puts usage
33
- exit
23
+ def options
24
+ yaml_file = File.expand_path(ENV['CAMPFIRE_YAML_FILE'] || '~/.campfire.yml')
25
+ if !File.exists?(yaml_file)
26
+ abort "File '#{yaml_file}' does not exist with campfire configuration."
27
+ end
28
+ YAML.load_file(yaml_file)
34
29
  end
35
30
 
36
- abort usage if ARGV.empty? || !%w{speak play}.include?(ARGV.first)
31
+ def action
32
+ @action ||= begin
33
+ abort usage if ARGV.empty?
34
+ action = ARGV.shift
35
+ abort usage if !%w{speak play help}.include?(action)
36
+ action
37
+ end
38
+ end
37
39
 
38
- Campy::Room.new(options).send(ARGV.shift, ARGV.shift)
40
+ def message
41
+ @message ||= begin
42
+ if ARGV.empty?
43
+ ARGF.read.chomp
44
+ else
45
+ ARGV.shift
46
+ end
47
+ end
48
+ end
49
+
50
+ case action
51
+ when "help"
52
+ puts usage
53
+ exit
54
+ else
55
+ Campy::Room.new(options).send(action, message)
56
+ end
@@ -4,8 +4,8 @@ require File.expand_path('../lib/campy/version', __FILE__)
4
4
  Gem::Specification.new do |gem|
5
5
  gem.authors = ["Fletcher Nichol"]
6
6
  gem.email = ["fnichol@nichol.ca"]
7
- gem.description = %q{Small Campfire client using Net::HTTP.}
8
- gem.summary = gem.description
7
+ gem.description = %q{Tiny Campfire Ruby client so you can get on with it.}
8
+ gem.summary = %q{Tiny Campfire Ruby client so you can get on with it. It's implemented on top of Net::HTTP and only requires the multi_json gem for Ruby compatibilities.}
9
9
  gem.homepage = "http://fnichol.github.com/campy/"
10
10
 
11
11
  gem.files = `git ls-files`.split($\)
@@ -55,6 +55,16 @@ module Campy
55
55
  send_message(msg)
56
56
  end
57
57
 
58
+ # Public: Pastes a message into the campfire room.
59
+ #
60
+ # msg - A String message.
61
+ #
62
+ # Returns true if message is delivered.
63
+ # Raises ConnectionError if an HTTP error occurs.
64
+ def paste(msg)
65
+ send_message(msg, 'PasteMessage')
66
+ end
67
+
58
68
  # Public: Plays a sound into the campfire room.
59
69
  #
60
70
  # sound - A String representing the sound.
@@ -1,4 +1,4 @@
1
1
  # -*- encoding: utf-8 -*-
2
2
  module Campy
3
- VERSION = "0.1.0"
3
+ VERSION = "0.1.1"
4
4
  end
@@ -133,6 +133,37 @@ describe Campy::Room do
133
133
  end
134
134
  end
135
135
 
136
+ describe "#paste" do
137
+ let(:subject) { Campy::Room.new(opts) }
138
+
139
+ before do
140
+ # stub out #room_id since we don't care about this API call
141
+ def subject.room_id ; 123456 ; end
142
+ end
143
+
144
+ it "calls the paste API with a message" do
145
+ stub = stub_speak!("big ol long paste\nwith newlines", "PasteMessage")
146
+ subject.paste "big ol long paste\nwith newlines"
147
+
148
+ assert_requested(stub)
149
+ end
150
+
151
+ it "returns true when message is delivered" do
152
+ stub = stub_speak!("big ol long paste\nwith newlines", "PasteMessage")
153
+
154
+ subject.paste("big ol long paste\nwith newlines").must_equal true
155
+ end
156
+
157
+ WRAPPED_ERRORS.each do |error|
158
+ it "wraps #{error} and raises a ConnectionError" do
159
+ stub_speak_error!(error)
160
+
161
+ proc { subject.paste "nope" }.must_raise(
162
+ Campy::Room::ConnectionError)
163
+ end
164
+ end
165
+ end
166
+
136
167
  describe "#play" do
137
168
  let(:subject) { Campy::Room.new(opts) }
138
169
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: campy
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-04-04 00:00:00.000000000 Z
12
+ date: 2012-04-05 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: multi_json
16
- requirement: &70347351272720 !ruby/object:Gem::Requirement
16
+ requirement: &70142625292440 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ~>
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: '1.0'
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *70347351272720
24
+ version_requirements: *70142625292440
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: minitest
27
- requirement: &70347351272200 !ruby/object:Gem::Requirement
27
+ requirement: &70142625291800 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ~>
@@ -32,10 +32,10 @@ dependencies:
32
32
  version: 2.12.0
33
33
  type: :development
34
34
  prerelease: false
35
- version_requirements: *70347351272200
35
+ version_requirements: *70142625291800
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: webmock
38
- requirement: &70347351271740 !ruby/object:Gem::Requirement
38
+ requirement: &70142625290980 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ~>
@@ -43,8 +43,8 @@ dependencies:
43
43
  version: 1.8.5
44
44
  type: :development
45
45
  prerelease: false
46
- version_requirements: *70347351271740
47
- description: Small Campfire client using Net::HTTP.
46
+ version_requirements: *70142625290980
47
+ description: Tiny Campfire Ruby client so you can get on with it.
48
48
  email:
49
49
  - fnichol@nichol.ca
50
50
  executables:
@@ -83,7 +83,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
83
83
  version: '0'
84
84
  segments:
85
85
  - 0
86
- hash: 1286988910110324181
86
+ hash: 3548823882607646634
87
87
  required_rubygems_version: !ruby/object:Gem::Requirement
88
88
  none: false
89
89
  requirements:
@@ -92,13 +92,14 @@ required_rubygems_version: !ruby/object:Gem::Requirement
92
92
  version: '0'
93
93
  segments:
94
94
  - 0
95
- hash: 1286988910110324181
95
+ hash: 3548823882607646634
96
96
  requirements: []
97
97
  rubyforge_project:
98
98
  rubygems_version: 1.8.17
99
99
  signing_key:
100
100
  specification_version: 3
101
- summary: Small Campfire client using Net::HTTP.
101
+ summary: Tiny Campfire Ruby client so you can get on with it. It's implemented on
102
+ top of Net::HTTP and only requires the multi_json gem for Ruby compatibilities.
102
103
  test_files:
103
104
  - spec/campy/room_spec.rb
104
105
  - spec/fixtures/webmock_no_rooms.txt