rubyhexagon 1.4.0 → 1.5.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f648db04caba89f3461c14c60bf3054e0727c265bfa5ae5a45374135043fb284
4
- data.tar.gz: 40c7af470e95c3d8ab97f469354ec494cf6fbe71bc191e2b33770c0ffb494bd7
3
+ metadata.gz: 140a15c68030d059d158ea174fe82b2f426241491b1f0e5d8f348716ca2ef2b9
4
+ data.tar.gz: 58e18c80dfa100f432bb77119c1cffe88b95ca04d3a43467af27d9e2240b160f
5
5
  SHA512:
6
- metadata.gz: 45fd6046f22d1d6a539af0e08aa2a9a8676269b96fd32f00d0d298f3e28dadbcf37970b7b97be6bcae699ce3c4c3e168268408dc6d69cc4eb07ca119c00f6201
7
- data.tar.gz: ccd2c946edfcb2c2ce1dbff518f40ca6c84ad5d0a4e1311c60a9586ebc02f950f6dbe49ce5d776f4a026685f87c607ae73604d97881e4d631fa1996615441018
6
+ metadata.gz: e4caa755f4c8802d59d19ad981031297944c54fc3725afe7a967eeafea65439c7fa682721d78df516166f1349b7a1aa2243697e1de1eb4eee4458f3bcf646c8e
7
+ data.tar.gz: 43c6d7a6e62afd236a5834e18912449dca8aead0f35e0dd3ee411ee9f3165611ff7c32f38d95ab761e2cc92490722190a2a45f216ab7d7688ae9171dc891083d
data/lib/rubyhexagon.rb CHANGED
@@ -22,29 +22,30 @@ require 'uri'
22
22
  require 'json'
23
23
  require 'digest/md5'
24
24
 
25
- require 'rubyhexagon/helper/api'
26
- require 'rubyhexagon/error'
27
- require 'rubyhexagon/user'
28
- require 'rubyhexagon/tag'
29
- require 'rubyhexagon/artist'
30
- require 'rubyhexagon/type'
31
- require 'rubyhexagon/image'
32
- require 'rubyhexagon/level'
33
- require 'rubyhexagon/post'
34
- require 'rubyhexagon/pool'
35
- require 'rubyhexagon/tag_change'
36
- require 'rubyhexagon/search/posts'
37
- require 'rubyhexagon/search/pools'
38
- require 'rubyhexagon/search/tags'
39
- require 'rubyhexagon/search/flag_history'
40
- require 'rubyhexagon/search/tag_history'
25
+ require_relative 'rubyhexagon/helper/api'
26
+ require_relative 'rubyhexagon/error'
27
+ require_relative 'rubyhexagon/user'
28
+ require_relative 'rubyhexagon/tag'
29
+ require_relative 'rubyhexagon/artist'
30
+ require_relative 'rubyhexagon/type'
31
+ require_relative 'rubyhexagon/image'
32
+ require_relative 'rubyhexagon/level'
33
+ require_relative 'rubyhexagon/post'
34
+ require_relative 'rubyhexagon/pool'
35
+ require_relative 'rubyhexagon/login'
36
+ require_relative 'rubyhexagon/tag_change'
37
+ require_relative 'rubyhexagon/search/posts'
38
+ require_relative 'rubyhexagon/search/pools'
39
+ require_relative 'rubyhexagon/search/tags'
40
+ require_relative 'rubyhexagon/search/flag_history'
41
+ require_relative 'rubyhexagon/search/tag_history'
41
42
 
42
43
  # Namespace for all classes in this gem.
43
44
  # @author Maxine Michalski
44
45
  # @since 0.4.3
45
46
  module Rubyhexagon
46
47
  MAJOR = 1
47
- MINOR = 4
48
+ MINOR = 5
48
49
  PATCH = 0
49
50
  NAME = 'rubyhexagon'
50
51
  VERSION = "#{MAJOR}.#{MINOR}.#{PATCH}"
@@ -59,7 +59,12 @@ module Rubyhexagon
59
59
  #
60
60
  # @return [Hash] JSON parsed response.
61
61
  def fetch(noun, action, query)
62
- query = query.to_a.map { |q| "#{q.first}=#{q.last}" }.join('&')
62
+ login = Login.instance
63
+ if login.setup?
64
+ query.store(:login, login.login)
65
+ query.store(:password_hash, login.password_hash)
66
+ end
67
+ query = query.map { |k, v| "#{k}=#{v}" }.join('&')
63
68
  query = "?#{query}" unless query == ''
64
69
  uri = "#{@base}/#{noun}/#{action}.json#{query}"
65
70
  uri = URI.parse(uri)
@@ -0,0 +1,42 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Copyright 2014-2018 Maxine Michalski <maxine@furfind.net>
4
+ #
5
+ # This file is part of rubyhexagon.
6
+ #
7
+ # rubyhexagon is free software: you can redistribute it and/or modify
8
+ # it under the terms of the GNU General Public License as published by
9
+ # the Free Software Foundation, either version 3 of the License, or
10
+ # (at your option) any later version.
11
+ #
12
+ # rubyhexagon is distributed in the hope that it will be useful,
13
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
14
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
+ # GNU General Public License for more details.
16
+ #
17
+ # You should have received a copy of the GNU General Public License
18
+ # along with rubyhexagon. If not, see <http://www.gnu.org/licenses/>.
19
+
20
+ require 'singleton'
21
+
22
+ module Rubyhexagon
23
+ # A singleton class to store API login credentials. This is used to make sure
24
+ # that those data can be used on outgoing API calls, but also centralizes
25
+ # their use.
26
+ #
27
+ # @author Maxine Michalski
28
+ # @since 1.5.0
29
+ class Login
30
+ include Singleton
31
+
32
+ # @return [String] login name for user
33
+ attr_accessor :login
34
+
35
+ # @return [String] api key for calls
36
+ attr_accessor :password_hash
37
+
38
+ def setup?
39
+ !(@login.nil? || @password_hash.nil?)
40
+ end
41
+ end
42
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rubyhexagon
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.4.0
4
+ version: 1.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Maxine Michalski
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-04-15 00:00:00.000000000 Z
11
+ date: 2018-07-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: json
@@ -36,6 +36,7 @@ files:
36
36
  - lib/rubyhexagon/helper/api.rb
37
37
  - lib/rubyhexagon/image.rb
38
38
  - lib/rubyhexagon/level.rb
39
+ - lib/rubyhexagon/login.rb
39
40
  - lib/rubyhexagon/pool.rb
40
41
  - lib/rubyhexagon/post.rb
41
42
  - lib/rubyhexagon/search/flag_history.rb
@@ -67,7 +68,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
67
68
  version: '0'
68
69
  requirements: []
69
70
  rubyforge_project:
70
- rubygems_version: 2.7.6
71
+ rubygems_version: 2.7.7
71
72
  signing_key:
72
73
  specification_version: 4
73
74
  summary: Rubyhexagon, Ruby bindings for e621.