timberline 0.3.1 → 0.4.0

Sign up to get free protection for your applications and to get access to all the features.
metadata CHANGED
@@ -1,110 +1,125 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: timberline
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.1
5
- prerelease:
4
+ version: 0.4.0
6
5
  platform: ruby
7
6
  authors:
8
7
  - Tommy Morgan
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2012-08-28 00:00:00.000000000 Z
11
+ date: 2014-06-02 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
14
  name: redis
16
15
  requirement: !ruby/object:Gem::Requirement
17
- none: false
18
16
  requirements:
19
- - - ! '>='
17
+ - - '>='
20
18
  - !ruby/object:Gem::Version
21
19
  version: '0'
22
20
  type: :runtime
23
21
  prerelease: false
24
22
  version_requirements: !ruby/object:Gem::Requirement
25
- none: false
26
23
  requirements:
27
- - - ! '>='
24
+ - - '>='
28
25
  - !ruby/object:Gem::Version
29
26
  version: '0'
30
27
  - !ruby/object:Gem::Dependency
31
28
  name: redis-namespace
32
29
  requirement: !ruby/object:Gem::Requirement
33
- none: false
34
30
  requirements:
35
- - - ! '>='
31
+ - - '>='
36
32
  - !ruby/object:Gem::Version
37
33
  version: '0'
38
34
  type: :runtime
39
35
  prerelease: false
40
36
  version_requirements: !ruby/object:Gem::Requirement
41
- none: false
42
37
  requirements:
43
- - - ! '>='
38
+ - - '>='
44
39
  - !ruby/object:Gem::Version
45
40
  version: '0'
46
41
  - !ruby/object:Gem::Dependency
47
42
  name: redis-expiring-set
48
43
  requirement: !ruby/object:Gem::Requirement
49
- none: false
50
44
  requirements:
51
- - - ! '>='
45
+ - - '>='
52
46
  - !ruby/object:Gem::Version
53
47
  version: '0'
54
48
  type: :runtime
55
49
  prerelease: false
56
50
  version_requirements: !ruby/object:Gem::Requirement
57
- none: false
58
51
  requirements:
59
- - - ! '>='
52
+ - - '>='
60
53
  - !ruby/object:Gem::Version
61
54
  version: '0'
62
55
  - !ruby/object:Gem::Dependency
63
56
  name: trollop
64
57
  requirement: !ruby/object:Gem::Requirement
65
- none: false
66
58
  requirements:
67
- - - ! '>='
59
+ - - '>='
68
60
  - !ruby/object:Gem::Version
69
61
  version: '0'
70
62
  type: :runtime
71
63
  prerelease: false
72
64
  version_requirements: !ruby/object:Gem::Requirement
73
- none: false
74
65
  requirements:
75
- - - ! '>='
66
+ - - '>='
76
67
  - !ruby/object:Gem::Version
77
68
  version: '0'
78
69
  - !ruby/object:Gem::Dependency
79
70
  name: daemons
80
71
  requirement: !ruby/object:Gem::Requirement
81
- none: false
82
72
  requirements:
83
- - - ! '>='
73
+ - - '>='
84
74
  - !ruby/object:Gem::Version
85
75
  version: '0'
86
76
  type: :runtime
87
77
  prerelease: false
88
78
  version_requirements: !ruby/object:Gem::Requirement
89
- none: false
90
79
  requirements:
91
- - - ! '>='
80
+ - - '>='
92
81
  - !ruby/object:Gem::Version
93
82
  version: '0'
94
83
  - !ruby/object:Gem::Dependency
95
- name: nutrasuite
84
+ name: rake
96
85
  requirement: !ruby/object:Gem::Requirement
97
- none: false
98
86
  requirements:
99
- - - ! '>='
87
+ - - '>='
100
88
  - !ruby/object:Gem::Version
101
89
  version: '0'
102
90
  type: :development
103
91
  prerelease: false
104
92
  version_requirements: !ruby/object:Gem::Requirement
105
- none: false
106
93
  requirements:
107
- - - ! '>='
94
+ - - '>='
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
97
+ - !ruby/object:Gem::Dependency
98
+ name: rspec
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - ~>
102
+ - !ruby/object:Gem::Version
103
+ version: 3.0.0.rc1
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - ~>
109
+ - !ruby/object:Gem::Version
110
+ version: 3.0.0.rc1
111
+ - !ruby/object:Gem::Dependency
112
+ name: pry
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - '>='
116
+ - !ruby/object:Gem::Version
117
+ version: '0'
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - '>='
108
123
  - !ruby/object:Gem::Version
