piwigo-api 0.5.7 → 0.6.0

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
  SHA256:
3
- metadata.gz: f30d55372255b2d6264ac04c4a1b9505df2cab733fc55747102c4a0ffb6259a0
4
- data.tar.gz: 30dadc7c02600cb6e33e8d8d221f5c47153197402018444306c6bd151835d0a2
3
+ metadata.gz: 7fc5b8141101c1b604876f7d5bf09effc43bbb016fc1a41b46541e8d3b743553
4
+ data.tar.gz: bde9f990a5d2dc96577094a89677fdc5d013edd75d77be152dd51e1cb8eeab82
5
5
  SHA512:
6
- metadata.gz: 68dea3ce0f47d39bd8dc3ce2f04f3baf4a1561d2d0a5d81c88b62611500d27353e96a078492959ffcf35b49c22dbb9f561b5fae3d8683a95eebc6b8fa6bae225
7
- data.tar.gz: 1d48cf3f865e5625bcbcf84923e7b7401db6346696f65b3a1836861f86378c99d942a248c6c19654f28a31fb5dae87443544d41c691e10e2ded5a6a782b5603d
6
+ metadata.gz: e073d758652e9f9bba60b7de66d1025b22c03cbf5b051692c4187b9ea9c3b88fe1c308d449bc2df047960604ec0e6d507f68a316024acc0fd7e9cf4fc0fe7e58
7
+ data.tar.gz: 3b0375000c48966b96d67a51b79f49e3958493390087854eaa1b629c6438c4587e1a3b08ba0d0d838e272a8d77f46d91a245de62487219467da3da8c0ced6b2e
@@ -1,36 +1,35 @@
1
1
  name: Ruby Gem
2
2
 
3
3
  on:
4
- pull_request:
5
- branches:
6
- - master
7
4
  push:
8
- branches:
9
- - master
5
+ branches: [ master ]
10
6
 
11
7
  jobs:
12
8
  build:
13
9
  name: Build + Publish
14
10
  runs-on: ubuntu-latest
11
+ permissions:
12
+ contents: read
13
+ packages: write
15
14
 
16
15
  steps:
17
- - uses: actions/checkout@master
16
+ - uses: actions/checkout@v2
18
17
  - name: Set up Ruby 2.6
19
18
  uses: actions/setup-ruby@v1
20
19
  with:
21
- version: 2.6.x
20
+ ruby-version: 2.6.x
22
21
 
23
22
  - name: Publish to GPR
24
23
  run: |
25
24
  mkdir -p $HOME/.gem
26
25
  touch $HOME/.gem/credentials
27
26
  chmod 0600 $HOME/.gem/credentials
28
- printf -- "---\n:github: Bearer ${GEM_HOST_API_KEY}\n" > $HOME/.gem/credentials
27
+ printf -- "---\n:github: ${GEM_HOST_API_KEY}\n" > $HOME/.gem/credentials
29
28
  gem build *.gemspec
30
29
  gem push --KEY github --host https://rubygems.pkg.github.com/${OWNER} *.gem
31
30
  env:
32
- GEM_HOST_API_KEY: ${{secrets.GPR_AUTH_TOKEN}}
33
- OWNER: KKDad
31
+ GEM_HOST_API_KEY: "Bearer ${{secrets.GITHUB_TOKEN}}"
32
+ OWNER: ${{ github.repository_owner }}
34
33
 
35
34
  - name: Publish to RubyGems
36
35
  run: |
@@ -41,4 +40,4 @@ jobs:
41
40
  gem build *.gemspec
42
41
  gem push *.gem
43
42
  env:
44
- GEM_HOST_API_KEY: ${{secrets.RUBYGEMS_AUTH_TOKEN}}
43
+ GEM_HOST_API_KEY: "${{secrets.RUBYGEMS_AUTH_TOKEN}}"
@@ -1,20 +1,26 @@
1
+
1
2
  name: Ruby
2
3
 
3
- on: [push]
4
+ on:
5
+ push:
6
+ branches: [ master ]
7
+ pull_request:
8
+ branches: [ master ]
4
9
 
5
10
  jobs:
6
- build:
11
+ test:
7
12
 
8
13
  runs-on: ubuntu-latest
14
+ strategy:
15
+ matrix:
16
+ ruby-version: ['2.6', '2.7', '3.0']
9
17
 
