Skip to content
This repository has been archived by the owner on May 14, 2019. It is now read-only.

Commit

Permalink
Renaming license file
Browse files Browse the repository at this point in the history
  • Loading branch information
bermi committed Jan 24, 2010
1 parent e0f50b0 commit debf736
Show file tree
Hide file tree
Showing 39 changed files with 21,016 additions and 6 deletions.
14 changes: 8 additions & 6 deletions LGPL-LICENSE → LICENSE
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
GNU LESSER GENERAL PUBLIC LICENSE
Version 2.1, February 1999
Copyright (c) 2005-2010 Bermi Ferrer Martinez

GNU LESSER GENERAL PUBLIC LICENSE
Version 2.1, February 1999

Copyright (C) 1991, 1999 Free Software Foundation, Inc.
51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Expand All @@ -10,7 +12,7 @@
as the successor of the GNU Library Public License, version 2, hence
the version number 2.1.]

Preamble
Preamble

The licenses for most software are designed to take away your
freedom to share and change it. By contrast, the GNU General Public
Expand Down Expand Up @@ -112,7 +114,7 @@ modification follow. Pay close attention to the difference between a
former contains code derived from the library, whereas the latter must
be combined with the library in order to run.

GNU LESSER GENERAL PUBLIC LICENSE
GNU LESSER GENERAL PUBLIC LICENSE
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION

0. This License Agreement applies to any software library or other
Expand Down Expand Up @@ -432,7 +434,7 @@ decision will be guided by the two goals of preserving the free status
of all derivatives of our free software and of promoting the sharing
and reuse of software generally.

NO WARRANTY
NO WARRANTY

15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO
WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW.
Expand All @@ -455,4 +457,4 @@ FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF
SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
DAMAGES.

END OF TERMS AND CONDITIONS
END OF TERMS AND CONDITIONS
114 changes: 114 additions & 0 deletions akelos_utils/doc_builder/installers/doc_installer.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
<?php

