gls_agent 0.2.0 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- ODI0NTc3YTlhN2NhZTcxMzcyM2QyY2NkZjg1YjY0OWUzNjI1NjgyNw==
4
+ ZDk4YzRmNDRkYzIxNDdlMDY0MGRiYTFmODZiN2FiNDdmNDhlZDljYQ==
5
5
  data.tar.gz: !binary |-
6
- YTcyYmEyZWEyMjgwYTE1NjNjZGNiMjBmYzg3N2M1MThkMzUwYWJhMQ==
6
+ YWQ1OTY3NzlkZjJiOWMwMDkwZmMzNDk0MDU2NWZlOTVmNTkxNTUxMA==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- ODYxMWExZGI3Y2RlZjljMDljZWZlNDIwN2Q5YWY3MjQwODM5MWNiOTQ0Y2Q2
10
- NmM4NTUwNzIxOTE5OWE5ZTdmNDA2YWQ4YmZlNjM1ZWY2MzBjMzIyYWI0Y2Rm
11
- ODNlNThiYTQ0OWVmNWU3YWQwZjhlYWYwYTM3ODQ2NDhhMTJlOGU=
9
+ ODY5Y2M1YzBiY2ViMDA3YWUyNGNiMTZlNDBiZjM5YTc3ZmMwODVkN2QwYWIw
10
+ YzQ4MTVjNmUzZGE2NDk0NmJmMjMzMjVhNmJlNDlkYzkwODQ0OTljY2ZjY2Q5
11
+ YTI4NDI3OWZjMjZjNzZhMWJiNTNhZDcwYzVkNzY0NWFmYjMwZTM=
12
12
  data.tar.gz: !binary |-
13
- OWM3YzNmODIwMjNjYzcyMzhhM2Q5MDA5OWQwNDg0YTMxYzI4NWEwY2M1ZmUx
14
- MDExYTI0YzUyYjMxNzczMmE2OTY2YjcxYWFiYzRmMmI4MjRiZmQzZjQwNjU3
15
- ZDNjN2EzMDlkMTEyMzY1MDcwMWU5YzYzZWY5YTJmNzgwZTZiMjc=
13
+ ZTQ2NjUwMTZkODVmNzAyYzE3MDVjZjY4MjU3MjdmZGVmNDM3Y2Y5YjZmODhl
14
+ OTYxMDg4YzI0ZjFmNzY5NjlhY2YwODJiNTZmNGI3NmM0ZWM4NzBmYmY0OTk0
15
+ NzMyNTE3NWRjYTRhZjI1N2IwNzllNjUwZTRhYTNiNjc5ZGViNDQ=
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --color
2
+ --format documentation
3
+
data/README.md CHANGED
@@ -24,7 +24,7 @@ Or install it yourself as:
24
24
 
25
25
  There is a small standalone script:
26
26
 
27
- $ gls_create_label -u glsuser -p glspass -d "John Doe,Home Street,1,1234,City,1" -o output.pdf
27
+ $ gls_create_label -u glsuser -p glspass -d "12.12.2014,John Doe,Home Street,1,1234,City,1" -o output.pdf
28
28
 
29
29
  Note that while not gemified, use
30
30
 
@@ -45,10 +45,10 @@ To use gls_agent in your ruby project, install the gem and use something along t
45
45
  mech.user = options[:user]
46
46
  mech.pass = options[:pass]
47
47
 
48
- GLSAgent::ParcelJob.new('Frank Sinatra','CloudStreet','1',1234,'HeavenCity','1')
48
+ GLSAgent::ParcelJob.new('31.01.2014','Frank Sinatra','CloudStreet','1',1234,'HeavenCity','1')
49
49
  saved_as = mech.save_parcel_label parcel,'gls_label_frank_sinatra.pdf'
50
50
 
51
- ## Configuration
51
+ ### Configuration
52
52
 
53
53
  You can invoke gls_agent without any configuration by specifying command line parameters.
54
54
  If you do not want to retype your gls credentials or do not want them to travel the wire (ssh), be present in the history (i.e. bash) or visible in the process list, you can put credentials or delivery details in ~/.gls_agent .
data/bin/gls_create_label CHANGED
@@ -22,10 +22,11 @@ optparse = OptionParser.new do |opts|
22
22
 
23
23
  opts.on('-l', '--label-data DATA', 'Label data, comma-separated.') do |l|
24
24
  fields = l.split(',')
25
- if fields.length != 6
26
- STDERR.puts 'Error: label data has to be in format "John Doe,Home Street,1,1234,City,1".'
25
+ if fields.length != 7
26
+ STDERR.puts 'Error: label data has to be in format "01.01.2016,John Doe,Home Street,1,1234,City,1".'
27
27
  exit 1
28
28
  end
29
+ options[:date] = fields.shift
29
30
  options[:name] = fields.shift
30
31
  options[:street] = fields.shift
31
32
  options[:streetno] = fields.shift
@@ -57,14 +58,14 @@ end
57
58
  optparse.parse!
58
59
 
59
60
  defaults = GLSAgent::Dotfile::get_opts
60
- options = default.merge options
61
+ options = defaults.merge options
61
62
 
62
63
  if !options[:user] || !options[:pass]
63
64
  STDERR.puts 'Error: Need to specify user and pass in ~/.gls_agent or -u -p .'
64
65
  exit 1
