Class: GitMedia::Transport::Local
- Defined in:
- lib/git-media/transport/local.rb
Instance Method Summary collapse
- #get_file(sha, to_file) ⇒ Object
- #get_unpushed(files) ⇒ Object
-
#initialize(path) ⇒ Local
constructor
A new instance of Local.
- #put_file(sha, from_file) ⇒ Object
- #read? ⇒ Boolean
- #write? ⇒ Boolean
Methods inherited from Base
Constructor Details
#initialize(path) ⇒ Local
Returns a new instance of Local.
12 13 14 |
# File 'lib/git-media/transport/local.rb', line 12 def initialize(path) @path = path end |
Instance Method Details
#get_file(sha, to_file) ⇒ Object
20 21 22 23 24 25 26 27 |
# File 'lib/git-media/transport/local.rb', line 20 def get_file(sha, to_file) from_file = File.join(@path, sha) if File.exists?(from_file) FileUtils.cp(from_file, to_file) return true end return false end |
#get_unpushed(files) ⇒ Object
42 43 44 45 46 |
# File 'lib/git-media/transport/local.rb', line 42 def get_unpushed(files) files.select do |f| !File.exist?(File.join(@path, f)) end end |
#put_file(sha, from_file) ⇒ Object
33 34 35 36 37 38 39 40 |
# File 'lib/git-media/transport/local.rb', line 33 def put_file(sha, from_file) to_file = File.join(@path, sha) if File.exists?(from_file) FileUtils.cp(from_file, to_file) return true end return false end |
#read? ⇒ Boolean
16 17 18 |
# File 'lib/git-media/transport/local.rb', line 16 def read? File.exist?(@path) end |
#write? ⇒ Boolean
29 30 31 |
# File 'lib/git-media/transport/local.rb', line 29 def write? File.exist?(@path) end |