nextcloud 1.3.0 → 1.3.1

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: 53bda8e8c13b3595070f0895adb7a29cf4773d0f
4
- data.tar.gz: a8c34ecb37ed8ea38d8468f310933ec8cd4ca134
3
+ metadata.gz: ea93ad0137fdb867612e398a39d8404017ff98ec
4
+ data.tar.gz: 55d7e48456006f7b73ed46b160675acc749d149d
5
5
  SHA512:
6
- metadata.gz: ee9515e02c319536ddc9fd05c290a9bee3330a9a6aff0bca307fd522dacf8dfa41002a5cf719faf7d070a4e9b9f4148264773594514cce7a3c5f405b1857bf3f
7
- data.tar.gz: 937566070385aaad0702f91585e15a60e0bcc01bb3de31eacb9e92415d209b280339c49ae98909ec46ab03cc61ba73c66c77c4f0ab516f248a0b2009136165fa
6
+ metadata.gz: 304a696a381fcd3ceae6e9f711ce869451c00634049c8430aa91ffbee21cc7f6d2de57fd5f870f8886ebdd215f75d0e51741f16080e5f18925e44b17b4f3f427
7
+ data.tar.gz: 61d3d482ace84ef5f7656f7db9a5fc8ae881495254c952abaf670d474eb1e0fedb7d28b22e80d29a7b58e037f5d478bd8e704a8b45d3799121976564e350609a
data/.gitignore CHANGED
@@ -7,8 +7,5 @@
7
7
  /spec/reports/
8
8
  /tmp/
9
9
 
10
- # temporarily rspec
11
- .rspec
12
-
13
10
  # rspec failure tracking
14
11
  .rspec_status
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --format documentation
2
+ --color
3
+ --require spec_helper
data/.ruby-version ADDED
@@ -0,0 +1 @@
1
+ ruby-2.4.2
data/.travis.yml CHANGED
@@ -2,4 +2,4 @@ sudo: false
2
2
  language: ruby
3
3
  rvm:
4
4
  - 2.4.1
5
- before_install: gem install bundler -v 1.16.0
5
+ before_install: gem install bundler -v 1.16.0
data/Gemfile CHANGED
@@ -4,3 +4,5 @@ git_source(:github) { |repo_name| "https://github.com/#{repo_name}" }
4
4
 
5
5
  # Specify your gem's dependencies in nextcloud.gemspec
6
6
  gemspec
7
+
8
+ gem "coveralls", require: false
data/Gemfile.lock CHANGED
@@ -19,9 +19,16 @@ GEM
19
19
  public_suffix (>= 2.0.2, < 4.0)
20
20
  ast (2.3.0)
21
21
  concurrent-ruby (1.0.5)
22
+ coveralls (0.8.21)
23
+ json (>= 1.8, < 3)
24
+ simplecov (~> 0.14.1)
25
+ term-ansicolor (~> 1.3)
26
+ thor (~> 0.19.4)
27
+ tins (~> 1.6)
22
28
  crack (0.4.3)
23
29
  safe_yaml (~> 1.0.0)
24
30
  diff-lcs (1.3)
31
+ docile (1.1.5)
25
32
  hashdiff (0.3.7)
26
33
  i18n (0.9.1)
27
34
  concurrent-ruby (~> 1.0)
@@ -61,7 +68,16 @@ GEM
61
68
  unicode-display_width (~> 1.0, >= 1.0.1)
62
69
  ruby-progressbar (1.9.0)
63
70
  safe_yaml (1.0.4)
71
+ simplecov (0.14.1)
72
+ docile (~> 1.1.0)
73
+ json (>= 1.8, < 3)
74
+ simplecov-html (~> 0.10.0)
75
+ simplecov-html (0.10.2)
76
+ term-ansicolor (1.6.0)
77
+ tins (~> 1.0)
78
+ thor (0.19.4)
64
79
  thread_safe (0.3.6)
80
+ tins (1.15.1)
65
81
  tzinfo (1.2.4)
66
82
  thread_safe (~> 0.1)
67
83
  unicode-display_width (1.3.0)
@@ -76,6 +92,7 @@ PLATFORMS
76
92
 
77
93
  DEPENDENCIES
78
94
  bundler (~> 1.16)
95
+ coveralls
79
96
  nextcloud!
80
97
  rake (~> 10.0)
81
98
  rspec (~> 3.0)