10
18
  steps:
11
- - uses: actions/checkout@v1
12
- - name: Set up Ruby 2.6
13
- uses: actions/setup-ruby@v1
19
+ - uses: actions/checkout@v2
20
+ - name: Set up Ruby
21
+ uses: ruby/setup-ruby@v1
14
22
  with:
15
- ruby-version: 2.6.x
16
- - name: Build and test with Rake
17
- run: |
18
- gem install bundler
19
- bundle install --jobs 4 --retry 3
20
- bundle exec rake
23
+ ruby-version: ${{ matrix.ruby-version }}
24
+ bundler-cache: true
25
+ - name: Run tests
26
+ run: bundle exec rake
data/.gitignore CHANGED
@@ -8,4 +8,5 @@
8
8
  /tmp/
9
9
  *.gem
10
10
  main.rb
11
- settings.json
11
+ settings.json
12
+ /.idea/
data/CHANGELOG.md CHANGED
@@ -4,6 +4,21 @@ All notable changes to this project will be documented in this file.
4
4
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
5
5
  and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
6
6
 
7
+ 0.6.0 - 2022-01-17
8
+ - Added support for specifying the port to connect to Piwigo on, and added an example
9
+ - Fixed a regression bug from updating EXITF gem
10
+ - Additional spelling fixes
11
+
12
+ 0.5.10 - 2022-01-16
13
+ - Update Gemfile dependencies
14
+ - Code and documentation cleanups
15
+
16
+ 0.5.9 - 2021-07-13
17
+ - Update version to fix github actions
18
+
19
+ 0.5.8 - 2021-07-13
20
+ - Update dependencies address CVE-2021-32740
21
+
7
22
  0.5.7 - 2020-03-01
8
23
  - Fixed open-ended dependency on codecov
9
24
 
@@ -14,8 +29,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
14
29
  - Fix another encoding issue when synchronizing folder with accented characters.
15
30
 
16
31
  0.5.4 - 2019-11-26
17
- - Fix crash in sniff_attributes when the image dosn't contain a valid EXIF data
18
- - Fix parent albums when syncronizing a folder-tree of albums into Piwigo
32
+ - Fix crash in sniff_attributes when the image doesn't contain a valid EXIF data
33
+ - Fix parent albums when synchronizing a folder-tree of albums into Piwigo
19
34
 
20
35
  0.5.3 - 2019-11-25
21
36
  - Fixed to coverage reports
@@ -28,10 +43,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
28
43
 
29
44
  0.5.0 - 2019-11-23
30
45
  - Added a directory of example scripts
31
- - Added a folder-album syncronization methods
46
+ - Added a folder-album synchronization methods
32
47
 
33
48
  0.4.0 - 2019-11-20
34
- - Add methods to check for the existance of a specific image and to upload images
49
+ - Add methods to check for the existence of a specific image and to upload images
35
50
 
36
51
  0.3.1 - 2019-11-20
37
52
  - Add a codecov.yaml for coverage reports
data/Gemfile.lock CHANGED
@@ -1,73 +1,73 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- piwigo-api (0.5.6)
4
+ piwigo-api (0.6.0)
5
5
  exifr (~> 1.3)
6
- http (~> 4.2)
7
- logger (~> 1.4)
6
+ http (~> 5.0)
7
+ logger (~> 1.5)
8
8
 
9
9
  GEM
10
10
  remote: https://rubygems.org/
11
11
  specs:
12
- addressable (2.7.0)
12
+ addressable (2.8.0)
13
13
  public_suffix (>= 2.0.2, < 5.0)
14
14
  ansi (1.5.0)
15
15
  builder (3.2.4)
16
- codecov (0.1.16)
17
- json
18
- simplecov
19
- url
20
- docile (1.3.2)
16
+ codecov (0.6.0)
17
+ simplecov (>= 0.15, < 0.22)
18
+ docile (1.4.0)
21
19
  domain_name (0.5.20190701)
22
20
  unf (>= 0.0.5, < 1.0.0)
23
- exifr (1.3.6)
24
- ffi (1.12.2)
25
- ffi (1.12.2-x64-mingw32)
21
+ exifr (1.3.9)
22
+ ffi (1.15.5)
23
+ ffi (1.15.5-x64-mingw32)
26
24
  ffi-compiler (1.0.1)
