Sha256: 60f8ff9656f9a1b1ae1261489f99e7c0106a78b67ffdd72ec1dbec9640d60d41

Contents?: true

Size: 1.96 KB

Versions: 95

Compression:

Stored size: 1.96 KB

Contents

module Origen
  class Generator
    class Compiler # :nodoc: all
      # Helper methods that are available to all templates
      module Helpers

        def self.archive_name=(val)
          @archive_name = val
        end

        def self.archive_name
          @archive_name
        end

        def generate_hard_links?
          !!archive_name
        end

        def archive_name
          Origen::Generator::Compiler::Helpers.archive_name
        end

        def current_path
          path(options[:top_level_file].to_s.sub(/^.*\/templates\/web/, '').sub(/\..*$/, ''))
        end

        def current_url
          "#{domain_minus_root_path}#{current_path}"
        end

        # Like current_url except always returns the latest version of the url and
        # not one with an embedded production version
        def current_latest_url
          current_url.sub(_archive, 'latest')
        end

        def path(p)
          p = "/#{p}" unless p =~ /^\//
          
          if Origen.development?
            "#{p}"   # dev mode used for local website generation
          # For Git deploy don't maintain versions
          elsif Origen.app.deployer.deploy_to_git?
            "#{root_path}#{p}"
          else          
            "#{root_path}/#{_archive}#{p}"
          end
        end

        def url(p)
          "#{domain_minus_root_path}#{path(p)}"
        end

        def domain
          Origen.config.web_domain
        end

        def domain_minus_root_path
          domain.sub /#{root_path}$/, ''
        end

        def _archive
          if generate_hard_links?
            archive_name.to_s.gsub(".", "_")
          else
            'latest'
          end
        end

        # Returns any path attached to the domain, for example will return "/jtag"
        # for "http://origen-sdk.org/jtag"
        def root_path # :nodoc:
          if domain =~ /\/\/[^\/]*(\/.*)/  # http://rubular.com/r/UY06Z6DXUS
            $1
          end
        end

      end
    end
  end
end

Version data entries

95 entries across 95 versions & 1 rubygems

Version Path
origen-0.37.0 helpers/url.rb
origen-0.36.1 helpers/url.rb
origen-0.36.0 helpers/url.rb
origen-0.35.1 helpers/url.rb
origen-0.35.0 helpers/url.rb
origen-0.34.3 helpers/url.rb
origen-0.34.2 helpers/url.rb
origen-0.34.1 helpers/url.rb
origen-0.34.0 helpers/url.rb
origen-0.33.3 helpers/url.rb
origen-0.33.2 helpers/url.rb
origen-0.33.1 helpers/url.rb
origen-0.33.0 helpers/url.rb
origen-0.32.1 helpers/url.rb
origen-0.32.0 helpers/url.rb
origen-0.31.0 helpers/url.rb
origen-0.30.0 helpers/url.rb
origen-0.29.0 helpers/url.rb
origen-0.28.2 helpers/url.rb
origen-0.28.1 helpers/url.rb