seafile-api 0.1 → 0.2

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 25a300668ad3660778a9ec20e04f2f32dce08dad
4
- data.tar.gz: eb9ee71f58ceb014ceb0af09e4a9a1716e056462
3
+ metadata.gz: 97deea6169b4ffe3d30e0039f0d8642c72db8c55
4
+ data.tar.gz: 96fd4e208078bd5dbefbab4d82d5317d389b726e
5
5
  SHA512:
6
- metadata.gz: 569007ea2f8b4f756c43ef29f3ac2e34a4a24bab2ebfbba1426c0f0a620fdca647c060302839716086afdda3a7e3c0438506dbd58b50c80f45aee42dc9cf902b
7
- data.tar.gz: a9c79effaafddff0dee542fd8baf0f176ac1a9f7127a8cb7dc74d2975d2c2e5c7962752df1928cf702ee7ae2ecf20b116ec9154e444d03a774dadd0c21abed47
6
+ metadata.gz: 2da1003c4cb6cd806f21b389a737d4a7c94d0fc5f548723eb8a7393b6b385a010b2dee72bb47ad9013ca19c9eb471388f572061c676e4b5a21d273482a06fd7b
7
+ data.tar.gz: a2f172bf7cce81f3f45cc385b4fb2bfa865b6520977f66c85b1d9c3db5958018320e88cdace0547fa0fd62fe41adab10bc1289508f5154c0af19a2eb09dd337a
data/lib/seafile-api.rb CHANGED
@@ -10,11 +10,13 @@ module SeafileApi
10
10
  attr_accessor :password
11
11
  attr_accessor :host
12
12
  attr_accessor :repo
13
+ attr_accessor :token
13
14
  def initialize(user_name ,password,host,repo)
14
15
  self.user_name = user_name
15
16
  self.password = password
16
17
  self.host = host
17
18
  self.repo = repo
19
+ self.token = self.get_token
18
20
  end
19
21
 
20
22
  end
@@ -40,5 +42,4 @@ require "seafile-api/shared/shared_libraries"
40
42
  require "seafile-api/file/dry_methods"
41
43
  require "seafile-api/file/file_operations"
42
44
  require "seafile-api/file/get_operations"
43
- require "seafile-api/config"
44
45
  require "seafile-api/file"
@@ -27,18 +27,20 @@ module SeafileApi
27
27
  cl_body_str(http)
28
28
  end
29
29
 
30
+
30
31
  #curl -d "operation=mkdir" -v -H 'Authorization: Tokacd9c6ccb8133606d94ff8e61d99b477fd' -H 'Accept: application/json; charset=utf-8; indent=4' https://cloud.seafile.com/api2/repos/dae8cecc-2359-4d33-aa42-01b7846c4b32/dir/?p=/foo
31
32
  def post_create_dir(path,repo)
32
33
  curl_post("#{self.host}/api2/repos/#{repo}/dir/?p=#{path}",{"operation"=>"mkdir"}).body_str
33
34
  end
34
35
 
35
- #curl -X DELETE -v -H 'Authorization: Token f2210dacd3606d94ff8e61d99b477fd' -H 'Accept: application/json; charset=utf-8; indent=4' https://cloud.seafile.com/api2/repos/dae8cecc-2359-4d33-aa42-01b7846c4b32/dir/?p=/foo
36
- def delete_directory(repo,path)
36
+
37
+ #curl -X DELETE -v -H 'Authorization: Token f2210dacd3606d94ff8e61d99b477fd' -H 'Accept: application/json; charset=utf-8; indent=4' https://cloud.seafile.com/api2/repos/dae8cecc-2359-4d33-aa42-01b7846c4b32/dir/?p=/foo
38
+ def delete_directory(path,repo)
37
39
  curl_delete("#{self.host}/api2/repos/#{repo}/dir/?p=#{path}").body_str
38
40
  end
39
41
 
40
42
  #curl -H 'Authorization: Token f2210dacd3606d94ff8e61d99b477fd' -H 'Accept: application/json; charset=utf-8; indent=4' https://cloud.seafile.com/api2/repos/dae8cecc-2359-4d33-aa42-01b7846c4b32/dir/download/?p=/foo
41
- def get_download_dir(repo,path)
43
+ def get_download_dir(path,repo)
42
44
  http = curl_get("repos/#{repo}/dir/download/?p=#{path}")
43
45
  cl_body_str(http)
44
46
  end
@@ -5,13 +5,13 @@ module SeafileApi
5
5
  def file_link(filename,repo=self.repo)
6
6
  get_file_link(filename,repo)
7
7
  end
8
- def token
8
+ def get_token
9
9
  get_sf_token
10
10
  end
11
11
  def file_detail(filename,repo=self.repo)
12
12
  get_description(filename,repo)
13
13
  end
14
-
14
+ #TODO: write test
15
15
  def link_revision(filename,commit_id,repo=self.repo)
16
16
  get_link_file_revision(filename,commit_id,repo)
17
17
  end
@@ -27,7 +27,7 @@ module SeafileApi
27
27
  def upload_file(file,repo=self.repo)
