heroku-readonly 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,34 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "optparse"
4
+ require "heroku/readonly"
5
+
6
+ options = {
7
+ :force => true,
8
+ :url => ENV['READONLY_URL'],
9
+ :cache => '/tmp/readonly'
10
+ }
11
+
12
+ OptionParser.new do |opts|
13
+ opts.banner = "usage: heroku-readonly [options]"
14
+
15
+ opts.on("-u", "--url URL", "URL to fetch") { |u| options[:url] = u }
16
+ opts.on("-c", "--cache FILE", "enable caching") { |f| options[:cache] = f }
17
+ end.parse!
18
+
19
+ if !options[:url]
20
+ STDERR.puts "Missing url"
21
+ exit 2
22
+ end
23
+
24
+ if cache = options.delete(:cache)
25
+ options[:write_cache] = options[:read_cache] = cache
26
+ end
27
+
28
+ if Heroku::ReadOnly.new(options).poll
29
+ puts "enabled"
30
+ exit 1
31
+ else
32
+ puts "disabled"
33
+ exit 0
34
+ end
@@ -3,6 +3,8 @@ require 'rest_client'
3
3
  module Heroku
4
4
  class ReadOnly
5
5
  def initialize(options={})
6
+ raise ArgumentError unless options.is_a?(Hash)
7
+
6
8
  @enabled = false
7
9
  @have_polled = false
8
10
  @url = options[:url]
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 0
8
- - 2
9
- version: 0.0.2
8
+ - 3
9
+ version: 0.0.3
10
10
  platform: ruby
11
11
  authors:
12
12
  - Heroku
@@ -14,7 +14,7 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2010-11-15 00:00:00 -08:00
17
+ date: 2010-11-29 00:00:00 -08:00
18
18
  default_executable:
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
@@ -101,13 +101,14 @@ dependencies:
101
101
  version_requirements: *id006
102
102
  description:
103
103
  email: support@heroku.com
104
- executables: []
105
-
104
+ executables:
105
+ - heroku-readonly
106
106
  extensions: []
107
107
 
108
108
  extra_rdoc_files: []
109
109
 
110
110
  files:
111
+ - bin/heroku-readonly
111
112
  - lib/heroku/readonly.rb
112
113
  - spec/readonly_spec.rb
113
114
  - spec/spec_helper.rb