fire_and_forget 0.2.0 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile CHANGED
@@ -1,6 +1,5 @@
1
1
  source "http://rubygems.org"
2
2
 
3
- gem "json", "~>1.4.6"
4
3
  gem "daemons", "~>1.1.0"
5
4
 
6
5
  group :development do
data/Gemfile.lock CHANGED
@@ -8,7 +8,6 @@ GEM
8
8
  git (>= 1.2.5)
9
9
  rake
10
10
  jnunemaker-matchy (0.4.0)
11
- json (1.4.6)
12
11
  rake (0.8.7)
13
12
  rr (1.0.2)
14
13
  shoulda (2.11.3)
@@ -21,6 +20,5 @@ DEPENDENCIES
21
20
  daemons (~> 1.1.0)
22
21
  jeweler (~> 1.5.1)
23
22
  jnunemaker-matchy (~> 0.4)
24
- json (~> 1.4.6)
25
23
  rr (~> 1.0.2)
26
24
  shoulda
data/README.rdoc CHANGED
@@ -88,8 +88,12 @@ will issue the following command in the background
88
88
 
89
89
  as well as setting it's nice value to 12 and updating ENV with the extra parameter "ENVIRONMENT_SETTING".
90
90
 
91
- Parameter values are JSON encoded so you can pass arrays or hashes. Again, it is
92
- up to the script to decode these values.
91
+ Parameter values are encoded in a format compatible with Thor:
92
+
93
+ Arrays are encoded as --array=1 2 3
94
+ Hashes as --hash=key1:value1 key2:value2
95
+
96
+ Again, it is up to the script to decode these values.
93
97
 
94
98
  Interprocess communication is relatively easy. Take the following as the source of the script "/path/to/script"
95
99
 
@@ -148,6 +152,7 @@ single non-shared server (potentially running many sites).
148
152
 
149
153
  - Improve security restrictions (perhaps by limiting the tasks that each user can launch)
150
154
  - Improve the tests so they are closer to testing the full stack
155
+ - Add in scheduled/delayed execution of tasks
151
156
 
152
157
  == Contributing to fire_and_forget
153
158
 
data/bin/fire_forget CHANGED
@@ -7,13 +7,10 @@ faf_lib_path = File.expand_path(File.dirname(__FILE__) + "/../lib")
7
7
  $:.unshift(faf_lib_path) unless $:.include?(faf_lib_path)
8
8
 
9
9
  # include dependencies without using rubygems (to save memory)
10
- $:.unshift('vendor/json-1.5.0/lib')
11
10
  $:.unshift('vendor/daemons-1.1.0/lib')
12
11
 
13
- require 'vendor/json-1.5.0/lib/json/pure'
14
12
  require 'vendor/daemons-1.1.0/lib/daemons'
15
13
 
16
-
17
14
  require 'ostruct'
18
15
  require 'optparse'
19
16
  require 'socket'
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{fire_and_forget}
8
- s.version = "0.2.0"
8
+ s.version = "0.3.0"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Garry Hill"]
12
- s.date = %q{2011-01-19}
12
+ s.date = %q{2011-01-20}
13
13
  s.default_executable = %q{fire_forget}
14
14
  s.email = %q{garry@magnetised.info}
15
15
  s.executables = ["fire_forget"]
@@ -64,23 +64,7 @@ Gem::Specification.new do |s|
64
64
  "vendor/daemons-1.1.0/lib/daemons/pid.rb",
65
65
  "vendor/daemons-1.1.0/lib/daemons/pidfile.rb",
66
66
  "vendor/daemons-1.1.0/lib/daemons/pidmem.rb",
