Sha256: aa8ec6b1ca29235924d2c8b5500d60856b1eada0c3cb582a67ea846fd9390f2e

Contents?: true

Size: 1.66 KB

Versions: 3

Compression:

Stored size: 1.66 KB

Contents

#!/usr/bin/env ruby
$LOAD_PATH.unshift(File.expand_path(File.join(File.dirname(__FILE__), '..', 'lib')))

require 'localeapp'

# Don't connect to the net if we're running under cucumber for testing
# Use FakeWeb to simulate api.localeapp.com
if ENV['FAKE_WEB_DURING_CUCUMBER_RUN'] && fake_data_as_json = ENV['FAKE_WEB_FAKES']
  require 'fakeweb'
  FakeWeb.allow_net_connect = false
  fakes = JSON.parse(fake_data_as_json)
  fakes.each do |fake|
    FakeWeb.register_uri fake['method'].to_sym, fake['uri'], { :body => fake['body'], :status => fake['status'] }.merge(fake['headers'])
  end
end

args = ARGV.dup

command = args.shift.strip rescue nil

unless %w{help install}.include?(command)
  unless Localeapp.include_config_file
    puts "Could not load config file"
    exit
  end
end

case command
when 'install'
  key = args.shift.strip rescue nil
  installer = Localeapp::CLI::Install.new
  if installer.execute(key)
    exit 0
  else
    exit 1
  end
when 'pull'
  Localeapp::CLI::Pull.new.execute
when 'push'
  file = args.shift.strip rescue nil
  pusher = Localeapp::CLI::Push.new
  pusher.execute(file)
when 'update'
  Localeapp::CLI::Update.new.execute
when 'daemon'
  while true do
    Localeapp::CLI::Update.new.execute
    sleep 5
  end
else
puts <<-HELP
Usage: localeapp COMMAND [ARGS]

Commands:
  install <api_key> - Creates new configuration files and confirms key works
  pull              - Pulls all translations from localeapp.com
  push <file>       - Pushes a translation file to localeapp.com
  update            - Gets any changes since the last poll and updates the yml files
  daemon            - Simple daemon that checks every 5 seconds for new translations
HELP
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
localeapp-0.0.11 bin/localeapp
localeapp-0.0.10 bin/localeapp
localeapp-0.0.8 bin/localeapp