109
124
  version: '0'
110
125
  description: Timberline is a simple and extensible queuing system built in Ruby and
@@ -119,6 +134,9 @@ extensions: []
119
134
  extra_rdoc_files: []
120
135
  files:
121
136
  - .gitignore
137
+ - .rspec
138
+ - .ruby-gemset
139
+ - .travis.yml
122
140
  - Gemfile
123
141
  - README.markdown
124
142
  - Rakefile
@@ -128,47 +146,39 @@ files:
128
146
  - lib/timberline/envelope.rb
129
147
  - lib/timberline/queue.rb
130
148
  - lib/timberline/version.rb
131
- - test/fake_rails/config/timberline.yaml
132
- - test/partial_minispec.rb
133
- - test/test_config.yaml
134
- - test/test_helper.rb
135
- - test/unit/config_test.rb
136
- - test/unit/envelope_test.rb
137
- - test/unit/queue_test.rb
138
- - test/unit/timberline_test.rb
149
+ - spec/config/test_config.yaml
150
+ - spec/fake_rails/config/timberline.yaml
151
+ - spec/lib/timberline/config_spec.rb
152
+ - spec/lib/timberline/envelope_spec.rb
153
+ - spec/lib/timberline/queue_spec.rb
154
+ - spec/lib/timberline_spec.rb
155
+ - spec/spec_helper.rb
156
+ - spec/support/fake_rails.rb
157
+ - spec/support/timberline_reset.rb
158
+ - spec/support/timberline_yaml.rb
139
159
  - timberline.gemspec
140
- homepage: http://github.com/duwanis/timberline
160
+ homepage: http://github.com/treehouse/timberline
141
161
  licenses: []
162
+ metadata: {}
142
163
  post_install_message:
143
164
  rdoc_options: []
144
165
  require_paths:
145
166
  - lib
146
167
  required_ruby_version: !ruby/object:Gem::Requirement
147
- none: false
148
168
  requirements:
149
- - - ! '>='
169
+ - - '>='
150
170
  - !ruby/object:Gem::Version
151
171
  version: '0'
152
172
  required_rubygems_version: !ruby/object:Gem::Requirement
153
- none: false
154
173
  requirements:
155
- - - ! '>='
174
+ - - '>='
156
175
  - !ruby/object:Gem::Version
157
176
  version: '0'
158
177
  requirements: []
159
178
  rubyforge_project: timberline
160
- rubygems_version: 1.8.24
179
+ rubygems_version: 2.2.2
161
180
  signing_key:
162
- specification_version: 3
181
+ specification_version: 4
163
182
  summary: Timberline is a simple and extensible queuing system built in Ruby and backed
164
183
  by Redis.