65
66
  end
66
67
 
67
- if !options[:name] || !options[:street] || !options[:streetno] || !options[:zip] || !options[:city] || !options[:weight]
68
+ if !options[:date] || !options[:name] || !options[:street] || !options[:streetno] || !options[:zip] || !options[:city] || !options[:weight]
68
69
  STDERR.puts 'Error: Need to specify delivery data in ~/.gls_agent or -l .'
69
70
  exit 1
70
71
  end
@@ -20,7 +20,7 @@ class GLSMech
20
20
 
21
21
  # Saves parcel label as pdf, does not overwrite file if exists,
22
22
  # returns filename that label was saved to.
23
- # returns nil if login or redirection failed.
23
+ # returns nil if login, creation or redirect failed.
24
24
  def save_parcel_label parcel_job, filename
25
25
  return nil if !login! @user, @pass
26
26
 
@@ -32,9 +32,19 @@ class GLSMech
32
32
  form.field_with(:name => 'txtZipCodeDisplay').value = parcel_job.zip
33
33
  form.field_with(:name => 'txtCity').value = parcel_job.city
34
34
  form.field_with(:name => 'txtWeight').value = parcel_job.weight
35
+ form.field_with(:name => 'txtDate').value = parcel_job.date
35
36
 
36
37
  @mech.submit(form, form.buttons.first)
37
- @mech.page.iframes.first.content.save_as filename
38
+
39
+ pdf_iframe = @mech.page.iframes.first
40
+
41
+ if pdf_iframe
42
+ return @mech.page.iframes.first.content.save_as filename
43
+ elsif @mech.log
44
+ @mech.page.save_as "gls_agent_debug_save-parcel-fail.html"
45
+ end
46
+
47
+ return nil
38
48
  end
39
49
 
40
50
  private
@@ -1,3 +1,3 @@
1
1
  module GLSAgent
2
- VERSION = "0.2.0".freeze
2
+ VERSION = "0.3.0".freeze
3
3
  end
data/lib/gls_agent.rb CHANGED
@@ -3,11 +3,11 @@ require 'gls_agent/gls_mech'
3
3
  require 'gls_agent/dotfile'
4
4
 
5
5
  module GLSAgent
6
- ParcelJob = Struct.new(:name, :street, :streetno, :zip, :city, :weight)
6
+ ParcelJob = Struct.new(:date, :name, :street, :streetno, :zip, :city, :weight)
7
7
 
8
8
  def self.job_from_csv string
9
9
  fields = string.split(',')
10
- if fields.length != 6
10
+ if fields.length != 7
11
11
  fail 'job_from_csv needs 6 fields'
12
12
  return nil
13
13
  end
@@ -15,6 +15,6 @@ module GLSAgent
15
15
  end
16
16
 
17
17
  def self.job_from_hash hash
18
- ParcelJob.new(hash[:name], hash[:street], hash[:streetno], hash[:zip], hash[:city], hash[:weight])
18
+ ParcelJob.new(hash[:date], hash[:name], hash[:street], hash[:streetno], hash[:zip], hash[:city], hash[:weight])
19
19
  end
20
20
  end
Binary file
@@ -2,7 +2,8 @@ require_relative '../lib/gls_agent'
2
2
 
3
3
  describe 'GLSAgent Module helpers' do
4
4
  it 'creates ParcelJob from csv string' do
5
- job = GLSAgent::job_from_csv 'Name,Street,1,1234,City,1'
5
+ job = GLSAgent::job_from_csv '02.02.2014,Name,Street,1,1234,City,1'
6
+ expect(job.date).to eq '02.02.2014'
6
7
  expect(job.name).to eq 'Name'
7
8
  expect(job.street).to eq 'Street'
8
9
  expect(job.streetno).to eq '1'
@@ -12,8 +13,9 @@ describe 'GLSAgent Module helpers' do
12
13
  end
13
14
 
14
15
  it 'creates ParcelJob from hash' do
15
- hash = {:name => 'Name', :street => 'Street', :streetno => '1', :zip => '1234', :city => 'City', :weight => '1'}
16
+ hash = {:date => '02.12.2012', :name => 'Name', :street => 'Street', :streetno => '1', :zip => '1234', :city => 'City', :weight => '1'}
16
17
  job = GLSAgent::job_from_hash hash
18
+ expect(job.date).to eq '02.12.2012'
17
19
  expect(job.name).to eq 'Name'
18
20
  expect(job.street).to eq 'Street'
19
21
  expect(job.streetno).to eq '1'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gls_agent
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Felix Wolfsteller
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-04-04 00:00:00.000000000 Z
11
+ date: 2014-04-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: mechanize
@@ -75,6 +75,7 @@ extensions: []
75
75
  extra_rdoc_files: []
76
76
  files:
77
77
  - .gitignore
78
+ - .rspec
78
79
  - .rvmrc
79
80
  - Gemfile
80
81
  - LICENSE.txt
@@ -86,6 +87,7 @@ files:
86
87
  - lib/gls_agent/dotfile.rb
87
88
  - lib/gls_agent/gls_mech.rb
88
89
  - lib/gls_agent/version.rb
90
+ - lib/ruby-gls-agent_0.0.1_all.deb
89
91
  - spec/gls_agent_spec.rb
90
92
  homepage: https://github.com/fwolfst/gls_agent
91
93
  licenses: