zmeygo_sync 0.21 → 0.22

Sign up to get free protection for your applications and to get access to all the features.
data/TODO CHANGED
@@ -1,5 +0,0 @@
1
- Write tests to test 3 basic things this gem will do
2
- 1. Gather cache
3
- 2. Send cache (push method)
4
- 3. Receive locale data (pull method)
5
-
@@ -8,7 +8,7 @@ require 'active_support/core_ext/hash'
8
8
  require 'yaml'
9
9
  require 'logger'
10
10
 
11
- require File.join(File.dirname(__FILE__),'/version')
11
+ #require File.join(File.dirname(__FILE__),'/version')
12
12
  require File.join(File.dirname(__FILE__),'/constant')
13
13
  require File.join(File.dirname(__FILE__),'/configuration')
14
14
  require File.join(File.dirname(__FILE__),'/client')
@@ -23,6 +23,9 @@ module ZmeygoSync
23
23
  attr_accessor :logger
24
24
 
25
25
  def method_missing(method, *args)
26
+ if self.cache.blank?
27
+ ZmeygoSync.configure
28
+ end
26
29
  self.cache.respond_to?(method)? cache.send(method, *args) : super
27
30
  end
28
31
 
@@ -33,6 +36,12 @@ module ZmeygoSync
33
36
  end
34
37
  self.cache = Cache.new
35
38
  self.logger = Logger.new(File.join(Rails.root, 'log', 'zmeygo_sync.log'))
39
+ if self.config['api_token'].blank?
40
+ raise "API TOKEN missing in cofiguration of zmeygo_sync"
41
+ end
42
+ if self.config['project'].blank?
43
+ raise "project missing in cofiguration of zmeygo_sync"
44
+ end
36
45
  end
37
46
  end
38
47
  end
@@ -42,7 +42,7 @@ module ZmeygoSync
42
42
  return
43
43
  end
44
44
  end
45
- hash
45
+ {@config['project'] => hash}
46
46
  end
47
47
 
48
48
  def clear_cache
@@ -20,10 +20,10 @@ module ZmeygoSync
20
20
  keys = []
21
21
  hash = ZmeygoSync.load_cache
22
22
  puts "cache=#{hash}" if options[:verbose]
23
- ZmeygoSync.clear_cache
24
23
  begin
25
24
  puts "POST #{url}" if options[:verbose]
26
25
  response = RestClient.post(url,:data => hash)
26
+ ZmeygoSync.clear_cache
27
27
  rescue
28
28
  puts "Direct http request #{url} failed!" if options[:verbose]
29
29
  if RestClient.proxy.nil?
@@ -49,9 +49,11 @@ module ZmeygoSync
49
49
  end
50
50
  step = 0
51
51
  loop do
52
+ Rails.logger.info "[zmeygo_sync] pushing..."
52
53
  self.client.push
53
54
  # once in 5 minutes download locales from server
54
55
  if step % 10 == 0
56
+ Rails.logger.info "[zmeygo_sync] pulling..."
55
57
  self.client.pull
56
58
  end
57
59
  step += 1
@@ -61,7 +63,7 @@ module ZmeygoSync
61
63
  sleep(@options[:sleep_delay])
62
64
  end
63
65
  rescue => e
64
- # Rails.logger.fatal e
66
+ Rails.logger.fatal e
65
67
  STDERR.puts e.message
66
68
  exit 1
67
69
  end
@@ -1,3 +1,3 @@
1
1
  module ZmeygoSync
2
- VERSION = "0.21"
2
+ VERSION = "0.22"
3
3
  end
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: zmeygo_sync
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: "0.21"
5
+ version: "0.22"
6
6
  platform: ruby
7
7
  authors:
8
8
  - Eugen Ciur