bestchange 1.1 → 1.3

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: d8081c2cc7f9b963ede0ad28cc64923c9a550f0b9cbd4f388bf17600ccfc6ade
4
- data.tar.gz: f4813b0a6675c55e9c17c57a2ddbbe71f13706241eb21a43afcfb250cf305487
3
+ metadata.gz: 1d6a02d56b4b2a21310cec76c34b7b35565953193839cd881e601a8793713da9
4
+ data.tar.gz: 79f74ffaad6279e4786bf0feb0c6adf0cf2cde65ae219a4831290460aa0b968f
5
5
  SHA512:
6
- metadata.gz: 573465318a1d906fe83c98659ebbb4167d473bfeb3cafe4e07869133add1363077958026c3771c2f24afea9957db5b113dc6687055b63a771ce70e360d4fbf73
7
- data.tar.gz: 477626b6f7183c6da3390c6e204755c42f26274f5b0bada6ae0fb671c511d3259ecf8e23376134cf231a84a4894dab3db8c5cdd21c8a5071dcefa7aac5d6f3db
6
+ metadata.gz: 9390b359cafddf3c1f1cda493f47a0e6a3723575dc049b4e1f037795677d2f474d93163195e8e0c9ea56ec78c88d5b976c5bc315640aef2261440879cb7e6f54
7
+ data.tar.gz: 0f0b6ba210438209fddbece962396ecc7336c48b509d834e974fc0ff1ec0049260258294e5655d1514f1bae42746f5e357aeec223cbf3b8f1f3e3966d545229e
data/.rubocop.yml CHANGED
@@ -3,4 +3,4 @@ AllCops:
3
3
  Style/Documentation:
4
4
  Enabled: false
5
5
  Metrics/MethodLength:
6
- Max: 15
6
+ Max: 20
data/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # Change log
2
2
 
3
+ ## [1.3]
4
+ Add on_extract callback support to ZipExtractor initializer
5
+
6
+ ## [1.2]
7
+ Add base connection, request constants
8
+
3
9
  ## [1.1]
4
10
  Fix tempfile location
5
11
 
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- bestchange-api (1.1)
4
+ bestchange (1.3)
5
5
  rubyzip (= 2.3.2)
6
6
 
7
7
  GEM
@@ -48,7 +48,7 @@ PLATFORMS
48
48
  arm64-darwin-22
49
49
 
50
50
  DEPENDENCIES
51
- bestchange-api!
51
+ bestchange!
52
52
  minitest (= 5.17.0)
53
53
  minitest-reporters
54
54
  pry (= 0.14.2)
data/README.md CHANGED
@@ -1,14 +1,14 @@
1
1
 
2
- # bestchange-api
2
+ # bestchange
3
3
 
4
- bestchange-api is a simple library for getting data from Bestchange aggregator
4
+ bestchange is a simple library for getting data from Bestchange aggregator
5
5
 
6
6
  ## Installation
7
7
 
8
8
  Add this line to your application's Gemfile:
9
9
 
10
10
  ```ruby
11
- gem 'bestchange-api'
11
+ gem 'bestchange'
12
12
  ```
13
13
 
14
14
  And then execute:
@@ -17,7 +17,7 @@ And then execute:
17
17
 
18
18
  Or install it yourself as:
19
19
 
20
- $ gem install bestchange-api
20
+ $ gem install bestchange
21
21
 
22
22
  ## Usage