67
- "vendor/daemons-1.1.0/setup.rb",
68
- "vendor/json-1.5.0/COPYING",
69
- "vendor/json-1.5.0/GPL",
70
- "vendor/json-1.5.0/README",
71
- "vendor/json-1.5.0/README-json-jruby.markdown",
72
- "vendor/json-1.5.0/Rakefile",
73
- "vendor/json-1.5.0/TODO",
74
- "vendor/json-1.5.0/VERSION",
75
- "vendor/json-1.5.0/lib/json.rb",
76
- "vendor/json-1.5.0/lib/json/add/core.rb",
77
- "vendor/json-1.5.0/lib/json/add/rails.rb",
78
- "vendor/json-1.5.0/lib/json/common.rb",
79
- "vendor/json-1.5.0/lib/json/editor.rb",
80
- "vendor/json-1.5.0/lib/json/pure.rb",
81
- "vendor/json-1.5.0/lib/json/pure/generator.rb",
82
- "vendor/json-1.5.0/lib/json/pure/parser.rb",
83
- "vendor/json-1.5.0/lib/json/version.rb"
67
+ "vendor/daemons-1.1.0/setup.rb"
84
68
  ]
85
69
  s.homepage = %q{http://github.com/magnetised/fire_and_forget}
86
70
  s.licenses = ["MIT"]
@@ -97,7 +81,6 @@ Gem::Specification.new do |s|
97
81
  s.specification_version = 3
98
82
 
99
83
  if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
100
- s.add_runtime_dependency(%q<json>, ["~> 1.4.6"])
101
84
  s.add_runtime_dependency(%q<daemons>, ["~> 1.1.0"])
102
85
  s.add_development_dependency(%q<shoulda>, [">= 0"])
103
86
  s.add_development_dependency(%q<jnunemaker-matchy>, ["~> 0.4"])
@@ -105,7 +88,6 @@ Gem::Specification.new do |s|
105
88
  s.add_development_dependency(%q<jeweler>, ["~> 1.5.1"])
106
89
  s.add_development_dependency(%q<rr>, ["~> 1.0.2"])
107
90
  else
108
- s.add_dependency(%q<json>, ["~> 1.4.6"])
109
91
  s.add_dependency(%q<daemons>, ["~> 1.1.0"])
110
92
  s.add_dependency(%q<shoulda>, [">= 0"])
111
93
  s.add_dependency(%q<jnunemaker-matchy>, ["~> 0.4"])
@@ -114,7 +96,6 @@ Gem::Specification.new do |s|
114
96
  s.add_dependency(%q<rr>, ["~> 1.0.2"])
115
97
  end
116
98
  else
117
- s.add_dependency(%q<json>, ["~> 1.4.6"])
118
99
  s.add_dependency(%q<daemons>, ["~> 1.1.0"])
119
100
  s.add_dependency(%q<shoulda>, [">= 0"])
120
101
  s.add_dependency(%q<jnunemaker-matchy>, ["~> 0.4"])
@@ -1,5 +1,5 @@
1
1
 
2
- require 'daemons'
2
+ require 'daemons' unless defined?(Daemons)
3
3
 
4
4
  module FireAndForget
5
5
  module Command
@@ -1,4 +1,3 @@
1
- require "json"
2
1
 
3
2
  module FireAndForget
4
3
  module Utilities
@@ -8,12 +7,23 @@ module FireAndForget
8
7
  end.join(" ")
9
8
  end
10
9
 
10
+ # Maps objects to command line parameters suitable for parsing by Thor
11
+ # @see https://github.com/wycats/thor
11
12
  def to_parameter(obj)
12
- if obj.is_a?(String)
13
+ case obj
14
+ when String
15
+ obj.inspect
16
+ when Array
17
+ obj.map { |o| to_parameter(o) }.join(' ')
18
+ when Hash
19
+ obj.map do |k, v|
20
+ "#{k}:#{to_parameter(obj[k])}"
21
+ end.join(' ')
22
+ when Numeric
13
23
  obj
14
24
  else
15
- JSON.generate(obj)
16
- end.inspect
25
+ to_parameter(obj.to_s)
26
+ end
17
27
  end
18
28
  end
19
29
  end
@@ -1,4 +1,4 @@
1
1
 
2
2
  module FireAndForget
3
- VERSION = "0.2.0"
3
+ VERSION = "0.3.0"
4
4
  end
@@ -6,8 +6,9 @@ class TestFireAndForget < Test::Unit::TestCase
6
6
  FAF.to_arguments({
7
7
  :param1 => "value1",
8
8
  :param2 => "value2",
9
- :array => [1, 2, "3"]
10
- }).should == %(--array="[1,2,\\"3\\"]" --param1="value1" --param2="value2")
9
+ :array => [1, 2, "3 of 4"],
10
+ :hash => {:name => "Fred", :age => 23}
11
+ }).should == %(--array=1 2 "3 of 4" --hash=age:23 name:"Fred" --param1="value1" --param2="value2")
11
12
  end
