importeer_plan 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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 79ce0a1b7123048d843c95db51825345149ea6e9
4
- data.tar.gz: c59c7770eace830abcc8a437fc4cf6d447d9ad31
3
+ metadata.gz: 22f4b9e5d459365c156b711c0923cac15e5c0269
4
+ data.tar.gz: ad7866e0a4a85bbc2c8db4e65261be2f1c60aeaa
5
5
  SHA512:
6
- metadata.gz: f76e8c149c27688780be62d21e3cd08e2851abf7122b36d290342fbd334d5a7cf8571f71aad9027dbc1fd6d7da7068b503fc8134fe1a3bafd99cb360b2853218
7
- data.tar.gz: 07a71f2ba712f1616584ac8d9f0fc05b272a4449b76791e2e56d8bb76509f33ba7fb15e8ee595fd08e0d9cfab265b72af3afd55eccba65685787220eb3c0f734
6
+ metadata.gz: 3f1b2e15b31999ac5f50f21450f4b8f547920ba1a6dd555516c1bef91b6d62c2bf1dd565c6db0aade88e3263be738f9852797b14ccccd01b34362e27b81edc80
7
+ data.tar.gz: 2206f4bafae6bd4409858a04425f040bad1b69f98ac7fd42c2a3b89ce3caee46f0ce6bbf9adc5dd4ec078c08e7f8173635e5b6254731b7be5b3ad13090bc04a8
data/README.md CHANGED
@@ -32,7 +32,8 @@ My applications-classes for processing data from external files inherit from Imp
32
32
 
33
33
  * xls: ImporteerPlan::MyXls
34
34
  * csv: ImporteerPlan::MyCsv
35
- * txt: ImporteerPlan::MyTxt
35
+ * txt: ImporteerPlan::MyTxt (todo)
36
+
36
37
 
37
38
  ```ruby
38
39
  class ImporteerSomething < ImporteerPlan::MyXls
@@ -47,6 +48,15 @@ class ImporteerSomething < ImporteerPlan::MyXls
47
48
  end
48
49
  ```
49
50
 
51
+
52
+ ### methods
53
+
54
+ ##### importeer
55
+
56
+ * commaf(string) where string is a dutch amount, separated by ',' turning to a float
57
+
58
+ * pointf(string) where string is a dutch amount, separated by '.' turning to a float
59
+
50
60
  ## Test
51
61
  ImporteerPlan uses minitest.
52
62
  Run rake to start the test-suite.
data/changelog.md CHANGED
@@ -1,3 +1,8 @@
1
+ ###### 0.1.1
2
+ inherit from ImporteerPlan::MyCsv
3
+ added commaf to importeer
4
+ added pointf to importeer
5
+
1
6
  ###### 0.1.0
2
7
  version bump
3
8
 
@@ -13,8 +13,8 @@ Gem::Specification.new do |spec|
13
13
  # spec.metadata['allowed_push_host'] = "TODO: Set to 'http://mygemserver.com' to prevent pushes to rubygems.org, or delete to allow pushes to any server."
14
14
  # end
15
15
 
16
- spec.summary = %q{only purpose is provide some reusable defaults for importing and handling (.xls-)files }
17
- spec.description = %q{only purpose is provide some reusable defaults for importing and handling (.xls-)files }
16
+ spec.summary = %q{only purpose is provide some reusable defaults for processing my (.xls-, .csv-, .txt)files }
17
+ spec.description = %q{only purpose is provide some reusable defaults for processing my (.xls-, .csv-, .txt)files }
18
18
  spec.homepage = "http://www.l-plan.nl"
19
19
  spec.license = "MIT"
20
20
 
@@ -1,3 +1,3 @@
1
1
  module ImporteerPlan
2
- VERSION = "0.1.0"
2
+ VERSION = "0.1.1"
3
3
  end
@@ -1,8 +1,8 @@
1
- # require "importeer_plan/version"
1
+ require "importeer_plan/version"
2
2
 
3
3
  module ImporteerPlan
4
4
  class Importeer
5
- require 'spreadsheet'
5
+
6
6
 
7
7
  attr_accessor :path, :name, :dir, :size_batch
8
8
  #call importeer("filename") to import the file in batches of 1000, optional importeer("filename", size_)
@@ -26,9 +26,18 @@ module ImporteerPlan
26
26
  bron.each{|batch| importeer_batch batch}
27
27
  end
28
28
 
29
+ def commaf(str) # comma-float; "1,234"
30
+ ('%.2f' % str.gsub(',', '.') ).to_f
31
+ end
32
+
33
+ def pointf(str) # point-float; "1.234"
34
+ ('%.2f' % str.gsub(',', '.') ).to_f
35
+ end
36
+
29
37
  end
30
38
 
31
39
  class MyXls < Importeer
40
+ require 'spreadsheet'
32
41
  def initialize(*)
33
42
  super
34
43
  end
@@ -39,12 +48,14 @@ module ImporteerPlan
39
48
  end
40
49
 
41
50
  class MyCsv< Importeer
51
+ require 'csv'
42
52
  def initialize(*)
43
53
  super
54
+ @sep = ";"
44
55
  end
45
56
 
46
57
  def bron
47
- # Csv.open(@path).worksheet(0).to_a.tap{|x| x.shift}.each_slice(size_batch).each
58
+ CSV.read(path, { :col_sep => @sep , :encoding => "ISO-8859-1"}).tap{|x| x.shift}.each_slice(@size_batch)
48
59
  end
49
60
  end
50
61
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: importeer_plan
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - rolf
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-07-09 00:00:00.000000000 Z
11
+ date: 2015-07-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: spreadsheet
@@ -122,8 +122,8 @@ dependencies:
122
122
  - - "~>"
123
123
  - !ruby/object:Gem::Version
124
124
  version: '0'
125
- description: 'only purpose is provide some reusable defaults for importing and handling
126
- (.xls-)files '
125
+ description: 'only purpose is provide some reusable defaults for processing my (.xls-,
126
+ .csv-, .txt)files '
127
127
  email:
128
128
  - rolf@l-plan.nl
129
129
  executables: []
@@ -163,6 +163,6 @@ rubyforge_project:
163
163
  rubygems_version: 2.4.6
164
164
  signing_key:
165
165
  specification_version: 4
166
- summary: only purpose is provide some reusable defaults for importing and handling
167
- (.xls-)files
166
+ summary: only purpose is provide some reusable defaults for processing my (.xls-,
167
+ .csv-, .txt)files
168
168
  test_files: []