herdic 1.0.3 → 1.0.4

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
  SHA1:
3
- metadata.gz: 76bb219a1e205279d9c5fe7ea6387d028e6f7d61
4
- data.tar.gz: 26bfb9573646e1fef72de5d946fff6d118fa3746
3
+ metadata.gz: 5e6a6415b3aa01cb18489c8092ba5e83fbd1fae3
4
+ data.tar.gz: f49947d5d1b82ed0703bdaf3f679e5f84880772d
5
5
  SHA512:
6
- metadata.gz: 954aa0df95280a8232b542a714895a453a9d2a0919a2637692e1b0df668561ec7809bfeec58d8c85f88cbc8c0e20996a8f5c920c8ee69c7cc6516699c12af942
7
- data.tar.gz: 0d969818ec0da955b19b4086d3aded6dfb691eb081bbaa868e71f060b99d83e8edd6fbaa6995fc3e015b3c880a8d058dfe860e5de2d1ac5325379bacb916e1f5
6
+ metadata.gz: 496aae96af64c3fe56b2ea4c05164c28e662461f66b8cfe04f40f6bef4da7a1d536bd50904e5c2d185b8dd8286064496c3fe2988c99876f782b637ba89680151
7
+ data.tar.gz: 4c80144839b47a70caedea5ca81a51b2e37b836088545a199477322507b8285f8abf4d5a7ac5e7c7497104bce38509f89970849b86f8e47d2e1aa3cbd7105d74
data/bin/herdic CHANGED
@@ -3,7 +3,7 @@
3
3
  require 'herdic'
4
4
 
5
5
 
6
- options = ARGV.getopts 'e', 'c:', 'use-ssl'
6
+ options = ARGV.getopts 'e', 'c:', 'use-ssl', 'no-cookie'
7
7
  file = ARGV[0]
8
8
 
9
9
  raise 'No file given' if !file || file.empty?
@@ -25,8 +25,9 @@ module Herdic
25
25
  @printer = Printer.new @options
26
26
  @printer.start_message @config_file
27
27
 
28
- @store = Store.new @config_file
28
+ @store = Store.new @config_file
29
29
  @registry = @store.data
30
+ @cookie = (@registry[:_cookie] ||= {})
30
31
  end
31
32
 
32
33
  def load_config(file)
@@ -76,6 +77,8 @@ module Herdic
76
77
  register response, body
77
78
  end
78
79
 
80
+ save_cookie response unless @options['no-cookie']
81
+
79
82
  @printer.response response, body
80
83
  end
81
84
 
@@ -102,6 +105,10 @@ module Herdic
102
105
 
103
106
  @meta['method'].upcase!
104
107
  @header = @header.map { |k, v| [k, v.to_s] }.to_h
108
+
109
+ unless @options['no-cookie'] || @cookie.empty?
110
+ @header['Cookie'] = @cookie.map { |k, v| '%s=%s' % [k, v] }.join ';'
111
+ end
105
112
  end
106
113
 
107
114
  private def register(response, body)
@@ -119,5 +126,12 @@ module Herdic
119
126
  end
120
127
  end
121
128
 
129
+ private def save_cookie(response)
130
+ Array(response.get_fields('Set-Cookie')).each do |str|
131
+ k, v = str.split(';')[0].split '='
132
+ @cookie[k] = v
133
+ end
134
+ end
135
+
122
136
  end
123
137
  end
@@ -2,7 +2,7 @@ module Herdic
2
2
 
3
3
  MAJOR = 1
4
4
  MINOR = 0
5
- REVISION = 3
5
+ REVISION = 4
6
6
 
7
7
  VERSION = [MAJOR, MINOR, REVISION].compact.join '.'
8
8
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: herdic
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.3
4
+ version: 1.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Yuki Iwanaga
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-12-04 00:00:00.000000000 Z
11
+ date: 2014-12-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport