Module: Slds

Extended by:
Slds
Included in:
Slds
Defined in:
lib/slds.rb,
lib/slds/engine.rb,
lib/slds/version.rb,
app/controllers/slds/slds_controller.rb

Defined Under Namespace

Modules: Helper Classes: Engine, SldsController

Constant Summary collapse

VERSION =
'1.1.0'

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#debugObject

for logging in the controller for each request



11
12
13
# File 'lib/slds.rb', line 11

def debug
  @debug
end

#loggerObject

Returns the value of attribute logger.



8
9
10
# File 'lib/slds.rb', line 8

def logger
  @logger
end

#max_ageObject

Returns the value of attribute max_age.



9
10
11
# File 'lib/slds.rb', line 9

def max_age
  @max_age
end

#s_maxageObject

Returns the value of attribute s_maxage.



10
11
12
# File 'lib/slds.rb', line 10

def s_maxage
  @s_maxage
end

#urlObject

Returns the value of attribute url.



7
8
9
# File 'lib/slds.rb', line 7

def url
  @url
end

#versionObject

Returns the value of attribute version.



6
7
8
# File 'lib/slds.rb', line 6

def version
  @version
end

Instance Method Details

#assets_path(path, v = version) ⇒ Object

creates a relative path for the slds asset that uses the version and starts with /slds For example: Slds.assets_path(‘/icons/utility-sprite/svg/symbols.svg’)

creates this url => "/slds/2.2.1/icons/utility-sprite/svg/symbols.svg"

This path can be put in your app and the Slds controller (of this gem) will handle the path (because it starts with /slds) and make a reverse proxy Net::http call to the url.

The above url makes a http call to:

=> 'https://unpkg.com/@salesforce-ux/[email protected]/assets/icons/utility-sprite/svg/symbols.svg"


49
50
51
52
# File 'lib/slds.rb', line 49

def assets_path(path, v = version)
  validate_version(v)
  "/slds/#{v}/#{trim_path(path)}"
end

#assets_url(path, v = version) ⇒ Object

creates a absolute url that uses the url (unpkg.com) by prepending the url parameter. Note that /assets/ should not be part of your path. Slds.assets_url(‘styles/salesforce-lightning-design-system.min.css’)

=> 'https://unpkg.com/@salesforce-ux/[email protected]/assets/styles/salesforce-lightning-design-system.min.css'


35
36
37
38
# File 'lib/slds.rb', line 35

def assets_url(path, v = version)
  validate_version(v)
  url.gsub('VERSION', v) + trim_path(path)
end

#config(options = {}) ⇒ Object

Set the version and the url (dont mess with the url unless you know what you are doing) Usage: Slds.config { |slds| slds.version = ‘2.2.1’; slds.debug = true }



21
22
23
24
25
26
27
28
29
# File 'lib/slds.rb', line 21

def config(options = {})
  if options.present?
    options.each { |key, value| send("#{key}=", value) }
  else
    yield self
  end

  validate_version(version)
end