12
13
  end
13
14
  context "configuration" do
metadata CHANGED
@@ -4,9 +4,9 @@ version: !ruby/object:Gem::Version
4
4
  prerelease: false
5
5
  segments:
6
6
  - 0
7
- - 2
7
+ - 3
8
8
  - 0
9
- version: 0.2.0
9
+ version: 0.3.0
10
10
  platform: ruby
11
11
  authors:
12
12
  - Garry Hill
@@ -14,25 +14,11 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2011-01-19 00:00:00 +00:00
17
+ date: 2011-01-20 00:00:00 +00:00
18
18
  default_executable: fire_forget
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
21
21
  version_requirements: &id001 !ruby/object:Gem::Requirement
22
- requirements:
23
- - - ~>
24
- - !ruby/object:Gem::Version
25
- segments:
26
- - 1
27
- - 4
28
- - 6
29
- version: 1.4.6
30
- name: json
31
- requirement: *id001
32
- prerelease: false
33
- type: :runtime
34
- - !ruby/object:Gem::Dependency
35
- version_requirements: &id002 !ruby/object:Gem::Requirement
36
22
  requirements:
37
23
  - - ~>
38
24
  - !ruby/object:Gem::Version
@@ -42,11 +28,11 @@ dependencies:
42
28
  - 0
43
29
  version: 1.1.0
44
30
  name: daemons
45
- requirement: *id002
31
+ requirement: *id001
46
32
  prerelease: false
47
33
  type: :runtime
48
34
  - !ruby/object:Gem::Dependency
49
- version_requirements: &id003 !ruby/object:Gem::Requirement
35
+ version_requirements: &id002 !ruby/object:Gem::Requirement
50
36
  requirements:
51
37
  - - ">="
52
38
  - !ruby/object:Gem::Version
@@ -54,11 +40,11 @@ dependencies:
54
40
  - 0
55
41
  version: "0"
56
42
  name: shoulda
57
- requirement: *id003
43
+ requirement: *id002
58
44
  prerelease: false
59
45
  type: :development
60
46
  - !ruby/object:Gem::Dependency
61
- version_requirements: &id004 !ruby/object:Gem::Requirement
47
+ version_requirements: &id003 !ruby/object:Gem::Requirement
62
48
  requirements:
63
49
  - - ~>
64
50
  - !ruby/object:Gem::Version
@@ -67,11 +53,11 @@ dependencies:
67
53
  - 4
68
54
  version: "0.4"
69
55
  name: jnunemaker-matchy
70
- requirement: *id004
56
+ requirement: *id003
71
57
  prerelease: false
72
58
  type: :development
73
59
  - !ruby/object:Gem::Dependency
74
- version_requirements: &id005 !ruby/object:Gem::Requirement
60
+ version_requirements: &id004 !ruby/object:Gem::Requirement
75
61
  requirements:
76
62
  - - ~>
77
63
  - !ruby/object:Gem::Version
@@ -81,11 +67,11 @@ dependencies:
81
67
  - 0
82
68
  version: 1.0.0
83
69
  name: bundler
84
- requirement: *id005
70
+ requirement: *id004
85
71
  prerelease: false
86
72
  type: :development
87
73
  - !ruby/object:Gem::Dependency
88
- version_requirements: &id006 !ruby/object:Gem::Requirement
74
+ version_requirements: &id005 !ruby/object:Gem::Requirement
89
75
  requirements:
90
76
  - - ~>
91
77
  - !ruby/object:Gem::Version
@@ -95,11 +81,11 @@ dependencies:
95
81
  - 1
96
82
  version: 1.5.1
97
83
  name: jeweler
98
- requirement: *id006
84
+ requirement: *id005
99
85
  prerelease: false
100
86
  type: :development
101
87
  - !ruby/object:Gem::Dependency