27
25
  ffi (>= 1.0.0)
28
26
  rake
29
- http (4.3.0)
30
- addressable (~> 2.3)
27
+ http (5.0.4)
28
+ addressable (~> 2.8)
31
29
  http-cookie (~> 1.0)
32
30
  http-form_data (~> 2.2)
33
- http-parser (~> 1.2.0)
34
- http-cookie (1.0.3)
31
+ llhttp-ffi (~> 0.4.0)
32
+ http-cookie (1.0.4)
35
33
  domain_name (~> 0.5)
36
- http-form_data (2.2.0)
37
- http-parser (1.2.1)
38
- ffi-compiler (>= 1.0, < 2.0)
39
- json (2.3.0)
40
- logger (1.4.2)
41
- minitest (5.14.0)
42
- minitest-reporters (1.4.2)
34
+ http-form_data (2.3.0)
35
+ llhttp-ffi (0.4.0)
36
+ ffi-compiler (~> 1.0)
37
+ rake (~> 13.0)
38
+ logger (1.5.0)
39
+ minitest (5.15.0)
40
+ minitest-reporters (1.5.0)
43
41
  ansi
44
42
  builder
45
43
  minitest (>= 5.0)
46
44
  ruby-progressbar
47
- public_suffix (4.0.3)
48
- rake (13.0.1)
49
- ruby-progressbar (1.10.1)
50
- simplecov (0.18.5)
45
+ public_suffix (4.0.6)
46
+ rake (13.0.6)
47
+ ruby-progressbar (1.11.0)
48
+ simplecov (0.21.2)
51
49
  docile (~> 1.1)
52
50
  simplecov-html (~> 0.11)
53
- simplecov-html (0.12.2)
51
+ simplecov_json_formatter (~> 0.1)
52
+ simplecov-html (0.12.3)
53
+ simplecov_json_formatter (0.1.3)
54
54
  unf (0.1.4)
55
55
  unf_ext
56
- unf_ext (0.0.7.6)
57
- url (0.3.2)
56
+ unf_ext (0.0.8)
57
+ unf_ext (0.0.8-x64-mingw32)
58
58
 
59
59
  PLATFORMS
60
60
  ruby
61
61
  x64-mingw32
62
62
 
63
63
  DEPENDENCIES
64
- bundler (~> 2.0)
65
- codecov (~> 0.1, >= 0.1.10)
66
- minitest (~> 5.0)
67
- minitest-reporters (~> 1.4)
64
+ bundler (~> 2.3)
65
+ codecov (~> 0.6)
66
+ minitest (~> 5.15)
67
+ minitest-reporters (~> 1.5)
68
68
  piwigo-api!
69
69
  rake (~> 13.0)
70
- simplecov (~> 0.17)
70
+ simplecov (~> 0.21)
71
71
 
72
72
  BUNDLED WITH
