Browse Source

Issue #100: Minor fixes to the nice /Users/lakshmivyas/.environments/hyde/bin:/usr/local/bin:/usr/local/sbin:/usr/local/share/python:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/X11/bin based exec discovery by @nud

main
Lakshmi Vyasarajan 13 years ago
parent
commit
b39464ac63
7 changed files with 26 additions and 38 deletions
  1. +1
    -2
      CHANGELOG.rst
  2. +4
    -2
      hyde/ext/plugins/less.py
  3. +4
    -2
      hyde/ext/plugins/uglify.py
  4. +14
    -6
      hyde/plugin.py
  5. +0
    -4
      hyde/tests/ext/test_less.py
  6. +2
    -21
      hyde/tests/ext/test_uglify.py
  7. +1
    -1
      hyde/util.py

+ 1
- 2
CHANGELOG.rst View File

@@ -3,8 +3,7 @@ Version 0.8.4c16

Thanks to @nud

* Bug Fix: Fix class name of `test_stylus` (Issue #97)

* Bug Fix: Fix class name of `test_stylus` (Issue #97)

Version 0.8.4c15
============================================================


+ 4
- 2
hyde/ext/plugins/less.py View File

@@ -15,11 +15,13 @@ class LessCSSPlugin(CLTransformer):
The plugin class for less css
"""

default_app_path = "lessc"

def __init__(self, site):
super(LessCSSPlugin, self).__init__(site)

@property
def executable_name(self):
return "lessc"

def begin_site(self):
"""
Find all the less css files and set their relative deploy path.


+ 4
- 2
hyde/ext/plugins/uglify.py View File

@@ -11,11 +11,13 @@ class UglifyPlugin(CLTransformer):
The plugin class for Uglify JS
"""

default_app_path = "uglifyjs"

def __init__(self, site):
super(UglifyPlugin, self).__init__(site)

@property
def executable_name(self):
return "uglifyjs"

@property
def plugin_name(self):
"""


+ 14
- 6
hyde/plugin.py View File

@@ -18,7 +18,6 @@ import re
import subprocess
import traceback


logger = getLoggerWithNullHandler('hyde.engine')

class PluginProxy(object):
@@ -207,6 +206,8 @@ class CLTransformer(Plugin):
def plugin_name(self):
"""
The name of the plugin. Makes an intelligent guess.

This is used to lookup the settings for the plugin.
"""

return self.__class__.__name__.replace('Plugin', '').lower()
@@ -221,10 +222,11 @@ class CLTransformer(Plugin):
return {}

@property
def default_app_path(self):
def executable_name(self):
"""
Default command line application path. Can be overridden
by specifying it in config.
The executable name for the plugin. This can be overridden in the
config. If a configuration option is not provided, this is used
to guess the complete path of the executable.
"""
return self.plugin_name

@@ -237,7 +239,10 @@ class CLTransformer(Plugin):

return ("%(name)s executable path not configured properly. "
"This plugin expects `%(name)s.app` to point "
"to the `%(name)s` executable." % {"name": self.plugin_name})
"to the full path of the `%(exec)s` executable." %
{
"name":self.plugin_name, "exec": self.executable_name
})

@property
def settings(self):
@@ -256,12 +261,15 @@ class CLTransformer(Plugin):
def app(self):
"""
Gets the application path from the site configuration.

If the path is not configured, attempts to guess the path
from the sytem path environment variable.
"""

try:
app_path = getattr(self.settings, 'app')
except AttributeError:
app_path = self.default_app_path
app_path = self.executable_name

# Honour the PATH environment variable.
if app_path is not None and not os.path.isabs(app_path):


+ 0
- 4
hyde/tests/ext/test_less.py View File

@@ -29,10 +29,6 @@ class TestLess(object):
def test_can_execute_less(self):
s = Site(TEST_SITE)
s.config.plugins = ['hyde.ext.plugins.less.LessCSSPlugin']
paths = ['/usr/local/share/npm/bin/lessc']
for path in paths:
if File(path).exists:
s.config.less = Expando(dict(app=path))
source = TEST_SITE.child('content/media/css/site.less')
target = File(Folder(s.config.deploy_root_path).child('media/css/site.css'))
gen = Generator(s)


+ 2
- 21
hyde/tests/ext/test_uglify.py View File

@@ -22,7 +22,7 @@ class TestUglify(object):
JS = TEST_SITE.child_folder('content/media/js')
JS.make()
UGLIFY_SOURCE.copy_contents_to(JS)

def tearDown(self):
TEST_SITE.delete()
@@ -31,10 +31,6 @@ class TestUglify(object):
s = Site(TEST_SITE)
s.config.plugins = ['hyde.ext.plugins.uglify.UglifyPlugin']
s.config.mode = "production"
paths = ['/usr/local/share/npm/bin/uglifyjs']
for path in paths:
if File(path).exists:
s.config.uglify = Expando(dict(app=path))
source = TEST_SITE.child('content/media/js/jquery.js')
target = File(Folder(s.config.deploy_root_path).child('media/js/jquery.js'))
gen = Generator(s)
@@ -49,14 +45,7 @@ class TestUglify(object):
s = Site(TEST_SITE)
s.config.plugins = ['hyde.ext.plugins.uglify.UglifyPlugin']
s.config.mode = "production"
paths = ['/usr/local/share/npm/bin/uglifyjs', '~/local/bin/uglifyjs',
'/usr/bin/uglifyjs', '~/bin/uglifyjs']
uglify = [path for path in paths if File(path).exists]
if not uglify:
assert False, "Cannot find the uglify executable"

uglify = uglify[0]
s.config.uglify = Expando(dict(app=uglify, args={"nc":""}))
s.config.uglify = Expando(dict(args={"nc":""}))
source = TEST_SITE.child('content/media/js/jquery.js')
target = File(Folder(s.config.deploy_root_path).child('media/js/jquery.js'))
gen = Generator(s)
@@ -72,14 +61,6 @@ class TestUglify(object):
s = Site(TEST_SITE)
s.config.plugins = ['hyde.ext.plugins.uglify.UglifyPlugin']
s.config.mode = "dev"
paths = ['/usr/local/share/npm/bin/uglifyjs', '~/local/bin/uglifyjs',
'/usr/bin/uglifyjs', '~/bin/uglifyjs']
uglify = [path for path in paths if File(path).exists]
if not uglify:
assert False, "Cannot find the uglify executable"

uglify = uglify[0]
s.config.uglify = Expando(dict(app=path))
source = TEST_SITE.child('content/media/js/jquery.js')
target = File(Folder(s.config.deploy_root_path).child('media/js/jquery.js'))
gen = Generator(s)


+ 1
- 1
hyde/util.py View File

@@ -133,4 +133,4 @@ def discover_executable(name):
full_name = os.path.join(path, name)
if os.path.exists(full_name):
return full_name
return None
return None

Loading…
Cancel
Save