Class: GitCloud::Git
- Inherits:
-
Object
- Object
- GitCloud::Git
- Defined in:
- lib/git_cloud/git.rb
Instance Method Summary collapse
-
#initialize(config = nil) ⇒ Git
constructor
Public: initializes a Git instance by loading in your persisted data.
-
#upload!(file_path) ⇒ Object
Public: uploads the File to the cloud.
-
#url ⇒ Object
Public: get the url for the pushed file path.
Constructor Details
#initialize(config = nil) ⇒ Git
Public: initializes a Git instance by loading in your persisted data.
ParseConfig - The configuration options
Returns nothing.
11 12 13 14 15 16 |
# File 'lib/git_cloud/git.rb', line 11 def initialize(config = nil) @config = config @folder_name = Time.now.strftime(folder_layout) @folder_path = File.join(repo_path,folder_name) bootstrap_folder unless File.exist?(@folder_path) end |
Instance Method Details
#upload!(file_path) ⇒ Object
Public: uploads the File to the cloud
file_path - String file_path to push to the cloud
Raises FileNotFound Exception if file_path is invlaid Raises GitException if it fails to add, commit, or push
24 25 26 27 28 29 30 |
# File 'lib/git_cloud/git.rb', line 24 def upload!(file_path) raise GitCloud::FileException.new("NotFound") unless File.exists? file_path file = File.new(File.(file_path)) add(file) commit push end |
#url ⇒ Object
Public: get the url for the pushed file path
Returns the String url of the pushed file path
35 36 37 38 39 |
# File 'lib/git_cloud/git.rb', line 35 def url type = File.directory?(file) ? "tree" : "raw" name = file.path.split('/').last %{#{upstream}/#{type}/#{branch}/#{folder_name}/#{name}} end |