Use RbConfig instead of obsolete and deprecated Config.
This commit is contained in:
parent
ca7b98099c
commit
668e0f4d85
6
Gemfile
6
Gemfile
@ -6,15 +6,15 @@ gem 'rake'
|
|||||||
|
|
||||||
require 'rbconfig'
|
require 'rbconfig'
|
||||||
|
|
||||||
if Config::CONFIG['target_os'] =~ /darwin/i
|
if RbConfig::CONFIG['target_os'] =~ /darwin/i
|
||||||
gem 'rb-fsevent', '>= 0.4.0', :require => false
|
gem 'rb-fsevent', '>= 0.4.0', :require => false
|
||||||
gem 'growl', '~> 1.0.3', :require => false
|
gem 'growl', '~> 1.0.3', :require => false
|
||||||
end
|
end
|
||||||
if Config::CONFIG['target_os'] =~ /linux/i
|
if RbConfig::CONFIG['target_os'] =~ /linux/i
|
||||||
gem 'rb-inotify', '>= 0.8.5', :require => false
|
gem 'rb-inotify', '>= 0.8.5', :require => false
|
||||||
gem 'libnotify', '~> 0.1.3', :require => false
|
gem 'libnotify', '~> 0.1.3', :require => false
|
||||||
end
|
end
|
||||||
if Config::CONFIG['target_os'] =~ /mswin|mingw/i
|
if RbConfig::CONFIG['target_os'] =~ /mswin|mingw/i
|
||||||
gem 'win32console', :require => false
|
gem 'win32console', :require => false
|
||||||
gem 'rb-fchange', '>= 0.0.2', :require => false
|
gem 'rb-fchange', '>= 0.0.2', :require => false
|
||||||
gem 'rb-notifu', '>= 0.0.4', :require => false
|
gem 'rb-notifu', '>= 0.0.4', :require => false
|
||||||
|
4
Rakefile
4
Rakefile
@ -7,7 +7,7 @@ task :default => :spec
|
|||||||
|
|
||||||
require 'rbconfig'
|
require 'rbconfig'
|
||||||
namespace(:spec) do
|
namespace(:spec) do
|
||||||
if Config::CONFIG['host_os'] =~ /mswin|mingw/i
|
if RbConfig::CONFIG['host_os'] =~ /mswin|mingw/i
|
||||||
desc "Run all specs on multiple ruby versions (requires pik)"
|
desc "Run all specs on multiple ruby versions (requires pik)"
|
||||||
task(:portability) do
|
task(:portability) do
|
||||||
%w[187 192 161].each do |version|
|
%w[187 192 161].each do |version|
|
||||||
@ -31,4 +31,4 @@ namespace(:spec) do
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -116,15 +116,15 @@ module Guard
|
|||||||
end
|
end
|
||||||
|
|
||||||
def self.mac?
|
def self.mac?
|
||||||
Config::CONFIG['target_os'] =~ /darwin/i
|
RbConfig::CONFIG['target_os'] =~ /darwin/i
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.linux?
|
def self.linux?
|
||||||
Config::CONFIG['target_os'] =~ /linux/i
|
RbConfig::CONFIG['target_os'] =~ /linux/i
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.windows?
|
def self.windows?
|
||||||
Config::CONFIG['target_os'] =~ /mswin|mingw/i
|
RbConfig::CONFIG['target_os'] =~ /mswin|mingw/i
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
@ -58,7 +58,7 @@ module Guard
|
|||||||
def watch_change
|
def watch_change
|
||||||
@watch_change = true
|
@watch_change = true
|
||||||
until @stop
|
until @stop
|
||||||
if Config::CONFIG['build'] =~ /java/ || IO.select([inotify.to_io], [], [], latency)
|
if RbConfig::CONFIG['build'] =~ /java/ || IO.select([inotify.to_io], [], [], latency)
|
||||||
break if @stop
|
break if @stop
|
||||||
|
|
||||||
sleep latency
|
sleep latency
|
||||||
|
@ -11,7 +11,7 @@ module Guard
|
|||||||
|
|
||||||
def self.turn_on
|
def self.turn_on
|
||||||
ENV["GUARD_NOTIFY"] = 'true'
|
ENV["GUARD_NOTIFY"] = 'true'
|
||||||
case Config::CONFIG['target_os']
|
case RbConfig::CONFIG['target_os']
|
||||||
when /darwin/i
|
when /darwin/i
|
||||||
require_growl
|
require_growl
|
||||||
when /linux/i
|
when /linux/i
|
||||||
@ -26,7 +26,7 @@ module Guard
|
|||||||
image = options.delete(:image) || :success
|
image = options.delete(:image) || :success
|
||||||
title = options.delete(:title) || "Guard"
|
title = options.delete(:title) || "Guard"
|
||||||
|
|
||||||
case Config::CONFIG['target_os']
|
case RbConfig::CONFIG['target_os']
|
||||||
when /darwin/i
|
when /darwin/i
|
||||||
notify_mac(title, message, image, options)
|
notify_mac(title, message, image, options)
|
||||||
when /linux/i
|
when /linux/i
|
||||||
|
@ -50,7 +50,7 @@ module Guard
|
|||||||
end
|
end
|
||||||
|
|
||||||
def color_enabled?
|
def color_enabled?
|
||||||
@color_enabled ||= if Config::CONFIG['target_os'] =~ /mswin|mingw/i
|
@color_enabled ||= if RbConfig::CONFIG['target_os'] =~ /mswin|mingw/i
|
||||||
unless ENV['ANSICON']
|
unless ENV['ANSICON']
|
||||||
begin
|
begin
|
||||||
require 'rubygems' unless ENV['NO_RUBYGEMS']
|
require 'rubygems' unless ENV['NO_RUBYGEMS']
|
||||||
|
@ -4,25 +4,25 @@ describe Guard::Listener do
|
|||||||
subject { Guard::Listener }
|
subject { Guard::Listener }
|
||||||
|
|
||||||
describe ".select_and_init" do
|
describe ".select_and_init" do
|
||||||
before(:each) { @target_os = Config::CONFIG['target_os'] }
|
before(:each) { @target_os = RbConfig::CONFIG['target_os'] }
|
||||||
after(:each) { Config::CONFIG['target_os'] = @target_os }
|
after(:each) { RbConfig::CONFIG['target_os'] = @target_os }
|
||||||
|
|
||||||
it "uses the Darwin listener on Mac OS X" do
|
it "uses the Darwin listener on Mac OS X" do
|
||||||
Config::CONFIG['target_os'] = 'darwin10.4.0'
|
RbConfig::CONFIG['target_os'] = 'darwin10.4.0'
|
||||||
Guard::Darwin.stub(:usable?).and_return(true)
|
Guard::Darwin.stub(:usable?).and_return(true)
|
||||||
Guard::Darwin.should_receive(:new)
|
Guard::Darwin.should_receive(:new)
|
||||||
subject.select_and_init
|
subject.select_and_init
|
||||||
end
|
end
|
||||||
|
|
||||||
it "uses the Windows listener on Windows" do
|
it "uses the Windows listener on Windows" do
|
||||||
Config::CONFIG['target_os'] = 'mingw'
|
RbConfig::CONFIG['target_os'] = 'mingw'
|
||||||
Guard::Windows.stub(:usable?).and_return(true)
|
Guard::Windows.stub(:usable?).and_return(true)
|
||||||
Guard::Windows.should_receive(:new)
|
Guard::Windows.should_receive(:new)
|
||||||
subject.select_and_init
|
subject.select_and_init
|
||||||
end
|
end
|
||||||
|
|
||||||
it "uses the Linux listener on Linux" do
|
it "uses the Linux listener on Linux" do
|
||||||
Config::CONFIG['target_os'] = 'linux'
|
RbConfig::CONFIG['target_os'] = 'linux'
|
||||||
Guard::Linux.stub(:usable?).and_return(true)
|
Guard::Linux.stub(:usable?).and_return(true)
|
||||||
Guard::Linux.should_receive(:new)
|
Guard::Linux.should_receive(:new)
|
||||||
subject.select_and_init
|
subject.select_and_init
|
||||||
@ -158,5 +158,4 @@ describe Guard::Listener do
|
|||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
end
|
end
|
||||||
|
@ -17,7 +17,7 @@ describe Guard::Notifier do
|
|||||||
describe ".turn_on" do
|
describe ".turn_on" do
|
||||||
context "on Mac OS" do
|
context "on Mac OS" do
|
||||||
before do
|
before do
|
||||||
Config::CONFIG.should_receive(:[]).with('target_os').and_return 'darwin'
|
RbConfig::CONFIG.should_receive(:[]).with('target_os').and_return 'darwin'
|
||||||
end
|
end
|
||||||
|
|
||||||
context "with the Growl library available" do
|
context "with the Growl library available" do
|
||||||
@ -39,7 +39,7 @@ describe Guard::Notifier do
|
|||||||
|
|
||||||
context "on Linux" do
|
context "on Linux" do
|
||||||
before do
|
before do
|
||||||
Config::CONFIG.should_receive(:[]).with('target_os').and_return 'linux'
|
RbConfig::CONFIG.should_receive(:[]).with('target_os').and_return 'linux'
|
||||||
end
|
end
|
||||||
|
|
||||||
context "with the Libnotify library available" do
|
context "with the Libnotify library available" do
|
||||||
@ -61,7 +61,7 @@ describe Guard::Notifier do
|
|||||||
|
|
||||||
context "on Windows" do
|
context "on Windows" do
|
||||||
before do
|
before do
|
||||||
Config::CONFIG.should_receive(:[]).with('target_os').and_return 'mswin'
|
RbConfig::CONFIG.should_receive(:[]).with('target_os').and_return 'mswin'
|
||||||
end
|
end
|
||||||
|
|
||||||
context "with the rb-notifu library available" do
|
context "with the rb-notifu library available" do
|
||||||
@ -87,7 +87,7 @@ describe Guard::Notifier do
|
|||||||
|
|
||||||
context "on Mac OS" do
|
context "on Mac OS" do
|
||||||
before do
|
before do
|
||||||
Config::CONFIG.should_receive(:[]).with('target_os').and_return 'darwin'
|
RbConfig::CONFIG.should_receive(:[]).with('target_os').and_return 'darwin'
|
||||||
subject.stub(:require_growl)
|
subject.stub(:require_growl)
|
||||||
Object.send(:remove_const, :Growl) if defined?(Growl)
|
Object.send(:remove_const, :Growl) if defined?(Growl)
|
||||||
Growl = Object.new
|
Growl = Object.new
|
||||||
@ -134,7 +134,7 @@ describe Guard::Notifier do
|
|||||||
|
|
||||||
context "on Linux" do
|
context "on Linux" do
|
||||||
before do
|
before do
|
||||||
Config::CONFIG.should_receive(:[]).with('target_os').and_return 'linux'
|
RbConfig::CONFIG.should_receive(:[]).with('target_os').and_return 'linux'
|
||||||
subject.stub(:require_libnotify)
|
subject.stub(:require_libnotify)
|
||||||
Object.send(:remove_const, :Libnotify) if defined?(Libnotify)
|
Object.send(:remove_const, :Libnotify) if defined?(Libnotify)
|
||||||
Libnotify = Object.new
|
Libnotify = Object.new
|
||||||
@ -181,7 +181,7 @@ describe Guard::Notifier do
|
|||||||
|
|
||||||
context "on Windows" do
|
context "on Windows" do
|
||||||
before do
|
before do
|
||||||
Config::CONFIG.should_receive(:[]).with('target_os').and_return 'mswin'
|
RbConfig::CONFIG.should_receive(:[]).with('target_os').and_return 'mswin'
|
||||||
subject.stub(:require_rbnotifu)
|
subject.stub(:require_rbnotifu)
|
||||||
Object.send(:remove_const, :Notifu) if defined?(Notifu)
|
Object.send(:remove_const, :Notifu) if defined?(Notifu)
|
||||||
Notifu = Object.new
|
Notifu = Object.new
|
||||||
|
@ -1,11 +1,11 @@
|
|||||||
def mac?
|
def mac?
|
||||||
Config::CONFIG['target_os'] =~ /darwin/i
|
RbConfig::CONFIG['target_os'] =~ /darwin/i
|
||||||
end
|
end
|
||||||
|
|
||||||
def linux?
|
def linux?
|
||||||
Config::CONFIG['target_os'] =~ /linux/i
|
RbConfig::CONFIG['target_os'] =~ /linux/i
|
||||||
end
|
end
|
||||||
|
|
||||||
def windows?
|
def windows?
|
||||||
Config::CONFIG['target_os'] =~ /mswin|mingw/i
|
RbConfig::CONFIG['target_os'] =~ /mswin|mingw/i
|
||||||
end
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user