gdelugre / origami

Origami is a pure Ruby library to parse, modify and generate PDF documents.
GNU Lesser General Public License v3.0
323 stars 109 forks source link

The include Origami in README #52

Closed kke closed 5 years ago

kke commented 5 years ago

There's this in the README:

require 'origami'
include Origami

It's unconventional and in my opinion only causes problems such as this one on stack overflow and #12

It even breaks for example Array, Date and others:

puts Array.new(4).inspect # => [nil, nil, nil, nil]
puts Date.new.friday? # => false

include Origami
puts Array.new(4).inspect # => Expected type Array, received Integer. (TypeError)
puts Date.new.friday? # => missing keyword: year (ArgumentError)

There's a huge number of constants it will bring:

require 'origami'

class FooFoo
  include Origami
end

puts FooFoo::VERSION
# "2.1.0"

puts FooFoo::OPTIONS.inspect
# {:enable_type_checking=>true, :enable_type_guessing=>true, :enable_type_propagation=>true, :ignore_bad_references=>false, :ignore_zlib_errors=>false, :ignore_png_errors=>false}

Full list of constants:

# FooFoo.constants.each(&method(:puts))
Resources
Outline
ObjectStream
URL
InvalidHexaStringObjectError
Dictionary
Integer
ExternalFile
String
Array
EmbeddedFileParameters
InvalidLiteralStringObjectError
InvalidDateError
Collection
OutputIntent
Reference
XRefToCompressedObject
Linearization
InvalidHintTableError
HintTable
XRef
InvalidXRefError
XFA
XDP
Stream
Font
Filter
Signature
Encryption
InvalidHintStreamObjectError
HintStream
XFAStream
PageLabel
FontStream
Encoding
FontDescriptor
InvalidXRefStreamObjectError
InteractiveForm
Metadata
Field
ContentStream
Annotation
Graphics
InvalidTrailerError
MetadataStream
WebCapture
Extensions
XRefStream
DeveloperExtension
OptionalContent
Obfuscator
InvalidArrayObjectError
Projection3D
CatalogAdditionalActions
Rectangle
Catalog
VERSION
PageLayout
InvalidStreamObjectError
FileSpec
Background3D
TypeConversion
EncryptionError
Real
Boolean
Null
LiteralString
FieldAccessor
StandardObject
RenderMode3D
PageMode
EncryptionInvalidPasswordError
EncryptionNotSupportedError
UsageRights
InvalidReferenceError
Perms
InvalidObjectError
UnterminatedObjectError
Text
WHITESPACES
WHITECHARS_NORET
EOL
WHITECHARS
REGEXP_WHITESPACES
Action
Requirement
ViewerPreferences
LightingScheme3D
Date
Parser
ExternalStream
InvalidObjectStreamObjectError
Error
CrossSection3D
OPTIONS
Node3D
Measurement3D
PageTreeNode
LinearDimensionMeasurement3D
FDF
PPKLite
HexaString
PDF
Function
InvalidPDFInstructionError
PerpendicularDimensionMeasurement3D
AngularDimensionMeasurement3D
NameLeaf
RadialMeasurement3D
CommentNote3D
InvalidPDFError
InvalidNullObjectError
View3D
REGULARCHARS
InvalidNameObjectError
InvalidDictionaryObjectError
Destination
AnimationStyle3D
U3DStream
Trailer
Object
Reference3D
Units3D
Page
OutlineItem
InvalidNameTreeError
NameTreeNode
DestinationDictionary
InvalidBooleanObjectError
Names
EmbeddedFileStream
NumberTreeNode
InvalidIntegerObjectError
Number
InvalidRealObjectError
InvalidPageTreeError
ResourcesHolder
Filename
Name

In conclusion: It's bad and does more harm than good.

gdelugre commented 5 years ago

Fair enough, I thought it would be okay for some simple examples but it will lead to namespace clashing if people uses it in real projects.

I have changed this.