public function setUp() { parent::setUp(); $config = new AssetConfig([]); $config->load(APP . 'config/integration.ini'); $this->factory = new Factory($config); }
/** * Get the injected config or build a config object from the CLI option. * * @return \MiniAsset\AssetConfig */ public function config() { if (!$this->config) { $config = new AssetConfig(); $config->load($this->cli->arguments->get('config')); $this->config = $config; } return $this->config; }
/** * Load a config file and its `.local` file if it exists. * * @param \MiniAsset\AssetConfig $config The config object to update. * @param string $path The config file to load. * @param string $prefix The prefix to use. * @return void */ protected function _load($config, $path, $prefix = '') { if (file_exists($path)) { $config->load($path, $prefix); } $localConfig = preg_replace('/(.*)\\.ini$/', '$1.local.ini', $path); if (file_exists($localConfig)) { $config->load($localConfig, $prefix); } }
public function __construct(Module $modules, Module\Loader $load) { $configs = new AssetConfig($this->configs); if (!($cache_path = config_item('cache_path'))) { $cache_path = FCPATH . 'asset/cache/'; config_item('cache_path', $cache_path); } $configs->cachePath('js', $cache_path . 'js'); $configs->cachePath('css', $cache_path . 'css'); foreach ($modules->getList('module') as $module) { $configs->set('js.paths', $module->path . 'asset/scripts/**'); $configs->set('css.paths', $module->path . 'asset/styles/**'); } $this->factory = new Factory($configs); }
public function setUp() { parent::setUp(); $configFile = APP . 'config/integration.ini'; $this->config = AssetConfig::buildFromIniFile($configFile); $this->middleware = new AssetMiddleware($this->config, sys_get_temp_dir() . DIRECTORY_SEPARATOR, '/assets/'); }
/** * Create a filter registry containing all the configured filters. * * @return \MiniAsset\Filter\FilterRegistry */ public function filterRegistry() { $filters = []; foreach ($this->config->allFilters() as $name) { $filters[$name] = $this->buildFilter($name, $this->config->filterConfig($name)); } return new FilterRegistry($filters); }
/** * Get the AssetCompress factory based on the config object. * * @return \AssetCompress\Factory */ protected function factory() { if (empty($this->factory)) { $this->config->theme($this->theme); $this->factory = new Factory($this->config); } return $this->factory; }
/** * Returns the build name for a requested asset * * @param \MiniAsset\AssetConfig $config The config object to use. * @param string $url The url to get an asset name from. * @return bool|string false if no build can be parsed from URL * with url path otherwise */ protected function getName($config, $url) { $parts = explode('.', $url); if (count($parts) < 2) { return false; } $path = $config->cachePath($parts[count($parts) - 1]); if (empty($path)) { return false; } $root = str_replace('\\', '/', WWW_ROOT); $path = str_replace('\\', '/', $path); $path = str_replace($root, '', $path); if (strpos($url, $path) !== 0) { return false; } return str_replace($path, '', $url); }
public function setUp() { parent::setUp(); $this->_testFiles = APP; $this->_themeConfig = $this->_testFiles . 'config' . DS . 'themed.ini'; $this->_pluginConfig = $this->_testFiles . 'config' . DS . 'plugins.ini'; $testFile = $this->_testFiles . 'config' . DS . 'integration.ini'; $this->config = AssetConfig::buildFromIniFile($testFile); $this->config->paths('js', null, array($this->_testFiles . 'js' . DS, $this->_testFiles . 'js' . DS . '*')); $this->config->paths('css', null, array($this->_testFiles . 'css' . DS, $this->_testFiles . 'css' . DS . '*')); }
public function setUp() { parent::setUp(); $cli = $this->getMock('League\\CLImate\\CLImate', ['usage', 'out', 'err']); $cli->expects($this->any())->method('out')->will($this->returnSelf()); $config = AssetConfig::buildFromIniFile(APP . 'config/integration.ini', ['WEBROOT' => TMP]); $this->task = new BuildTask($cli, $config); $this->cli = $cli; mkdir(TMP . 'cache_js'); mkdir(TMP . 'cache_css'); }
/** * clear the builds for a specific extension. * * @return void */ protected function _clearBuilds() { $themes = (array) $this->config->general('themes'); if ($themes) { $this->config->theme($themes[0]); } $assets = $this->factory->assetCollection(); if (count($assets) === 0) { $this->err('No build targets defined, skipping'); return; } $targets = array_map(function ($target) { return $target->name(); }, iterator_to_array($assets)); $this->_clearPath(CACHE . 'asset_compress' . DS, $themes, $targets); $this->_clearPath($this->config->cachePath('js'), $themes, $targets); $this->_clearPath($this->config->cachePath('css'), $themes, $targets); }
public function testWriter() { $config = AssetConfig::buildFromIniFile($this->integrationFile); $config->theme('Red'); $config->set('js.timestamp', true); $factory = new Factory($config); $writer = $factory->writer(); $expected = ['timestamp' => ['js' => true, 'css' => false], 'path' => TMP, 'theme' => 'Red']; $this->assertEquals($expected, $writer->config()); }
public function testExtendedConfig() { $config = new AssetConfig(); $config->load($this->extendConfig); $expected = ['classes/base_class.js', 'classes/template.js', 'library_file.js']; $this->assertEquals($expected, $config->files('extended.js')); $expected = ['classes/base_class.js', 'classes/template.js', 'library_file.js', 'local_script.js']; $this->assertEquals($expected, $config->files('more.js')); $expected = ['classes/base_class.js', 'classes/template.js', 'library_file.js', 'lots_of_comments.js']; $this->assertEquals($expected, $config->files('second.js')); $expected = ['Sprockets', 'JsMinFilter']; $this->assertEquals($expected, $config->targetFilters('extended.js')); $this->assertEquals($expected, $config->targetFilters('more.js')); $this->assertTrue($config->isThemed('theme.js')); }
public function load($path, $prefix = '') { parent::$_extensionTypes = array_merge(parent::$_extensionTypes, $this->extensions()); return parent::load($path, $prefix); }