copy_paste_pdf 0.0.1 → 0.0.2

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: 136b95ea0d8543294bce8905905ae9f638d34367
4
- data.tar.gz: c5f220fe4fcf77b4fedf3d6fc5e186487b492ef8
3
+ metadata.gz: 52f0830d2a7adfa5a108b6a2e73b47e9c384bc22
4
+ data.tar.gz: 7be6080ee75fc74faf820475c97b2718a9c9a494
5
5
  SHA512:
6
- metadata.gz: 2522bdfe9adf4f87114d73d3b0d8ca11576fd517af6c1459c286ed22340ca6225aee4320a84e4a9513ad18f98d56117a48f9e1ffd8130260b0c05fb0130c233b
7
- data.tar.gz: 91686dc0fdcc83700e5d4e72500fa2667ec212880176eb82587111bfa8c3bab7503c6476979b66130271f120e6604354c05a050feec0e8f76ef2079dff2cba86
6
+ metadata.gz: b639499bf827557c0f2c586dc27bd19bb6b2a1609b206060f650051252cb29d2fb73562a808f01317c21f9d53ec552501491cf5fc951549851392b0dc202a46d
7
+ data.tar.gz: b34b0222c2e000921d8006a3adf33ca45406a01b6610fda1c95afe0b2353941a5fa7c4bfc2aeb96b9866801e6c959395af507d48b27dd2269571ebb5da6cbfa5
@@ -14,6 +14,7 @@ on run argv
14
14
  if count of argv is 2 then set close_applications to false
15
15
 
16
16
  tell application "Preview"
17
+ -- It seems Preview won't work if we `run` or `launch` it.
17
18
  activate
18
19
  open input
19
20
  end
@@ -51,7 +52,7 @@ on run argv
51
52
  end repeat
52
53
 
53
54
  tell application "Microsoft Excel"
54
- activate
55
+ launch
55
56
  make new workbook
56
57
  paste worksheet active sheet
57
58
  save workbook as active workbook filename output file format CSV file format overwrite yes
@@ -1 +1,9 @@
1
1
  require 'copy_paste_pdf/table'
2
+
3
+ module CopyPastePDF
4
+ class Error < StandardError; end
5
+ class CopyToNonEmptyCellError < Error; end
6
+ class MissingSourceError < Error; end
7
+ class InvalidRowError < Error; end
8
+ class MergeWithEmptyCellError < Error; end
9
+ end
@@ -13,9 +13,11 @@ module CopyPastePDF
13
13
  # @param [Array] indices the cell indices to copy
14
14
  # @yieldparam [Array] row a row in the table
15
15
  # @yieldreturn [Boolean] whether to skip the row from the table
16
- # @raise if a destination has no source
17
- # @raise if a destination cell has a value
18
- # @raise if a row is neither a source nor a destination
16
+ # @raise [CopyPastePDF::MissingSourceError] if a destination has no source
17
+ # @raise [CopyPastePDF::CopyToNonEmptyCellError] if a destination cell
18
+ # already has a value
19
+ # @raise [CopyPastePDF::InvalidRowError] if a row is neither a source nor a
20
+ # destination
19
21
  def copy_into_cell_below(*indices)
20
22
  source = nil
21
23
  each do |row|
@@ -28,16 +30,16 @@ module CopyPastePDF
28
30
  if source
29
31
  indices.each_with_index do |index,i|
30
32
  if row[index]
31
- raise "#{index} contains #{row[index]}"
33
+ raise CopyToNonEmptyCellError, "destination cell #{index} already has a value #{row[index]}"
32
34
  else
33
35
  row[index] = source[i]
34
36
  end
35
37
  end
36
38
  else
37
- raise "#{row} has no source"
39
+ raise MissingSourceError, "#{row} is a destination, but it has no source"
38
40
  end
39
41
  else
40
- raise "#{row} is neither a source nor a destination"
42
+ raise InvalidRowError, "#{row} is neither a source nor a destination"
41
43
  end
42
44
  end
43
45
  end
@@ -47,7 +49,7 @@ module CopyPastePDF
47
49
  # empty, into the corresponding cells of the prececeding line.
48
50
  #
49
51
  # @param [Array] indices the cell indices to merge
50
- # @raise if a destination cell is empty
52
+ # @raise [CopyPastePDF::MergeWithEmptyCellError] if a destination cell is empty
51
53
  def merge_into_cell_above(*indices)
52
54
  each_with_index.reverse_each do |row,i|
53
55
  if row.each_with_index.all?{|value,j| value.nil? || indices.include?(j)}
@@ -55,7 +57,7 @@ module CopyPastePDF
55
57
  if self[i - 1][index]
56
58
  self[i - 1][index] = "#{self[i - 1][index]}\n#{row[index]}"
57
59
  else
58
- raise "#{index} is empty"
60
+ raise MergeWithEmptyCellError, "cell #{index} is empty and can't be merged"
59
61
  end
60
62
  end
61
63
  delete_at(i)
@@ -1,3 +1,3 @@
1
1
  module CopyPastePDF
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: copy_paste_pdf
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Open North
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-10-10 00:00:00.000000000 Z
11
+ date: 2013-10-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: coveralls