File: core.rb

package info (click to toggle)
ruby-compass 1.0.3~dfsg-4
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 8,184 kB
  • ctags: 1,789
  • sloc: ruby: 12,904; makefile: 100; perl: 43; xml: 14; sh: 4
file content (82 lines) | stat: -rw-r--r-- 2,347 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
require "compass/core/version"

module Compass
  module Core
    class << self
      attr_accessor :module_deprecation_warning_issued
    end
    def base_directory(*subdirs)
      File.expand_path(File.join('/usr/share/compass/frameworks/compass', *subdirs))
    end
    def lib_directory(*subdirs)
      File.expand_path(File.join(File.dirname(__FILE__), "..", *subdirs))
    end

    module_function :base_directory, :lib_directory
  end

  module HasDeprecatedConstantsFromCore
    def self.extended(base)
      new_base = base.name.sub(/^Compass/,"Compass::Core")
      base.class_eval <<-RUBY
        def self.const_missing(const_name)
          puts "cannot find \#{const_name}"
          if #{new_base}.const_defined?(const_name)
            unless Compass::Core.module_deprecation_warning_issued
              Compass::Core.module_deprecation_warning_issued = true
              Compass::Util.compass_warn(
                "DEPRECATED: #{base.name}::\#{const_name} has been moved to " +
                "#{new_base}::\#{const_name}.\\n" +
                "Please update \#{caller[0]}")
            end
            #{new_base}.const_get(const_name)
          end
        end
      RUBY
    end
  end

  extend HasDeprecatedConstantsFromCore

  module SassExtensions
    extend HasDeprecatedConstantsFromCore

    module Functions
      extend HasDeprecatedConstantsFromCore
    end
  end

  def shared_extension_paths
    @shared_extension_paths ||= begin
      if ENV["HOME"] && File.directory?(ENV["HOME"])
        [File.join(ENV["HOME"], ".compass", "extensions")]
      else
        []
      end
    rescue ArgumentError # If HOME is relative
      []
    end
    if File.directory?('/usr/share/compass/frameworks')
      @shared_extension_paths +=
        [Dir.new('/usr/share/compass/frameworks')]
    end
  end
  module_function :shared_extension_paths
end

require "sass"
require "sass/plugin"
require 'compass/util'
require "compass/frameworks"
require "compass/core/caniuse"
require 'compass/core/sass_extensions'
require 'compass/error'
require 'compass/browser_support'
require 'compass/configuration'

Compass::Frameworks.register(
  "compass",
  :stylesheets_directory => Compass::Core.base_directory("stylesheets"),
  :templates_directory => Compass::Core.base_directory("templates"),
  :version => Compass::Core::VERSION
)