28
28
  post_upload(repo,{"file"=> file,"filename"=> File.basename(file),"parent_dir"=> "/"})
29
29
  end
30
-
30
+ #TODO: write test
31
31
  def update_file(file,target_file=nil,repo=self.repo)
32
32
  post_update(repo,{"file" => file, "filename" =>File.basename(file), "target_file"=> target_file ||File.basename(file)})
33
33
  end
@@ -40,8 +40,9 @@ module SeafileApi
40
40
  post_rename(old_name,repo,{"operation"=>"rename", "newname" => new_name})
41
41
  end
42
42
 
43
- def copy_file(filename,dst_dir='/',dest_repo=self.repo,src_repo=self.repo)
44
- post_copy(src_repo,{"file_names"=>filename, "dst_repo" => dest_repo, "dst_dir"=>dst_dir})
43
+ #TODO: missing arguments
44
+ def copy_file(filename,dst_dir='/',dst_repo=self.repo,src_repo=self.repo)
45
+ post_copy(src_repo,{"file_names"=>filename, "dst_repo" => dst_repo, "dst_dir"=>dst_dir})
45
46
  end
46
47
 
47
48
  def move_file(filename,dst_dir='/',dest_repo=self.repo,src_repo=self.repo)
@@ -2,14 +2,18 @@ module SeafileApi
2
2
  class Connect
3
3
  private
4
4
  def get_sf_token
5
- token_url = URI.parse("#{self.host}/api2/auth-token/")
6
- begin
7
- res = Net::HTTP.post_form(token_url, :username => self.user_name , :password => self.password)
8
- rescue Exception => e
9
- p "!!!!!!!!!!!!!!!! #{e}"
10
- end
11
- JSON.parse(res.body)["token"]
12
- end
5
+ if self.token == nil
6
+ token_url = URI.parse("#{self.host}/api2/auth-token/")
7
+ begin
8
+ res = Net::HTTP.post_form(token_url, :username => self.user_name , :password => self.password)
9
+ rescue Exception => e
10
+ p "!!!!!!!!!!!!!!!! #{e}"
11
+ end
12
+ JSON.parse(res.body)["token"]
13
+ else
14
+ self.token
15
+ end
16
+ end
13
17
 
14
18
  #curl -H 'Authorization: Token f2210dacd3606d94ff8e61d99b477fd' -H 'Accept: application/json; charset=utf-8; indent=4' https://cloud.seafile.com/api2/repos/dae8cecc-2359-4d33-aa42-01b7846c4b32/file/revision/?p=/foo.c\&commit_id=a1ec20709675f4dc8db825cdbca296be245d189b
15
19
  def get_link_file_revision(filename,commit_id,repo)
@@ -34,6 +38,7 @@ module SeafileApi
34
38
  #get file description
35
39
  def get_description(filename,repo)
36
40
  http = curl_get("repos/#{repo}/file/detail/?p=#{filename}")
41
+
37
42
  result(cl_body_str(http))
38
43
  end
39
44
 
@@ -24,9 +24,6 @@ module SeafileApi
24
24
  get_share_file_detail(file_t)
25
25
  end
26
26
 
27
- def del_shared_file(file_t)
28
- delete_shared_file(file_t)
29
- end
30
27
  #
31
28
  #TODO need know what is private shared file -> need test"error_msg\": \"Token not found\"}
32
29
  def download_private_shared_file(file_t)
@@ -25,10 +25,7 @@ module SeafileApi
25
25
  curl_get("s/f/#{file_t}/detail/").body_str
26
26
  end
27
27
 
28
- #curl -v -X DELETE -H 'Authorization: Token f2210dacd9c6ccb8133606d94ff8e61d99b477fd' "https://cloud.seafile.com/api2/shared-files/?t=94aace406a"
29
- def delete_shared_file(file_t)
30
- curl_delete("#{self.host}/api2/shared-links/?t=#{file_t}").head.split()[2]
31
- end
28
+
32
29
  end
33
30
 
34
31
  end
metadata CHANGED
@@ -1,15 +1,29 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: seafile-api
3
3
  version: !ruby/object:Gem::Version
4
- version: '0.1'
4
+ version: '0.2'
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kostiantyn Semchenko
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-06-24 00:00:00.000000000 Z
11
+ date: 2014-07-17 00:00:00.000000000 Z
12
12
  dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: rspec
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ~>
18
+ - !ruby/object:Gem::Version
19
+ version: 3.0.0
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ~>
25
+ - !ruby/object:Gem::Version
26
+ version: 3.0.0
13
27
  - !ruby/object:Gem::Dependency
14
28
  name: bundler
15
29
  requirement: !ruby/object:Gem::Requirement
@@ -61,7 +75,6 @@ extra_rdoc_files: []
61
75
  files:
62
76
  - lib/seafile-api.rb
63
77
  - lib/seafile-api/account.rb
64
- - lib/seafile-api/config.rb
65
78
  - lib/seafile-api/directory.rb
66
79
  - lib/seafile-api/file.rb
67
80
  - lib/seafile-api/file/dry_methods.rb
@@ -1,7 +0,0 @@
1
- module SeafileApi
2
-
3
- class Connect
4
-
5
- end
6
-
7
- end