brand2csv 0.2.4 → 0.2.5

Sign up to get free protection for your applications and to get access to all the features.
File without changes
data/.gitignore CHANGED
@@ -1,4 +1,6 @@
1
1
  *~
2
2
  *#
3
+ .ruby-version
4
+ .bundle
3
5
  ausgabe.csv
4
6
  mechanize/
@@ -1,3 +1,7 @@
1
+ === 0.2.5 26.08.2013
2
+
3
+ * Add timespan validator
4
+
1
5
  === 0.2.4 06.06.2013
2
6
 
3
7
  * Rescue another exception
@@ -5,6 +5,7 @@ root = Pathname.new(__FILE__).realpath.parent.parent
5
5
  $:.unshift root.join('lib') if $0 == __FILE__
6
6
 
7
7
  require 'optparse'
8
+ require "date"
8
9
  require 'brand2csv'
9
10
 
10
11
  def help
@@ -22,32 +23,78 @@ Usage:
22
23
  EOS
23
24
  end
24
25
 
25
- parser = OptionParser.new
26
- opts = {}
27
- parser.on('--swiss_only') {|v| opts[:swiss_only] = true }
28
- parser.on_tail('-h', '--help') { puts help; exit }
29
-
30
- args = ARGV.dup
31
- begin
32
- parser.parse!(args)
33
- rescue OptionParser::MissingArgument,
34
- OptionParser::InvalidArgument,
35
- OptionParser::InvalidOption
36
- puts help
37
- exit 1
26
+ def validates_timespan(arg)
27
+ valid = true
28
+ timespan = ""
29
+ dates = arg.gsub(/[^\d\.-]/, '').split("-")
30
+ catch (:error) do
31
+ dates.map.with_index do |d, i|
32
+ sep = (dates.length > 1 && i != 0) ? "-" : ""
33
+ begin
34
+ Date.parse(d)
35
+ timespan << sep + d
36
+ rescue ArgumentError
37
+ valid = false
38
+ elms = d.split(".")
39
+ prms = [elms[2], elms[1], -1].map(&:to_i)
40
+ begin
41
+ cand = Date.new(*prms).strftime("%d.%m.%Y")
42
+ if elms[0] == (elms - cand.to_s.split(".")).first
43
+ timespan << sep + cand.to_s
44
+ else
45
+ raise
46
+ end
47
+ rescue ArgumentError
48
+ timespan = "" # unknown
49
+ throw :error
50
+ end
51
+ end
52
+ end
53
+ end
54
+ message = nil
55
+ unless valid
56
+ if timespan.empty?
57
+ message = "Timespan is invalid"
58
+ else
59
+ message = "Did you mean #{timespan} ?"
60
+ end
61
+ end
62
+ [valid, message]
38
63
  end
39
64
 
65
+ if $0 == __FILE__
66
+ parser = OptionParser.new
67
+ opts = {}
68
+ parser.on('--swiss_only') {|v| opts[:swiss_only] = true }
69
+ parser.on_tail('-h', '--help') { puts help; exit }
40
70
 
41
- unless args.size >= 1
42
- puts help
43
- exit 1
44
- end
71
+ args = ARGV.dup
72
+ begin
73
+ parser.parse!(args)
74
+ rescue OptionParser::MissingArgument,
75
+ OptionParser::InvalidArgument,
76
+ OptionParser::InvalidOption
77
+ puts help
78
+ exit 1
79
+ end
45
80
 
46
- begin
47
- Brand2csv::run(args[0], args[1], opts[:swiss_only])
48
- rescue Interrupt
49
- puts "Unterbrochen. Breche mit Fehler ab"
50
- exit 1
51
- end
81
+ unless args.size >= 1
82
+ puts help
83
+ exit 1
84
+ end
85
+
86
+ valid,message = validates_timespan(args[0])
87
+ unless valid
88
+ puts message
89
+ exit 1
90
+ end
52
91
 
53
- puts "#{__FILE__} completed successfully" if $VERBOSE
92
+ begin
93
+ Brand2csv::run(args[0], args[1], opts[:swiss_only])
94
+ rescue Interrupt
95
+ puts "Unterbrochen. Breche mit Fehler ab"
96
+ exit 1
97
+ end
98
+
99
+ puts "#{__FILE__} completed successfully" if $VERBOSE
100
+ end
@@ -1,3 +1,3 @@
1
1
  module Brand2csv
2
- VERSION = "0.2.4"
2
+ VERSION = "0.2.5"
3
3
  end
@@ -0,0 +1,25 @@
1
+ # encoding: utf-8
2
+ $:.unshift File.join(File.dirname(__FILE__), '..', 'lib')
3
+ $:.unshift File.dirname(__FILE__)
4
+
5
+ require 'bundler/setup'
6
+ Bundler.require
7
+
8
+ require 'rspec'
9
+ require 'brand2csv'
10
+
11
+ Dir[File.join(File.dirname(__FILE__), "spec/support/**/*.rb")].each { |f| require f }
12
+
13
+ RSpec.configure do |config|
14
+ config.treat_symbols_as_metadata_keys_with_true_values = true
15
+ config.run_all_when_everything_filtered = true
16
+ config.filter_run :focus
17
+ config.filter_run_excluding :slow
18
+ #config.exclusion_filter = {:slow => true}
19
+
20
+ # Run specs in random order to surface order dependencies. If you find an
21
+ # order dependency and want to debug it, you can fix the order by providing
22
+ # the seed, which is printed after each run.
23
+ # --seed 1234
24
+ config.order = 'random'
25
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: brand2csv
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.4
4
+ version: 0.2.5
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-06-06 00:00:00.000000000 Z
12
+ date: 2013-08-26 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: mechanize
@@ -28,23 +28,23 @@ dependencies:
28
28
  - !ruby/object:Gem::Version
