Module: Configuration
- Extended by:
- Configuration
- Included in:
- Configuration
- Defined in:
- lib/easycomments/ec_configuration.rb
Constant Summary collapse
- CONFIG =
configuration constants holding user options from _config.yml
YAML.load_file('_config.yml')
- CONNECTION =
check_env_var(CONFIG["connection"])
- APPROVE_BY_DEFAULT =
- ALLOW_ANONYMOUS_POST =
- TIMESTAMP_FORMAT =
- USERNAME =
- PASSWORD =
- ALLOW_CORS =
- CORS_ORIGIN =
- AUTO_ESCAPE_HTML =
- PAGINATE =
- COMMENTS_PER_PAGE =
CONFIG["comments_per_page"].to_i
Instance Method Summary collapse
-
#check_env_var(var) ⇒ Object
allows enviroment variables to be used as a connection option.
-
#comment_wall ⇒ Object
wall of help text to be added in _config.yml.
Instance Method Details
#check_env_var(var) ⇒ Object
allows enviroment variables to be used as a connection option
8 9 10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/easycomments/ec_configuration.rb', line 8 def check_env_var(var) if var =~ /ENV\[(.*)/ || var !~ /(:+)|(\/+)/ env_var = var.sub("ENV[", "").sub("]","") var_seq = [] env_var.split(//).each do |char| if char =~ /[0-9a-zA-Z]/ var_seq.push(char) end end var = ENV[var_seq.join] end var end |
#comment_wall ⇒ Object
wall of help text to be added in _config.yml
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 |
# File 'lib/easycomments/ec_configuration.rb', line 37 def comment_wall comments = <<-COMMENTS # ##connection : database connection url to be passed to sequel's connect method. ##check http://sequel.jeremyevans.net/rdoc/files/doc/opening_databases_rdoc.html ##all adapters supported by sequel can be used ##you can also use an enviroment variable formatted as ENV["variable"] or just "variable" holding your db's url # ##approve_by_default : set to true to allow all coments to be posted without moderation. # ##allow_anonymous_post : set to true to allow comments without a name. # ##timestamp_format : datetime format to be passed to strftime. ##see availabe options here http://ruby-doc.org/core-2.2.1/Time.html#method-i-strftime # ##allow_cors : set to true to enable cross-origin resource sharing. # ##cors_origin : see available formats here https://github.com/cyu/rack-cors # ##auto_escape_html : automatically escape html in comment bodies # ##paginate : set to true to have pagination support in comment retrieval # ##comments_per_page : how many comments to return per page if paginate is true # ##users : do not edit this by hand use 'rake adduser' instead. # ##if you edit this file after 'rake init' use 'rake update' for the changes to take effect. # COMMENTS end |