165
- test_files:
166
- - test/fake_rails/config/timberline.yaml
167
- - test/partial_minispec.rb
168
- - test/test_config.yaml
169
- - test/test_helper.rb
170
- - test/unit/config_test.rb
171
- - test/unit/envelope_test.rb
172
- - test/unit/queue_test.rb
173
- - test/unit/timberline_test.rb
174
- has_rdoc:
184
+ test_files: []
@@ -1,14 +0,0 @@
1
- development:
2
- host: localhost
3
- port: 12345
4
- timeout: 10
5
- password: foo
6
- database: 3
7
- namespace: treecurve
8
- production:
9
- host: redis.myawesomeproduct.com
10
- port: 56789
11
- timeout: 10
12
- password: foo
13
- database: 3
14
- namespace: myawesomeproduct
@@ -1,229 +0,0 @@
1
- ## This is code stolen from the definition file for Minitest::Spec. We really
2
- # like everything about Minitest::Spec except for the expectations part, so we
3
- # are stealing it and using it here. Shamelessly.
4
- #
5
- # This code may go out of date in future versions of Ruby, so we should keep an
6
- # eye on that. But that's better than reinventing the wheel.
7
-
8
- module Kernel # :nodoc:
9
- ##
10
- # Describe a series of expectations for a given target +desc+.
11
- #
12
- # TODO: find good tutorial url.
13
- #
14
- # Defines a test class subclassing from either MiniTest::Spec or
15
- # from the surrounding describe's class. The surrounding class may
16
- # subclass MiniTest::Spec manually in order to easily share code:
17
- #
18
- # class MySpec < MiniTest::Spec
19
- # # ... shared code ...
20
- # end
21
- #
22
- # class TestStuff < MySpec
23
- # it "does stuff" do
24
- # # shared code available here
25
- # end
26
- # describe "inner stuff" do
27
- # it "still does stuff" do
28
- # # ...and here
29
- # end
30
- # end
31
- # end
32
-
33
- def describe desc, additional_desc = nil, &block # :doc:
34
- stack = MiniTest::Spec.describe_stack
35
- name = [stack.last, desc, additional_desc].compact.join("::")
36
- sclas = stack.last || if Class === self && self < MiniTest::Spec then
37
- self
38
- else
39
- MiniTest::Spec.spec_type desc
40
- end
41
-
42
- cls = sclas.create name, desc
43
-
44
- stack.push cls
45
- cls.class_eval(&block)
46
- stack.pop
47
- cls
48
- end
49
- private :describe
50
- end
51
-
52
- ##
53
- # MiniTest::Spec -- The faster, better, less-magical spec framework!
54
- #
55
- # For a list of expectations, see MiniTest::Expectations.
56
-
57
- class MiniTest::Spec < MiniTest::Unit::TestCase
58
- ##
59
- # Contains pairs of matchers and Spec classes to be used to
60
- # calculate the superclass of a top-level describe. This allows for
61
- # automatically customizable spec types.
62
- #
63
- # See: register_spec_type and spec_type
64
-
65
- TYPES = [[//, MiniTest::Spec]]
66
-
67
- ##
68
- # Register a new type of spec that matches the spec's description.
69
- # This method can take either a Regexp and a spec class or a spec
70
- # class and a block that takes the description and returns true if
71
- # it matches.
72
- #
73
- # Eg:
74
- #
75
- # register_spec_type(/Controller$/, MiniTest::Spec::Rails)
76
- #
77
- # or:
78
- #
79
- # register_spec_type(MiniTest::Spec::RailsModel) do |desc|
80
- # desc.superclass == ActiveRecord::Base
81
- # end
82
-
83
- def self.register_spec_type(*args, &block)
84
- if block then
85
- matcher, klass = block, args.first
86
- else
87
- matcher, klass = *args
88
- end
89
- TYPES.unshift [matcher, klass]
90
- end
91
-
92
- ##
93
- # Figure out the spec class to use based on a spec's description. Eg:
94
- #
95
- # spec_type("BlahController") # => MiniTest::Spec::Rails
96
-
97
- def self.spec_type desc
98
- TYPES.find { |matcher, klass|
99
- if matcher.respond_to? :call then
100
- matcher.call desc
101
- else
102
- matcher === desc.to_s
103
- end
104
- }.last
105
- end
106
-
107
- @@describe_stack = []
108
- def self.describe_stack # :nodoc:
109
- @@describe_stack
110
- end
111
-
112
- ##
113
- # Returns the children of this spec.
114
-
115
- def self.children
116
- @children ||= []
117
- end
118
-
119
- def self.nuke_test_methods! # :nodoc:
120
- self.public_instance_methods.grep(/^test_/).each do |name|
121
- self.send :undef_method, name
122
- end
123
- end
124
-
125
- ##
126
- # Define a 'before' action. Inherits the way normal methods should.
127
- #
128
- # NOTE: +type+ is ignored and is only there to make porting easier.
129
- #
130
- # Equivalent to MiniTest::Unit::TestCase#setup.
131
-
132
- def self.before type = :each, &block
133
- raise "unsupported before type: #{type}" unless type == :each
134
-
135
- add_setup_hook {|tc| tc.instance_eval(&block) }
136
- end
137
-
138
- ##
139
- # Define an 'after' action. Inherits the way normal methods should.
140
- #
141
- # NOTE: +type+ is ignored and is only there to make porting easier.
142
- #
143
- # Equivalent to MiniTest::Unit::TestCase#teardown.
144
-
145
- def self.after type = :each, &block
146
- raise "unsupported after type: #{type}" unless type == :each
147
-
148
- add_teardown_hook {|tc| tc.instance_eval(&block) }
149
- end
150
-
151
- ##
152
- # Define an expectation with name +desc+. Name gets morphed to a
153
- # proper test method name. For some freakish reason, people who
154
- # write specs don't like class inheritence, so this goes way out of
155
- # its way to make sure that expectations aren't inherited.
156
- #
157
- # This is also aliased to #specify and doesn't require a +desc+ arg.
158
- #
159
- # Hint: If you _do_ want inheritence, use minitest/unit. You can mix
160
- # and match between assertions and expectations as much as you want.
161
-
162
- def self.it desc = "anonymous", &block
163
- block ||= proc { skip "(no tests defined)" }
164
-
165
- @specs ||= 0
166
- @specs += 1
167
-
168
- name = "test_%04d_%s" % [ @specs, desc.gsub(/\W+/, '_').downcase ]
169
-
170
- define_method name, &block
171
-
172
- self.children.each do |mod|
173
- mod.send :undef_method, name if mod.public_method_defined? name
174
- end
175
- end
176
-
177
- ##
178
- # Essentially, define an accessor for +name+ with +block+.
179
- #
180
- # Why use let instead of def? I honestly don't know.
181
-
182
- def self.let name, &block
183
- define_method name do
184
- @_memoized ||= {}
185
- @_memoized.fetch(name) { |k| @_memoized[k] = instance_eval(&block) }
186
- end
187
- end
188
-
189
- ##
190
- # Another lazy man's accessor generator. Made even more lazy by
191
- # setting the name for you to +subject+.
192
-
193
- def self.subject &block
194
- let :subject, &block
195
- end
196
-
197
- def self.create name, desc # :nodoc:
198
- cls = Class.new(self) do
199
- @name = name
200
- @desc = desc
201
-
202
- nuke_test_methods!
203
- end
204
-
205
- children << cls
206
-
207
- cls
208
- end
209
-
210
- def self.to_s # :nodoc:
211
- defined?(@name) ? @name : super
212
- end
213
-
214
- # :stopdoc:
215
- def after_setup
216
- run_setup_hooks
217
- end
218
-
219
- def before_teardown
220
- run_teardown_hooks
221
- end
222
-
223
- class << self
224
- attr_reader :desc
225
- alias :specify :it
226
- alias :name :to_s
227
- end
228
- # :startdoc:
229
- end
data/test/test_helper.rb DELETED
@@ -1,25 +0,0 @@
1
- require 'test/unit'
2
- require 'ostruct'
3
-
4
- require 'nutrasuite'
5
-
6
- # include the gem
7
- require 'timberline'
8
-
9
- def reset_timberline
10
- Timberline.redis = nil
11
- Timberline.instance_variable_set("@config", nil)
12
- clear_test_db
13
- Timberline.redis = nil
14
- Timberline.instance_variable_set("@queue_list", {})
15
- end
16
-
17
- # Use database 15 for testing, so we don't risk overwriting any data that's
18
- # actually useful
19
- def clear_test_db
20
- Timberline.config do |c|
21
- c.database = 15
22
- end
23
- Timberline.redis.flushdb
24
- end
25
-
@@ -1,122 +0,0 @@
1
- require 'test_helper'
2
-
3
- class ConfigTest < Test::Unit::TestCase
4
- a "Config object without any preset YAML configs" do
5
- before do
6
- @config = Timberline::Config.new
7
- end
8
-
9
- it "builds a proper config hash for Redis" do
10
- @logger = Logger.new STDERR
11
-
12
- @config.host = "localhost"
13
- @config.port = 12345
14
- @config.timeout = 10
15
- @config.password = "foo"
16
- @config.database = 3
17
- @config.logger = @logger
18
-
19
- config = @config.redis_config
20
-
21
- assert_equal "localhost", config[:host]
22
- assert_equal 12345, config[:port]
23
- assert_equal 10, config[:timeout]
24
- assert_equal "foo", config[:password]
25
- assert_equal 3, config[:db]
26
- assert_equal @logger, config[:logger]
27
-
28
- end
29
-
30
- it "reads configuration from a YAML config file" do
31
- base_dir = File.dirname(File.path(__FILE__))
32
- yaml_file = File.join(base_dir, "..", "test_config.yaml")
33
- config = YAML.load_file(yaml_file)
34
-
35
- @config.load_from_yaml(config)
36
- assert_equal "localhost", @config.host
37
- assert_equal 12345, @config.port
38
- assert_equal 10, @config.timeout
39
- assert_equal "foo", @config.password
40
- assert_equal 3, @config.database
41
- assert_equal "treecurve", @config.namespace
42
- end
43
- end
44
-
45
- a "Config object in a Rails app without a config file" do
46
- before do
47
- Object::Rails = OpenStruct.new(:root => File.join(File.dirname(File.path(__FILE__)), "..", "gibberish"), :env => "development")
48
- @config = Timberline::Config.new
49
- end
50
-
51
- after do
52
- Object.send(:remove_const, :Rails)
53
- end
54
-
55
- it "loads successfully without any configs." do
56
- ["database","host","port","timeout","password","logger"].each do |setting|
57
- assert_equal nil, @config.instance_variable_get("@#{setting}")
58
- end
59
-
60
- # check defaults
61
- assert_equal "timberline", @config.namespace
62
- assert_equal 5, @config.max_retries
63
- assert_equal 60, @config.stat_timeout
64
- end
65
- end
66
-
67
- a "Config object in a Rails app with a config file" do
68
- before do
69
- Object::Rails = OpenStruct.new(:root => File.join(File.dirname(File.path(__FILE__)), "..", "fake_rails"), :env => "development")
70
- @config = Timberline::Config.new
71
- end
72
-
73
- after do
74
- Object.send(:remove_const, :Rails)
75
- end
76
-
77
- it "loads the config/timberline.yaml file" do
78
- assert_equal "localhost", @config.host
79
- assert_equal 12345, @config.port
80
- assert_equal 10, @config.timeout
81
- assert_equal "foo", @config.password
82
- assert_equal 3, @config.database
83
- assert_equal "treecurve", @config.namespace
84
- end
85
- end
86
-
87
- a "Config object when TIMBERLINE_YAML is defined" do
88
- before do
89
- Object::TIMBERLINE_YAML = File.join(File.dirname(File.path(__FILE__)), "..", "test_config.yaml")
90
- @config = Timberline::Config.new
91
- end
92
-
93
- after do
94
- Object.send(:remove_const, :TIMBERLINE_YAML)
95
- end
96
-
97
- it "loads the specified yaml file" do
98
- assert_equal "localhost", @config.host
99
- assert_equal 12345, @config.port
100
- assert_equal 10, @config.timeout
101
- assert_equal "foo", @config.password
102
- assert_equal 3, @config.database
103
- assert_equal "treecurve", @config.namespace
104
- end
105
- end
106
-
107
- a "Config object when TIMBERLINE_YAML is defined, but doesn't exist" do
108
- before do
109
- Object::TIMBERLINE_YAML = File.join(File.dirname(File.path(__FILE__)), "..", "fake_config.yaml")
110
- end
111
-
112
- after do
113
- Object.send(:remove_const, :TIMBERLINE_YAML)
114
- end
115
-
116
- it "raises an exception" do
117
- assert_raises RuntimeError do
118
- @config = Timberline::Config.new
119
- end
120
- end
121
- end
122
- end
@@ -1,69 +0,0 @@
1
- require 'test_helper'
2
- require 'date'
3
-
4
- class EnvelopeTest < Test::Unit::TestCase
5
-
6
- a "newly instantiated Envelope object" do
7
- before do
8
- @envelope = Timberline::Envelope.new
9
- end
10
-
11
- it "raises a MissingContentException when to_s is called because the contents are nil" do
12
- assert_raises Timberline::MissingContentException do
13
- @envelope.to_s
14
- end
15
- end
16
-
17
- it "has an empty hash for metadata" do
18
- assert_equal({}, @envelope.metadata)
19
- end
20
-
21
- it "allows for the reading of attributes via method_missing magic" do
22
- @envelope.metadata["original_queue"] = "test_queue"
23
- assert_equal "test_queue", @envelope.original_queue
24
- end
25
-
26
- it "allows for the setting of attributes via method_missing magic" do
27
- @envelope.original_queue = "test_queue"
28
- assert_equal "test_queue", @envelope.metadata["original_queue"]
29
- end
30
- end
31
-
32
- an "Envelope object with contents" do
33
- before do
34
- @envelope = Timberline::Envelope.new
35
- @envelope.contents = "Test data"
36
- end
37
-
38
- it "returns a JSON string when to_s is called" do
39
- json_string = @envelope.to_s
40
- json_data = JSON.parse(json_string)
41
- assert_equal "Test data", json_data["contents"]
42
- end
43
-
44
- it "only includes a 'contents' parameter by default" do
45
- json_string = @envelope.to_s
46
- json_data = JSON.parse(json_string)
47
- assert_equal 1, json_data.keys.size
48
- end
49
-
50
- it "also includes metadata, if provided" do
51
- time = DateTime.now
52
- time_s = DateTime.now.to_s
53
- @envelope.first_posted = time
54
- @envelope.origin_queue = "test_queue"
55
-
56
- json_string = @envelope.to_s
57
- json_data = JSON.parse(json_string)
58
- assert_equal "test_queue", json_data["origin_queue"]
59
- assert_equal time_s, json_data["first_posted"]
60
- end
61
-
62
- it "parses itself back correctly using from_json" do
63
- json_string = @envelope.to_s
64
- new_envelope = Timberline::Envelope.from_json(json_string)
65
- assert_equal @envelope.contents, new_envelope.contents
66
- assert_equal @envelope.metadata, new_envelope.metadata
67
- end
68
- end
69
- end