aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/acts_as_xapian/acts_as_xapian.rb58
-rw-r--r--lib/attachment_to_html/adapter.rb67
-rw-r--r--lib/attachment_to_html/adapters/could_not_convert.rb41
-rw-r--r--lib/attachment_to_html/adapters/google_docs_viewer.rb38
-rw-r--r--lib/attachment_to_html/adapters/pdf.rb50
-rw-r--r--lib/attachment_to_html/adapters/rtf.rb50
-rw-r--r--lib/attachment_to_html/adapters/text.rb41
-rw-r--r--lib/attachment_to_html/attachment_to_html.rb2
-rw-r--r--lib/configuration.rb2
-rw-r--r--lib/has_tag_string/has_tag_string.rb4
-rw-r--r--lib/health_checks/checks/days_ago_check.rb2
-rw-r--r--lib/health_checks/health_checkable.rb6
-rw-r--r--lib/health_checks/health_checks.rb2
-rw-r--r--lib/mail_handler/backends/mail_backend.rb4
-rw-r--r--lib/mail_handler/backends/mail_extensions.rb8
-rw-r--r--lib/mail_handler/mail_handler.rb2
-rw-r--r--lib/strip_attributes/test/test_helper.rb2
-rw-r--r--lib/world_foi_websites.rb6
18 files changed, 135 insertions, 250 deletions
diff --git a/lib/acts_as_xapian/acts_as_xapian.rb b/lib/acts_as_xapian/acts_as_xapian.rb
index 7076fc586..565212904 100644
--- a/lib/acts_as_xapian/acts_as_xapian.rb
+++ b/lib/acts_as_xapian/acts_as_xapian.rb
@@ -39,7 +39,7 @@ module ActsAsXapian
######################################################################
# Module level variables
# TODO: must be some kind of cattr_accessor that can do this better
- def ActsAsXapian.bindings_available
+ def self.bindings_available
$acts_as_xapian_bindings_available
end
class NoXapianRubyBindingsError < StandardError
@@ -58,40 +58,40 @@ module ActsAsXapian
$acts_as_xapian_class_var_init = true
end
- def ActsAsXapian.db
+ def self.db
@@db
end
- def ActsAsXapian.db_path=(db_path)
+ def self.db_path=(db_path)
@@db_path = db_path
end
- def ActsAsXapian.db_path
+ def self.db_path
@@db_path
end
- def ActsAsXapian.writable_db
+ def self.writable_db
@@writable_db
end
- def ActsAsXapian.stemmer
+ def self.stemmer
@@stemmer
end
- def ActsAsXapian.term_generator
+ def self.term_generator
@@term_generator
end
- def ActsAsXapian.enquire
+ def self.enquire
@@enquire
end
- def ActsAsXapian.query_parser
+ def self.query_parser
@@query_parser
end
- def ActsAsXapian.values_by_prefix
+ def self.values_by_prefix
@@values_by_prefix
end
- def ActsAsXapian.config
+ def self.config
@@config
end
######################################################################
# Initialisation
- def ActsAsXapian.init(classname = nil, options = nil)
+ def self.init(classname = nil, options = nil)
if not classname.nil?
# store class and options for use later, when we open the db in readable_init
@@init_values.push([classname,options])
@@ -99,7 +99,7 @@ module ActsAsXapian
end
# Reads the config file (if any) and sets up the path to the database we'll be using
- def ActsAsXapian.prepare_environment
+ def self.prepare_environment
return unless @@db_path.nil?
# barf if we can't figure out the environment
@@ -130,17 +130,17 @@ module ActsAsXapian
# Opens / reopens the db for reading
# TODO: we perhaps don't need to rebuild database and enquire and queryparser -
# but db.reopen wasn't enough by itself, so just do everything it's easier.
- def ActsAsXapian.readable_init
+ def self.readable_init
raise NoXapianRubyBindingsError.new("Xapian Ruby bindings not installed") unless ActsAsXapian.bindings_available
raise "acts_as_xapian hasn't been called in any models" if @@init_values.empty?
prepare_environment
# We need to reopen the database each time, so Xapian gets changes to it.
- # Calling reopen() does not always pick up changes for reasons that I can
+ # Calling reopen does not always pick up changes for reasons that I can
# only speculate about at the moment. (It is easy to reproduce this by
- # changing the code below to use reopen() rather than open() followed by
- # close(), and running rake spec.)
+ # changing the code below to use reopen rather than open followed by
+ # close, and running rake spec.)
if !@@db.nil?
@@db.close
end
@@ -157,7 +157,7 @@ module ActsAsXapian
end
# Make a new query parser
- def ActsAsXapian.init_query_parser
+ def self.init_query_parser
# for queries
@@query_parser = Xapian::QueryParser.new
@@query_parser.stemmer = @@stemmer
@@ -193,7 +193,7 @@ module ActsAsXapian
end
end
- def ActsAsXapian.init_values(values)
+ def self.init_values(values)
values.each do |method, index, prefix, value_type|
raise "Value index '#{index}' must be an Integer, is #{index.class}" unless index.is_a? Integer
if @@values_by_number.include?(index) && @@values_by_number[index] != prefix
@@ -225,7 +225,7 @@ module ActsAsXapian
end
end
- def ActsAsXapian.init_terms(terms)
+ def self.init_terms(terms)
terms.each do |method, term_code, prefix|
raise "Use a single capital letter for term code" if not term_code.match(/^[A-Z]$/)
raise "M and I are reserved for use as the model/id term" if term_code == "M" || term_code == "I"
@@ -244,7 +244,7 @@ module ActsAsXapian
end
end
- def ActsAsXapian.writable_init(suffix = "")
+ def self.writable_init(suffix = "")
raise NoXapianRubyBindingsError.new("Xapian Ruby bindings not installed") unless ActsAsXapian.bindings_available
raise "acts_as_xapian hasn't been called in any models" if @@init_values.empty?
@@ -260,7 +260,7 @@ module ActsAsXapian
# for indexing
@@writable_db = Xapian::WritableDatabase.new(full_path, Xapian::DB_CREATE_OR_OPEN)
@@enquire = Xapian::Enquire.new(@@writable_db)
- @@term_generator = Xapian::TermGenerator.new()
+ @@term_generator = Xapian::TermGenerator.new
@@term_generator.set_flags(Xapian::TermGenerator::FLAG_SPELLING, 0)
@@term_generator.database = @@writable_db
@@term_generator.stemmer = @@stemmer
@@ -336,7 +336,7 @@ module ActsAsXapian
delay *= 2
delay = MSET_MAX_DELAY if delay > MSET_MAX_DELAY
- ActsAsXapian.db.reopen()
+ ActsAsXapian.db.reopen
retry
else
raise
@@ -559,7 +559,7 @@ module ActsAsXapian
matches = ActsAsXapian.enquire.mset(0, 100, 100) # TODO: so this whole method will only work with 100 docs
# Get set of relevant terms for those documents
- selection = Xapian::RSet.new()
+ selection = Xapian::RSet.new
iter = matches._begin
while not iter.equals(matches._end)
selection.add_document(iter)
@@ -611,7 +611,7 @@ module ActsAsXapian
# flush your changes. Specifying flush will reduce performance, but make
# sure that each index update is definitely saved to disk before
# logging in the database that it has been.
- def ActsAsXapian.update_index(flush = false, verbose = false)
+ def self.update_index(flush = false, verbose = false)
# STDOUT.puts("start of ActsAsXapian.update_index") if verbose
# Before calling writable_init we have to make sure every model class has been initialized.
@@ -655,7 +655,7 @@ module ActsAsXapian
ActsAsXapian.writable_db.close
end
- def ActsAsXapian.run_job(job, flush, verbose)
+ def self.run_job(job, flush, verbose)
STDOUT.puts("ActsAsXapian.update_index #{job.action} #{job.model} #{job.model_id.to_s} #{Time.now.to_s}") if verbose
begin
@@ -682,7 +682,7 @@ module ActsAsXapian
job.destroy
end
- def ActsAsXapian._is_xapian_db(path)
+ def self._is_xapian_db(path)
is_db = File.exist?(File.join(path, "iamflint")) || File.exist?(File.join(path, "iamchert"))
return is_db
end
@@ -694,7 +694,7 @@ module ActsAsXapian
# happens (i.e. while the .new database is there) - any index update jobs
# are left in the database, and will run after the rebuild has finished.
- def ActsAsXapian.rebuild_index(model_classes, verbose = false, terms = true, values = true, texts = true, safe_rebuild = true)
+ def self.rebuild_index(model_classes, verbose = false, terms = true, values = true, texts = true, safe_rebuild = true)
#raise "when rebuilding all, please call as first and only thing done in process / task" if not ActsAsXapian.writable_db.nil?
prepare_environment
@@ -755,7 +755,7 @@ module ActsAsXapian
@@db_path = old_path
end
- def ActsAsXapian._rebuild_index_safely(model_classes, verbose, terms, values, texts)
+ def self._rebuild_index_safely(model_classes, verbose, terms, values, texts)
batch_size = 1000
for model_class in model_classes
model_class_count = model_class.count
diff --git a/lib/attachment_to_html/adapter.rb b/lib/attachment_to_html/adapter.rb
new file mode 100644
index 000000000..d8b9f41f7
--- /dev/null
+++ b/lib/attachment_to_html/adapter.rb
@@ -0,0 +1,67 @@
+module AttachmentToHTML
+ class Adapter
+ attr_reader :attachment
+
+ # Public: Initialize a converter
+ #
+ # attachment - the FoiAttachment to convert to HTML
+ # opts - a Hash of options (default: {}):
+ # No options currently accepted
+ def initialize(attachment, opts = {})
+ @attachment = attachment
+ end
+
+ # Public: The title to use in the <title> tag
+ #
+ # Returns a String
+ def title
+ @title ||= attachment.display_filename
+ end
+
+ # Public: The contents of the extracted html <body> tag
+ #
+ # Returns a String
+ def body
+ @body ||= parse_body
+ end
+
+ def parse_body
+ convert
+ end
+
+ # Public: Was the document conversion successful?
+ #
+ # Returns true
+ def success?
+ true
+ end
+
+ def has_content?
+ !body.gsub(/\s+/,"").gsub(/\<[^\>]*\>/, "").empty?
+ end
+
+ def contains_images?
+ !!body.match(/<img[^>]*>/mi)
+ end
+
+ def create_tempfile(text)
+ tempfile = if RUBY_VERSION.to_f >= 1.9
+ Tempfile.new('foiextract', '.', :encoding => text.encoding)
+ else
+ Tempfile.new('foiextract', '.')
+ end
+ tempfile.print(text)
+ tempfile.flush
+ tempfile
+ end
+
+ def cleanup_tempfile(tempfile)
+ tempfile.close
+ tempfile.delete
+ end
+
+ def attachment_body
+ @attachment_body ||= attachment.body
+ end
+ end
+end
diff --git a/lib/attachment_to_html/adapters/could_not_convert.rb b/lib/attachment_to_html/adapters/could_not_convert.rb
index f23583590..745a54114 100644
--- a/lib/attachment_to_html/adapters/could_not_convert.rb
+++ b/lib/attachment_to_html/adapters/could_not_convert.rb
@@ -1,50 +1,15 @@
# -*- encoding : utf-8 -*-
module AttachmentToHTML
module Adapters
- class CouldNotConvert
-
- attr_reader :attachment
-
- # Public: Initialize a PDF converter
- #
- # attachment - the FoiAttachment to convert to HTML
- # opts - a Hash of options (default: {}):
- # No options currently accepted
- def initialize(attachment, opts = {})
- @attachment = attachment
- end
-
- # Public: The title to use in the <title> tag
- #
- # Returns a String
- def title
- @title ||= attachment.display_filename
- end
-
- # Public: The contents of the extracted html <body> tag
- #
- # Returns a String
- def body
- @body ||= parse_body
- end
-
-
- # Public: Was the document conversion successful?
- # As this is a fallback option and not doing anything dynamic
- # we're assuming this is successful whatever the case
- #
- # Returns true
- def success?
- true
- end
-
+ # As this is a fallback option and not doing anything dynamic
+ # we're assuming this is successful whatever the case
+ class CouldNotConvert < Adapter
private
def parse_body
"<p>Sorry, we were unable to convert this file to HTML. " \
"Please use the download link at the top right.</p>"
end
-
end
end
end
diff --git a/lib/attachment_to_html/adapters/google_docs_viewer.rb b/lib/attachment_to_html/adapters/google_docs_viewer.rb
index 343a89791..0817d08fd 100644
--- a/lib/attachment_to_html/adapters/google_docs_viewer.rb
+++ b/lib/attachment_to_html/adapters/google_docs_viewer.rb
@@ -2,9 +2,13 @@
module AttachmentToHTML
module Adapters
# Renders the attachment in a Google Docs Viewer
- class GoogleDocsViewer
-
- attr_reader :attachment, :attachment_url
+ #
+ # We can't really tell whether the document conversion has been
+ # successful as such; We're assuming that given a correctly
+ # constructed iframe (which is tested) that Google will make this
+ # Just Work.
+ class GoogleDocsViewer < Adapter
+ attr_reader :attachment_url
# Public: Initialize a GoogleDocsViewer converter
#
@@ -13,35 +17,10 @@ module AttachmentToHTML
# :attachment_url - a String url to the attachment for
# Google to render (default: nil)
def initialize(attachment, opts = {})
- @attachment = attachment
+ super
@attachment_url = opts.fetch(:attachment_url, nil)
end
- # Public: The title to use in the <title> tag
- #
- # Returns a String
- def title
- @title ||= attachment.display_filename
- end
-
- # Public: The contents of the extracted html <body> tag
- #
- # Returns a String
- def body
- @body ||= parse_body
- end
-
- # Public: Was the document conversion successful?
- # We can't really tell whether the document conversion has been
- # successful as such; We're assuming that given a correctly
- # constructed iframe (which is tested) that Google will make this
- # Just Work.
- #
- # Returns true
- def success?
- true
- end
-
private
def parse_body
@@ -51,7 +30,6 @@ module AttachmentToHTML
def protocol
AlaveteliConfiguration.force_ssl ? 'https' : 'http'
end
-
end
end
end
diff --git a/lib/attachment_to_html/adapters/pdf.rb b/lib/attachment_to_html/adapters/pdf.rb
index f99bdc78b..afc8fbcb0 100644
--- a/lib/attachment_to_html/adapters/pdf.rb
+++ b/lib/attachment_to_html/adapters/pdf.rb
@@ -2,10 +2,10 @@
module AttachmentToHTML
module Adapters
# Convert application/pdf documents in to HTML
- class PDF
+ class PDF < Adapter
TOO_MANY_IMAGES = 51
- attr_reader :attachment, :tmpdir
+ attr_reader :tmpdir
# Public: Initialize a PDF converter
#
@@ -14,24 +14,10 @@ module AttachmentToHTML
# :tmpdir - String name of directory to store the
# converted document
def initialize(attachment, opts = {})
- @attachment = attachment
+ super
@tmpdir = opts.fetch(:tmpdir, ::Rails.root.join('tmp'))
end
- # Public: The title to use in the <title> tag
- #
- # Returns a String
- def title
- @title ||= attachment.display_filename
- end
-
- # Public: The contents of the extracted html <body> tag
- #
- # Returns a String
- def body
- @body ||= parse_body
- end
-
# Public: Was the document conversion successful?
#
# Returns a Boolean
@@ -48,14 +34,6 @@ module AttachmentToHTML
match ? match[1] : ''
end
- def has_content?
- !body.gsub(/\s+/,"").gsub(/\<[^\>]*\>/, "").empty?
- end
-
- def contains_images?
- body.match(/<img[^>]*>/mi) ? true : false
- end
-
# Works around https://bugs.freedesktop.org/show_bug.cgi?id=77932 in pdftohtml
def contains_too_many_images?
number_of_images_in_body >= TOO_MANY_IMAGES
@@ -82,28 +60,6 @@ module AttachmentToHTML
html
end
end
-
- def create_tempfile(text)
- tempfile = if RUBY_VERSION.to_f >= 1.9
- Tempfile.new('foiextract', '.',
- :encoding => text.encoding)
- else
- Tempfile.new('foiextract', '.')
- end
- tempfile.print(text)
- tempfile.flush
- tempfile
- end
-
- def cleanup_tempfile(tempfile)
- tempfile.close
- tempfile.delete
- end
-
- def attachment_body
- @attachment_body ||= attachment.body
- end
-
end
end
end
diff --git a/lib/attachment_to_html/adapters/rtf.rb b/lib/attachment_to_html/adapters/rtf.rb
index 90478d9ca..4a08bf618 100644
--- a/lib/attachment_to_html/adapters/rtf.rb
+++ b/lib/attachment_to_html/adapters/rtf.rb
@@ -2,9 +2,9 @@
module AttachmentToHTML
module Adapters
# Convert application/rtf documents in to HTML
- class RTF
+ class RTF < Adapter
- attr_reader :attachment, :tmpdir
+ attr_reader :tmpdir
# Public: Initialize a RTF converter
#
@@ -13,24 +13,10 @@ module AttachmentToHTML
# :tmpdir - String name of directory to store the
# converted document
def initialize(attachment, opts = {})
- @attachment = attachment
+ super
@tmpdir = opts.fetch(:tmpdir, ::Rails.root.join('tmp'))
end
- # Public: The title to use in the <title> tag
- #
- # Returns a String
- def title
- @title ||= attachment.display_filename
- end
-
- # Public: The contents of the extracted html <body> tag
- #
- # Returns a String
- def body
- @body ||= parse_body
- end
-
# Public: Was the document conversion successful?
#
# Returns a Boolean
@@ -45,14 +31,6 @@ module AttachmentToHTML
match ? match[1] : ''
end
- def has_content?
- !body.gsub(/\s+/,"").gsub(/\<[^\>]*\>/, "").empty?
- end
-
- def contains_images?
- body.match(/<img[^>]*>/mi) ? true : false
- end
-
def convert
# Get the attachment body outside of the chdir call as getting
# the body may require opening files too
@@ -83,28 +61,6 @@ module AttachmentToHTML
end
html
end
-
- def create_tempfile(text)
- tempfile = if RUBY_VERSION.to_f >= 1.9
- Tempfile.new('foiextract', '.',
- :encoding => text.encoding)
- else
- Tempfile.new('foiextract', '.')
- end
- tempfile.print(text)
- tempfile.flush
- tempfile
- end
-
- def cleanup_tempfile(tempfile)
- tempfile.close
- tempfile.delete
- end
-
- def attachment_body
- @attachment_body ||= attachment.body
- end
-
end
end
end
diff --git a/lib/attachment_to_html/adapters/text.rb b/lib/attachment_to_html/adapters/text.rb
index 7e22422e2..61e4e57a8 100644
--- a/lib/attachment_to_html/adapters/text.rb
+++ b/lib/attachment_to_html/adapters/text.rb
@@ -2,33 +2,7 @@
module AttachmentToHTML
module Adapters
# Convert text/plain documents in to HTML
- class Text
-
- attr_reader :attachment
-
- # Public: Initialize a Text converter
- #
- # attachment - the FoiAttachment to convert to HTML
- # opts - a Hash of options (default: {}):
- # No options currently accepted
- def initialize(attachment, opts = {})
- @attachment = attachment
- end
-
- # Public: The title to use in the <title> tag
- #
- # Returns a String
- def title
- @title ||= attachment.display_filename
- end
-
- # Public: The contents of the extracted html <body> tag
- #
- # Returns a String
- def body
- @body ||= parse_body
- end
-
+ class Text < Adapter
# Public: Was the document conversion successful?
#
# Returns a Boolean
@@ -44,19 +18,6 @@ module AttachmentToHTML
text = MySociety::Format.make_clickable(text)
text = text.gsub(/\n/, '<br>')
end
-
- def parse_body
- convert
- end
-
- def has_content?
- !body.gsub(/\s+/,"").gsub(/\<[^\>]*\>/, "").empty?
- end
-
- def contains_images?
- body.match(/<img[^>]*>/mi) ? true : false
- end
-
end
end
end
diff --git a/lib/attachment_to_html/attachment_to_html.rb b/lib/attachment_to_html/attachment_to_html.rb
index e95f67262..2e8d35ca9 100644
--- a/lib/attachment_to_html/attachment_to_html.rb
+++ b/lib/attachment_to_html/attachment_to_html.rb
@@ -1,6 +1,8 @@
# -*- encoding : utf-8 -*-
require 'view'
+require 'attachment_to_html/adapter'
+
Dir[File.dirname(__FILE__) + '/adapters/*.rb'].each do |file|
require file
end
diff --git a/lib/configuration.rb b/lib/configuration.rb
index 30c1286da..ab7d1a65c 100644
--- a/lib/configuration.rb
+++ b/lib/configuration.rb
@@ -92,7 +92,7 @@ module AlaveteliConfiguration
}
end
- def AlaveteliConfiguration.method_missing(name)
+ def self.method_missing(name)
key = name.to_s.upcase
if DEFAULTS.has_key?(key.to_sym)
MySociety::Config.get(key, DEFAULTS[key.to_sym])
diff --git a/lib/has_tag_string/has_tag_string.rb b/lib/has_tag_string/has_tag_string.rb
index a1af8c597..42d6c8898 100644
--- a/lib/has_tag_string/has_tag_string.rb
+++ b/lib/has_tag_string/has_tag_string.rb
@@ -32,7 +32,7 @@ module HasTagString
# Parses a text version of one single tag, such as "a:b" and returns
# the name and value, with nil for value if there isn't one.
- def HasTagStringTag.split_tag_into_name_value(tag)
+ def self.split_tag_into_name_value(tag)
sections = tag.split(/:/)
name = sections[0]
if sections[1]
@@ -152,7 +152,7 @@ module HasTagString
######################################################################
# Main entry point, add has_tag_string to your model.
module HasMethods
- def has_tag_string()
+ def has_tag_string
has_many :tags, :conditions => "model = '" + self.to_s + "'", :foreign_key => "model_id", :class_name => 'HasTagString::HasTagStringTag'
include InstanceMethods
diff --git a/lib/health_checks/checks/days_ago_check.rb b/lib/health_checks/checks/days_ago_check.rb
index 9e574fe95..3c1cb784f 100644
--- a/lib/health_checks/checks/days_ago_check.rb
+++ b/lib/health_checks/checks/days_ago_check.rb
@@ -20,7 +20,7 @@ module HealthChecks
"#{ super }: #{ subject.call }"
end
- def check
+ def ok?
subject.call >= days.days.ago
end
diff --git a/lib/health_checks/health_checkable.rb b/lib/health_checks/health_checkable.rb
index f71ca36ca..1e324c1c7 100644
--- a/lib/health_checks/health_checkable.rb
+++ b/lib/health_checks/health_checkable.rb
@@ -13,12 +13,8 @@ module HealthChecks
self.class.to_s
end
- def check
- raise NotImplementedError
- end
-
def ok?
- check ? true : false
+ raise NotImplementedError
end
def message
diff --git a/lib/health_checks/health_checks.rb b/lib/health_checks/health_checks.rb
index 54cb0d96b..6c98365fc 100644
--- a/lib/health_checks/health_checks.rb
+++ b/lib/health_checks/health_checks.rb
@@ -32,7 +32,7 @@ module HealthChecks
private
def assert_valid_check(check)
- check.respond_to?(:check)
+ check.respond_to?(:ok?)
end
end
diff --git a/lib/mail_handler/backends/mail_backend.rb b/lib/mail_handler/backends/mail_backend.rb
index 89fc24bb9..5a7e0ef65 100644
--- a/lib/mail_handler/backends/mail_backend.rb
+++ b/lib/mail_handler/backends/mail_backend.rb
@@ -36,7 +36,7 @@ module MailHandler
module Backends
module MailBackend
- def backend()
+ def backend
'Mail'
end
@@ -124,7 +124,7 @@ module MailHandler
envelope_to = mail['envelope-to'] ? [mail['envelope-to'].value.to_s] : []
((mail.to || []) +
(mail.cc || []) +
- (envelope_to || [])).uniq
+ (envelope_to || [])).compact.uniq
end
def empty_return_path?(mail)
diff --git a/lib/mail_handler/backends/mail_extensions.rb b/lib/mail_handler/backends/mail_extensions.rb
index 38997861c..b39e54d08 100644
--- a/lib/mail_handler/backends/mail_extensions.rb
+++ b/lib/mail_handler/backends/mail_extensions.rb
@@ -38,7 +38,7 @@ module Mail
# Can be removed when we no longer support Ruby 1.8
class Ruby18
- def Ruby18.b_value_decode(str)
+ def self.b_value_decode(str)
match = str.match(/\=\?(.+)?\?[Bb]\?(.+)?\?\=/m)
if match
encoding = match[1]
@@ -56,7 +56,7 @@ module Mail
str
end
- def Ruby18.q_value_decode(str)
+ def self.q_value_decode(str)
match = str.match(/\=\?(.+)?\?[Qq]\?(.+)?\?\=/m)
if match
encoding = match[1]
@@ -76,7 +76,7 @@ module Mail
private
- def Ruby18.fix_encoding(encoding)
+ def self.fix_encoding(encoding)
case encoding.upcase
when 'UTF8'
'UTF-8'
@@ -87,7 +87,7 @@ module Mail
end
class Ruby19
- def Ruby19.b_value_decode(str)
+ def self.b_value_decode(str)
match = str.match(/\=\?(.+)?\?[Bb]\?(.+)?\?\=/m)
if match
charset = match[1]
diff --git a/lib/mail_handler/mail_handler.rb b/lib/mail_handler/mail_handler.rb
index 0c60fd3f5..313869d16 100644
--- a/lib/mail_handler/mail_handler.rb
+++ b/lib/mail_handler/mail_handler.rb
@@ -134,7 +134,7 @@ module MailHandler
begin
zip_file = Zip::ZipFile.open(tempfile.path)
text += get_attachment_text_from_zip_file(zip_file)
- zip_file.close()
+ zip_file.close
rescue
$stderr.puts("Error processing zip file: #{$!.inspect}")
end
diff --git a/lib/strip_attributes/test/test_helper.rb b/lib/strip_attributes/test/test_helper.rb
index b69440715..6a4f6136a 100644
--- a/lib/strip_attributes/test/test_helper.rb
+++ b/lib/strip_attributes/test/test_helper.rb
@@ -10,7 +10,7 @@ require "#{PLUGIN_ROOT}/init"
class ActiveRecord::Base
alias_method :save, :valid?
- def self.columns()
+ def self.columns
@columns ||= []
end
diff --git a/lib/world_foi_websites.rb b/lib/world_foi_websites.rb
index b63d0860d..a1e705c82 100644
--- a/lib/world_foi_websites.rb
+++ b/lib/world_foi_websites.rb
@@ -78,7 +78,11 @@ class WorldFOIWebsites
{:name => "Слободен пристап",
:country_name => "Република Македонија",
:country_iso_code => "MK",
- :url => "http://www.slobodenpristap.mk/"}
+ :url => "http://www.slobodenpristap.mk/"},
+ {:name => "Imamo pravo znati",
+ :country_name => "Republika Hrvatska",
+ :country_iso_code => "HR",
+ :url => "http://imamopravoznati.org/"}
]
return world_foi_websites
end