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.7.28 helpers/url.rb
origen-0.7.27 helpers/url.rb
origen-0.7.26 helpers/url.rb
origen-0.7.25 helpers/url.rb
origen-0.7.24 helpers/url.rb
origen-0.7.23 helpers/url.rb
origen-0.7.22 helpers/url.rb
origen-0.7.21 helpers/url.rb
origen-0.7.20 helpers/url.rb
origen-0.7.19 helpers/url.rb
origen-0.7.18 helpers/url.rb
origen-0.7.17 helpers/url.rb
origen-0.7.16 helpers/url.rb
origen-0.7.15 helpers/url.rb
origen-0.7.14 helpers/url.rb