zold 0.11.11 → 0.11.12

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: 8166417b26ad8c5745a7c83ddec0f463bc641d1e
4
- data.tar.gz: 8d8747d23ab292070a3fd1d5b86efd3fa27bb4ad
3
+ metadata.gz: 90832b265cac310c342302076196ba278cb95a61
4
+ data.tar.gz: 6dfa38e0c58cf822e932e02f6069d320bb27ea3c
5
5
  SHA512:
6
- metadata.gz: b86e8bcb2f3f79e072f6c33b769089c1711ce8d4ef6cfb855c88b5a130964146d5a5e5a184d604ead24d2fee82a2cc6c519a0c0ce09e403b3802edc23b15ec8a
7
- data.tar.gz: 41bc7348572a88dcf9d7951f9f8f21ad9b54f35cd3430df64587e2e50567b124fae6719e96aaf17608efb29af4a88a8552dd2143fd29a2c99975cb2b87059fbc
6
+ metadata.gz: b9bad4cfcf2359824214fceb42944f835864fd6beac8603f63862d9a0311b0a9a64cc4dc016bfe96db5043416a51e29cce4d449a6090e968aa301ad80b5a4e8c
7
+ data.tar.gz: be26c9b2ff2d1afaafbfb96d3074b32fe31633d28430e9d9d62d46c8a089e6a77c0aee107bd7404b17904fa8d2d62d41cbfbf4222ff365a8c218968d3c9b03cf
data/bin/zold-nohup CHANGED
@@ -29,6 +29,7 @@ require 'open3'
29
29
  $opts = Slop.parse(ARGV, strict: false, suppress_errors: true) do |o|
30
30
  o.string '--log-file', 'The file to save logs into', default: 'zold-node.log'
31
31
  o.bool '--skip-install', 'Don\'t re-install Zold gem', default: false
32
+ o.bool '--sudo-install', 'Install Zold gem via sudo', default: false
32
33
  end
33
34
 
34
35
  def log(line)
@@ -58,7 +59,7 @@ $pid = fork do
58
59
  end
59
60
  loop do
60
61
  exec("zold #{$opts.arguments.join(' ')}")
61
- exec('gem install zold') unless $opts['skip-install']
62
+ exec(($opts['sudo-install'] ? 'sudo ' : '') + 'gem install zold') unless $opts['skip-install']
62
63
  end
63
64
  end
64
65
  Process.detach($pid)
data/lib/zold/http.rb CHANGED
@@ -98,7 +98,8 @@ module Zold
98
98
  def headers
99
99
  headers = {
100
100
  'User-Agent': "Zold #{VERSION}",
101
- 'Connection': 'close'
101
+ 'Connection': 'close',
102
+ 'Accept-Encoding': 'gzip'
102
103
  }
103
104
  headers[Http::VERSION_HEADER] = VERSION
104
105
  headers[Http::SCORE_HEADER] = @score.reduced(4).to_text if @score.valid? && !@score.expired? && @score.value > 3
@@ -58,6 +58,7 @@ module Zold
58
58
  set :remotes, nil? # to be injected at node.rb
59
59
  set :copies, nil? # to be injected at node.rb
60
60
  end
61
+ use Rack::Deflater
61
62
 
62
63
  before do
63
64
  name = "HTTP-#{Http::SCORE_HEADER}".upcase.tr('-', '_')
@@ -147,7 +148,7 @@ module Zold
147
148
  id = Id.new(params[:id])
148
149
  wallet = settings.wallets.find(id)
149
150
  request.body.rewind
150
- after = request.body.read
151
+ after = request.body.read.to_s
151
152
  before = wallet.exists? ? AtomicFile.new(wallet.path).read : ''
152
153
  if before == after
153
154
  status 304
data/lib/zold/version.rb CHANGED
@@ -23,5 +23,5 @@
23
23
  # Copyright:: Copyright (c) 2018 Yegor Bugayenko
24
24
  # License:: MIT
25
25
  module Zold
26
- VERSION = '0.11.11'.freeze
26
+ VERSION = '0.11.12'.freeze
27
27
  end
@@ -102,4 +102,18 @@ class FrontTest < Minitest::Test
102
102
  end
103
103
  end
104
104
  end
105
+
106
+ def test_gzip
107
+ FakeNode.new(log: test_log).run(['--ignore-score-weakness']) do |port|
108
+ response = Zold::Http.new(URI("http://localhost:#{port}/")).get
109
+ assert_equal(
110
+ '200', response.code,
111
+ "Expected HTTP 200 OK: Found #{response.code}"
112
+ )
113
+ assert_operator(
114
+ 500, :>, response['content-length'].to_i,
115
+ 'Expected the content to be smaller than 500bytes for gzip'
116
+ )
117
+ end
118
+ end
105
119
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: zold
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.11.11
4
+ version: 0.11.12
5
5
  platform: ruby
6
6
  authors:
7
7
  - Yegor Bugayenko