# group :development do
#   source 'http://rubygems.org'
# end

require 'yaml'

gem 'rails', '~> 3.2.3'

gem 'devise'
gem 'devise-i18n'
gem 'devise_unix2_chkpwd_authenticatable'
gem 'cancan'

gem "sqlite3", '>= 1.3.6'

gem 'haml'

gem "ruby-dbus"

gem "fast_gettext", '>= 0.6.4'
gem 'gettext_i18n_rails', '>= 0.4.3'

gem "builder"

#checking which policykit is used
WEBYAST_CONFIG_FILE = "/etc/webyast/config.yml"
if File.exist?(WEBYAST_CONFIG_FILE)
  values = YAML::load_file WEBYAST_CONFIG_FILE
  ENV['WEBYAST_POLICYKIT']= 'true' if values["polkit1"] == false
end

if ENV['WEBYAST_POLICYKIT']== 'true'
  gem 'polkit'
else
  gem 'polkit1'
end

if ENV["WEBYAST_LOAD_GEMS"] != "false"
  plugin_path = File.expand_path("../../plugins",  __FILE__)
  gemspecs = Dir.glob(File.join(plugin_path, "**", "*.gemspec"))

  if gemspecs.empty?
    # Loading webyast gems from the gem path
    Dir.glob(Gem.default_path.map{|p| File.join(p, "gems/webyast-*")}).each do |pth|
      # get gem name from path: /usr/lib64/ruby/gems/1.8/gems/webyast-users-0.1 => webyast-users
      gem File.basename(pth).split("-")[0..-2].join("-")
    end
  else
    #We are in devel. mode. Loading all plugins
    gemspecs.each do |gemspec|
      plugin_name = gemspec.split("/").pop.split(".").first
      gem plugin_name, :path => File.expand_path("../../plugins/#{gemspec.split("/").pop(2).first}", __FILE__)
    end
  end
end

# make sure the rake tasks are always loaded,
# load the local tasks when running from Git
local_tasks_path = File.expand_path("../../webyast-tasks",  __FILE__)
if File.exist?(local_tasks_path)
  gem "webyast-rake-tasks", :path => local_tasks_path
else
  gem "webyast-rake-tasks"
end

# group :development do
#   gem 'gettext', :require => false
# end

# group :test do
#   gem "mocha",  :require => false
# end

# add extra Gems for development in Git checkout
if File.exists? File.expand_path("../../.git",  __FILE__)
#     group :development do
#       # for downloading online help via "rake download:online_help", but usually not needed
#       # gem 'nokogiri'
# 
#       # for "rake restdoc"
#       gem 'restility'
# 
#       # needed for rake gettext:find
#       gem 'ruby_parser'
# 
#       # uncomment to enable debugger support
#       # gem "debugger"
#     end
end
