timberline-rails 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: bd1b6647a272ed349fa5841ea5c034cc5d08113c
4
+ data.tar.gz: 91c83bda9ed02f63524e2f3dcc5c89f205e7d220
5
+ SHA512:
6
+ metadata.gz: d760c7a1f26209a068f3c7f378b531ed3e81a3f4f3e1c8f983e6450c28865c7e364fd363fd3804b2b5fbb8f50366ccf350b784695e0d71b75c0538960420ba76
7
+ data.tar.gz: 0d952ff2409dbf5d29f42eb24e27ebaf8357d45dde94fbdb5fdeb317089b1341d55d0286abb8378ded345746022d6e98aa1531d5b9f6e84e46dd7f823dd61cee
data/.rspec ADDED
@@ -0,0 +1 @@
1
+ --color
data/.ruby-gemset ADDED
@@ -0,0 +1 @@
1
+ timberline-rails
data/.travis.yml ADDED
@@ -0,0 +1,10 @@
1
+ language: ruby
2
+ rvm:
3
+ - 1.9.3
4
+ - jruby-19mode
5
+ - jruby-head
6
+ - 2.0.0
7
+ - 2.1.0
8
+ - ruby-head
9
+ services:
10
+ - redis-server
data/CHANGELOG ADDED
@@ -0,0 +1,3 @@
1
+ 0.1.0
2
+ - First public release of Timberline-Rails
3
+ - Add Rails-specific configuration logic for loading config/timberline.yml
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source "http://rubygems.org"
2
+
3
+ # Gem dependencies specified in timberline-rails.gemspec
4
+ gemspec
data/Gemfile.lock ADDED
@@ -0,0 +1,52 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ timberline-rails (0.1.0)
5
+ timberline (~> 0.6.0)
6
+
7
+ GEM
8
+ remote: http://rubygems.org/
9
+ specs:
10
+ coderay (1.1.0)
11
+ daemons (1.1.9)
12
+ diff-lcs (1.2.5)
13
+ method_source (0.8.2)
14
+ pry (0.9.12.6)
15
+ coderay (~> 1.0)
16
+ method_source (~> 0.8)
17
+ slop (~> 3.4)
18
+ rake (10.3.2)
19
+ redis (3.0.7)
20
+ redis-expiring-set (0.1.2)
21
+ redis
22
+ redis-namespace (1.4.1)
23
+ redis (~> 3.0.4)
24
+ rspec (3.0.0)
25
+ rspec-core (~> 3.0.0)
26
+ rspec-expectations (~> 3.0.0)
27
+ rspec-mocks (~> 3.0.0)
28
+ rspec-core (3.0.0)
29
+ rspec-support (~> 3.0.0)
30
+ rspec-expectations (3.0.0)
31
+ diff-lcs (>= 1.2.0, < 2.0)
32
+ rspec-support (~> 3.0.0)
33
+ rspec-mocks (3.0.0)
34
+ rspec-support (~> 3.0.0)
35
+ rspec-support (3.0.0)
36
+ slop (3.5.0)
37
+ timberline (0.6.0)
38
+ daemons
39
+ redis
40
+ redis-expiring-set
41
+ redis-namespace
42
+ trollop
43
+ trollop (2.0)
44
+
45
+ PLATFORMS
46
+ ruby
47
+
48
+ DEPENDENCIES
49
+ pry
50
+ rake
51
+ rspec (~> 3.0.0)
52
+ timberline-rails!
data/README.markdown ADDED
@@ -0,0 +1,53 @@
1
+ # Timberline-Rails
2
+
3
+ ## Purpose
4
+
5
+ Timberline-Rails adds some extra functionality to
6
+ [Timberline](https://github.com/treehouse/timberline) to make it easier to use
7
+ in the context of a Rails application.
8
+
9
+ ## What's New
10
+
11
+ ### Configuration
12
+
13
+ In base Timberline, you have a few options for configuration, from defining a
14
+ `TIMBERLINE\_YAML` constant that points to a yaml config file to defining the
15
+ configuration in code using `Timberline.configure`. Timberline-Rails adds in
16
+ automatic detection for a config file at `config/timberline.yml` in your Rails
17
+ app, complete with environment support (just like database.yml).
18
+
19
+ ## Usage
20
+
21
+ Timberline-Rails works exactly like Timberline; just make sure that you have
22
+ `timberline-rails` listed in your Gemfile and you're good to go.
23
+
24
+ ## TODO
25
+
26
+ Still to be done:
27
+
28
+ - **Rails Workers** - implement workers that expect to operate on ActiveRecord objects
29
+ so you can quickly and easily background tasks in Rails.
30
+
31
+ ## Contributions
32
+
33
+ If Timberline-Rails interests you and you think you might want to contribute,
34
+ hit me up over Github. You can also just fork it and make some changes, but
35
+ there's a better chance that your work won't be duplicated or rendered obsolete
36
+ if you check in on the current development status first.
37
+
38
+ ## Development notes
39
+
40
+ You need Redis installed to do development on Timberline-Rails, and currently the test
41
+ suites assume that you're using the default configurations for Redis. That
42
+ should probably change, but it probably won't until someone needs it to.
43
+
44
+ Gem requirements/etc. should be handled by Bundler.
45
+
46
+ ## License
47
+ Copyright (C) 2014 by Tommy Morgan
48
+
49
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
50
+
51
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
52
+
53
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/Rakefile ADDED
@@ -0,0 +1,7 @@
1
+ require "bundler/gem_tasks"
2
+ require "rake/testtask"
3
+ require 'rspec/core/rake_task'
4
+
5
+ RSpec::Core::RakeTask.new(:spec)
6
+
7
+ task default: :spec
@@ -0,0 +1,5 @@
1
+ class Timberline
2
+ class Rails
3
+ VERSION = "0.1.0"
4
+ end
5
+ end
@@ -0,0 +1,24 @@
1
+ require 'timberline'
2
+ require 'timberline/rails/version'
3
+
4
+ class Timberline
5
+ class Config
6
+ def rails_initialize
7
+ if defined? ::Rails
8
+ config_file = File.join(::Rails.root, 'config', 'timberline.yml')
9
+ if File.exists?(config_file)
10
+ configs = YAML.load_file(config_file)
11
+ config = configs[::Rails.env]
12
+ load_from_yaml(config)
13
+ else
14
+ non_rails_initialize
15
+ end
16
+ else
17
+ non_rails_initialize
18
+ end
19
+ end
20
+
21
+ alias_method :non_rails_initialize, :initialize
22
+ alias_method :initialize, :rails_initialize
23
+ end
24
+ end
@@ -0,0 +1,7 @@
1
+ development:
2
+ host: localhost
3
+ port: 12345
4
+ timeout: 10
5
+ password: foo
6
+ database: 3
7
+ namespace: treecurve
@@ -0,0 +1,53 @@
1
+ require 'spec_helper'
2
+
3
+ describe Timberline::Config do
4
+ context "When there is a valid config file" do
5
+ before { SpecSupport::FakeRails.create_fake_env }
6
+ after { SpecSupport::FakeRails.destroy_fake_env }
7
+
8
+ it "does not delegate to the original Timberline constructor" do
9
+ config = Timberline::Config.new
10
+ expect(config).not_to receive(:non_rails_initialize)
11
+ config.rails_initialize
12
+ end
13
+
14
+ context "loading data from the config file:" do
15
+ subject { Timberline::Config.new }
16
+
17
+ it "host" do
18
+ expect(subject.host).to eq("localhost")
19
+ end
20
+
21
+ it "port" do
22
+ expect(subject.port).to eq(12345)
23
+ end
24
+
25
+ it "timeout" do
26
+ expect(subject.timeout).to eq(10)
27
+ end
28
+
29
+ it "password" do
30
+ expect(subject.password).to eq("foo")
31
+ end
32
+
33
+ it "database" do
34
+ expect(subject.database).to eq(3)
35
+ end
36
+
37
+ it "namespace" do
38
+ expect(subject.namespace).to eq("treecurve")
39
+ end
40
+ end
41
+ end
42
+
43
+ context "When there is not a valid config file" do
44
+ before { SpecSupport::FakeRails.create_fake_env_without_config }
45
+ after { SpecSupport::FakeRails.destroy_fake_env }
46
+
47
+ it "delegates to the original Timberline constructor" do
48
+ config = Timberline::Config.new
49
+ expect(config).to receive(:non_rails_initialize)
50
+ config.rails_initialize
51
+ end
52
+ end
53
+ end
@@ -0,0 +1,19 @@
1
+ require 'rspec'
2
+ require 'pry'
3
+
4
+ require File.expand_path("../../lib/timberline-rails", __FILE__)
5
+
6
+ Dir[File.expand_path("../support/**/*.rb", __FILE__)].each { |f| require f }
7
+
8
+ RSpec.configure do |config|
9
+ config.mock_with :rspec
10
+ config.expect_with :rspec do |c|
11
+ c.syntax = [:expect]
12
+ end
13
+
14
+ config.order = "random"
15
+
16
+ config.after(:each) do
17
+ SpecSupport::TimberlineReset.clear_config
18
+ end
19
+ end
@@ -0,0 +1,17 @@
1
+ module SpecSupport
2
+ module FakeRails
3
+ def self.create_fake_env
4
+ fake_rails = OpenStruct.new(root: File.join(File.dirname(File.path(__FILE__)), "..", "fake_rails"), env: "development")
5
+ Object.send(:const_set, :Rails, fake_rails)
6
+ end
7
+
8
+ def self.create_fake_env_without_config
9
+ fake_rails = OpenStruct.new(root: File.join(File.dirname(File.path(__FILE__)), "..", "gibberish"), env: "development")
10
+ Object.send(:const_set, :Rails, fake_rails)
11
+ end
12
+
13
+ def self.destroy_fake_env
14
+ Object.send(:remove_const, :Rails)
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,20 @@
1
+ module SpecSupport
2
+ module TimberlineReset
3
+ def self.clear_config
4
+ Timberline.redis = nil
5
+ Timberline.instance_variable_set("@config", nil)
6
+ clear_test_db
7
+ Timberline.redis = nil
8
+ end
9
+
10
+ # Use database 15 for testing, so we don't risk overwriting any data that's
11
+ # actually useful
12
+ def self.clear_test_db
13
+ Timberline.config do |c|
14
+ c.database = 15
15
+ end
16
+ Timberline.redis.flushdb
17
+ end
18
+
19
+ end
20
+ end
@@ -0,0 +1,26 @@
1
+ # -*- encoding: utf-8 -*-
2
+ $:.push File.expand_path("../lib", __FILE__)
3
+ require "timberline/rails/version"
4
+
5
+ Gem::Specification.new do |s|
6
+ s.name = "timberline-rails"
7
+ s.version = Timberline::Rails::VERSION
8
+ s.authors = ["Tommy Morgan"]
9
+ s.email = ["tommy.morgan@gmail.com"]
10
+ s.homepage = "http://github.com/treehouse/timberline-rails"
11
+ s.summary = %q{Rails logic and niceties for the Timberline queueing system.}
12
+ s.description = %q{Timberline is a simple and extensible queuing system built in Ruby and backed by Redis. It makes as few assumptions as possible about how you want to interact with your queues while also allowing for some functionality that should be universally useful, like allowing for automatic retries of jobs and queue statistics.}
13
+
14
+ s.rubyforge_project = "timberline-rails"
15
+
16
+ s.files = `git ls-files`.split("\n")
17
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
18
+ s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
19
+ s.require_paths = ["lib"]
20
+
21
+ s.add_runtime_dependency "timberline", "~> 0.6.0"
22
+
23
+ s.add_development_dependency "rake"
24
+ s.add_development_dependency "rspec", '~> 3.0.0'
25
+ s.add_development_dependency "pry"
26
+ end
metadata ADDED
@@ -0,0 +1,118 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: timberline-rails
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Tommy Morgan
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-06-06 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: timberline
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ~>
18
+ - !ruby/object:Gem::Version
19
+ version: 0.6.0
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ~>
25
+ - !ruby/object:Gem::Version
26
+ version: 0.6.0
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - '>='
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - '>='
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rspec
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ~>
46
+ - !ruby/object:Gem::Version
47
+ version: 3.0.0
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ~>
53
+ - !ruby/object:Gem::Version
54
+ version: 3.0.0
55
+ - !ruby/object:Gem::Dependency
56
+ name: pry
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - '>='
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ description: Timberline is a simple and extensible queuing system built in Ruby and
70
+ backed by Redis. It makes as few assumptions as possible about how you want to interact
71
+ with your queues while also allowing for some functionality that should be universally
72
+ useful, like allowing for automatic retries of jobs and queue statistics.
73
+ email:
74
+ - tommy.morgan@gmail.com
75
+ executables: []
76
+ extensions: []
77
+ extra_rdoc_files: []
78
+ files:
79
+ - .rspec
80
+ - .ruby-gemset
81
+ - .travis.yml
82
+ - CHANGELOG
83
+ - Gemfile
84
+ - Gemfile.lock
85
+ - README.markdown
86
+ - Rakefile
87
+ - lib/timberline-rails.rb
88
+ - lib/timberline/rails/version.rb
89
+ - spec/fake_rails/config/timberline.yml
90
+ - spec/lib/config_spec.rb
91
+ - spec/spec_helper.rb
92
+ - spec/support/fake_rails.rb
93
+ - spec/support/timberline_reset.rb
94
+ - timberline-rails.gemspec
95
+ homepage: http://github.com/treehouse/timberline-rails
96
+ licenses: []
97
+ metadata: {}
98
+ post_install_message:
99
+ rdoc_options: []
100
+ require_paths:
101
+ - lib
102
+ required_ruby_version: !ruby/object:Gem::Requirement
103
+ requirements:
104
+ - - '>='
105
+ - !ruby/object:Gem::Version
106
+ version: '0'
107
+ required_rubygems_version: !ruby/object:Gem::Requirement
108
+ requirements:
109
+ - - '>='
110
+ - !ruby/object:Gem::Version
111
+ version: '0'
112
+ requirements: []
113
+ rubyforge_project: timberline-rails
114
+ rubygems_version: 2.2.2
115
+ signing_key:
116
+ specification_version: 4
117
+ summary: Rails logic and niceties for the Timberline queueing system.
118
+ test_files: []