73
- 2.0.2
73
+ 2.3.5
@@ -0,0 +1,42 @@
1
+ ## Specify a URL with a port
2
+
3
+ If you are running Piwigo on a non-standard port in docker, you can specify the port when connecting:
4
+
5
+ ```ruby
6
+ require 'piwigo/session'
7
+ require 'piwigo/images'
8
+
9
+
10
+ session = Piwigo::Session.login('localhost', 'root', 'piwigo', port: 8083, https: false)
11
+ unless session.nil?
12
+ require 'piwigo/session'
13
+ require 'piwigo/albums'
14
+
15
+ album = Piwigo::Albums::Album.new
16
+ album.name = "Chippy"
17
+ album = Piwigo::Albums.add(session, album)
18
+
19
+ filename = 'C:\Photos\chippy.jpg'
20
+ if Piwigo::Images.lookup(session, filename).nil?
21
+ Piwigo::Images.upload(session, filename, album, 'apple-pie-bars')
22
+ end
23
+ end
24
+ ```
25
+
26
+ Example output:
27
+ ~~~
28
+ $ ruby main.rb
29
+ I, [2022-01-16T20:40:27.437987 #13428] INFO -- : Login succeeded: {"stat":"ok","result":true}
30
+ I, [2022-01-16T20:40:27.471733 #13428] INFO -- : Status succeeded
31
+ I, [2022-01-16T20:40:27.475731 #13428] INFO -- : Encoding: Chippy - UTF-8
32
+ I, [2022-01-16T20:40:27.534389 #13428] INFO -- : Album Add succeeded: Chippy(1) created.
33
+ I, [2022-01-16T20:40:27.589282 #13428] INFO -- : Image lookup succeeded: {"e49804192ae97cd09460e09fddb8187a"=>nil}
34
+ I, [2022-01-16T20:40:27.702908 #13428] INFO -- : Image AddChunk #0 succeeded: {"stat"=>"ok", "result"=>nil}
35
+ I, [2022-01-16T20:40:27.817544 #13428] INFO -- : Image AddChunk #1 succeeded: {"stat"=>"ok", "result"=>nil}
36
+ I, [2022-01-16T20:40:27.901301 #13428] INFO -- : Image AddChunk #2 succeeded: {"stat"=>"ok", "result"=>nil}
37
+ I, [2022-01-16T20:40:27.902947 #13428] INFO -- : --> GPS: 45.33110277777778, -75.79546111111111
38
+ I, [2022-01-16T20:40:27.903224 #13428] INFO -- : {:date_creation=>"2022-01-16", :categories=>1}
39
+ {"stat"=>"ok", "result"=>{"image_id"=>1, "url"=>"http://localhost:8083:8000/picture.php?/1/category/1"}}
40
+ I, [2022-01-16T20:40:27.980021 #13428] INFO -- : Image Add succeeded.
41
+
42
+ ~~~
@@ -1,6 +1,6 @@
1
- ## Syncronize a Directory with Piwigo
1
+ ## Synchronize a Directory with Piwigo
2
2
 
3
- To syncronize a folder-tree of im ages with Piwigo:
3
+ To synchronize a folder-tree of im ages with Piwigo:
4
4
 
5
5
  ```ruby
6
6
  require 'piwigo/session'
@@ -14,7 +14,7 @@ unless session.nil?
14
14
  end
15
15
  ```
16
16
 
17
- Call the script with the directory to syncronize. Eg:
17
+ Call the script with the directory to synchronize. Eg:
18
18
 
19
19
  ```ruby
20
20
  ruby main.rb //DISKSTATION/photos/
@@ -9,9 +9,13 @@ require 'piwigo/images'
9
9
 
10
10
  session = Piwigo::Session.login('10.100.230.78', 'Adrian', 'mypassword', https: false)
11
11
  unless session.nil?
12
+ album = Piwigo::Albums::Album.new
13
+ album.name = "Recipes"
14
+ album = Piwigo::Albums.add(session, album)
15
+
12
16
  filename = 'C:\photos\apple-pie-bars-articleLarge.jpg'
13
- if Piwigo::Images.Lookup(session, filename).nil?
14
- Piwigo::Images.Upload(session, filename, 'apple-pie-bars')
17
+ if Piwigo::Images.lookup(session, filename).nil?
18
+ Piwigo::Images.upload(session, filename, album, 'apple-pie-bars')
15
19
  end
16
20
  end
17
21
  ```
data/lib/piwigo/albums.rb CHANGED
@@ -3,8 +3,8 @@ require 'uri'
3
3
  require 'json'
4
4
  require 'logger'
5
5
 
6
- # Piwigo organizes images by albums. The album tree has unlimted depth and each photo can belong to multiple albums. The Piwigo API
7
- # refers to a Album as a Category.
6
+ # Piwigo organizes images by albums. The album tree has unlimited depth and each photo can belong to multiple albums.
7
+ # The Piwigo API refers to a Album as a Category.
8
8
  module Piwigo
9
9
  class Albums
10
10
  class Album
@@ -59,7 +59,7 @@ module Piwigo
59
59
  def initialize(hash: nil)
60
60
  hash&.each do |key, value|
61
61
  # Bug: If the encoding is Windows-1252, then Piwigo will blowup when creating the album
62
- value = value.encode('UTF-8', 'Windows-1252') if value.class == String && value.encoding.to_s == 'Windows-1252'
62
+ value = value.encode('UTF-8', 'Windows-1252') if value.instance_of?(String) && value.encoding.to_s == 'Windows-1252'
63
63
  send("#{key}=", value)
64
64
  end
65
65
  end
@@ -73,10 +73,10 @@ module Piwigo
73
73
  #
74
74
  # @param [Session] session - Session
75
75
  # @param [Number] album_id - Album to fetch, Optional
76
- # @param [Boolean] recursive - Include subalbums, Optional
76
+ # @param [Boolean] recursive - Include sub albums, Optional
77
77
  # @param [Boolean] public - Only include public albums, Optional
78
78
  # @param [Boolean] fullname - ???, Optional
79
- # @param [String] thumbnail_size - Size of thumbname to return, One of: square, thumb, 2small, xsmall, small, medium, large, xlarge, xxlarge. Optional
79
+ # @param [String] thumbnail_size - Size of thumbnail to return, One of: square, thumb, 2small, xsmall, small, medium, large, xlarge, xxlarge. Optional
80
80
  # @param [Logger] logger logger to output debug messages to (Optional)
81
81
  #
82
82
  # @return [Array<Album>] All albums that match the criteria, or nil there were no matches
@@ -5,7 +5,7 @@ require_relative 'albums'
5
5
  require_relative 'image_uploader'
6
6
 
7
7
  module Piwigo
8
- # Syncronize a folder with Piwigo
8
+ # Synchronize a folder with Piwigo
9
9
  # - Album name will be the same as the folder name
10
10
  # - Will be created as a top-level folder unless specified
11
11
  class FolderSync
@@ -27,11 +27,11 @@ module Piwigo
27
27
  FolderSync.new(session, logger: logger).synchronize(directory)
28
28
  end
29
29
 
30
- # Syncronize a folder with Piwigo
30
+ # Synchronize a folder with Piwigo
31
31
  #
32
- # @param [String] directory - directory to syncronize.
32
+ # @param [String] directory - directory to synchronize.
33
33
  def synchronize(directory)
34
- if ['originals', '.picasaoriginals'].include? File.basename(directory.downcase)
34
+ if %w[originals .picasaoriginals].include? File.basename(directory.downcase)
35
35
  @logger.info "Skipping special directory: #{directory}"
36
36
  return
37
37
  else
@@ -75,7 +75,7 @@ module Piwigo
75
75
 
76
76
  def process_file(directory_entry)
77
77
  # Only attempt to import images
78
- return unless ['.jpg', '.png', '.gif'].include? File.extname(directory_entry).downcase
78
+ return unless %w[.jpg .png .gif].include? File.extname(directory_entry).downcase
79
79
 
80
80
  @logger.info "Processing Image: '#{directory_entry}' in album '#{@current_album}'"
81
81
  image = Piwigo::Images.lookup(@session, directory_entry)
@@ -4,10 +4,11 @@ require 'json'
4
4
  require 'logger'
5
5
  require 'digest'
6
6
  require 'base64'
7
+ require 'exifr/jpeg'
7
8
 
8
9
  # Add a photo.
9
10
  #
10
- # To avoid limitations on HTTP POST maximum size, the piwigo requires the image to be splitted into several calls to pwg.images.addChunk
11
+ # To avoid limitations on HTTP POST maximum size, the piwigo requires the image to be splitted into several calls to pwg.images.addChunk
11
12
  # and then a single call to pwg.images.add.
12
13
  #
13
14
  # Reference: https://piwigo.org/doc/doku.php?id=dev:webapi:pwg.images.add
@@ -17,8 +18,6 @@ module Piwigo
17
18
  MEGABYTE = 1024 * 1024
18
19
 
19
20
  # Create a new ImageUploader
20
- #
21
- # @param [Session] session - session to a piwigo instance
22
21
  def initialize(logger: nil)
23
22
  @logger = logger || Logger.new(STDOUT)
24
23
  end
@@ -30,7 +29,7 @@ module Piwigo
30
29
  # @param [<Type>] name of the image
31
30
  #
32
31
  # @return [Boolean] True if successful
33
- def upload(session, filename, name, album: null)
32
+ def upload(session, filename, name, album: nil)
34
33
  @session = session
35
34
  raise 'Invalid session' if @session.uri.nil?
36
35
 
@@ -126,15 +125,17 @@ module Piwigo
126
125
  request['Cookie'] = [@session.id]
127
126
 
128
127
  response = http.request(request)
129
- if response.code == '500'
128
+ case response.code
129
+ when '500'
130
130
  @logger.error "Image Add failed: #{response.message}"
131
131
  false
132
- elsif response.code == '200'
132
+ when '200'
133
133
  data = JSON.parse(response.body)
134
134
  p data
135
135
  @logger.info 'Image Add succeeded.'
136
136
  true
137
137
  else
138
+ @logger.error "Unexpected error: #{response.code}"
138
139
  false
139
140
  end
140
141
  rescue Timeout::Error, Errno::EINVAL, Errno::ECONNRESET, EOFError, Net::HTTPBadResponse, Net::HTTPHeaderSyntaxError, Net::ProtocolError => e
@@ -144,7 +145,7 @@ module Piwigo
144
145
 
145
146
  def sniff_attributes(filename, album: nil)
146
147
  attributes = {}
147
- begin
148
+ begin
148
149
  info = EXIFR::JPEG.new(filename)
149
150
  @logger.info "--> GPS: #{info.gps.latitude}, #{info.gps.longitude}" unless info.gps.nil?
150
151
  exif = info.exif.first.to_hash if info.exif?
data/lib/piwigo/images.rb CHANGED
@@ -6,12 +6,12 @@ require 'logger'
6
6
  require 'digest'
7
7
  require_relative 'image_uploader'
8
8
 
9
- # Piwigo organizes images by albums. The album tree has unlimted depth and each photo can belong to multiple albums. The Piwigo API
9
+ # Piwigo organizes images by albums. The album tree has unlimited depth and each photo can belong to multiple albums. The Piwigo API
10
10
  # refers to a Album as a Category.
11
11
  module Piwigo
12
12
  class Images
13
13
  class Image
14
- # @return [Number] Unique ID idenifying this ie
14
+ # @return [Number] Unique ID identifying this ie
15
15
  attr_accessor :id
16
16
 
17
17
  # @return [Number] Width of the image in pixels
@@ -53,7 +53,7 @@ module Piwigo
53
53
  def initialize(hash: nil)
54
54
  hash&.each do |key, value|
55
55
  # Bug: If the encoding is Windows-1252, then Piwigo will blowup when creating the album
56
- value = value.encode('UTF-8', 'Windows-1252') if value.class == String && value.encoding.to_s == 'Windows-1252'
56
+ value = value.encode('UTF-8', 'Windows-1252') if value.instance_of?(String) && value.encoding.to_s == 'Windows-1252'
57
57
  send("#{key}=", value)
58
58
  end
59
59
  end
@@ -75,7 +75,7 @@ module Piwigo
75
75
  def initialize(hash: nil)
76
76
  hash&.each do |key, value|
77
77
  # Bug: If the encoding is Windows-1252, then Piwigo will blowup when creating the album
78
- value = value.encode('UTF-8', 'Windows-1252') if value.class == String && value.encoding.to_s == 'Windows-1252'
78
+ value = value.encode('UTF-8', 'Windows-1252') if value.instance_of?(String) && value.encoding.to_s == 'Windows-1252'
79
79
  send("#{key}=", value)
80
80
  end
81
81
  end
@@ -131,11 +131,12 @@ module Piwigo
131
131
  #
132
132
  # @param [<Type>] session
133
133
  # @param [<Type>] filename of the file to upload
134
- # @param [<Type>] name of the image
134
+ # @param [Album] album to place tge image in
135
+ # @param [String] name of the image
135
136
  #
136
137
  # @return [Boolean] True if successful
137
- def self.upload(session, file, name)
138
- ImageUploader.new(session, file, name).upload
138
+ def self.upload(session, file, album, name)
139
+ ImageUploader.new.upload(session, file, name, album: album)
139
140
  end
140
141
 
141
142
  # Checks existence of images
@@ -28,7 +28,7 @@ module Piwigo
28
28
  # Gets information about the current session. Also provides a token useable with admin methods.
29
29
  # @return [<Type>] <description>
30
30
  def status
31
- logger ||= Logger.new(STDOUT)
31
+ logger ||= Logger.new($stdout)
32
32
 
33
33
  begin
34
34
  # Create the HTTP objects
@@ -60,11 +60,11 @@ module Piwigo
60
60
  def logout(logger: nil)
61
61
  raise 'This session has already been logged out' if uri.nil?
62
62
 
63
- logger ||= Logger.new(STDOUT)
63
+ logger ||= Logger.new($stdout)
64
64
 
65
65
  # Create the HTTP objects
66
66
  http = Net::HTTP.new(uri.host, uri.port)
67
- request = Net::HTTP::Get.new(uri.request_uri + '&method=pwg.session.logout')
67
+ request = Net::HTTP::Get.new("#{uri.request_uri}&method=pwg.session.logout")
68
68
  request['Cookie'] = id
69
69
 
70
70
  # Send the request
@@ -78,17 +78,21 @@ module Piwigo
78
78
  # @param [string] piwigo - host to connect to. Can be fqdn or ip.
79
79
  # @param [string] username - user to connect as
80
80
  # @param [string] password - password for user
81
- # @param [boolean] https - Use HTTPS?
81
+ # @param [boolean] https -
82
+ # @param [port] Optional port. If not specified, then http connections will use 80, https 443
82
83
  # @param [Logger] logger logger to output debug messages to (Optional)
83
- def self.login(host, username, password, https: true, logger: nil)
84
+ def self.login(host, username, password, https: true, port: nil, logger: nil)
84
85
  raise 'host should not be nil' if host.nil?
85
86
  raise 'username should not be nil' if username.nil?
86
87
 
87
- logger ||= Logger.new(STDOUT)
88
+ logger ||= Logger.new($stdout)
88
89
 
89
90
  begin
90
- uri = https ? URI::HTTPS.build(host: host, path: '/ws.php', query: 'format=json') :
91
- URI::HTTP.build(host: host, path: '/ws.php', query: 'format=json')
91
+ uri = if https
92
+ URI::HTTPS.build(host: host, port: port.nil? ? 443 : port, path: '/ws.php', query: 'format=json')
93
+ else
94
+ URI::HTTP.build(host: host, port: port.nil? ? 80 : port, path: '/ws.php', query: 'format=json')
95
+ end
92
96
 
93
97
  # Create the HTTP objects
94
98
  http = Net::HTTP.new(uri.host, uri.port)
@@ -105,7 +109,7 @@ module Piwigo
105
109
 
106
110
  if response.code == '200'
107
111
  logger.info "Login succeeded: #{response.body}"
108
- pwg_id = response.response['set-cookie'].split(';').select { |i| i.strip.start_with? 'pwg_id' }.first
112
+ pwg_id = response.response['set-cookie'].split(/[;,\,]/).select { |i| i.strip.start_with? 'pwg_id' }.first
109
113
  return Session.new(pwg_id, uri)
110
114
  else
111
115
  logger.error "Login failed: #{response.body}"
@@ -1,3 +1,3 @@
1
1
  module Piwigo
2
- VERSION = '0.5.7'.freeze
2
+ VERSION = '0.6.0'.freeze
3
3
  end
data/piwigo-api.gemspec CHANGED
@@ -27,14 +27,14 @@ Gem::Specification.new do |spec|
27
27
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
28
28
  spec.require_paths = ['lib']
29
29
 
30
- spec.add_development_dependency 'bundler', '~> 2.0'
31
- spec.add_development_dependency 'codecov', '~> 0.1', '>= 0.1.10'
32
- spec.add_development_dependency 'minitest', '~> 5.0'
33
- spec.add_development_dependency 'minitest-reporters', '~>1.4'
30
+ spec.add_development_dependency 'bundler', '~> 2.3'
31
+ spec.add_development_dependency 'codecov', '~> 0.6'
32
+ spec.add_development_dependency 'minitest', '~> 5.15'
33
+ spec.add_development_dependency 'minitest-reporters', '~>1.5'
34
34
  spec.add_development_dependency 'rake', '~> 13.0'
35
- spec.add_development_dependency 'simplecov', '~> 0.17'
35
+ spec.add_development_dependency 'simplecov', '~> 0.21'
36
36
 
37
- spec.add_runtime_dependency 'http', '~>4.2'
38
- spec.add_runtime_dependency 'logger', '~>1.4'
37
+ spec.add_runtime_dependency 'http', '~>5.0'
38
+ spec.add_runtime_dependency 'logger', '~>1.5'
39
39
  spec.add_runtime_dependency 'exifr', '~>1.3'
40
40
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: piwigo-api
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.7
4
+ version: 0.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Adrian Gilbert
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-03-01 00:00:00.000000000 Z
11
+ date: 2022-01-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -16,62 +16,56 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '2.0'
19
+ version: '2.3'
20
20
  type: :development
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: '2.0'
26
+ version: '2.3'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: codecov
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: '0.1'
34
- - - ">="
35
- - !ruby/object:Gem::Version
36
- version: 0.1.10
33
+ version: '0.6'
37
34
  type: :development
38
35
  prerelease: false
39
36
  version_requirements: !ruby/object:Gem::Requirement
40
37
  requirements:
41
38
  - - "~>"
42
39
  - !ruby/object:Gem::Version
43
- version: '0.1'
44
- - - ">="
45
- - !ruby/object:Gem::Version
46
- version: 0.1.10
40
+ version: '0.6'
47
41
  - !ruby/object:Gem::Dependency
48
42
  name: minitest
49
43
  requirement: !ruby/object:Gem::Requirement
50
44
  requirements:
51
45
  - - "~>"
52
46
  - !ruby/object:Gem::Version
53
- version: '5.0'
47
+ version: '5.15'
54
48
  type: :development
55
49
  prerelease: false
56
50
  version_requirements: !ruby/object:Gem::Requirement
57
51
  requirements:
58
52
  - - "~>"
59
53
  - !ruby/object:Gem::Version
60
- version: '5.0'
54
+ version: '5.15'
61
55
  - !ruby/object:Gem::Dependency
62
56
  name: minitest-reporters
63
57
  requirement: !ruby/object:Gem::Requirement
64
58
  requirements:
65
59
  - - "~>"
66
60
  - !ruby/object:Gem::Version
67
- version: '1.4'
61
+ version: '1.5'
68
62
  type: :development
69
63
  prerelease: false
70
64
  version_requirements: !ruby/object:Gem::Requirement
71
65
  requirements:
72
66
  - - "~>"
73
67
  - !ruby/object:Gem::Version
74
- version: '1.4'
68
+ version: '1.5'
75
69
  - !ruby/object:Gem::Dependency
76
70
  name: rake
77
71
  requirement: !ruby/object:Gem::Requirement
@@ -92,42 +86,42 @@ dependencies:
92
86
  requirements:
93
87
  - - "~>"
94
88
  - !ruby/object:Gem::Version
95
- version: '0.17'
89
+ version: '0.21'
96
90
  type: :development
97
91
  prerelease: false
98
92
  version_requirements: !ruby/object:Gem::Requirement
99
93
  requirements:
100
94
  - - "~>"
101
95
  - !ruby/object:Gem::Version
102
- version: '0.17'
96
+ version: '0.21'
103
97
  - !ruby/object:Gem::Dependency
104
98
  name: http
105
99
  requirement: !ruby/object:Gem::Requirement
106
100
  requirements:
107
101
  - - "~>"
108
102
  - !ruby/object:Gem::Version
109
- version: '4.2'
103
+ version: '5.0'
110
104
  type: :runtime
111
105
  prerelease: false
112
106
  version_requirements: !ruby/object:Gem::Requirement
113
107
  requirements:
114
108
  - - "~>"
115
109
  - !ruby/object:Gem::Version
116
- version: '4.2'
110
+ version: '5.0'
117
111
  - !ruby/object:Gem::Dependency
118
112
  name: logger
119
113
  requirement: !ruby/object:Gem::Requirement
120
114
  requirements:
121
115
  - - "~>"
122
116
  - !ruby/object:Gem::Version
123
- version: '1.4'
117
+ version: '1.5'
124
118
  type: :runtime
125
119
  prerelease: false
126
120
  version_requirements: !ruby/object:Gem::Requirement
127
121
  requirements:
128
122
  - - "~>"
129
123
  - !ruby/object:Gem::Version
130
- version: '1.4'
124
+ version: '1.5'
131
125
  - !ruby/object:Gem::Dependency
132
126
  name: exifr
133
127
  requirement: !ruby/object:Gem::Requirement
@@ -166,6 +160,7 @@ files:
166
160
  - bin/console
167
161
  - bin/setup
168
162
  - codecov.yml
163
+ - examples/Different_Port.md
169
164
  - examples/Syncronize_Folder.md
170
165
  - examples/Upload_Image.md
171
166
  - lib/piwigo.rb
@@ -199,7 +194,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
199
194
  - !ruby/object:Gem::Version
200
195
  version: '0'
201
196
  requirements: []
202
- rubygems_version: 3.0.3
197
+ rubygems_version: 3.0.3.1
203
198
  signing_key:
204
199
  specification_version: 4
205
200
  summary: Gem to interact with the Piwigo API