data/README.md CHANGED
@@ -1,4 +1,4 @@
1
- [![Gem](https://img.shields.io/gem/v/nextcloud.svg?style=flat-square)](https://rubygems.org/gems/nextcloud)
1
+ [![Gem](https://img.shields.io/gem/v/nextcloud.svg?style=flat-square)](https://rubygems.org/gems/nextcloud) [![Travis](https://img.shields.io/travis/dachinat/nextcloud.svg?style=flat-square)](https://travis-ci.org/dachinat/nextcloud) [![Coveralls github](https://img.shields.io/coveralls/github/dachinat/nextcloud.svg?style=flat-square)](https://coveralls.io/github/dachinat/nextcloud) [![Yard Docs](https://img.shields.io/badge/yard-docs-blue.svg?style=flat-square)](http://rubydoc.info/github/dachinat/nextcloud/master)
2
2
 
3
3
  # Nextcloud Ruby API
4
4
 
@@ -54,6 +54,19 @@ webdav = Nextcloud.webdav(
54
54
  )
55
55
  ```
56
56
 
57
+ You can also initialize and work with both APIs (useful if credentials are same):
58
+
59
+ ```
60
+ nextcloud = Nextcloud.new(
61
+ url: "https://cloud.yourdomain.com",
62
+ username: "your_username",
63
+ password: "your_password"
64
+ )
65
+
66
+ ocs = nextcloud.ocs
67
+ webdav = nextcloud.webdav
68
+ ```
69
+
57
70
  #### Initialize specific APIs
58
71
 
59
72
  Previously described method is recommended, however you can initialize in a differt manner.
@@ -61,38 +74,38 @@ Previously described method is recommended, however you can initialize in a diff
61
74
  Initialize OCS Users API:
62
75
 
63
76
  ```
64
- user = Nextcloud::Ocs::User.new(url: "...", username: "...", password: "...")
77
+ user = Nextcloud::Ocs::User.new(url: "", username: "", password: "")
65
78
  ```
66
79
 
67
80
  Initialize OCS Groups API:
68
81
 
69
82
  ```
70
- group = Nextcloud::Ocs::Group.new(url: "...", username: "...", password: "...")
83
+ group = Nextcloud::Ocs::Group.new(url: "", username: "", password: "")
71
84
  ```
72
85
 
73
86
  Initialize OCS Apps API:
74
87
 
75
88
  ```
76
- app = Nextcloud::Ocs::App.new(url: "...", username: "...", password: "...")
89
+ app = Nextcloud::Ocs::App.new(url: "", username: "", password: "")
77
90
  ```
78
91
 
79
92
  Initialize OCS File Sharing API:
80
93
 
81
94
  ```
82
- file_sharing = Nextcloud::Ocs::FileSharingApi.new(url: "...", username: "...", password: "...")
95
+ file_sharing = Nextcloud::Ocs::FileSharingApi.new(url: "", username: "", password: "")
83
96
  ```
84
97
 
85
98
  Initialize WebDAV Directory API:
86
99
 
87
100
  ```
88
- directory = Nextcloud::WebDav::Directory.new(url: "...", username: "...", password: "...")
101
+ directory = Nextcloud::WebDav::Directory.new(url: "", username: "", password: "")
89
102
  ```
90
103
 
91
104
  > When initializing this way, to work with certain objects some circumstances might force you use `set` method.
92
105
  > For example if you wish to list members of group admin, using first way you could simply write
93
106
  `ocs.group('admin').members`, in this case you will need to use `group.set('admin').members`. There is another way to
94
107
  set object of intereset by putting it into initialize arguments, like so
95
- `Nextcloud::Ocs::Group.new({...credentials}, groupid: "admin")` it can be then reset with
108
+ `Nextcloud::Ocs::Group.new({credentials}, groupid: "admin")` it can be then reset with
96
109
  `set`. Corressponding parameter names for other classes are `userid` and `appid`.
97
110
 
98
111
  ### *OCS Api usage*
@@ -119,7 +132,7 @@ response_meta = users.meta
119
132
 
120
133
  ```
121
134
  user = ocs.user.find("your_user_1")
122
- # => #<Nextcloud::Models::User:0x00000103964020 @enabled="true", @id="your_user_1", ..., @meta={"status"=>"ok", "statuscode"=>"200", "message"=>"OK"}>
135
+ # => #<Nextcloud::Models::User:0x00000103964020 @enabled="true", @id="your_user_1", …, @meta={"status"=>"ok", "statuscode"=>"200", "message"=>"OK"}>
123
136
  ```
124
137
 
125
138
  Having `user` variable you have access to following attributes:
@@ -348,7 +361,7 @@ meta = ocs.group.destroy("group3").meta
348
361
 
349
362
  ```
350
363
  enabled = ocs.app.enabled
351
- # => [...]
364
+ # => []
352
365
  meta = enabled.meta
353
366
  # => {"status"=>"ok", "statuscode"=>"200", "message"=>"OK"}
354
367
  ```
@@ -357,7 +370,7 @@ meta = enabled.meta
357
370
 
358
371
  ```
359
372
  disabled = ocs.app.disabled
360
- # => [...]
373
+ # => []
361
374
  meta = disabled.meta
362
375
  # => {"status"=>"ok", "statuscode"=>"200", "message"=>"OK"}
363
376
  ```
@@ -366,7 +379,7 @@ meta = disabled.meta
366
379
 
367
380
  ```
368
381
  app = ocs.app.find("appname")
369
- # => {...}
382
+ # => {}
370
383
  meta = app.meta
371
384
  # => {"status"=>"ok", "statuscode"=>"200", "message"=>"OK"}
372
385
  ```
@@ -414,13 +427,13 @@ ocs_fs = Nextcloud::Ocs::FileSharingApi.new(
414
427
  An URL has to be a base of your Nextcloud instance. For Sharing API requests, it will be parsed to
415
428
  `https://cloud.yourdomain.com/ocs/v2.php/apps/files_sharing/api/v1/`
416
429
 
417
- > You can also initialize with `Nextcloud.ocs(...credentials).file_sharing`
430
+ > You can also initialize with `Nextcloud.ocs(credentials).file_sharing`
418
431
 
419
432
  #### Retrieve all shares of an (authenticated) user
420
433
 
421
434
  ```
422
435
  all_shares = ocs_fs.all
423
- # => [{...}, {...}]
436
+ # => [{}, {}]
424
437
  meta = all_shares.meta
425
438
  # => {"status"=>"ok", "statuscode"=>"200", "message"=>"OK"}
426
439
  ```
@@ -429,7 +442,7 @@ meta = all_shares.meta
429
442
 
430
443
  ```
431
444
  share = ocs_fs.find(11)
432
- # => {"id" => "22", "shareType" => "0", ...}
445
+ # => {"id" => "22", "shareType" => "0", }
433
446
  meta = share.meta
434
447
  # => {"status"=>"ok", "statuscode"=>"200", "message"=>"OK"}
435
448
  ```
@@ -529,7 +542,7 @@ To create a federated cloud shares you can use `create` method on `FileSharingAp
529
542
 
530
543
  ```
531
544
  accepted = ocs_fs.federated.accepted
532
- # => [{...}, {...}]
545
+ # => [{}, {}]
533
546
  meta = accepted.meta
534
547
  # => {"status"=>"ok", "statuscode"=>"200", "message"=>"OK"}
535
548
  ```
@@ -538,7 +551,7 @@ meta = accepted.meta
538
551
 
539
552
  ```
540
553
  pending = ocs_fs.federated.pending
541
- # => [{...}, {...}]
554
+ # => [{}, {}]
542
555
  meta = pending.meta
543
556
  # => {"status"=>"ok", "statuscode"=>"200", "message"=>"OK"}
544
557
  ```
@@ -547,7 +560,7 @@ meta = pending.meta
547
560
 
548
561
  ```
549
562
  federated_share = ocs_fs.federated.find(12)
550
- # => {"id"=>"12", "remote"=>"https://...", ...}
563
+ # => {"id"=>"12", "remote"=>"https://…", }
551
564
  meta = federated_share.meta
552
565
  # => {"status"=>"ok", "statuscode"=>"200", "message"=>"OK"}
553
566
  ```
data/lib/nextcloud/api.rb CHANGED
@@ -47,5 +47,19 @@ module Nextcloud
47
47
  # end
48
48
  raw ? response.body : Nokogiri::XML.parse(response.body)
49
49
  end
50
+
51
+ # Creates Ocs API instance
52
+ #
53
+ # @return [Object] OcsApi
54
+ def ocs
55
+ OcsApi.new(url: @url, username: @username, password: @password)
56
+ end
57
+
58
+ # Create WebDav API instance
59
+ #
60
+ # @return [Object] WebdavApi
61
+ def webdav
62
+ WebdavApi.new(url: @url, username: @username, password: @password)
63
+ end
50
64
  end
51
65
  end
@@ -73,8 +73,8 @@ module Nextcloud
73
73
  # 8 delete
74
74
  # 16 share, 31 all rights. Value should be one of previously listed.
75
75
  # @return [Object] Instance including meta response
76
- def create(path, shareType, shareWith, publicUpload = nil, password = nil, permissions = nil)
77
- args = local_variables.reduce({}) { |c, i| c[i] = eval(i.to_s); c }
76
+ def create(path, shareType, shareWith=nil, publicUpload=nil, password=nil, permissions=nil)
77
+ args = local_variables.reduce({}) { |c, i| c[i] = binding.local_variable_get(i); c }
78
78
  response = request(:post, "/shares", args)
79
79
  (@meta = get_meta(response)) && self
80
80
  end
@@ -1,5 +1,5 @@
1
1
  module Nextcloud
2
2
  module Version
3
- VERSION = "1.3.0".freeze
3
+ VERSION = "1.3.1".freeze
4
4
  end
5
5
  end
data/lib/nextcloud.rb CHANGED
@@ -24,6 +24,13 @@ require "nextcloud/models/directory"
24
24
  # Namespace for Nextcloud OCS API communication
25
25
  module Nextcloud
26
26
  class << self
27
+ # Allow base initializing
28
+ #
29
+ # @return [Object] Api
30
+ def new(args)
31
+ Api.new(args)
32
+ end
33
+
27
34
  # Access to OCS API from base instance
28
35
  #
29
36
  # @param [Hash] args authentication credentials.
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: nextcloud
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.0
4
+ version: 1.3.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dachi Natsvlishvili
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-11-24 00:00:00.000000000 Z
11
+ date: 2017-11-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -160,7 +160,9 @@ extensions: []
160
160
  extra_rdoc_files: []
161
161
  files:
162
162
  - ".gitignore"
163
+ - ".rspec"
163
164
  - ".rubocop.yml"
165
+ - ".ruby-version"
164
166
  - ".travis.yml"
165
167
  - CODE_OF_CONDUCT.md
166
168
  - Gemfile