schlep 0.2.1 → 0.2.2

Sign up to get free protection for your applications and to get access to all the features.
data/Readme.md CHANGED
@@ -1 +1,71 @@
1
1
  # schlep [![Build Status](https://secure.travis-ci.org/Movitas/schlep-ruby.png)](https://secure.travis-ci.org/Movitas/schlep-ruby) [![Dependency Status](https://gemnasium.com/Movitas/schlep-ruby.png)](https://gemnasium.com/Movitas/schlep-ruby)
2
+
3
+ ## Requirements
4
+
5
+ Schlep needs a [Redis server](http://redis.io), a [Schlep server](http://github.com/Movitas/schlep), and some events. It's [tested on most versions of Ruby](https://secure.travis-ci.org/Movitas/schlep-ruby).
6
+
7
+ ## Installation
8
+
9
+ ```sh
10
+ gem install schlep
11
+ ```
12
+
13
+ or, add it to your Gemfile:
14
+
15
+ ```rb
16
+ gem 'schlep'
17
+ ```
18
+
19
+ and then run `bundle install`.
20
+
21
+ ## Configuration
22
+
23
+ By default, Schlep will connect to Redis locally, use a blank string as the app name, and get the hostname by running `hostname`.
24
+
25
+ To change this, you can configure things one at a time:
26
+
27
+ ```rb
28
+ Schlep.app = "My App"
29
+ Schlep.hostname = "localhost"
30
+ Schlep.redis_url = "redis://redis:password@localhost:6379"
31
+ ```
32
+
33
+ or in a block:
34
+
35
+ ```rb
36
+ Schlep.configure do |config|
37
+ config.app = "My App"
38
+ config.hostname = "localhost"
39
+ config.redis_url = "redis://redis:password@localhost:6379"
40
+ end
41
+ ```
42
+
43
+ If you're using Rails, you should probably put the block above in `config/initializers/schlep.rb`.
44
+
45
+ For other Ruby apps, anywhere before your first Schlep event is fine.
46
+
47
+ ## Usage
48
+
49
+ ### Basic event
50
+
51
+ ```rb
52
+ Schlep.event "event_type", something
53
+ ```
54
+
55
+ `something` can be almost any Ruby object, and Schlep will do it's best to serialize it to JSON.
56
+
57
+ ### Multiple events
58
+
59
+ For performance, Schlep can send multiple events of the same type to Redis in a more efficient manner. To use this, simply call `Schlep.events` instead of `Schlep.event`, and pass an array of objects to serialize:
60
+
61
+ ```rb
62
+ events = []
63
+
64
+ 1_000_000.times { |n| events << n }
65
+
66
+ Schlep.events "load_test", events
67
+ ```
68
+
69
+ ## Support
70
+
71
+ If you run into any problems, please [submit an issue](http://github.com/Movitas/schlep-ruby/issues).
data/lib/schlep.rb CHANGED
@@ -42,7 +42,11 @@ module Schlep
42
42
  end
43
43
 
44
44
  def hostname
45
- @hostname ||= `hostname`.split(".").first
45
+ @hostname ||= `hostname`
46
+
47
+ @hostname.gsub! /\s/, "" if @hostname =~ /\s/
48
+
49
+ @hostname
46
50
  end
47
51
 
48
52
  def redis
@@ -1,3 +1,3 @@
1
1
  module Schlep
2
- VERSION = "0.2.1"
2
+ VERSION = "0.2.2"
3
3
  end
data/test/schlep_test.rb CHANGED
@@ -57,6 +57,15 @@ class SchlepTest < Test::Unit::TestCase
57
57
  should "be a string" do
58
58
  assert Schlep.hostname.is_a? String
59
59
  end
60
+
61
+ should "strip whitespace and newlines" do
62
+ Schlep.hostname = "test string\n"
63
+ assert_equal "teststring", Schlep.hostname
64
+ end
65
+
66
+ should "not include a newline from the hostname command" do
67
+ assert_nil Schlep.hostname =~ /\s/
68
+ end
60
69
  end
61
70
 
62
71
  context "redis_url" do
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: schlep
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.2.2
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: 2011-12-13 00:00:00.000000000 Z
12
+ date: 2012-01-04 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: redis
16
- requirement: &70336884445720 !ruby/object:Gem::Requirement
16
+ requirement: &70203744654020 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: '0'
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *70336884445720
24
+ version_requirements: *70203744654020
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: guard-test
27
- requirement: &70336884444540 !ruby/object:Gem::Requirement
27
+ requirement: &70203744652700 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ! '>='
@@ -32,10 +32,10 @@ dependencies:
32
32
  version: '0'
33
33
  type: :development
34
34
  prerelease: false
35
- version_requirements: *70336884444540
35
+ version_requirements: *70203744652700
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: rake
38
- requirement: &70336884443720 !ruby/object:Gem::Requirement
38
+ requirement: &70203744652060 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ! '>='
@@ -43,10 +43,10 @@ dependencies:
43
43
  version: '0'
44
44
  type: :development
45
45
  prerelease: false
46
- version_requirements: *70336884443720
46
+ version_requirements: *70203744652060
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: shoulda
49
- requirement: &70336884442280 !ruby/object:Gem::Requirement
49
+ requirement: &70203744650800 !ruby/object:Gem::Requirement
50
50
  none: false
51
51
  requirements:
52
52
  - - ! '>='
@@ -54,7 +54,7 @@ dependencies:
54
54
  version: '0'
55
55
  type: :development
56
56
  prerelease: false
57
- version_requirements: *70336884442280
57
+ version_requirements: *70203744650800
58
58
  description: Ruby client for schlep. Schlep provides a simple interface for logging
59
59
  and broadcasting events.
60
60
  email: