preflight 0.0.6 → 0.1.0

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.
data/CHANGELOG CHANGED
@@ -1,10 +1,9 @@
1
- v0.0.6 (25th April 2011)
2
- - more improvements to the MinPpi rule. Improves accuracy
3
- in some situtations
1
+ v0.1.0 (4th July 2011)
2
+ - Added support for loading new rules into a profile instance
3
+ - Fix typo in measurement conversion code
4
4
 
5
- v0.0.5 (25th April 2011)
6
- - bug: improve accuracy of MinPpi rule, it was incorrectly calculating the
7
- ppi of many images
5
+ v0.0.6 (25th April 2011)
6
+ - Improved accuracy of MinPpi rule in some situations
8
7
 
9
8
  v0.0.4 (24th April 2011)
10
9
  - bug: fix occasional crash due to not dereferencing an object
@@ -15,7 +14,7 @@ v0.0.3 (7th April 2011)
15
14
  - added some additional rules to the pdfx1a profile
16
15
 
17
16
  v0.0.2 (1st April 2011)
18
- * fix possible execption in MinPpi rule
17
+ * fix possible exception in MinPpi rule
19
18
 
20
19
  v0.0.1 (27th March 2011)
21
20
  * initial release
@@ -19,7 +19,9 @@ and friends, but hopefully it'll get you most of the way with less stress.
19
19
 
20
20
  == Usage
21
21
 
22
- == Standard Profile ( PDF/X-1a )
22
+ === Standard Profile ( PDF/X-1a )
23
+
24
+ To test a PDF file against a well known standard and rule set.
23
25
 
24
26
  require "preflight"
25
27
 
@@ -31,7 +33,9 @@ and friends, but hopefully it'll get you most of the way with less stress.
31
33
  puts preflight.check(file).inspect
32
34
  end
33
35
 
34
- == Custom Profile
36
+ === Custom Profile
37
+
38
+ Create a custom set of rules to check against.
35
39
 
36
40
  require "preflight"
37
41
 
@@ -49,7 +53,9 @@ and friends, but hopefully it'll get you most of the way with less stress.
49
53
 
50
54
  puts preflight.check("somefile.pdf").inspect
51
55
 
52
- == Extend A Profile
56
+ === Extend A Profile
57
+
58
+ Use an existing rule set as the base for a larger set of rules.
53
59
 
54
60
  require "preflight"
55
61
 
@@ -69,11 +75,24 @@ and friends, but hopefully it'll get you most of the way with less stress.
69
75
 
70
76
  puts preflight.check("somefile.pdf").inspect
71
77
 
78
+ === Adding Rules to a Profile Instance
79
+
80
+ Use an existing rule set as the base for a larger set of rules by adding
81
+ rules to a profile instance. Useful when the required set of rules depends
82
+ dynamic conditions.
83
+
84
+ require "preflight"
85
+
86
+ preflight = Preflight::Profiles::PDFX1A.new
87
+ prefight.rule Preflight::Rules::MaxVersion, 1.4
88
+
89
+ puts preflight.check("somefile.pdf").inspect
90
+
72
91
  == Status
73
92
 
74
93
  This library is in an early stage of development. Use at your own risk.
75
94
 
76
- == Compatability
95
+ == Compatibility
77
96
 
78
97
  This is pure ruby should run on most ruby VMs. I develop on MRI 1.9.2.
79
98
 
@@ -17,7 +17,7 @@ module Preflight
17
17
  # convert mm to standard PDF points
18
18
  #
19
19
  def mm2pt(mm)
20
- return mm * (BigDecimal.new("72") / BigDecimal.new("24.4"))
20
+ return mm * (BigDecimal.new("72") / BigDecimal.new("25.4"))
21
21
  end
22
22
 
23
23
  # convert mm to standard PDF points
@@ -45,6 +45,10 @@ module Preflight
45
45
  end
46
46
  end
47
47
 
48
+ def rule(*args)
49
+ instance_rules << args.flatten
50
+ end
51
+
48
52
  private
49
53
 
50
54
  def check_filename(filename)
@@ -57,6 +61,14 @@ module Preflight
57
61
  check_receivers(io) + check_hash(io)
58
62
  end
59
63
 
64
+ def instance_rules
65
+ @instance_rules ||= []
66
+ end
67
+
68
+ def all_rules
69
+ self.class.rules + instance_rules
70
+ end
71
+
60
72
  # TODO: this is nasty, we parse the full file once for each receiver.
61
73
  # PDF::Reader needs to be updated to support multiple receivers
62
74
  #
@@ -80,7 +92,7 @@ module Preflight
80
92
  end
81
93
 
82
94
  def hash_rules
83
- self.class.rules.select { |arr|
95
+ all_rules.select { |arr|
84
96
  meth = arr.first.instance_method(:messages)
85
97
  meth && meth.arity == 1
86
98
  }.map { |arr|
@@ -90,7 +102,7 @@ module Preflight
90
102
  end
91
103
 
92
104
  def receiver_rules
93
- self.class.rules.select { |arr|
105
+ all_rules.select { |arr|
94
106
  meth = arr.first.instance_method(:messages)
95
107
  meth && meth.arity == 0
96
108
  }.map { |arr|
metadata CHANGED
@@ -4,9 +4,9 @@ version: !ruby/object:Gem::Version
4
4
  prerelease: false
5
5
  segments:
6
6
  - 0
7
+ - 1
7
8
  - 0
8
- - 6
9
- version: 0.0.6
9
+ version: 0.1.0
10
10
  platform: ruby
11
11
  authors:
12
12
  - James Healy
@@ -14,7 +14,7 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2011-04-26 00:00:00 +10:00
17
+ date: 2011-07-05 00:00:00 +10:00
18
18
  default_executable:
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
@@ -23,12 +23,13 @@ dependencies:
23
23
  requirement: &id001 !ruby/object:Gem::Requirement
24
24
  none: false
25
25
  requirements:
26
- - - ">="
26
+ - - ~>
27
27
  - !ruby/object:Gem::Version
28
28
  segments:
29
29
  - 0
30
30
  - 9
31
- version: "0.9"
31
+ - 1
32
+ version: 0.9.1
32
33
  type: :runtime
33
34
  version_requirements: *id001
34
35
  - !ruby/object:Gem::Dependency