Class: Piwik::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/piwik/base.rb

Direct Known Subclasses

Site, User

Constant Summary collapse

@@template =
<<-EOF
# .piwik
# 
# Please fill in fields like this:
#
#  piwik_url: http://your.piwik.site
#  auth_token: secret
#
piwik_url: 
auth_token: 
EOF

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.config_fileObject



33
34
35
36
37
38
39
40
41
42
43
44
# File 'lib/piwik/base.rb', line 33

def self.config_file
  if defined?(Rails.root) && Rails.root!=nil
#     puts "config_file from Rails.root: #{Rails.root.to_s}"
    Rails.root.join('config', 'piwik.yml')
#   elsif defined?(RAILS_ROOT) && RAILS_ROOT!=nil
#     puts "config_file from RAILS_ROOT: #{RAILS_ROOT}"
#     File.join(RAILS_ROOT, 'config', 'piwik.yml')
  else
#     puts "config_file from ~/.piwik"
    File.join( ENV['HOME'] || ENV['USERPROFILE'] || ENV['HOMEPATH'] || ".", '.piwik' )
  end
end

.parse_json(json) ⇒ Object



46
47
48
# File 'lib/piwik/base.rb', line 46

def self.parse_json json
  JSON.parse json
end

Instance Method Details

#parse_json(json) ⇒ Object



50
51
52
# File 'lib/piwik/base.rb', line 50

def parse_json json 
  self.class.parse_json json
end