Class: ActiveScaffold::Assets::JqueryUiThemeGenerator

Inherits:
Object
  • Object
show all
Defined in:
lib/active_scaffold/assets/jquery_ui_theme_generator.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeJqueryUiThemeGenerator

Returns a new instance of JqueryUiThemeGenerator.



35
36
37
38
39
# File 'lib/active_scaffold/assets/jquery_ui_theme_generator.rb', line 35

def initialize
  @jquery_ui_spec = Gem.loaded_specs['jquery-ui-rails']
  @source_path = File.join(@jquery_ui_spec.full_gem_path, 'app/assets/stylesheets/jquery-ui/theme.css.erb')
  @theme_path = Rails.root.join('app/assets/stylesheets/active_scaffold/jquery-ui/theme.css')
end

Class Method Details

.generate!(force: false) ⇒ Object



14
15
16
17
18
19
# File 'lib/active_scaffold/assets/jquery_ui_theme_generator.rb', line 14

def generate!(force: false)
  return unless jquery_ui_installed?

  generator = new
  generator.generate!(force: force)
end

.generate_if_neededObject



7
8
9
10
11
12
# File 'lib/active_scaffold/assets/jquery_ui_theme_generator.rb', line 7

def generate_if_needed
  return unless jquery_ui_installed?

  generator = new
  generator.generate_if_needed
end

.needs_generation?Boolean

Returns:

  • (Boolean)


21
22
23
24
25
26
# File 'lib/active_scaffold/assets/jquery_ui_theme_generator.rb', line 21

def needs_generation?
  return false unless jquery_ui_installed?

  generator = new
  generator.needs_generation?
end

Instance Method Details

#generate!(force: false) ⇒ Object



47
48
49
50
51
52
53
54
55
56
57
# File 'lib/active_scaffold/assets/jquery_ui_theme_generator.rb', line 47

def generate!(force: false)
  return unless source_exists?

  if force || needs_generation?
    Rails.logger.info 'ActiveScaffold: Generating jQuery UI theme...'
    perform_generation
    true
  else
    false
  end
end

#generate_if_neededObject



41
42
43
44
45
# File 'lib/active_scaffold/assets/jquery_ui_theme_generator.rb', line 41

def generate_if_needed
  return unless source_exists?

  generate! if needs_generation?
end

#needs_generation?Boolean

Returns:

  • (Boolean)


59
60
61
62
63
64
# File 'lib/active_scaffold/assets/jquery_ui_theme_generator.rb', line 59

def needs_generation?
  return true unless File.exist?(@theme_path)
  return true if source_newer_than_generated?

  false
end

#source_exists?Boolean

Returns:

  • (Boolean)


66
67
68
# File 'lib/active_scaffold/assets/jquery_ui_theme_generator.rb', line 66

def source_exists?
  File.exist?(@source_path)
end