ohajiki 0.0.5 → 0.0.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/README.md CHANGED
@@ -14,8 +14,8 @@ Write config file
14
14
  ```ruby
15
15
  REMOTE_REPO_URL = 'https://github.com/kitak/ohajiki.git' # Your remote repository url (necessary entry)
16
16
  SYNC_DIR_PATH = '/Users/kitak/.ohajiki' # Sync target (necessary entry)
17
- SYNC_INTERVAL_SEC = 5 # Polling Interval (optional entry. default 10)
18
- LOGPATH = '/tmp/ohajiki.log' # Logfile location (optional entry)
17
+ SYNC_INTERVAL_SEC = 5 # Polling interval (optional entry. default 10)
18
+ LOG_PATH = '/tmp/ohajiki.log' # Logfile location (optional entry. default /tmp/ohajiki.log)
19
19
  ```
20
20
 
21
21
  start
@@ -1,8 +1,9 @@
1
1
  require "ohajiki/version"
2
2
  require File.expand_path('../ohajiki/config', __FILE__)
3
- require File.expand_path('../ohajiki/controller', __FILE__)
3
+ require File.expand_path('../ohajiki/service', __FILE__)
4
4
  require File.expand_path('../ohajiki/repo', __FILE__)
5
5
 
6
6
  module Ohajiki
7
7
  class ConfigNotFound < StandardError; end
8
+ class RepositoryMissing < StandardError; end
8
9
  end
@@ -21,6 +21,8 @@ module Ohajiki
21
21
  raise ConfigNotFound, "require SYNC_DIR_PATH in config file"
22
22
  when :SYNC_INTERVAL_SEC
23
23
  10
24
+ else
25
+ super
24
26
  end
25
27
  end
26
28
  end
@@ -6,27 +6,28 @@ require File.expand_path('../config', __FILE__)
6
6
  require File.expand_path('../repo', __FILE__)
7
7
 
8
8
  module Ohajiki
9
- class Controller
9
+ class Service
10
10
  def initialize
11
11
  @log = Logger.new(File.expand_path(Config::LOG_PATH))
12
12
  @interval_sec = Config::SYNC_INTERVAL_SEC
13
13
 
14
14
  dir_path = File.expand_path(Config::SYNC_DIR_PATH)
15
15
  FileUtils.mkdir_p dir_path
16
-
17
- @repo =
18
- unless Repo.exist? dir_path
19
- Repo.init(dir_path) do
20
- remote_add('origin', Config::REMOTE_REPO_URL)
21
- pull!
22
- end
23
- else
24
- Repo.new dir_path
25
- end
16
+ @repo = fetch_repository(dir_path)
26
17
  rescue => e
27
- puts "#{e.message}"
28
- puts "#{e.backtrace}"
29
- @log.error "start: #{e.message}" if @log
18
+ @log.error "init: #{e.message}"
19
+ raise InitializeError
20
+ end
21
+
22
+ def fetch_repository
23
+ unless Repo.exist? dir_path
24
+ Repo.init(dir_path) do
25
+ remote_add('origin', Config::REMOTE_REPO_URL)
26
+ pull!
27
+ end
28
+ else
29
+ Repo.new dir_path
30
+ end
30
31
  end
31
32
 
32
33
  def start
@@ -1,3 +1,3 @@
1
1
  module Ohajiki
2
- VERSION = "0.0.5"
2
+ VERSION = "0.0.6"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ohajiki
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.5
4
+ version: 0.0.6
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-02-20 00:00:00.000000000 Z
12
+ date: 2013-02-22 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: grit
@@ -59,8 +59,8 @@ files:
59
59
  - bin/ohajiki
60
60
  - lib/ohajiki.rb
61
61
  - lib/ohajiki/config.rb
62
- - lib/ohajiki/controller.rb
63
62
  - lib/ohajiki/repo.rb
63
+ - lib/ohajiki/service.rb
64
64
  - lib/ohajiki/version.rb
65
65
  - ohajiki.conf.sample
66
66
  - ohajiki.gemspec