23
23
  [Bestchange api description](https://github.com/karpinovsky/bestchange-api/blob/master/API_DOC.txt)
@@ -83,4 +83,4 @@ The gem is available as open source under the terms of the [MIT License](https:/
83
83
 
84
84
  ## Code of Conduct
85
85
 
86
- Everyone interacting in the bestchange-api project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/karpinovsky/bestchange-api/blob/master/CODE_OF_CONDUCT.md).
86
+ Everyone interacting in the bestchange project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/karpinovsky/bestchange-api/blob/master/CODE_OF_CONDUCT.md).
@@ -0,0 +1,39 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative 'lib/bestchange/version'
4
+
5
+ Gem::Specification.new do |spec|
6
+ spec.name = 'bestchange'
7
+ spec.summary = 'Bestchange client'
8
+ spec.description = 'A simple library for getting data from Bestchange aggregator'
9
+
10
+ spec.version = Bestchange::VERSION
11
+ spec.required_ruby_version = Gem::Requirement.new('>= 3.1.3')
12
+
13
+ spec.authors = ['Kirill Karpinovsky']
14
+ spec.email = 'karpinovsky@gmail.com'
15
+
16
+ spec.homepage = 'https://github.com/karpinovsky/bestchange'
17
+
18
+ spec.metadata['homepage_uri'] = spec.homepage
19
+ spec.metadata['source_code_uri'] = spec.homepage
20
+ spec.metadata['bug_tracker_uri'] = "#{spec.homepage}/issues"
21
+ spec.metadata['changelog_uri'] = "#{spec.homepage}/blob/master/CHANGELOG.md"
22
+
23
+ spec.extra_rdoc_files = Dir['README.md', 'CHANGELOG.md', 'LICENSE.txt']
24
+
25
+ spec.files = Dir.chdir(File.expand_path(__dir__)) do
26
+ `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
27
+ end
28
+
29
+ spec.require_paths = ['lib']
30
+
31
+ spec.add_dependency 'rubyzip', '2.3.2'
32
+
33
+ spec.add_development_dependency 'minitest', '5.17.0'
34
+ spec.add_development_dependency 'minitest-reporters'
35
+ spec.add_development_dependency 'pry', '0.14.2'
36
+ spec.add_development_dependency 'rubocop', '1.47.0'
37
+
38
+ spec.license = 'MIT'
39
+ end
@@ -9,25 +9,17 @@ require 'zip'
9
9
  module Bestchange
10
10
  class Api
11
11
  BASE_URI = 'http://api.bestchange.ru/info.zip'
12
+ BASE_CONNECTION = Net::HTTP.new(URI(BASE_URI).host, URI(BASE_URI).port)
13
+ BASE_REQUEST = Net::HTTP::Get.new(URI(BASE_URI))
12
14
 
13
- def initialize(conn = default_conn)
15
+ def initialize(conn = BASE_CONNECTION)
14
16
  @conn = conn
15
17
  end
16
18
 
17
19
  attr_reader :conn
18
20
 
19
- def request(request = default_request)
21
+ def request(request = BASE_REQUEST)
20
22
  conn.request(request)
21
23
  end
22
-
23
- private
24
-
25
- def default_conn
26
- Net::HTTP.new(URI(BASE_URI).host, URI(BASE_URI).port)
27
- end
28
-
29
- def default_request
30
- Net::HTTP::Get.new(URI(BASE_URI))
31
- end
32
24
  end
33
25
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Bestchange
4
- VERSION = '1.1'
4
+ VERSION = '1.3'
5
5
  end
@@ -4,8 +4,9 @@ require 'zip'
4
4
 
5
5
  module Bestchange
6
6
  class ZipExtractor
7
- def initialize(zip_file)
7
+ def initialize(zip_file, on_extract: nil)
8
8
  @zip_file = zip_file
9
+ @on_extract = on_extract
9
10
  end
10
11
 
11
12
  def call(filename)
@@ -14,6 +15,7 @@ module Bestchange
14
15
  Zip::File.open(@zip_file) do |zip_file|
15
16
  entry = zip_file.find_entry(filename)
16
17
 
18
+ @on_extract&.call(entry)
17
19
  entry.extract(tempfile) { true }
18
20
  end
19
21
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bestchange
3
3
  version: !ruby/object:Gem::Version
4
- version: '1.1'
4
+ version: '1.3'
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kirill Karpinovsky
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-04-25 00:00:00.000000000 Z
11
+ date: 2023-05-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rubyzip
@@ -98,6 +98,7 @@ files:
98
98
  - LICENSE
99
99
  - README.md
100
100
  - Rakefile
101
+ - bestchange.gemspec
101
102
  - bin/console
102
103
  - bin/setup
103
104
  - lib/bestchange.rb