iiko 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/iiko/version.rb +1 -1
- data/lib/iiko/web.rb +8 -6
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3ce3a8127b3d546319f4a3c7f3c0e05bbf1ee978
|
4
|
+
data.tar.gz: c5be391404b27b224bdea673e50082035cd0b0f5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 68f887b96ecfd408c89dacf874a7498e7e637e1937f0ec45c1e44ba8e96ae96adabc82351c085b0e72add7ac85bd5505955a74b43692090ba2246539ee6af1c5
|
7
|
+
data.tar.gz: 95c44c72f1b32b2a90635e613e17ce8f565d3df0e77f3b5f60e1f1d5b1d0396c4344adc84af37193713e01f722b735b5d65e626acf03b859d50db1c82fc14193
|
data/lib/iiko/version.rb
CHANGED
data/lib/iiko/web.rb
CHANGED
@@ -4,13 +4,16 @@ module Iiko
|
|
4
4
|
class Web
|
5
5
|
IIKO_USER_AGENT = 'iiko agent'
|
6
6
|
|
7
|
-
attr_reader :agent, :result, :files, :settings, :logged
|
7
|
+
attr_reader :agent, :result, :files, :settings, :logged, :headers
|
8
8
|
|
9
9
|
def initialize(settings)
|
10
10
|
@settings = settings # :url, :user, :password, :user_agent
|
11
11
|
validate_arguments
|
12
12
|
|
13
13
|
@agent = Mechanize.new { |agent| agent.user_agent = settings[:user_agent] || IIKO_USER_AGENT }
|
14
|
+
|
15
|
+
#default_headers = { "Accept-Language" => 'ru-RU,ru;q=0.8,en-US;q=0.6,en;q=0.4' }
|
16
|
+
#@headers = settings[:headers] ? settings[:headers].merge(default_headers) : default_headers
|
14
17
|
end
|
15
18
|
|
16
19
|
def login
|
@@ -41,19 +44,18 @@ module Iiko
|
|
41
44
|
private
|
42
45
|
|
43
46
|
def write_file(file_name = nil, name, extension)
|
44
|
-
|
45
|
-
File.write(file_name, result.body)
|
46
|
-
else
|
47
|
+
unless file_name
|
47
48
|
file = extra_file(name, extension)
|
48
|
-
file.write(result.body)
|
49
|
+
#file.write(result.body)
|
49
50
|
file.close
|
50
51
|
file_name = file.path
|
51
52
|
end
|
53
|
+
File.write(file_name, result.body, mode: 'wb')
|
52
54
|
file_name
|
53
55
|
end
|
54
56
|
|
55
57
|
def extra_file(name, extension)
|
56
|
-
Tempfile.new([name, ".#{extension}"])
|
58
|
+
Tempfile.new([name, ".#{extension}"], encoding: 'ascii-8bit')
|
57
59
|
end
|
58
60
|
|
59
61
|
def validate_arguments
|