コード例 #1
0
 public function __construct(Codex $codex, Project $project, Filesystem $files, Container $container, Cache $cache)
 {
     ini_set('memory_limit', '2G');
     $path = $project->path($project->config('hooks.sassdoc.path'));
     $pathName = 'sassdoc';
     parent::__construct($codex, $project, $files, $container, $path, $pathName);
     $this->mergeAttributes($project->config('hooks.sassdoc'));
     $this->setPath($path);
     $this->cache = $cache;
 }
コード例 #2
0
ファイル: Syncer.php プロジェクト: codex-project/git-hook
 public function syncRef($ref, $type, Closure $progress = null)
 {
     $this->fire('git.syncer.start', [$ref, $type]);
     $owner = $this->setting('owner');
     $repo = $this->setting('repository');
     $docPath = $this->setting('sync.paths.docs');
     $menuPath = $this->setting('sync.paths.menu');
     $indexPath = $this->setting('sync.paths.index');
     $remote = $this->client($this->setting('remote'));
     $rfs = $remote->getFilesystem($repo, $owner, $ref);
     $files = $rfs->allFiles($this->setting('sync.paths.docs'));
     if (!$rfs->exists($indexPath)) {
         return $this->log('error', 'syncRef could not find the index file', [$indexPath]);
     }
     if (!$rfs->exists($menuPath)) {
         return $this->log('error', 'syncRef could not find the menu file', [$indexPath]);
     }
     $destinationDir = $this->project->path($ref);
     $menuContent = $rfs->get($this->setting('sync.paths.menu'));
     //#base64_decode($menu[ 'content' ]);
     $menuArray = Yaml::parse($menuContent);
     $unfilteredPages = [];
     $this->extractDocumentsFromMenu($menuArray['menu'], $unfilteredPages);
     $this->ensureDirectory($destinationDir);
     $files = $rfs->allFiles($this->setting('sync.paths.docs'));
     $total = count($files);
     $syncer = $this;
     foreach ($files as $current => $file) {
         $localPath = Path::makeRelative($file, $this->setting('sync.paths.docs'));
         if ($progress instanceof Closure) {
             #$file = new \SplFileInfo(path_join($this->project->getPath(), $destinationDir, $localPath));
             $this->project->getContainer()->call($progress, compact('current', 'total', 'file', 'files', 'syncer'));
         }
         $localPath = Path::join($destinationDir, $localPath);
         $dir = Path::getDirectory($localPath);
         $this->ensureDirectory($dir);
         $this->files->put($localPath, $rfs->get($file));
     }
     // index.md resolving
     $indexFile = $rfs->get($this->setting('sync.paths.index'));
     $this->files->put(Path::join($destinationDir, 'index.md'), $indexFile);
     if ($type === 'branch') {
         $branch = $remote->getBranch($this->setting('repository'), $ref, $this->setting('owner'));
         $this->cache->forever(md5($this->project->getName() . $branch['name']), $branch['sha']);
     }
     $this->fire('git.syncer.finish', [$ref, $type]);
 }