29
29
  version: '2.6'
30
30
  - !ruby/object:Gem::Dependency
31
- name: rdoc
31
+ name: rspec
32
32
  requirement: !ruby/object:Gem::Requirement
33
33
  none: false
34
34
  requirements:
35
- - - ~>
35
+ - - ! '>='
36
36
  - !ruby/object:Gem::Version
37
- version: '4.0'
37
+ version: '0'
38
38
  type: :development
39
39
  prerelease: false
40
40
  version_requirements: !ruby/object:Gem::Requirement
41
41
  none: false
42
42
  requirements:
43
- - - ~>
43
+ - - ! '>='
44
44
  - !ruby/object:Gem::Version
45
- version: '4.0'
45
+ version: '0'
46
46
  - !ruby/object:Gem::Dependency
47
- name: rspec
47
+ name: webmock
48
48
  requirement: !ruby/object:Gem::Requirement
49
49
  none: false
50
50
  requirements:
@@ -60,7 +60,23 @@ dependencies:
60
60
  - !ruby/object:Gem::Version
61
61
  version: '0'
62
62
  - !ruby/object:Gem::Dependency
63
- name: webmock
63
+ name: hoe
64
+ requirement: !ruby/object:Gem::Requirement
65
+ none: false
66
+ requirements:
67
+ - - ! '>='
68
+ - !ruby/object:Gem::Version
69
+ version: '3.4'
70
+ type: :development
71
+ prerelease: false
72
+ version_requirements: !ruby/object:Gem::Requirement
73
+ none: false
74
+ requirements:
75
+ - - ! '>='
76
+ - !ruby/object:Gem::Version
77
+ version: '3.4'
78
+ - !ruby/object:Gem::Dependency
79
+ name: rdoc
64
80
  requirement: !ruby/object:Gem::Requirement
65
81
  none: false
66
82
  requirements:
@@ -75,22 +91,38 @@ dependencies:
75
91
  - - ! '>='
76
92
  - !ruby/object:Gem::Version
77
93
  version: '0'
94
+ - !ruby/object:Gem::Dependency
95
+ name: rdoc
96
+ requirement: !ruby/object:Gem::Requirement
97
+ none: false
98
+ requirements:
99
+ - - ~>
100
+ - !ruby/object:Gem::Version
101
+ version: '3.10'
102
+ type: :development
103
+ prerelease: false
104
+ version_requirements: !ruby/object:Gem::Requirement
105
+ none: false
106
+ requirements:
107
+ - - ~>
108
+ - !ruby/object:Gem::Version
109
+ version: '3.10'
78
110
  - !ruby/object:Gem::Dependency
79
111
  name: hoe
80
112
  requirement: !ruby/object:Gem::Requirement
81
113
  none: false
82
114
  requirements:
83
- - - ! '>='
115
+ - - ~>
84
116
  - !ruby/object:Gem::Version
85
- version: '3.4'
117
+ version: '2.13'
86
118
  type: :development
87
119
  prerelease: false
88
120
  version_requirements: !ruby/object:Gem::Requirement
89
121
  none: false
90
122
  requirements:
91
- - - ! '>='
123
+ - - ~>
92
124
  - !ruby/object:Gem::Version
93
- version: '3.4'
125
+ version: '2.13'
94
126
  description: ! "brand2csv creates csv files for swiss brand registered in a specific
95
127
  time period. \n The csv contains the brand, link to image (if present), link to
96
128
  the detailinfo at swissreg.ch, name and address of owner (Inhaber)"
@@ -102,7 +134,6 @@ extra_rdoc_files:
102
134
  - History.txt
103
135
  - LICENCE.txt
104
136
  - Manifest.txt
105
- - README.md
106
137
  files:
107
138
  - .gitignore
108
139
  - .rspec
@@ -148,12 +179,13 @@ files:
148
179
  - spike_mechanize_swissreg.rb
149
180
  - spike_watir.rb
150
181
  - swissreg.rb
151
- homepage: https://github.com/zdavatz/brand2csv
182
+ - .gemtest
183
+ homepage:
152
184
  licenses: []
153
185
  post_install_message:
154
186
  rdoc_options:
155
187
  - --main
156
- - README.md
188
+ - README.txt
157
189
  require_paths:
158
190
  - lib
159
191
  required_ruby_version: !ruby/object:Gem::Requirement
@@ -170,7 +202,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
170
202
  version: '0'
171
203
  requirements: []
172
204
  rubyforge_project: brand2csv
173
- rubygems_version: 1.8.23
205
+ rubygems_version: 1.8.25
174
206
  signing_key:
175
207
  specification_version: 3
176
208
  summary: brand2csv creates csv files for swiss brands.