localjob 0.2.0 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 0d66cdf9e9ef8c26230cc76e00a40964249c62db
4
- data.tar.gz: cdb1b11bacb52f1d9cdc75dec508b4fbe61ee743
3
+ metadata.gz: 0917b722ab080a63864457aa154296a191d095ec
4
+ data.tar.gz: f15b71a3239ae2fd38cba2861c02d61b33b4c019
5
5
  SHA512:
6
- metadata.gz: 9fbe02975d57dd69a328050f4f04a1f3e07312714f6bd5ac8a6fdcbddf02ba55905a11a4a82e677a49524e2b1552f0da0a16d0090f9fc2adf433d8a547f45c5d
7
- data.tar.gz: 201974c4584b2c9c3c549ef07be74569b85500cdf7a307d1efd8d8079de9c63a79830a59a8c85a1bb3aa4f86264c23db1d6e5135311824a276401d839198e426
6
+ metadata.gz: 094f2204527babf51a1da02a0482826305c1510dac6c14e2ca75b7ad7417c8b00c60acb0242783edc24e866a4165ce3425ae909a6127623666aebfc71504ac95
7
+ data.tar.gz: fb2f04ea2bd0c6510d9e3ce9d3f3cb6feb8b62cb99d132dff6976ff18871adf07ca67c9ac41e5e5b132281dc50e189867a72b800ffe9544b7efe89569563557e
data/.travis.yml ADDED
@@ -0,0 +1,4 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.0.0
4
+ - 2.1.1
data/README.md CHANGED
@@ -1,4 +1,4 @@
1
- # Localjob
1
+ # Localjob [![Build Status](https://travis-ci.org/Sirupsen/localjob.png?branch=master)](https://travis-ci.org/Sirupsen/localjob) [![Code Climate](https://codeclimate.com/github/Sirupsen/localjob.png)](https://codeclimate.com/github/Sirupsen/localjob)
2
2
 
3
3
  Localjob is a simple, self-contained background queue built on top of [System V
4
4
  message queues][sysv] (SysV Message Queue => SysV MQ for short). Workers and the
data/lib/localjob/cli.rb CHANGED
@@ -2,43 +2,14 @@ require 'thor'
2
2
 
3
3
  class Localjob
4
4
  class CLI < Thor
5
- option :queues, aliases: ["-q"], type: :string, default: "localjob"
5
+ option :queue, aliases: ["-q"], type: :string, default: "0x10CA110B"
6
6
  option :require, aliases: ["-r"], type: :string, default: "."
7
7
  option :pid_file, aliases: ["-p"], type: :string
8
8
  option :daemon, aliases: ["-d"], type: :boolean
9
9
  desc "work", "Start worker to process jobs"
10
10
  def work
11
11
  load_environment options[:require]
12
-
13
- queues = options[:queues].split(",")
14
- Localjob::Worker.new(queues, options.slice(:daemon, :pid_file)).work
15
- end
16
-
17
- desc "size", "Outputs the size of queues"
18
- option :queues, aliases: ["-q"], type: :string, default: "localjob"
19
- def size
20
- queues = options[:queues].split(",")
21
- queues.each do |queue|
22
- puts "Size of /#{queue}: #{Localjob.new(queue).size}/#{msg_max}"
23
- end
24
- end
25
-
26
- desc "destroy", "Destroys all queues passed"
27
- option :queues, aliases: ["-q"], type: :string, default: "localjob"
28
- def destroy
29
- options[:queues].split(",").each do |queue|
30
- Localjob.new(queue).destroy
31
- end
32
- end
33
-
34
- desc "list", "Lists all queues"
35
- def list
36
- unless File.exists?("/dev/mqueue")
37
- system "mkdir /dev/mqueue"
38
- system "mount -t mqueue none /dev/mqueue"
39
- end
40
-
41
- system "ls -l /dev/mqueue"
12
+ Localjob::Worker.new(options[:queue].to_i(16), *options.slice(:daemon, :pid_file)).work
42
13
  end
43
14
 
44
15
  private
@@ -49,9 +20,6 @@ class Localjob
49
20
  ::Rails.application.eager_load!
50
21
  elsif File.file?(file)
51
22
  require File.expand_path(file)
52
- else
53
- puts "No require path passed, requires -r if not in Rails"
54
- exit
55
23
  end
56
24
  end
57
25
 
@@ -1,3 +1,3 @@
1
1
  class Localjob
2
- VERSION = "0.2.0"
2
+ VERSION = "0.3.0"
3
3
  end
@@ -7,6 +7,7 @@ class Localjob
7
7
 
8
8
  def initialize(queue, logger: Logger.new(STDOUT), **options)
9
9
  @queue, @logger = queue, logger
10
+ @queue = Localjob.new(@queue) if queue.kind_of?(Fixnum)
10
11
  @options = options
11
12
  @shutdown = false
12
13
  end
data/lib/localjob.rb CHANGED
@@ -33,8 +33,5 @@ class Localjob
33
33
 
34
34
  def shift
35
35
  serializer.load queue.receive
36
- # Bad serialization
37
- rescue Object
38
- nil
39
36
  end
40
37
  end
data/localjob.gemspec CHANGED
@@ -24,5 +24,4 @@ Gem::Specification.new do |spec|
24
24
  spec.add_development_dependency "bundler", "~> 1.3"
25
25
  spec.add_development_dependency "rake"
26
26
  spec.add_development_dependency "mocha"
27
- spec.add_development_dependency "stackprof"
28
27
  end
@@ -0,0 +1,12 @@
1
+ require 'localjob'
2
+
3
+ class PrintJob
4
+ def perform
5
+ puts "hello world"
6
+ end
7
+ end
8
+
9
+ if ARGV[0] == "produce"
10
+ queue = Localjob.new
11
+ queue << PrintJob.new
12
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: localjob
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Simon Eskildsen
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-02-27 00:00:00.000000000 Z
11
+ date: 2014-03-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: thor
@@ -80,20 +80,6 @@ dependencies:
80
80
  - - ">="
81
81
  - !ruby/object:Gem::Version
82
82
  version: '0'
83
- - !ruby/object:Gem::Dependency
84
- name: stackprof
85
- requirement: !ruby/object:Gem::Requirement
86
- requirements:
87
- - - ">="
88
- - !ruby/object:Gem::Version
89
- version: '0'
90
- type: :development
91
- prerelease: false
92
- version_requirements: !ruby/object:Gem::Requirement
93
- requirements:
94
- - - ">="
95
- - !ruby/object:Gem::Version
96
- version: '0'
97
83
  description: Simple, self-contained background queue built on top of POSIX message
98
84
  queues.
99
85
  email:
@@ -104,6 +90,7 @@ extensions: []
104
90
  extra_rdoc_files: []
105
91
  files:
106
92
  - ".gitignore"
93
+ - ".travis.yml"
107
94
  - Gemfile
108
95
  - LICENSE.txt
109
96
  - README.md
@@ -116,6 +103,7 @@ files:
116
103
  - lib/localjob/version.rb
117
104
  - lib/localjob/worker.rb
118
105
  - localjob.gemspec
106
+ - test/integration.rb
119
107
  - test/jobs.rb
120
108
  - test/localjob_test.rb
121
109
  - test/mock_adapter.rb
@@ -148,6 +136,7 @@ specification_version: 4
148
136
  summary: Simple, self-contained background queue built on top of POSIX message queues.
149
137
  It only works on Linux.
150
138
  test_files:
139
+ - test/integration.rb
151
140
  - test/jobs.rb
152
141
  - test/localjob_test.rb
153
142
  - test/mock_adapter.rb