Class: Passbook::Config
- Inherits:
-
Object
- Object
- Passbook::Config
- Includes:
- Singleton
- Defined in:
- lib/passbook/config.rb
Instance Attribute Summary collapse
-
#enable_routes ⇒ Object
Returns the value of attribute enable_routes.
-
#pass_config ⇒ Object
Returns the value of attribute pass_config.
-
#preload_template ⇒ Object
Returns the value of attribute preload_template.
-
#wwdr_certificate ⇒ Object
Returns the value of attribute wwdr_certificate.
-
#wwdr_intermediate_certificate_path ⇒ Object
Returns the value of attribute wwdr_intermediate_certificate_path.
Instance Method Summary collapse
- #add_pkpass {|_self| ... } ⇒ Object
- #configure {|_self| ... } ⇒ Object
- #load_files(path) ⇒ Object
- #read_p12_certificates ⇒ Object
- #read_templates ⇒ Object
- #read_wwdr_certificate ⇒ Object
Instance Attribute Details
#enable_routes ⇒ Object
Returns the value of attribute enable_routes.
25 26 27 |
# File 'lib/passbook/config.rb', line 25 def enable_routes @enable_routes end |
#pass_config ⇒ Object
Returns the value of attribute pass_config.
25 26 27 |
# File 'lib/passbook/config.rb', line 25 def pass_config @pass_config end |
#preload_template ⇒ Object
Returns the value of attribute preload_template.
25 26 27 |
# File 'lib/passbook/config.rb', line 25 def preload_template @preload_template end |
#wwdr_certificate ⇒ Object
Returns the value of attribute wwdr_certificate.
25 26 27 |
# File 'lib/passbook/config.rb', line 25 def wwdr_certificate @wwdr_certificate end |
#wwdr_intermediate_certificate_path ⇒ Object
Returns the value of attribute wwdr_intermediate_certificate_path.
25 26 27 |
# File 'lib/passbook/config.rb', line 25 def wwdr_intermediate_certificate_path @wwdr_intermediate_certificate_path end |
Instance Method Details
#add_pkpass {|_self| ... } ⇒ Object
33 34 35 36 37 38 39 |
# File 'lib/passbook/config.rb', line 33 def add_pkpass self.pass_config = Hash.new unless self.pass_config yield self self.preload_template ||= ::Rails.env.production? if defined? ::Rails read_templates if self.preload_template read_p12_certificates end |
#configure {|_self| ... } ⇒ Object
27 28 29 30 31 |
# File 'lib/passbook/config.rb', line 27 def configure self.pass_config = Hash.new unless self.pass_config yield self read_wwdr_certificate end |
#load_files(path) ⇒ Object
49 50 51 52 53 54 55 56 57 58 |
# File 'lib/passbook/config.rb', line 49 def load_files path files = {} Dir.glob(path+"/**/**").each do |file_path| next if File.directory? file_path filename = Pathname.new(file_path).relative_path_from(Pathname.new(path)) file = File.open(file_path, "rb") files[filename.to_s] = File.read(file) end files end |
#read_p12_certificates ⇒ Object
61 62 63 64 65 66 67 |
# File 'lib/passbook/config.rb', line 61 def read_p12_certificates pass_config.each do |pass_type_id, config| raise(ArgumentError, "Please specify cert_path (certificate path) in your configuration (in initializer)") unless config['cert_path'] && !config['cert_path'].blank? raise(ArgumentError, "Please specify cert_password (certificate password) in your configuration (in initializer)") unless config['cert_password'] config['p12_certificate'] ||= OpenSSL::PKCS12::new(File.read(config['cert_path']), config['cert_password']) end end |
#read_templates ⇒ Object
42 43 44 45 46 47 |
# File 'lib/passbook/config.rb', line 42 def read_templates self.pass_config.each do |pass_type_id, config| raise(ArgumentError, "Please specify a template_path in your configuration (in initializer)") unless config['template_path'] config['files']||= load_files config['template_path'] end end |
#read_wwdr_certificate ⇒ Object
70 71 72 73 |
# File 'lib/passbook/config.rb', line 70 def read_wwdr_certificate # raise(ArgumentError, "Please specify the WWDR Intermediate certificate in your initializer") unless self.wwdr_intermediate_certificate_path self.wwdr_certificate||= OpenSSL::X509::Certificate.new(File.read(self.wwdr_intermediate_certificate_path)) end |