bincache 0.0.5 → 0.0.6

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore CHANGED
@@ -20,3 +20,4 @@ pkg
20
20
 
21
21
  ## PROJECT::SPECIFIC
22
22
  .gitconfig
23
+ /scripts*
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.5
1
+ 0.0.6
data/bincache.gemspec CHANGED
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{bincache}
8
- s.version = "0.0.5"
8
+ s.version = "0.0.6"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Martin Rhoads"]
12
- s.date = %q{2010-10-09}
12
+ s.date = %q{2010-10-10}
13
13
  s.default_executable = %q{bincache}
14
14
  s.description = %q{longer description of your gem}
15
15
  s.email = %q{martinrhoads@gmail.com}
@@ -28,6 +28,8 @@ Gem::Specification.new do |s|
28
28
  "bin/bincache",
29
29
  "bincache.gemspec",
30
30
  "lib/bincache.rb",
31
+ "lib/bincache/provider/bincache.rb",
32
+ "lib/bincache/resource/bincache.rb",
31
33
  "scripts/script1",
32
34
  "scripts/script2",
33
35
  "scripts/script3",
@@ -0,0 +1,36 @@
1
+ require 'chef/config'
2
+ require 'chef/log'
3
+ require 'chef/provider'
4
+
5
+ class Chef
6
+ class Provider
7
+ class Bincache < Chef::Provider
8
+
9
+ def action_run
10
+ scripts = []
11
+
12
+ ## find all of the bincache resources that are running and collect the ones that are operating with the same directory
13
+ bincache_resources = self.run_context.resource_collection.all_resources.select { |r|
14
+ r.class.inspect == self.class.to_s.gsub(/Provider/,'Resource') &&
15
+ r.directory == @new_resource.directory }
16
+
17
+ ## add the scripts from each resource to our script list. Stop after we add our own script
18
+ bincache_resources.each do |r|
19
+ scripts << r.script
20
+ break if r.name == @new_resource.name
21
+ end
22
+
23
+ ## run bincache
24
+ require 'bincache'
25
+ bincache = BinCache.new
26
+ bincache.run_series(@new_resource.directory,scripts)
27
+ end
28
+
29
+
30
+ def load_current_resource
31
+ Chef::Resource::File.new(@new_resource.name)
32
+ end
33
+
34
+ end
35
+ end
36
+ end
@@ -0,0 +1,36 @@
1
+ require 'chef/resource'
2
+
3
+
4
+
5
+
6
+ class Chef
7
+ class Resource
8
+ class Bincache < Chef::Resource
9
+
10
+ def initialize(name, run_context=nil)
11
+ super
12
+ @resource_name = :bincache
13
+ @action = "run"
14
+ @allowed_actions.push(:run)
15
+ end
16
+
17
+ def script(arg=nil)
18
+ set_or_return(
19
+ :script,
20
+ arg,
21
+ :kind_of => String
22
+ )
23
+ end
24
+
25
+
26
+ def directory(arg=nil)
27
+ set_or_return(
28
+ :directory,
29
+ arg,
30
+ :kind_of => String
31
+ )
32
+ end
33
+
34
+ end
35
+ end
36
+ end
data/lib/bincache.rb CHANGED
@@ -1,9 +1,17 @@
1
1
  #!/bin/env ruby
2
2
 
3
+
3
4
  require 'digest/md5'
4
5
  require 'rubygems'
5
6
  require 'right_aws'
6
7
 
8
+
9
+ ## don't fail if chef is not installed
10
+ if Object.const_defined?("Chef")
11
+ require File.join(File.dirname(__FILE__),'bincache/provider/bincache')
12
+ require File.join(File.dirname(__FILE__),'bincache/resource/bincache')
13
+ end
14
+
7
15
  class BinCache
8
16
 
9
17
  def initialize()
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bincache
3
3
  version: !ruby/object:Gem::Version
4
- hash: 21
4
+ hash: 19
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 0
9
- - 5
10
- version: 0.0.5
9
+ - 6
10
+ version: 0.0.6
11
11
  platform: ruby
12
12
  authors:
13
13
  - Martin Rhoads
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2010-10-09 00:00:00 -07:00
18
+ date: 2010-10-10 00:00:00 -07:00
19
19
  default_executable: bincache
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
@@ -51,6 +51,8 @@ files:
51
51
  - bin/bincache
52
52
  - bincache.gemspec
53
53
  - lib/bincache.rb
54
+ - lib/bincache/provider/bincache.rb
55
+ - lib/bincache/resource/bincache.rb
54
56
  - scripts/script1
55
57
  - scripts/script2
56
58
  - scripts/script3