Class: Juicer::Install::JSLintInstaller

Inherits:
Base
  • Object
show all
Defined in:
lib/juicer/install/jslint_installer.rb

Overview

Install and uninstall routines for the JSLint library by Douglas Crockford. Installation downloads the jslintfull.js and rhino.js files and stores them in the Juicer installation directory.

Direct Known Subclasses

JslintInstaller

Instance Attribute Summary collapse

Attributes inherited from Base

#install_dir

Instance Method Summary collapse

Methods inherited from Base

#bin_path, #dependencies, #dependency, #download, #installed?, #log, #name, #path

Constructor Details

#initialize(install_dir = Juicer.home) ⇒ JSLintInstaller

Returns a new instance of JSLintInstaller.



15
16
17
18
19
20
21
22
# File 'lib/juicer/install/jslint_installer.rb', line 15

def initialize(install_dir = Juicer.home)
  super(install_dir)
  @latest = "1.0"
  @website = "http://www.jslint.com/"
  @path = "lib/jslint"
  @name = "JsLint"
  dependency :rhino
end

Instance Attribute Details

#latestObject (readonly)

Returns the value of attribute latest.



13
14
15
# File 'lib/juicer/install/jslint_installer.rb', line 13

def latest
  @latest
end

Instance Method Details

#install(version = nil) ⇒ Object

Install JSLint. Downloads the two js files and stores them in the installation directory.



28
29
30
31
32
# File 'lib/juicer/install/jslint_installer.rb', line 28

def install(version = nil)
  version = super(version)
  filename = download(File.join(@website, "rhino/jslint.js"))
  FileUtils.copy(filename, File.join(@install_dir, path, "bin", "jslint-#{version}.js"))
end

#uninstall(version = nil) ⇒ Object

Uninstalls JSLint



37
38
39
40
41
# File 'lib/juicer/install/jslint_installer.rb', line 37

def uninstall(version = nil)
  super(version) do |dir, version|
    File.delete(File.join(dir, "bin", "jslint-#{version}.js"))
  end
end