102
- version_requirements: &id007 !ruby/object:Gem::Requirement
88
+ version_requirements: &id006 !ruby/object:Gem::Requirement
103
89
  requirements:
104
90
  - - ~>
105
91
  - !ruby/object:Gem::Version
@@ -109,7 +95,7 @@ dependencies:
109
95
  - 2
110
96
  version: 1.0.2
111
97
  name: rr
112
- requirement: *id007
98
+ requirement: *id006
113
99
  prerelease: false
114
100
  type: :development
115
101
  description:
@@ -169,22 +155,6 @@ files:
169
155
  - vendor/daemons-1.1.0/lib/daemons/pidfile.rb
170
156
  - vendor/daemons-1.1.0/lib/daemons/pidmem.rb
171
157
  - vendor/daemons-1.1.0/setup.rb
172
- - vendor/json-1.5.0/COPYING
173
- - vendor/json-1.5.0/GPL
174
- - vendor/json-1.5.0/README
175
- - vendor/json-1.5.0/README-json-jruby.markdown
176
- - vendor/json-1.5.0/Rakefile
177
- - vendor/json-1.5.0/TODO
178
- - vendor/json-1.5.0/VERSION
179
- - vendor/json-1.5.0/lib/json.rb
180
- - vendor/json-1.5.0/lib/json/add/core.rb
181
- - vendor/json-1.5.0/lib/json/add/rails.rb
182
- - vendor/json-1.5.0/lib/json/common.rb
183
- - vendor/json-1.5.0/lib/json/editor.rb
184
- - vendor/json-1.5.0/lib/json/pure.rb
185
- - vendor/json-1.5.0/lib/json/pure/generator.rb
186
- - vendor/json-1.5.0/lib/json/pure/parser.rb
187
- - vendor/json-1.5.0/lib/json/version.rb
188
158
  has_rdoc: true
189
159
  homepage: http://github.com/magnetised/fire_and_forget
190
160
  licenses:
@@ -1,58 +0,0 @@
1
- Ruby is copyrighted free software by Yukihiro Matsumoto <matz@netlab.co.jp>.
2
- You can redistribute it and/or modify it under either the terms of the GPL
3
- (see GPL file), or the conditions below:
4
-
5
- 1. You may make and give away verbatim copies of the source form of the
6
- software without restriction, provided that you duplicate all of the
7
- original copyright notices and associated disclaimers.
8
-
9
- 2. You may modify your copy of the software in any way, provided that
10
- you do at least ONE of the following:
11
-
12
- a) place your modifications in the Public Domain or otherwise
13
- make them Freely Available, such as by posting said
14
- modifications to Usenet or an equivalent medium, or by allowing
15
- the author to include your modifications in the software.
16
-
17
- b) use the modified software only within your corporation or
18
- organization.
19
-
20
- c) rename any non-standard executables so the names do not conflict
21
- with standard executables, which must also be provided.
22
-
23
- d) make other distribution arrangements with the author.
24
-
25
- 3. You may distribute the software in object code or executable
26
- form, provided that you do at least ONE of the following:
27
-
28
- a) distribute the executables and library files of the software,
29
- together with instructions (in the manual page or equivalent)
30
- on where to get the original distribution.
31
-
32
- b) accompany the distribution with the machine-readable source of
33
- the software.
34
-
35
- c) give non-standard executables non-standard names, with
36
- instructions on where to get the original software distribution.
37
-
38
- d) make other distribution arrangements with the author.
39
-
40
- 4. You may modify and include the part of the software into any other
41
- software (possibly commercial). But some files in the distribution
42
- are not written by the author, so that they are not under this terms.
43
-
44
- They are gc.c(partly), utils.c(partly), regex.[ch], st.[ch] and some
45
- files under the ./missing directory. See each file for the copying
46
- condition.
47
-
48
- 5. The scripts and library files supplied as input to or produced as
49
- output from the software do not automatically fall under the
50
- copyright of the software, but belong to whomever generated them,
51
- and may be sold commercially, and may be aggregated with this
52
- software.
53
-
54
- 6. THIS SOFTWARE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR
55
- IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
56
- WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
57
- PURPOSE.
58
-