lib/hackpad/cli/store.rb in hackpad-cli-0.1.0 vs lib/hackpad/cli/store.rb in hackpad-cli-0.1.1
- old
+ new
@@ -1,26 +1,28 @@
require 'json'
require 'ostruct'
+
require_relative '../cli'
+require_relative 'config'
module Hackpad
module Cli
module Store
module_function
def prepare(config)
- @refresh = config[:refresh]
- dir = File.join(config[:configdir], config[:workspace])
- @pads_dir = File.join(dir, 'pads')
+ @refresh = config.refresh
+ @configdir = config.configdir
+ @pads_dir = File.join(config.workspacedir, 'pads')
@list_cache = File.join(@pads_dir, 'padlist')
prepare_dirs @pads_dir
end
def prepare_dirs(base)
(Hackpad::Cli::FORMATS + ['meta']).each { |f| FileUtils.mkdir_p File.join(base, f) }
end
- def exists?(*path)
+ def exist?(*path)
!@refresh && File.exist?(File.join(@pads_dir, *path))
end
def save(pad, ext)
File.open(File.join(@pads_dir, ext, pad.id), 'w') do |f|