class DocInstaller extends AkInstaller
{
function up_1()
{
$this->createTable('components', "
id,
name,
description,
parent_id,
created_at,
updated_at
");

$this->createTable('categories', "
id,
name,
description,
created_at,
updated_at
");

$this->createTable('related_categories', "
id,
category_id,
related_category_id
");

$this->createTable('files', "
id,
component_id,
path,
body,
hash,
has_been_analyzed,
created_at,
updated_at
");

$this->createTable('klasses', "
id,
name,
description,
file_id,
component_id,
parent_id,
created_at,
updated_at
");

$this->createTable('methods', "
id,
name,
description,
klass_id,
category_id,
is_private,
returns_reference bool default 0,
position int,
created_at,
updated_at
");

$this->createTable('parameters', "
id,
name,
method_id,
data_type_id,
default_value,
description,
is_reference,
position,
created_at,
updated_at
");

$this->createTable('data_types', '
id,
name
');


$this->createTable('examples', "
id,
name,
method_id,
component_id,
category_id,
body,
created_at,
updated_at
");

$this->createTable('comments', "
id,
body,
user,
email,
method_id,
ip_address,
spam_score integer default 0,
is_published bool default 0,
created_at,
updated_at
");
}

function down_1()
{
$this->dropTables('components,files,methods,klasses,parameters,examples,comments,categories,related_categories,data_types');
}

}
46 changes: 46 additions & 0 deletions akelos_utils/doc_builder/models/category.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
<?php

class Category extends AkActiveRecord
{
public $has_many = array('methods');
public $habtm = array('related_categories'=>array(
'association_foreign_key'=>'related_category_id',
'join_table'=>'related_categories',
'join_class_name'=>'RelatedCategory',
'unique' => true
));

public function validate()
{
$this->validatesUniquenessOf('name');
}

public function &updateCategoryDetails(&$Method, $method_details, &$SourceAnalyzer)
{
static $updated_categories = array();
if($method_details['category'] != 'none' && !in_array($method_details['category'], $updated_categories)){
$Category = $this->findOrCreateBy('name', $method_details['category']);
$Category->setAttributes(array(
'description' => $method_details['category_details']
));

$Category->save();
$Method->category->assign($Category);

$updated_categories[] = $method_details['category'];

if(false && !empty($method_details['category_relations'])){
$RelatedCategories = array();
foreach($method_details['category_relations'] as $category_name){
$RelatedCategories[] = $this->findOrCreateBy('name', $category_name);
}
$Category->related_category->set($RelatedCategories);
$Category->save();
}
}

// parameters doc_metadata category_id

return $Category;
}
}
7 changes: 7 additions & 0 deletions akelos_utils/doc_builder/models/comment.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?php

class Comment extends AkActiveRecord
{

}

46 changes: 46 additions & 0 deletions akelos_utils/doc_builder/models/component.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
<?php

class Component extends AkActiveRecord
{
public $acts_as = 'tree';
public $has_many = array('files', 'methods', 'categories', 'klasses');

public function validate()
{
$this->set('name', trim($this->get('name')));
$this->validatesUniquenessOf('name', array('scope'=>'parent_id'));
}


public function &updateComponentDetails(&$File, &$SourceAnalizer)
{
$details = $SourceAnalizer->getFileDetails($File->body);
$package = empty($details['package']) ? false : $details['package'];
$subpackage = empty($details['subpackage']) ? false : $details['subpackage'];

if(!$Component = $this->findFirstBy('name', $package)){
$SourceAnalizer->log('Adding package: '.$package);
$Component = $this->create(array('name'=> $package));
}

if(!$SubComponent = $this->findFirstBy('name AND parent_id', $subpackage, $Component->id)){
$SubComponent = $this->create(array('name'=> $subpackage));
$SourceAnalizer->log('Adding package: '.$subpackage);
}

if(empty($File->component_id)){
$SourceAnalizer->log('Relating file '.$File->path.' to component '.$subpackage);
$File->component->assign($SubComponent);
$File->save();
}

if($Component && $SubComponent && !in_array($SubComponent->id, $Component->collect($Component->tree->getChildren(),'id','id'))){
$SourceAnalizer->log('Setting package '.$subpackage.' as a child for '.$package);
$Component->tree->addChild($SubComponent);
$Component->save();
}

return $SubComponent;
}
}

6 changes: 6 additions & 0 deletions akelos_utils/doc_builder/models/data_type.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?php

class DataType extends AkActiveRecord
{
public $belongs_to = 'parameter';
}
6 changes: 6 additions & 0 deletions akelos_utils/doc_builder/models/example.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?php

class Example extends AkActiveRecord
{
public $belongs_to = array('method');
}
13 changes: 13 additions & 0 deletions akelos_utils/doc_builder/models/file.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?php

class File extends AkActiveRecord
{
public $has_many = array('methods');
public $belongs_to = array('component', 'category');

public function validate()
{
$this->validatesUniquenessOf('path');
}
}

100 changes: 100 additions & 0 deletions akelos_utils/doc_builder/models/klass.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
<?php

class Klass extends AkActiveRecord
{
public $acts_as = 'tree';
public $belongs_to = array('file', 'component');
public $has_many = array('methods'=>array('order'=>'position'), 'categories');

public function validate()
{
$this->validatesUniquenessOf('name');
}


public function &updateClassDetails(&$File, &$Component, &$SourceAnalyzer)
{
$MethodInstance = new Method(array('init'=>false));
$MethodInstance->setConnection($this->getConnection());
$MethodInstance->init();

$parsed_details = $SourceAnalyzer->getParsedArray($File->body);

$available_classes = empty($parsed_details['classes']) ? array() : array_keys($parsed_details['classes']);


if(empty($available_classes)){
return $available_classes;
}

$Classes = array();
foreach ($available_classes as $class_name){
$extends = !empty($parsed_details['classes'][$class_name]['extends']) ? $parsed_details['classes'][$class_name]['extends'] : false;

if($extends){
$SourceAnalyzer->log('Looking for parent class: '.$extends);
$ParentClass = $this->_addOrUpdateClassDetails($extends, $File, $Component, $SourceAnalyzer, array(), true);
}

$Class = $this->_addOrUpdateClassDetails($class_name, $File, $Component, $SourceAnalyzer, $parsed_details['classes'][$class_name]);

if(!empty($ParentClass)){
$SourceAnalyzer->log('Setting '.$extends.' as the parent of '.$class_name);
$ParentClass->tree->addChild($Class);
$ParentClass->save();
}

$Class->methods = array();
if(!empty($parsed_details['classes'][$class_name]['methods'])){
foreach ($parsed_details['classes'][$class_name]['methods'] as $method_name => $method_details){
$Class->methods[] = $MethodInstance->updateMethodDetails($Class, $method_name, $method_details, $SourceAnalyzer);
}
}

$Classes[] = $Class;
}

return $Classes;
}

public function &_addOrUpdateClassDetails($class_name, &$File, &$Component, &$SourceAnalyzer, $class_details, $ExtendedClass = null)
{
$class_details = array(
'name'=> $class_name,
'file_id' => $File->getId(),
'component_id' => $Component->getId(),
'description' => @$class_details['doc']
);
/*
'doc' => trim($this->_latest_docs, "\n\t "),
'doc_metadata' => $this->_latest_attributes,
'class_name' => $this->_current_class,
'extends' => trim($this->_current_class_extends),
*/

$class_details = array_filter($class_details, 'strlen');

if(!$Class = $this->findFirstBy('name', $class_name)){
$SourceAnalyzer->log('Adding class: '.$class_name);

if(!empty($ExtendedClass)){
$class_details = array('name'=>$class_details['name']);
}

$Class = new Klass(array('init'=>false));
$Class->setConnection($this->getConnection());
$Class->setAttributes($class_details);
$Class->save();

$SourceAnalyzer->log('Added class: '.$class_name);
}elseif(empty($ExtendedClass) && $File->getId() != $Class->get('file_id') || $Component->getId() != $Class->get('component_id')){
$SourceAnalyzer->log('Modifying class details: '.$class_name);
unset($class_details['name']);
$Class->setAttributes($class_details);
$Class->save();
}
return $Class;
}

}

Loading

0 comments on commit debf736

Please sign in to comment.