switches 0.1.4 → 0.1.5

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.4
1
+ 0.1.5
data/lib/switches.rb CHANGED
@@ -1,4 +1,5 @@
1
1
  require 'yaml'
2
+ require 'pp'
2
3
  require 'fileutils'
3
4
  require 'active_support'
4
5
 
@@ -16,6 +17,14 @@ module Switches
16
17
  TRANSACTION_PID_PATH = File.join CONFIG_DIR, 'transaction.pid'
17
18
 
18
19
  class << self
20
+ def dump(method)
21
+ if ENV['SWITCHES_XML'] == 'true'
22
+ puts send(method).to_xml
23
+ else
24
+ pp send(method)
25
+ end
26
+ end
27
+
19
28
  def say(str)
20
29
  $stderr.puts "[SWITCHES GEM] #{str.gsub "#{RAILS_ROOT}/", ''}"
21
30
  end
@@ -1,7 +1,7 @@
1
1
  # assumes you've got roles, deploy_to, rails_env
2
2
 
3
3
  require 'pp'
4
- require 'activesupport'
4
+ require 'active_support'
5
5
  require 'zlib'
6
6
 
7
7
  # basically { :a => 1, :b => 2 }.eql?({ :b => 2, :a => 1}) => true
@@ -27,7 +27,7 @@ namespace :s do
27
27
 
28
28
  # download switches xml from servers
29
29
  raw_input = Hash.new
30
- run "cd #{deploy_to}/current; rake --silent s:#{cmd}#{"[#{ENV['ARG']}]" if ENV['ARG'].present?} RAILS_ENV=#{rails_env}; true" do |channel, stream, data|
30
+ run "cd #{deploy_to}/current; rake --silent s:#{cmd}#{"[#{ENV['ARG']}]" if ENV['ARG'].present?} SWITCHES_XML=true RAILS_ENV=#{rails_env}; true" do |channel, stream, data|
31
31
  server = channel[:server]
32
32
  server_identifier = gfs ? server.host : "#{server.host}:#{server.port}".chomp(':')
33
33
  raw_input[server_identifier] ||= Array.new
@@ -3,52 +3,52 @@ require 'switches'
3
3
  namespace :s do
4
4
  desc "List current"
5
5
  task :c do
6
- puts Switches.current.to_xml
6
+ Switches.dump :current
7
7
  end
8
8
 
9
9
  desc "Diff current vs. default switches"
10
10
  task :d do
11
- puts Switches.diff.to_xml
11
+ Switches.dump :diff
12
12
  end
13
13
 
14
14
  desc "Turn on switch"
15
15
  task :on, :name do |t, args|
16
16
  Switches.turn_on args.name
17
- puts Switches.current.to_xml
17
+ Switches.dump :current
18
18
  end
19
19
 
20
20
  desc "Turn off switch"
21
21
  task :off, :name do |t, args|
22
22
  Switches.turn_off args.name
23
- puts Switches.current.to_xml
23
+ Switches.dump :current
24
24
  end
25
25
 
26
26
  desc "Clear switch"
27
27
  task :clear, :name do |t, args|
28
28
  Switches.clear args.name
29
- puts Switches.current.to_xml
29
+ Switches.dump :current
30
30
  end
31
31
 
32
32
  desc "Reset all switches to defaults"
33
33
  task :reset do
34
34
  Switches.reset
35
- puts Switches.current.to_xml
35
+ Switches.dump :current
36
36
  end
37
37
 
38
38
  desc "Backup all switches to defaults"
39
39
  task :backup do
40
40
  Switches.backup
41
- puts Switches.current.to_xml
41
+ Switches.dump :current
42
42
  end
43
43
 
44
44
  desc "Restore all switches to defaults"
45
45
  task :restore do
46
46
  Switches.restore
47
- puts Switches.current.to_xml
47
+ Switches.dump :current
48
48
  end
49
49
 
50
50
  desc "List default"
51
51
  task :default do
52
- puts Switches.default.to_xml
52
+ Switches.dump :default
53
53
  end
54
54
  end
data/switches.gemspec CHANGED
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{switches}
8
- s.version = "0.1.4"
8
+ s.version = "0.1.5"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Seamus Abshere"]
12
- s.date = %q{2009-11-17}
12
+ s.date = %q{2009-11-19}
13
13
  s.description = %q{
14
14
  Switches lets you turn on and off parts of your code from the commandline. There's a defaults.yml and a current.yml in the background.
15
15
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: switches
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.4
4
+ version: 0.1.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Seamus Abshere
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-11-17 00:00:00 -05:00
12
+ date: 2009-11-19 00:00:00 -05:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency