Commit eac083f3 authored by Andi Saurer's avatar Andi Saurer

add installer and config

parent 6e2697ec
module ShortMessage
module Generators
class InstallGenerator < Rails::Generators::Base
desc "Copy ShortMessage configuration files"
source_root File.expand_path('../templates', __FILE__)
def copy_config
template "config/initializers/short_message.rb"
template "config/locales/short_message.de.yml"
template "config/locales/short_message.en.yml"
end
end
end
end
ShortMessage.configure do |config|
# Configuration example www.gtx-messaging.com
config.gateway_server = "http.gtx-messaging.net"
config.gateway_port = 443
config.send_file_path = "smsc.php"
# config.account_functions_path = ""
# enter your details received from provider here
config.user = ""
config.password = ""
# config.default_reload_amount = 1000
config.default_mail_sender = "webmaster@your-domain.com"
config.reload_notification_email = "webmaster@your-domain.com" # send a message if payment is required
config.admin_notification_email = "webmaster@your-domain.com" # set nil to deactivate error mailing
config.voucher_notification_email = "give-me-money@your-domain.com" # set nil to disable voucher mailing
# set a default sms sender (used if no sender is present)
# config.default_sms_sender = ""
end
de:
short_message:
status:
code_1: "An Telefon zugestellt"
code_2: "Nicht an Telefon zugestellt"
code_4: "Bei SMSC in Warteschlange"
code_8: "Zugestellt an SMSC"
code_16: "Nicht zugestellt an SMSC"
en:
short_message:
status:
code_1: "Delivered to phone"
code_2: "Not delivered to phone"
code_4: "Queued on SMSC"
code_8: "Delivered to SMSC"
code_16: "Not delivered to SMSC"
require "short_message/engine"
require "short_message/config"
module ShortMessage
end
require 'active_support/configurable'
module ShortMessage
def self.configure(&block)
yield @config ||= ShortMessage::Configuration.new
end
def self.config
@config
end
class Configuration #:nodoc:
include ActiveSupport::Configurable
config_accessor :gateway_server
config_accessor :gateway_port
config_accessor :send_file_path
config_accessor :account_functions_path
config_accessor :user
config_accessor :password
config_accessor :default_sms_sender
config_accessor :default_reload_amount
config_accessor :reload_notification_email
config_accessor :admin_notification_email
config_accessor :voucher_notification_email
config_accessor :default_mail_sender
def param_name
config.param_name.respond_to?(:call) ? config.param_name.call : config.param_name
end
# define param_name writer
writer, line = 'def param_name=(value); config.param_name = value; end', __LINE__
singleton_class.class_eval writer, __FILE__, line
class_eval writer, __FILE__, line
end
end
module ShortMessage
class Engine < ::Rails::Engine
isolate_namespace ShortMessage
initializer "short_message.migrate_database" do |app|
Rails.application.config.paths['db/migrate'] << paths["db/migrate"].expanded.join
end
config.generators do |g|
g.test_framework false
g.assets false
g.helper false
end
end
end
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment