copy_paste_pdf 0.0.1 → 0.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/bin/copy-paste-pdf.applescript +2 -1
- data/lib/copy_paste_pdf.rb +8 -0
- data/lib/copy_paste_pdf/table.rb +10 -8
- data/lib/copy_paste_pdf/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 52f0830d2a7adfa5a108b6a2e73b47e9c384bc22
|
4
|
+
data.tar.gz: 7be6080ee75fc74faf820475c97b2718a9c9a494
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
-
|
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
|
data/lib/copy_paste_pdf.rb
CHANGED
data/lib/copy_paste_pdf/table.rb
CHANGED
@@ -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
|
18
|
-
#
|
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}
|
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)
|
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.
|
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-
|
11
|
+
date: 2013-10-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: coveralls
|