diff --git a/src/AbstractBuilder.php b/src/AbstractBuilder.php deleted file mode 100644 index e32f9a7..0000000 --- a/src/AbstractBuilder.php +++ /dev/null @@ -1,31 +0,0 @@ -appendToCollection('tune', $this->tune); - } -} \ No newline at end of file diff --git a/src/Application/UseCases/ExtractTuneFromCollection.php b/src/Application/UseCases/ExtractTuneFromCollection.php new file mode 100644 index 0000000..632adbd --- /dev/null +++ b/src/Application/UseCases/ExtractTuneFromCollection.php @@ -0,0 +1,28 @@ +tunes = $tunes; + } + + public static function create(TuneCollection $tunes) + { + return new self($tunes); + } + + public function extractTuneByTitle(string $title) + { + return $this->tunes + ->filter(function (Tune $tune) use ($title) { + return in_array($title, $tune->getTitles()); + }) + ->unique() + ; + } +} diff --git a/src/Application/UseCases/ImportAbcFile.php b/src/Application/UseCases/ImportAbcFile.php index 799f209..9aa529f 100644 --- a/src/Application/UseCases/ImportAbcFile.php +++ b/src/Application/UseCases/ImportAbcFile.php @@ -2,6 +2,7 @@ namespace XaiCorp\AbcParser\Application\UseCases; use Enzyme\Axiom\Atoms\StringAtom; +use XaiCorp\AbcParser\Domain\Core\Collection; use XaiCorp\AbcParser\Domain\Core\TuneCollection; use XaiCorp\AbcParser\Domain\Modules\Interpreter\Builder; use XaiCorp\AbcParser\Domain\Modules\Interpreter\Context; @@ -16,11 +17,18 @@ class ImportAbcFile protected $builderTemplate; /** - * @param Builder|null $builderTemplate + * @param Builder $builderTemplate */ - public function __construct(Builder $builderTemplate = null) + public function __construct(Builder $builderTemplate) { - $this->builderTemplate = $builderTemplate ?: new Builder(); + $this->builderTemplate = $builderTemplate; + } + + public static function create(Builder $builderTemplate = null) + { + $builder = $builderTemplate ?: new Builder(); + + return new self($builder); } /** @@ -32,7 +40,25 @@ class ImportAbcFile { $context = new Context(new StringAtom($abc)); $parser = $this->getBestParser($context); - $result = $parser->execute($context); + $result = $parser->execute($context)->getTunes(); + + return $result; + } + + /** + * @param array $abcs + * @return \XaiCorp\AbcParser\Domain\Core\TuneCollection + */ + public function importMultiple(array $abcs) + { + $result = Collection::make($abcs) + ->map(function (string $abc) { + return $this->import($abc); + }) + ->reduce(new TuneCollection(), function (TuneCollection $carry, TuneCollection $tunes) { + return $carry->merge($tunes); + }) + ; return $result; } @@ -41,9 +67,9 @@ class ImportAbcFile * @param Context $context * @return Interpreter */ - public function getBestParser(Context $context) : Interpreter + protected function getBestParser(Context $context) : Interpreter { - $builder = clone $this->builderTemplate; + $builder = clone ($this->builderTemplate); switch($context->getVersion()) { default: diff --git a/src/Application/UseCases/MergeCollections.php b/src/Application/UseCases/MergeCollections.php deleted file mode 100644 index 74187a1..0000000 --- a/src/Application/UseCases/MergeCollections.php +++ /dev/null @@ -1,15 +0,0 @@ -merge($additions); - } -} diff --git a/src/Domain/Core/Collection.php b/src/Domain/Core/Collection.php new file mode 100644 index 0000000..ebb4553 --- /dev/null +++ b/src/Domain/Core/Collection.php @@ -0,0 +1,492 @@ +items, $callback, $initial); + } + + /** + * @param \XaiCorp\AbcParser\Domain\Core\Collection $collection + * @return static + */ + public function merge(Collection $collection) + { + $results = $this->items; + foreach ($collection as $key => $value) { + if (is_numeric($key)) { + $results[] = $value; + } else { + $results[$key] = $value; + } + } + + return new static($results); + } + + /** + * Static helper method to instantiate a new collection. Useful for when you + * want to immediately chain a method. Eg: Collection::make([1, 2, 3])->map(...). + * + * @param array $initial + * + * @return Collection + */ + public static function make(array $initial) + { + return new static($initial); + } + + /** + * Get a PHP style array from the current collection. + * + * @return array + */ + public function toArray() + { + return $this->items; + } + + /** + * Whether the collection has the specified key, and/or value associated + * with the specified key. + * + * @param string $key + * @param mixed $value + * + * @return bool + */ + public function has($key, $value = null) + { + $key_exists = self::keyExists($key, $this->items); + + return null !== $value + ? $value === $this->get($key) + : $key_exists; + } + + /** + * Get the value associated with the specified key. + * + * @param string $key + * + * @throws CollectionException If the key does not exist. + * + * @return mixed + */ + public function get($key) + { + if (false === self::keyExists($key, $this->items)) { + throw new CollectionException( + "An element with the key [${key}] does not exist." + ); + } + + return $this->items[$key]; + } + + /** + * Get the value associated with the specified key or return a default value + * instead if it does not exist. + * + * @param string $key + * @param mixed $default + * + * @return mixed + */ + public function getOrDefault($key, $default = null) + { + try { + return $this->get($key); + } catch (CollectionException $e) { + return $default; + } + } + + /** + * Execute the given callback function for each element in this collection. + * + * @param Closure $fn + */ + public function each(Closure $fn) + { + foreach ($this->items as $key => $value) { + if (false === $fn($value, $key)) { + break; + } + } + } + + /** + * Execute the given callback function for each element in this collection + * and save the results to a new collection. + * + * @param Closure $fn + * + * @return Collection + */ + public function map(Closure $fn) + { + $results = []; + foreach ($this->items as $key => $value) { + $results[] = $fn($value, $key); + } + + return new static($results); + } + + /** + * Execute the given callback function for each element in this collection + * and save the results to a new collection with the specified key. The + * callback function should return a 1 element associative array, eg: + * ['key' => 'value'] to be mapped. + * + * @param Closure $fn + * + * @return Collection + */ + public function mapWithKey(Closure $fn) + { + $results = []; + foreach ($this->items as $key => $value) { + $result = $fn($value, $key); + $keys = array_keys($result); + + if (count($keys) < 1) { + throw new CollectionException( + 'Map with key expects a 1 element associative array.' + ); + } + + $results[$keys[0]] = $result[$keys[0]]; + } + + return new static($results); + } + + /** + * Pluck out all values in this collection which have the specified key. + * + * @param string $pluck_key + * @param bool $deep Whether to traverse into sub-arrays. + * + * @return Collection + */ + public function pluck($pluck_key, $deep = true) + { + return self::pluckKey($this->items, $pluck_key, $deep); + } + + /** + * Get the number of elements in this collection. + * + * @return int + */ + public function count() + { + return count($this->items); + } + + /** + * Whether this collection is empty. + * + * @return bool + */ + public function isEmpty() + { + return $this->count() < 1; + } + + /** + * Get the value of the first element in this collection. + * + * @throws CollectionException If the collection is empty. + * + * @return mixed + */ + public function first() + { + if (true === $this->isEmpty()) { + throw new CollectionException( + 'Cannot get first item as the collection is empty.' + ); + } + + return reset($this->items); + } + + /** + * Get the value of the first element in this collection or return the + * default value specified if the collection is empty. + * + * @param mixed $default + * + * @return mixed + */ + public function firstOrDefault($default = null) + { + try { + return $this->first(); + } catch (CollectionException $e) { + return $default; + } + } + + /** + * Get the value of the last element in this collection. + * + * @throws CollectionException If the collection is empty. + * + * @return mixed + */ + public function last() + { + if (true === $this->isEmpty()) { + throw new CollectionException( + 'Cannot get last element as collection is empty.' + ); + } + + end($this->items); + $key = key($this->items); + reset($this->items); + + return $this->items[$key]; + } + + /** + * Get the value of the last element in this collection or return the + * default value specified if the collection is empty. + * + * @param mixed $default + * + * @return mixed + */ + public function lastOrDefault($default = null) + { + try { + return $this->first(); + } catch (CollectionException $e) { + return $default; + } + } + + /** + * Get a new collection of only the elements in the current collection + * that have the specified keys. + * + * @param array $keys + * + * @return Collection + */ + public function only(array $keys) + { + return $this->filter(function ($value, $key) use ($keys) { + return true === self::keyExists($key, array_flip($keys)); + }); + } + + /** + * Get a new collection of all the elements in the current collection + * except those that have the specified keys. + * + * @param array $keys + * + * @return Collection + */ + public function except(array $keys) + { + return $this->filter(function ($value, $key) use ($keys) { + return false === self::keyExists($key, array_flip($keys)); + }); + } + + /** + * Return a new collection with the current collection's elements plus the + * given value pushed onto the end of the array. + * + * @param mixed $value + * + * @return Collection + */ + public function push($value) + { + $items = $this->items; + $items[] = $value; + + return new static($items); + } + + /** + * Return a new collection with the current collection's elements plus the + * given key and value pushed onto the end of the array. + * + * @param string $key + * @param mixed $value + * + * @return Collection + */ + public function pushWithKey($key, $value) + { + $items = $this->items; + $items[$key] = $value; + + return new static($items); + } + + /** + * Return a new collection with the current collection's elements plus the + * given array pushed onto the end of the array. + * + * @param array $data + * + * @return Collection + */ + public function pushArray(array $data) + { + $items = $this->items; + foreach ($data as $key => $value) { + if (true === is_int($key)) { + $items[] = $value; + } else { + $items[$key] = $value; + } + } + + return new static($items); + } + + /** + * Return a new collection with a subset of all the current collection's + * elements that pass the given callback functions truth test. + * + * @param Closure $fn + * + * @return static + */ + public function filter(Closure $fn) + { + $results = []; + foreach ($this->items as $key => $value) { + if (true === $fn($value, $key)) { + $results[$key] = $value; + } + } + + // Pushing this new array will normalize numeric keys if they exist. + // After filtering, they may not start at zero and sequentially + // go upwards, which is generally not expected. + return (new static())->pushArray($results); + } + + /** + * Sort the collection using the provided callback function. Same expected + * parameters and the PHP usort function. + * + * @param Closure $fn + * + * @return Collection + */ + public function sort(Closure $fn) + { + $sorted = $this->items; + $result = usort($sorted, $fn); + + if (false === $result) { + throw new CollectionException( + 'The collection could be not sorted.' + ); + } + + return new static($sorted); + } + + /** + * Whether this collection has the specified number of elements within the + * given range or equal too or above the minimum value specified. + * + * @param int $min + * @param int $max Default is null. + * + * @return bool + */ + public function hasCount($min, $max = null) + { + if (null === $max) { + return $this->count() >= $min; + } + + return $this->count() >= $min + && $this->count() <= $max; + } + + /** + * Get a list of the keys used by this collection. + * + * @return array + */ + public function keys() + { + return array_keys($this->items); + } + + /** + * Checks whether the specified key exists in the given collection. + * + * @param string $key + * @param array $collection + * + * @return bool + */ + protected static function keyExists($key, array $collection) + { + return true === isset($collection[$key]); + } + + /** + * Pluck all the values that have the specified key from the given + * collection. + * + * @param array $collection + * @param string $pluck_key + * @param bool $deep Whether to traverse into sub-arrays. + * + * @return Collection + */ + protected static function pluckKey(array $collection, $pluck_key, $deep) + { + $results = []; + foreach ($collection as $key => $value) { + if (true === $deep && true === is_array($value)) { + $deeper_results = self::pluckKey( + $value, + $pluck_key, + $deep + )->toArray(); + + foreach ($deeper_results as $deep_value) { + $results[] = $deep_value; + } + + continue; + } + + if ($key === $pluck_key) { + $results[] = $value; + } + } + + return new static($results); + } +} diff --git a/src/Domain/Core/Tune.php b/src/Domain/Core/Tune.php index b3de493..5921698 100644 --- a/src/Domain/Core/Tune.php +++ b/src/Domain/Core/Tune.php @@ -80,6 +80,20 @@ class Tune implements EntityInterface } } + public function getETag() + { + return md5(implode(';', array_flatten([ + $this->getTitles(), + $this->getAuthors(), + $this->getComposers(), + $this->getGroups(), + $this->getHistory(), + $this->getOrigins(), + $this->getRhythms(), + //TODO: add settings + ]))); + } + /** * @param UnsignedIntegerAtom $index * @return $this diff --git a/src/Domain/Core/TuneCollection.php b/src/Domain/Core/TuneCollection.php index 948b1d2..bbd5fcb 100644 --- a/src/Domain/Core/TuneCollection.php +++ b/src/Domain/Core/TuneCollection.php @@ -1,8 +1,6 @@ items as $key => $tune) { + $tuneId = $tune->getETag(); + $result[$tuneId] = $tune; + } + + return new TuneCollection(array_values($result)); + } } diff --git a/src/Domain/Modules/Interpreter/Builder.php b/src/Domain/Modules/Interpreter/Builder.php index 57d56d1..1ef2dd1 100644 --- a/src/Domain/Modules/Interpreter/Builder.php +++ b/src/Domain/Modules/Interpreter/Builder.php @@ -41,6 +41,15 @@ class Builder $this->tune->addSetting($this->setting); } + public function __clone() + { + $this->collection = new TuneCollection(); + $this->tune = new Tune([]); + $this->setting = new Setting(); + + $this->tune->addSetting($this->setting); + } + public function getTune() { return $this->tune; diff --git a/src/Framework/Laravel5/Models/Person.php b/src/Framework/Laravel5/Models/Person.php deleted file mode 100644 index 0ac6087..0000000 --- a/src/Framework/Laravel5/Models/Person.php +++ /dev/null @@ -1,37 +0,0 @@ - 'required', - 'name' => 'required|string|max:63', - 'email' => 'required|email|max:255' - ]; - - protected $hidden = ['email']; - - //Relationships - - - public function toArray() - { - return $this->name; - } -} diff --git a/src/Framework/Laravel5/Models/UuidTrait.php b/src/Framework/Laravel5/Models/UuidTrait.php deleted file mode 100644 index 0dc43ee..0000000 --- a/src/Framework/Laravel5/Models/UuidTrait.php +++ /dev/null @@ -1,32 +0,0 @@ -attributes['id'] = $uuid; - } - - public function getIdAttribute() - { - if (empty($this->attributes['id'])) { - $uuid = Uuid::generate(4); - $this->attributes['id'] = $uuid; - } - return Uuid::import($this->attributes['id']); - } - - public function setIdAttribute($value) - { - if (empty($this->attributes['id'])) { - $uuid = Uuid::generate(4); - $this->attributes['id'] = $uuid; - } - } -} diff --git a/src/Framework/Laravel5/Models/ValidatingModel.php b/src/Framework/Laravel5/Models/ValidatingModel.php deleted file mode 100644 index 73f6b26..0000000 --- a/src/Framework/Laravel5/Models/ValidatingModel.php +++ /dev/null @@ -1,27 +0,0 @@ -validate()) { - return parent::save($options); - } - return false; - } -} diff --git a/src/Framework/Laravel5/Models/ValidationTrait.php b/src/Framework/Laravel5/Models/ValidationTrait.php deleted file mode 100644 index d7eaeb0..0000000 --- a/src/Framework/Laravel5/Models/ValidationTrait.php +++ /dev/null @@ -1,60 +0,0 @@ -getAttributes(); - - $validator = Validator::make($data, $this->validationRules); - - if ($validator->fails()) { - if (! $this->messages) { - $this->messages = new MessageBag(); - } - $this->messages = $validator->getMessageBag(); - return false; - } - - return true; - } - - /** - * @return array|MessageBag - */ - public function getMessages() - { - return $this->messages?$this->messages->toArray():[]; - } - - /** - * @return array - */ - public function getValidationRules() - { - return $this->validationRules; - } - - /** - * fetch the validation rules for a model class - * - * @return array - */ - public static function getRules() - { - $class = get_called_class(); - $instance = new $class(); - return $instance->getValidationRules(); - } -} diff --git a/src/Framework/PersonDbMapper.php b/src/Framework/PersonDbMapper.php deleted file mode 100644 index c5c46b6..0000000 --- a/src/Framework/PersonDbMapper.php +++ /dev/null @@ -1,26 +0,0 @@ -abc = []; - } - - public function appendToCollection($key, $data) - { - $this->abc[$key][] = $data; - } - - public function setOnCollection($key, $data) - { - $this->abc[$key] = $data; - } - - public function getCollection() - { - return $this->abc; - } - - public function newTune() - { - $this->abc[++$this->tunedIdx] = []; - } - - public function appendToTune($key, $data) - { - $this->abc[$this->tunedIdx][$key][] = $data; - } - - public function setOnTune($key, $data) - { - $this->abc[$this->tunedIdx][$key] = $data; - } - - public function newSetting() - { - // - } - - public function appendToSetting($key, $data) - { - $this->appendToTune($key, $data); - } - - public function setOnSetting($key, $data) - { - $this->setOnTune($key, $data); - } - - public function newPerson(array $data) - { - return $data['name']; - } - - public function getTunes() - { - return $this->abc; - } - - public function removeTune($tuneIndex) - { - unset($this->abc[$tuneIndex]); - } - - public function toAbc() - { - //TODO: translate to abc not json; - return json_encode($this->abc); - } - - public function toJson() - { - return json_encode($this->abc); - } - - public function storeTune($music) - { - $this->abc[$this->tunedIdx]['music'] = trim($music); - } -} diff --git a/src/Models/Laravel5/Abc.php b/src/Models/Laravel5/Abc.php deleted file mode 100644 index e8fe98e..0000000 --- a/src/Models/Laravel5/Abc.php +++ /dev/null @@ -1,132 +0,0 @@ -collection = new Collection(); - } - - public function newCollection() - { - $this->collection = new Collection(); - } - public function appendToCollection($key, $data) - { - $allowedKeys = ['A', 'C', 'D', 'H', 'R', 'F', 'B', 'M', 'L', 'N', 'O', 'S', 'Z']; - - if (in_array($key, $allowedKeys)) { - $array = $this->collection->$key; - $array[] = $data; - $this->setOnCollection($key, $array); - } - } - - public function setOnCollection($key, $data) - { - $allowedKeys = ['A', 'C', 'D', 'H', 'R', 'F', 'B', 'M', 'L', 'N', 'O', 'S', 'Z']; - - if (in_array($key, $allowedKeys)) { - $this->collection->$key = $data; - } - } - - public function getCollection() - { - return $this->collection; - } - - - public function newTune() - { - $this->tune = new Tune(); - } - - public function appendToTune($key, $data) - { - $array = $this->setting->tune->$key; - $array[] = $data; - $this->setOnTune($key, $array); - } - - public function setOnTune($key, $data) - { - if ($key == 'X') { - $key = 'x_id'; - } - $this->setting->tune->$key = $data; - } - - - public function newSetting() - { - $this->setting = new TuneSetting(); - $this->setting->tune = $this->tune; - } - - public function appendToSetting($key, $data) - { - $array = $this->setting->$key; - $array[] = $data; - $this->setOnSetting($key, $array); - } - - public function setOnSetting($key, $data) - { - $this->setting->$key = $data; - } - - - public function newPerson(array $data) - { - $person = new Person(); - foreach ($data as $key => $value) { - $person->{$key} = $value; - } - - return $person; - } - - public function storeTune($music) - { - $this->setting->music = $music; - $this->setting->tune = $this->tune; - $this->collection->appendSetting($this->setting); - } - - - public function getTunes() - { - $this->collection->getSettings(); - } - - public function removeTune($tuneIndex) - {} - - public function toAbc() - { - $this->toJson(); - } - - public function toJson() - { - $this->collection->toJson(); - } - -} diff --git a/src/Models/Laravel5/AttributesTrait.php b/src/Models/Laravel5/AttributesTrait.php deleted file mode 100644 index ee09000..0000000 --- a/src/Models/Laravel5/AttributesTrait.php +++ /dev/null @@ -1,75 +0,0 @@ -$type; - } - - public function loadAttr($type) - { - $result = []; - call_user_func([$this->attributesClass, $type.'s'], [$this->id]) - ->get() - ->each(function ($item, $key) use (&$result) { - $result[] = $item->string; - }); - if (! empty($result)) { - $this->setAttr($type, $result); - } - return $this; - } - - public function setAttr($type, array $values) - { - $this->$type = $values; - } - - public function saveAttr($type) - { - $values = $this->$type; - if (! empty($values)) { - $instance = new $this->attributesClass(); - foreach ($values as $key => $value) { - $attr = $instance->attr($type, $value, $this)->first(); - if (!$attr) { - $attr = new $this->attributesClass(); - } - - $attr->fill([ - 'tune_id' => $this->id, - 'setting_id' => $this->id, - 'collection_id' => $this->id, - 'type' => $type, - 'string' => $value, - 'ordering' => $key, - ]); - $attr->save(); - } - } - } - - public function newFromBuilder($attributes = [], $connection = null) - { - $class = new \ReflectionClass($this->attributesClass); - $model = parent::newFromBuilder($attributes, $connection); - foreach ($class->getStaticPropertyValue('types') as $attribute) { - $model = $model->loadAttr($attribute); - } - return $model; - } - - public function saveAttributes(array $options = []) - { - $class = new \ReflectionClass($this->attributesClass); - foreach ($class->getStaticPropertyValue('types') as $attribute) { - $this->saveAttr($attribute); - } - $saved = parent::save($options); - - return $saved; - } -} diff --git a/src/Models/Laravel5/Collection.php b/src/Models/Laravel5/Collection.php deleted file mode 100644 index d2d2324..0000000 --- a/src/Models/Laravel5/Collection.php +++ /dev/null @@ -1,251 +0,0 @@ -settings) { - $this->settings = new \Illuminate\Support\Collection(); - } - - $this->settings->push($setting); - return $this->settings; - } - - public function getSettings() - { - return $this->settings; - } - - public function save(array $options = []) - { - if (! empty($this->settings)) { - foreach ($this->settings as $setting) { - $saved = $setting->save(); - } - } - return $this->saveAttributes($options); - } - - - /************************************************************** - * mutators and accessors - */ - - public function getMAttribute() - { - return $this->attributes['meter']; - } - - public function setMAttribute($value) - { - return $this->attributes['meter'] = $value; - } - - protected $Author; - public function getAAttribute() - { - return $this->getAttr('Author'); - } - - public function setAAttribute(array $values) - { - $this->setAttr('Author', $values); - } - - protected $Composer; - public function getCAttribute() - { - return $this->getAttr('Composer'); - } - - public function setCAttribute(array $values) - { - $this->setAttr('Composer', $values); - } - - protected $Discography; - public function getDAttribute() - { - return $this->getAttr('Discography'); - } - - public function setDAttribute(array $values) - { - $this->setAttr('Discography', $values); - } - - protected $Rhythm; - public function getRAttribute() - { - return $this->getAttr('Rhythm'); - } - - public function setRAttribute(array $values) - { - $this->setAttr('Rhythm', $values); - } - - protected $History; - public function getHAttribute() - { - return $this->getAttr('History'); - } - - public function setHAttribute(array $values) - { - $this->setAttr('History', $values); - } - - protected $File; - public function getFAttribute() - { - return $this->getAttr('File'); - } - - public function setFAttribute(array $values) - { - $this->setAttr('File', $values); - } - - protected $Book; - public function getBAttribute() - { - return $this->getAttr('Book'); - } - - public function setBAttribute(array $values) - { - $this->setAttr('Book', $values); - } - - protected $Note; - public function getNAttribute() - { - return $this->getAttr('Note'); - } - - public function setNAttribute(array $values) - { - $this->setAttr('Note', $values); - } - - protected $Origin; - public function getOAttribute() - { - return $this->getAttr('Origin'); - } - - public function setOAttribute(array $values) - { - $this->setAttr('Origin', $values); - } - - protected $Source; - public function getSAttribute() - { - return $this->getAttr('Source'); - } - - public function setSAttribute(array $values) - { - $this->setAttr('Source', $values); - } - - protected $Transcriber; - public function getZAttribute() - { - return $this->getAttr('Transcriber'); - } - - public function setZAttribute(array $values) - { - $this->setAttr('Transcriber', $values); - } - - - /** - * implementation of Countable::count() - * - * @return int the number of tunes in the collection - */ - public function count() - { - return count($this->settings); - } - - public function toArray() - { - $arr = parent::toArray(); - - foreach ($this->settings->toArray() as $key => $setting) { - $arr[$key+1] = $setting; - } - - foreach (['A', 'C', 'Z'] as $attr) { - if (isset($arr[$attr])) { - foreach ($arr[$attr] as $key => $person) { - $arr[$attr][$key] = $person->name; - } - } - } - - $arr['M'] = $this->meter; - foreach ($arr as $key => $val) { - if (empty($val)) { - unset($arr[$key]); - } - } - - return $arr; - } - -} diff --git a/src/Models/Laravel5/CollectionAttribute.php b/src/Models/Laravel5/CollectionAttribute.php deleted file mode 100644 index e6309cd..0000000 --- a/src/Models/Laravel5/CollectionAttribute.php +++ /dev/null @@ -1,190 +0,0 @@ - 'required|exists:collections,id', - 'type' => 'required|string|in:Author,Composer,Discography,Rhythm,History,File,Book,Note,Source,Transcriber', - 'string' => 'required|string|max:255', - 'ordering' => 'required|integer' - ]; - - /** - * supported attribute types - * @var array - */ - public static $types = [ - 'Author', - 'Composer', - 'Discography', - 'Rhythm', - 'History', - 'File', - 'Book', - 'Note', - 'Origin', - 'Source', - 'Transcriber', - ]; - - /** - * The attributes that are mass assignable. - * - * @var array - */ - protected $fillable = ['collection_id', 'type', 'string', 'ordering']; - - /** - * The attributes that should be hidden for arrays. - * - * @var array - */ - protected $hidden = ['collection_id', 'type', 'ordering']; - - public static function getTypes() - { - return self::$types; - } - - /***************************************************************** - * Scopes - */ - - /** - * @param \Illuminate\Database\Eloquent\Builder $query - * @param integer $id - * @return \Illuminate\Database\Eloquent\Builder - */ - public function scopeAuthors($query, $id) - { - return $query->where('type', 'Author')->where('collection_id', $id); - } - - /** - * @param \Illuminate\Database\Eloquent\Builder $query - * @param integer $id - * @return \Illuminate\Database\Eloquent\Builder - */ - public function scopeComposers($query, $id) - { - return $query->where('type', 'Composer')->where('collection_id', $id); - } - - /** - * @param \Illuminate\Database\Eloquent\Builder $query - * @param integer $id - * @return \Illuminate\Database\Eloquent\Builder - */ - public function scopeDiscographys($query, $id) - { - return $query->where('type', 'Discography')->where('collection_id', $id); - } - - /** - * @param \Illuminate\Database\Eloquent\Builder $query - * @param integer $id - * @return \Illuminate\Database\Eloquent\Builder - */ - public function scopeFiles($query, $id) - { - return $query->where('type', 'File')->where('collection_id', $id); - } - - /** - * @param \Illuminate\Database\Eloquent\Builder $query - * @param integer $id - * @return \Illuminate\Database\Eloquent\Builder - */ - public function scopeRhythms($query, $id) - { - return $query->where('type', 'Rhythm')->where('collection_id', $id); - } - - /** - * @param \Illuminate\Database\Eloquent\Builder $query - * @param integer $id - * @return \Illuminate\Database\Eloquent\Builder - */ - public function scopeHistorys($query, $id) - { - return $query->where('type', 'History')->where('collection_id', $id); - } - - /** - * @param \Illuminate\Database\Eloquent\Builder $query - * @param integer $id - * @return \Illuminate\Database\Eloquent\Builder - */ - public function scopeBooks($query, $id) - { - return $query->where('type', 'Book')->where('collection_id', $id); - } - - /** - * @param \Illuminate\Database\Eloquent\Builder $query - * @param integer $id - * @return \Illuminate\Database\Eloquent\Builder - */ - public function scopeNotes($query, $id) - { - return $query->where('type', 'Note')->where('collection_id', $id); - } - - /** - * @param \Illuminate\Database\Eloquent\Builder $query - * @param integer $id - * @return \Illuminate\Database\Eloquent\Builder - */ - public function scopeOrigins($query, $id) - { - return $query->where('type', 'Origin')->where('collection_id', $id); - } - - /** - * @param \Illuminate\Database\Eloquent\Builder $query - * @param integer $id - * @return \Illuminate\Database\Eloquent\Builder - */ - public function scopeSources($query, $id) - { - return $query->where('type', 'Source')->where('collection_id', $id); - } - - /** - * @param \Illuminate\Database\Eloquent\Builder $query - * @param integer $id - * @return \Illuminate\Database\Eloquent\Builder - */ - public function scopeTranscribers($query, $id) - { - return $query->where('type', 'Transcriber')->where('collection_id', $id); - } - - /** - * @param \Illuminate\Database\Eloquent\Builder $query - * @param string $attr - * @param mixed $value - * @param \XaiCorp\AbcParser\Models\Laravel5\Tune|null $collection - * @return \Illuminate\Database\Eloquent\Builder - */ - public function scopeAttr($query, $attr, $value, Collection $collection = null) - { - if ($collection) { - $query = $query->where('collection_id', $collection->id); - } - return $query->where('type', strtolower($attr))->where('string', $value); - } -} diff --git a/src/Models/Laravel5/Person.php b/src/Models/Laravel5/Person.php deleted file mode 100644 index 570a0bf..0000000 --- a/src/Models/Laravel5/Person.php +++ /dev/null @@ -1,37 +0,0 @@ - 'required', - 'name' => 'required|string|max:63', - 'email' => 'required|email|max:255' - ]; - - protected $hidden = ['email']; - - //Relationships - - - public function toArray() - { - return $this->name; - } -} diff --git a/src/Models/Laravel5/Tune.php b/src/Models/Laravel5/Tune.php deleted file mode 100644 index ba2f8f8..0000000 --- a/src/Models/Laravel5/Tune.php +++ /dev/null @@ -1,136 +0,0 @@ - 'integer|min:1', - ]; - - /** - * The attributes that are mass assignable. - * - * @var array - */ - protected $fillable = ['x_id', 'X', 'T']; - - protected $hidden = ['id', 'x_id', 'Title', 'Group', 'Origin', 'Rhythm', 'History']; - - protected $appends = ['T', 'G', 'O', 'R', 'H']; - - public function save(array $options = []) - { - $savedTune = true; - - app('db')->beginTransaction(); - $savedAttr = $this->saveAttributes($options); - if (isset($this->tune)) { - $savedTune = $this->tune->save(); - } - - if ($savedAttr && $savedTune) { - app('db')->commit(); - return true; - } else { - app('db')->rollBack(); - return false; - } - } - - /************************************************************** - * mutators and accessors - */ - - protected $Title; - public function getTAttribute() - { - return $this->getAttr('Title'); - } - - public function setTAttribute(array $values) - { - $this->setAttr('Title', $values); - } - - protected $Group; - public function getGAttribute() - { - return $this->getAttr('Group'); - } - public function setGAttribute(array $values) - { - $this->setAttr('Group', $values); - } - - public function getOAttribute() - { - return $this->getAttr('Origin'); - } - - protected $Origin; - public function setOAttribute(array $values) - { - $this->setAttr('Origin', $values); - } - - protected $Rhythm; - public function getRAttribute() - { - return $this->getAttr('Rhythm'); - } - - public function setRAttribute(array $values) - { - $this->setAttr('Rhythm', $values); - } - - protected $History; - public function getHAttribute() - { - return $this->getAttr('History'); - } - - public function setHAttribute(array $values) - { - $this->setAttr('History', $values); - } - - public function toArray() - { - $arr = parent::toArray(); - - foreach (['A','C'] as $attr) { - if (isset($arr[$attr])) { - foreach ($arr[$attr] as $key => $person) { - $arr[$attr][$key] = $person->name; - } - } - } - - foreach ($arr as $key => $val) { - if (empty($val)) { - unset($arr[$key]); - } - } - - return $arr; - } -} diff --git a/src/Models/Laravel5/TuneAttribute.php b/src/Models/Laravel5/TuneAttribute.php deleted file mode 100644 index 35e990f..0000000 --- a/src/Models/Laravel5/TuneAttribute.php +++ /dev/null @@ -1,134 +0,0 @@ - 'required|exists:tunes,id', - 'type' => 'required|string|in:Title,Group,Origin,Rhythm,History', - 'string' => 'required|string|max:255', - 'ordering' => 'required|integer' - ]; - - /** - * supported attribute types - * @var array - */ - public static $types = [ - 'Title', - 'Group', - 'Origin', - 'Rhythm', - 'History' - ]; - - /** - * The attributes that are mass assignable. - * - * @var array - */ - protected $fillable = ['tune_id', 'type', 'string', 'ordering']; - - /** - * The attributes that should be hidden for arrays. - * - * @var array - */ - protected $hidden = ['tune_id', 'type', 'ordering']; - - public static function getTypes() - { - return self::$types; - } - - /***************************************************************** - * Scopes - */ - - /** - * @param \Illuminate\Database\Eloquent\Builder $query - * @param integer $id - * @return \Illuminate\Database\Eloquent\Builder - */ - public function scopeTitle($query, $value) - { - return $query->where('type', 'Title')->where('string', $value); - } - - /** - * @param \Illuminate\Database\Eloquent\Builder $query - * @param integer $id - * @return \Illuminate\Database\Eloquent\Builder - */ - public function scopeTitles($query, $id) - { - return $query->where('type', 'Title')->where('tune_id', $id); - } - - /** - * @param \Illuminate\Database\Eloquent\Builder $query - * @param integer $id - * @return \Illuminate\Database\Eloquent\Builder - */ - public function scopeGroups($query, $id) - { - return $query->where('type', 'Group')->where('tune_id', $id); - } - - /** - * @param \Illuminate\Database\Eloquent\Builder $query - * @param integer $id - * @return \Illuminate\Database\Eloquent\Builder - */ - public function scopeOrigins($query, $id) - { - return $query->where('type', 'Origin')->where('tune_id', $id); - } - - /** - * @param \Illuminate\Database\Eloquent\Builder $query - * @param integer $id - * @return \Illuminate\Database\Eloquent\Builder - */ - public function scopeRhythms($query, $id) - { - return $query->where('type', 'Rhythm')->where('tune_id', $id); - } - - /** - * @param \Illuminate\Database\Eloquent\Builder $query - * @param integer $id - * @return \Illuminate\Database\Eloquent\Builder - */ - public function scopeHistorys($query, $id) - { - return $query->where('type', 'History')->where('tune_id', $id); - } - - /** - * @param \Illuminate\Database\Eloquent\Builder $query - * @param string $attr - * @param mixed $value - * @param \XaiCorp\AbcParser\Models\Laravel5\Tune|null $tune - * @return \Illuminate\Database\Eloquent\Builder - */ - public function scopeAttr($query, $attr, $value, Tune $tune = null) - { - if ($tune) { - $query = $query->where('tune_id', $tune->id); - } - return $query->where('type', strtolower($attr))->where('string', $value); - } -} diff --git a/src/Models/Laravel5/TuneSetting.php b/src/Models/Laravel5/TuneSetting.php deleted file mode 100644 index 659ff8e..0000000 --- a/src/Models/Laravel5/TuneSetting.php +++ /dev/null @@ -1,173 +0,0 @@ - 'required|exists:tunes,id', - 'meter' => 'string|max:3', - 'keysig' => 'string|max:5', - 'filename' => 'string|max:255', - 'tempo' => 'string|max:10', - 'L' => 'string|max:5', - 'music' => 'string', - 'parts' => 'string|max:255' - ]; - - public static $regex_Q = '/\d\/\d\d?=\d{2,3}/i'; - public static $regex_L = '/\d\/\d{1,2}/i'; - public static $regex_M = '/((C|C\|)|\d{1,2}\/\d{1,3})/i'; - public static $regex_K = '/[a-zA-G]{1,5}/i'; - - /** - * The attributes that are mass assignable. - * - * @var array - */ - protected $fillable = ['tune_id', 'meter', 'keysig', 'filename', 'tempo', 'L', 'music', 'parts']; - - protected $hidden = ['id', 'tune_id', 'Transcriber', 'Note', 'Discography', 'Source', 'Word', 'Book']; - - protected $appends = ['Z', 'N', 'D', 'S', 'W', 'B']; - - public function save(array $options = []) - { - return $this->saveAttributes($options); - } - - - /************************************************************** - * mutators and accessors - */ - - public function setMusicAttribute($value) - { - $this->attributes['music'] = trim($value); - } - - /** - * @var Tune - */ - protected $tune; - - public function setTuneAttribute(Tune $tune) - { - $this->tune = $tune; - } - - public function getTuneAttribute() - { - return $this->tune; - } - - protected $Transcriber; - public function getZAttribute() - { - return $this->getAttr('Transcriber'); - } - - public function setZAttribute(array $values) - { - $this->setAttr('Transcriber', $values); - } - - protected $Note; - public function getNAttribute() - { - return $this->getAttr('Note'); - } - - public function setNAttribute(array $values) - { - $this->setAttr('Note', $values); - } - - protected $Discography; - public function getDAttribute() - { - return $this->getAttr('Discography'); - } - - public function setDAttribute(array $values) - { - $this->setAttr('Discography', $values); - } - - protected $Source; - public function getSAttribute() - { - return $this->getAttr('Source'); - } - - public function setSAttribute(array $values) - { - $this->setAttr('Source', $values); - } - - protected $Word; - public function getWAttribute() - { - return $this->getAttr('Word'); - } - - public function setWAttribute(array $values) - { - $this->setAttr('Word', $values); - } - - protected $Book; - public function getBAttribute() - { - return $this->getAttr('Book'); - } - - public function setBAttribute(array $values) - { - $this->setAttr('Book', $values); - } - - - /** - * @return array - */ - public function toArray() - { - $arr = parent::toArray(); - - if (isset($arr['Z'])) { - foreach ($arr['Z'] as $key => $person) { - $arr['Z'][$key] = $person->name; - } - } - - foreach ($arr as $key => $val) { - if (empty($val)) { - unset($arr[$key]); - } - } - - $tune = $this->tune->toArray(); - return array_merge($this->tune->toArray(), $arr); - } -} diff --git a/src/Models/Laravel5/TuneSettingAttribute.php b/src/Models/Laravel5/TuneSettingAttribute.php deleted file mode 100644 index 00686fd..0000000 --- a/src/Models/Laravel5/TuneSettingAttribute.php +++ /dev/null @@ -1,145 +0,0 @@ - 'required|exists:tune_settings,id', - 'type' => 'required|string|in:Transcriber,Note,Discography,Source,Word,Book', - 'string' => 'required|string|max:255', - 'ordering' => 'required|integer' - ]; - - /** - * supported attribute types - * @var array - */ - public static $types = [ - 'Transcriber', - 'Note', - 'Discography', - 'Source', - 'Word', - 'Book' - ]; - - /** - * The attributes that are mass assignable. - * - * @var array - */ - protected $fillable = ['setting_id', 'type', 'string', 'ordering']; - - /** - * The attributes that should be hidden for arrays. - * - * @var array - */ - protected $hidden = ['setting_id', 'type', 'ordering']; - - public static function getTypes() - { - return self::$types; - } - - /***************************************************************** - * Scopes - */ - - /** - * @param \Illuminate\Database\Eloquent\Builder $query - * @param integer $id - * @return \Illuminate\Database\Eloquent\Builder - */ - public function scopeTranscriber($query, $value) - { - return $query->where('type', 'Transcriber')->where('string', $value); - } - - /** - * @param \Illuminate\Database\Eloquent\Builder $query - * @param integer $id - * @return \Illuminate\Database\Eloquent\Builder - */ - public function scopeTranscribers($query, $id) - { - return $query->where('type', 'Transcriber')->where('setting_id', $id); - } - - /** - * @param \Illuminate\Database\Eloquent\Builder $query - * @param integer $id - * @return \Illuminate\Database\Eloquent\Builder - */ - public function scopeNotes($query, $id) - { - return $query->where('type', 'Note')->where('setting_id', $id); - } - - /** - * @param \Illuminate\Database\Eloquent\Builder $query - * @param integer $id - * @return \Illuminate\Database\Eloquent\Builder - */ - public function scopeDiscographys($query, $id) - { - return $query->where('type', 'Discography')->where('setting_id', $id); - } - - /** - * @param \Illuminate\Database\Eloquent\Builder $query - * @param integer $id - * @return \Illuminate\Database\Eloquent\Builder - */ - public function scopeSources($query, $id) - { - return $query->where('type', 'Source')->where('setting_id', $id); - } - - /** - * @param \Illuminate\Database\Eloquent\Builder $query - * @param integer $id - * @return \Illuminate\Database\Eloquent\Builder - */ - public function scopeWords($query, $id) - { - return $query->where('type', 'Word')->where('setting_id', $id); - } - - /** - * @param \Illuminate\Database\Eloquent\Builder $query - * @param integer $id - * @return \Illuminate\Database\Eloquent\Builder - */ - public function scopeBooks($query, $id) - { - return $query->where('type', 'Book')->where('setting_id', $id); - } - - /** - * @param \Illuminate\Database\Eloquent\Builder $query - * @param string $attr - * @param mixed $value - * @param \XaiCorp\AbcParser\Models\Laravel5\Tune|null $setting - * @return \Illuminate\Database\Eloquent\Builder - */ - public function scopeAttr($query, $attr, $value, TuneSetting $setting = null) - { - if ($setting) { - $query = $query->where('setting_id', $setting->id); - } - return $query->where('type', strtolower($attr))->where('string', $value); - } -} diff --git a/src/Models/Memory/Abc.php b/src/Models/Memory/Abc.php deleted file mode 100644 index f9f58b5..0000000 --- a/src/Models/Memory/Abc.php +++ /dev/null @@ -1,97 +0,0 @@ -collectionRepository = $collectionRepository; - } - - public function newCollection() - { - $this->collection = new TuneCollection(); - } - - public function appendToCollection($key, $data) - { - $this->collection->append($key, $data); - } - - public function setOnCollection($key, $data) - { - $this->collection->set($key, $data); - } - - public function getCollection() - { - return count($this->collection) ? $this->collection : false; - } - - public function newTune() - { - $this->currentTune = new Tune(); - } - - public function appendToTune($key, $data) - { - $this->currentTune->append($key, $data); - } - - public function setOnTune($key, $data) - { - $this->currentTune->set($key, $data); - } - - public function newSetting() - { - $this->currentSetting = new Setting(); - } - - public function appendToSetting($key, $data) - { - $this->currentSetting->append($key, $data); - } - - public function setOnSetting($key, $data) - { - $this->currentSetting->set($key, $data); - } - - public function newPerson(array $data) - { - return new Person($data); - } - - public function storeTune($music) - { - $this->currentSetting->set('music', trim($music)); - $this->currentTune->append('collection', $this->currentSetting); - $this->collection->append('collection', $this->currentTune); - - // save to repositories - $this->collectionRepository->add($this->collection); - } -} diff --git a/src/Models/Memory/BaseIterator.php b/src/Models/Memory/BaseIterator.php deleted file mode 100644 index 00ae0a5..0000000 --- a/src/Models/Memory/BaseIterator.php +++ /dev/null @@ -1,114 +0,0 @@ -collection); - } - - /******************************************************** - * - * Implementation of ArrayAccess - * - ********************************************************/ - - public function offsetExists ( $offset ) - { - return isset($this->collection[$offset]); - } - - public function offsetGet ( $offset ) - { - return isset($this->collection[$offset])? $this->collection[$offset] : null; - } - - public function offsetSet ( $offset, $value ) - { - $offset = ($offset === NULL) ? count($this->collection) : $offset; - if(is_a($value, BaseObject::class)) { $this->collection[$offset] = $value; } - } - - public function offsetUnset ( $offset ) - { - unset($this->collection[$offset]); - } - - /******************************************************** - * - * Implementation of Iterator - * - ********************************************************/ - - /** - * implementation of Iterator::current() - * - * @return Tune - */ - public function current () - { - return $this->collection[$this->position]; - } - - /** - * implementation of Iterator::key() - * - * @return Scalar the current index - */ - public function key () - { - return $this->position; - } - - /** - * implementation of Iterator::next() - * - * sets the position to the next index - */ - public function next () - { - ++$this->position; - } - - /** - * implementation of Iterator::rewind() - * - * sets the position to the beginning of the collection - */ - public function rewind () - { - $this->position = 0; - } - - /** - * implementation of Iterator::valid() - * - * tests that there is a tune at the current position - * @return boolean - */ - public function valid () - { - $is_valid = isset($this->collection[$this->position]); - if(! $is_valid) { $this->rewind(); } - return $is_valid; - } - - - -} diff --git a/src/Models/Memory/BaseObject.php b/src/Models/Memory/BaseObject.php deleted file mode 100644 index f60725d..0000000 --- a/src/Models/Memory/BaseObject.php +++ /dev/null @@ -1,34 +0,0 @@ -change_hash = $this->generate_hash(); - } - - public static function propertyNames() - { - return static::propertyNames; - } - - protected abstract function generate_hash(); - -} diff --git a/src/Models/Memory/Person.php b/src/Models/Memory/Person.php deleted file mode 100644 index d189ff4..0000000 --- a/src/Models/Memory/Person.php +++ /dev/null @@ -1,130 +0,0 @@ -$val) - { - $this->set($key, $val); - } - - $this->change_hash = $this->generate_hash(); - } - - /** - * magic setter - * just passes to regular set method which contains validation - */ - public function __set($key, $value) - { - $this->set($key, $value); - } - - public function set($key, $value) - { - $retVar = FALSE; - switch($key) - { - case 'person_id' : - if( $this->person_id === 0 && is_numeric($value) && intval($value) > 0 ) - { - $this->{$key} = intval($value); - $retVar = TRUE; - } - break; - - case 'name': - if(is_string($value) && ! is_null($value)) - { - $this->{$key} = $value; - $retVar = TRUE; - } - break; - case 'email': - if(filter_var($value, FILTER_VALIDATE_EMAIL)) { - $this->{$key} = $value; - $retVar = TRUE; - } - break; - default: - } - - return $retVar; - } - - public function get($key) - { - if ( is_string($key) && isset($this->$key) ) - { - return $this->$key; - } - return FALSE; - } - - /** - * set default values for the person - * used when creating a new person from scratch - */ - // public function init() - // { - // $this->change_hash = $this->generate_hash(); - // } - - /** - * Test if the data has changed - * - * @return (bool) True if the data has changed since last load/save - */ - public function is_changed() - { - return $this->change_hash !== $this->generate_hash(); - } - - /******************************************************** - * - * Private functions - * - ********************************************************/ - - /** - * generate hash for the whole person object - * - * @returns (string) md5 hash of all attributes - */ - protected function generate_hash() - { - $data = array( - $this->person_id, - $this->name, - $this->email - ); - - return md5(serialize($data)); - } - - - - - - /******************************************************** - * - * Static functions - * - ********************************************************/ - - -} diff --git a/src/Models/Memory/Setting.php b/src/Models/Memory/Setting.php deleted file mode 100644 index 87be30f..0000000 --- a/src/Models/Memory/Setting.php +++ /dev/null @@ -1,281 +0,0 @@ - 'Transcriber', - 'N' => 'Notes', - 'D' => 'Discography', - 'S' => 'Source', - 'W' => 'Words,', - 'B' => 'Book', - 'F' => 'Filename', - 'P' => 'Parts', - 'Q' => 'Tempo,', - 'L' => 'default note length', - 'M' => 'Meter', - 'K' => 'Key', - ); - - /** - * Tune constructor - * - * @param $params (array) list of parameters to set at initialization - */ - function __construct(array $params = array()) { - //Init parameters - foreach($params as $key=>$val) - { - $this->set($key, $val); - } - - $this->change_hash = $this->generate_hash(); - } - - - /******************************************************** - * - * public functions - * - ********************************************************/ - - /** - * get the value of a private property - * - * @return (mixed) value of the property or FALSE if property does not exist - */ - public function get($property) - { - if(isset($this->{$property})) { return $this->{$property}; } - return FALSE; - } - - - /** - * magic setter - * just passes to regular set method which contains validation - */ - public function __set($key, $value) - { - $this->set($key, $value); - } - - /** - * set new value for a property - * overwrites the existing value - * - * @return (boolean) TRUE on success, FALSE otherwise - */ - public function set($property, $value) - { - $retVar = FALSE; - - switch($property) - { - case 'settingID': - if($this->settingID !== 0) { // if settingID is not 0 don't allow setting it - $retVar = FALSE; - break; - } - //follow through since this is also a numeric value - case 'tuneID': - if(is_numeric($value) && $value > 0) - { - $this->{$property} = (int)$value; - $retVar = TRUE; - } - break; - - case 'Q': - case 'L': - case 'M': - if ( ! Setting::validate_line($property, $value) ) { return FALSE; } - case 'K': - case 'P': - case 'music': - if( ! is_array($value) && ! is_int($value) ) - { - $this->{$property} = $value; - $retVar = TRUE; - } - break; - - case 'Z': - if( is_array($value) && count($value) > 0) - { - $contains_only = TRUE; - foreach($value as $person) - { - if(! is_a($person, __NAMESPACE__."\Person")) - { - $contains_only = FALSE; - break; - } - } - - if( $contains_only ) - { - $this->{$property} = $value; - $retVar = TRUE; - } - } - break; - - case 'F': - case 'N': - case 'D': - case 'S': - case 'W': - case 'B': - if( is_array($value) ) - { - $this->{$property} = $value; - $retVar = TRUE; - } - break; - - default: // non-existant or non-editable property - break; - } - - return $retVar; - } - - /** - * append a value to a property's array - * - * @param (string) $property name - * @param (mixed) $value to add to the array - * - * @return (Boolean) TRUE on success, FALSE otherwise - */ public function append($property, $value) - { - if( ! is_array($value) ) - { - switch($property) - { - case 'Z': - if( ! is_a($value, __NAMESPACE__."\Person") ) { - break; - } - case 'N': - case 'D': - case 'S': - case 'W': - case 'B': - case 'F': - $this->{$property}[] = $value; - return TRUE; - break; - - default: - $this->set($property, $value); - } - } - return FALSE; - } - - /** - * Test if the data has changed - * - * @return (bool) True if the data has changed since last load/save - */ - public function is_changed() - { - return $this->change_hash !== $this->generate_hash(); - } - - // public function init() - // { - // $this->change_hash = $this->generate_hash(); - // } - - - /******************************************************** - * - * Private functions - * - ********************************************************/ - - - /** - * generate hash for the whole person object - * - * @returns (string) md5 hash of all attributes - */ - protected function generate_hash() - { - $data = array( - $this->tuneID, - $this->settingID, - //TODO: take into account the transcribers - //$this->Z, - $this->N, - $this->D, - $this->S, - $this->W, - $this->B, - $this->F, - $this->P, - $this->Q, - $this->L, - $this->M, - $this->K, - $this->music, - ); - - return md5(serialize($data)); - } - - /******************************************************** - * - * Static functions - * - ********************************************************/ - - - - protected static function validate_line($key, $data) - { - $result = TRUE; - if(isset(Setting::${"regex_$key"})) - { - $regex = Setting::${"regex_$key"}; - $result = preg_match($regex, serialize($data)); - } - - return $result; - } - - -} diff --git a/src/Models/Memory/Tune.php b/src/Models/Memory/Tune.php deleted file mode 100644 index 72a9acb..0000000 --- a/src/Models/Memory/Tune.php +++ /dev/null @@ -1,254 +0,0 @@ - 'id', - 'T' => 'Title', - 'A' => 'Author', - 'C' => 'Composer', - 'G' => 'Group,', - 'H' => 'History', - 'O' => 'Origin', - 'R' => 'Rhythm', - ); - - /** - * Tune constructor - * - * @param $params (array) list of parameters to set at initialization - */ - function __construct(array $params = array()) { - //Init parameters - foreach($params as $key=>$val) - { - $this->set($key, $val); - } - - $this->change_hash = $this->generate_hash(); - } - - - /******************************************************** - * - * public functions - * - ********************************************************/ - - /** - * get the value of a private property - * - * @return (mixed) value of the property or FALSE if property does not exist - */ - public function get($property) - { - if(isset($this->{$property})) { return $this->{$property}; } - return FALSE; - } - - /** - * magic setter - * just passes to regular set method which contains validation - */ - public function __set($key, $value) - { - $this->set($key, $value); - } - - /** - * set new value for a property - * overwrites the existing value - * - * @return (boolean) TRUE on success, FALSE otherwise - */ - public function set($property, $value) - { - $retVar = FALSE; - - switch($property) - { - case 'tuneID': - if($this->tuneID !== 0) { // if tuneID is not 0 don't allow setting it - $retVar = FALSE; - break; - } - //follow through since this is also a numeric value - case 'X': - if(is_numeric($value) && $value > 0) - { - $this->{$property} = $value; - $retVar = TRUE; - } - break; - - case 'A': - case 'C': - if( is_array($value) && count($value) > 0) - { - $contains_only = TRUE; - foreach($value as $key=>$person) - { - if(! is_a($person, __NAMESPACE__ . '\\' ."Person")) - { - $contains_only = FALSE; - break; - } - } - - if( $contains_only ) - { - $this->{$property} = $value; - $retVar = TRUE; - } - } - break; - - case 'T': - case 'G': - case 'H': - case 'O': - case 'R': - if(is_array($value)) - { - $this->{$property} = $value; - $retVar = TRUE; - } - break; - - case 'collection': - if( is_array($value) && count($value) > 0) - { - $only_settings = TRUE; - foreach($value as $key=>$setting) - { - if(! is_a($setting, __NAMESPACE__ . '\\' ."Setting")) - { - $only_settings = FALSE; - break; - } - } - - if( $only_settings ) - { - $this->{$property} = $value; - $retVar = TRUE; - } - } - break; - - - default: // non-existant or non-editable property - break; - } - - return $retVar; - } - - /** - * append a value to a property's array - * - * @param (string) $property name - * @param (mixed) $value to add to the array - * - * @return (Boolean) TRUE on success, FALSE otherwise - */ public function append($property, $value) - { - if( ! is_array($value) ) - { - switch($property) - { - case 'T': - case 'A': - case 'C': - case 'G': - case 'H': - case 'O': - case 'R': - $this->{$property}[] = $value; - return TRUE; - break; - - case 'collection': - if( is_a($value, __NAMESPACE__ . '\\' ."Setting") ) - { - $this->{$property}[] = $value; - return TRUE; - } - break; - - default: - $this->set($property, $value); - break; - } - } - return FALSE; - } - - - /** - * Test if the data has changed - * - * @return (bool) True if the data has changed since last load/save - */ - public function is_changed() - { - return $this->change_hash !== $this->generate_hash(); - } - - /******************************************************** - * - * Private functions - * - ********************************************************/ - - - /** - * generate hash for the whole person object - * - * @returns (string) md5 hash of all attributes - */ - protected function generate_hash() - { - $data = array( - $this->tuneID, - $this->X, - $this->T, - // $this->A, - // $this->C, - $this->G, - $this->H, - $this->O, - $this->R, - // $this->collection, - ); - - return md5(serialize($data)); - } - - /******************************************************** - * - * Static functions - * - ********************************************************/ - - - -} diff --git a/src/Models/Memory/TuneCollection.php b/src/Models/Memory/TuneCollection.php deleted file mode 100644 index 3621cef..0000000 --- a/src/Models/Memory/TuneCollection.php +++ /dev/null @@ -1,316 +0,0 @@ -collection[] = $tune; - } - - /** - * pop last tune from the end of the collection - * - * @return Tune - */ - public function pop() - { - return array_pop($this->collection); - } - - - /** - * magic setter - * just passes to regular set method which contains validation - */ - public function __set($key, $value) - { - $this->set($key, $value); - } - - /** - * set new value for a property - * overwrites the existing value - * - * @return (boolean) TRUE on success, FALSE otherwise - */ - public function set($property, $value) - { - $retVar = FALSE; - - switch($property) - { - case 'change_hash': - $this->generate_hash(); - break; - - case 'tc_id': - if($this->tc_id !== 0) { // if tc_ID is not 0 don't allow setting it - $retVar = FALSE; - break; - } - - if(is_numeric($value) && $value > 0) - { - $this->{$property} = $value; - $retVar = TRUE; - } - break; - - case 'A': - case 'C': - case 'Z': - if( is_array($value) && count($value) > 0) - { - $contains_only = TRUE; - foreach($value as $key=>$person) - { - if(! is_a($person, __NAMESPACE__ . '\\' ."Person")) - { - $contains_only = FALSE; - break; - } - } - - if( $contains_only ) - { - $this->{$property} = $value; - $retVar = TRUE; - } - } - break; - - case 'B': - case 'D': - case 'F': - case 'H': - case 'N': - case 'O': - case 'S': - if(is_array($value)) - { - $this->{$property} = $value; - $retVar = TRUE; - } - break; - - case 'collection': - if( is_array($value) && count($value) > 0) - { - $contains_only_tunes = TRUE; - foreach($value as $key=>$tune) - { - if(! is_a($tune, __NAMESPACE__ . '\\' ."Tune")) - { - $contains_only_tunes = FALSE; - break; - } - } - - if( $contains_only_tunes ) - { - $this->{$property} = $value; - $retVar = TRUE; - } - } - break; - - case 'L' : - case 'M' : - case 'R' : - if(is_numeric($value)) { break; } - case 'cOwner' : - if(! is_array($value) ) - { - $this->{$property} = $value; - $retVar = TRUE; - } - break; - - default: // non-existant or non-editable property - break; - } - - return $retVar; - } - - /** - * append a value to a property's array - * - * @param (string) $property name - * @param (mixed) $value to add to the array - * - * @return (Boolean) TRUE on success, FALSE otherwise - */ - public function append($property, $value) - { - switch($property) - { - case 'A': - case 'C': - case 'Z': - if(! is_a($value, __NAMESPACE__ . '\\' .'Person')) { break; } - //Fall through if we pass the check - case 'B': - case 'D': - case 'F': - case 'H': - case 'N': - case 'O': - case 'S': - $this->{$property}[] = $value; - return TRUE; - break; - - case 'collection': - if( is_a($value, __NAMESPACE__."\Tune") ) - { - $this->{$property}[] = $value; - return TRUE; - } - break; - - default: - return $this->set($property, $value); - break; - } - return FALSE; - } - - /** - * get the value of a private property - * - * @return (mixed) value of the property or FALSE if property does not exist - */ - public function get($property) - { - if(isset($this->{$property})) { return $this->{$property}; } - return FALSE; - } - - - - /******************************************************** - * - * private functions - * - ********************************************************/ - - /** - * generate hash for the whole person object - * - * @returns (string) md5 hash of all attributes - */ - protected function generate_hash() - { - $data = array( - $this->tc_id, - $this->cOwner, - $this->A, - $this->B, - $this->C, - $this->D, - $this->F, - $this->H, - $this->L, - $this->M, - $this->N, - $this->O, - $this->R, - $this->S, - $this->Z, - // $this->collection, - ); - - return md5(serialize($data)); - } - - /** - * Get the unique identity for this mode. - * - * @return int - */ - public function identity() - { - //TODO: - } - - /** - * Checks whether this model has the given attribute set. - * - * @param string $attribute - * - * @return boolean - */ - public function has($attribute) - { - //TODO: - } - -// /** -// * Get the value associated with the given attribute. -// * -// * @param string $attribute -// * -// * @return mixed -// */ -// public function get($attribute) -// { -// //TODO: -// } - - /** - * Get all the attributes associated with this model. - * - * @return array - */ - public function getAll() - { - //TODO: - } -} diff --git a/src/Parser.php b/src/Parser.php deleted file mode 100644 index 519f584..0000000 --- a/src/Parser.php +++ /dev/null @@ -1,150 +0,0 @@ -builder = $builder; - } - - /** - * extract the attributes from the raw abc - * @param $abc string containing the raw abc - * - * @return - */ - public function parseABC($abc) - { - //tune is either new or existing data has been loaded - //create new setting - $mode = self::MODE_FILE_HEADER; - $this->builder->newCollection(); - $tune = null; - $setting = null; - $inHistory = false; - $inTunes = false; - $music = ""; - $keys_for_Settings = '/K|L|M|P|Q|B|N|D|S|W|Z|F/'; - $keys_for_Tunes = '/H|A|C|G|R|T|O/'; - //scan abc by line and see what the first char is - foreach (preg_split("/(\r?\n)/", $abc) as $line) { - - if (preg_match(self::LN_BLANK, $line)) { - if ($mode === self::MODE_TUNE_BODY || $mode === self::MODE_TUNE_HEADER) { - $this->builder->storeTune($music); - $music = ''; - } - - $mode = self::MODE_NO_DATA; - } elseif ($mode === self::MODE_TUNE_BODY) { - $music .= $line . PHP_EOL; - } elseif (preg_match(self::LN_VERSION, $line)) { - //this line might contain the abc version. - //What do we want to do with it? - } elseif (preg_match(self::LN_FIELD, $line) || $inHistory) { - if (preg_match(self::LN_FIELD, $line)) { $inHistory = FALSE; } - //split the line "key:data" - if($inHistory) { - $key = 'H'; - $data = $line; - } else { - $key = substr($line, 0, 1); - $data = trim(substr($line, 2)); - } - - if ($key === 'X') { - $mode = self::MODE_TUNE_HEADER; - $inTunes = true; - $this->builder->newTune(); - $this->builder->newSetting(); - $music = ''; - - $this->builder->setOnTune('X', $data); - - } elseif (preg_match($keys_for_Tunes, $key)) { - if ($key === 'H') { - $inHistory = TRUE; - } else { - $inHistory = FALSE; - } - if ($key === 'A' || $key === 'C') { - $data = $this->builder->newPerson(['name'=>$data]); - } - if ($mode === self::MODE_FILE_HEADER) { - if (in_array($key, self::SINGLE_VALUE_KEYS)) { - $this->builder->setOnCollection($key, $data); - } else { - $this->builder->appendToCollection($key, $data); - } - } elseif($inTunes) { - if (in_array($key, self::SINGLE_VALUE_KEYS)) { - $this->builder->setOnTune($key, $data); - } else { - $this->builder->appendToTune($key, $data); - } - } - - } elseif (preg_match($keys_for_Settings, $key)) { - if ($key === 'K' && $mode === self::MODE_TUNE_HEADER) { - $mode = self::MODE_TUNE_BODY; - } - - if ($key === 'Z') { - $data = $this->builder->newPerson(['name'=>$data]); - } - - - if ($mode == self::MODE_FILE_HEADER) { - if (in_array($key, self::SINGLE_VALUE_KEYS)) { - $this->builder->setOnCollection($key, $data); - } else { - $this->builder->appendToCollection($key, $data); - } - } elseif($inTunes){ - if (in_array($key, self::SINGLE_VALUE_KEYS)) { - $this->builder->setOnSetting($key, $data); - } else { - $this->builder->appendToSetting($key, $data); - } - } - } - - } - } - - return $this->builder->getCollection(); - } - -// private static function _storeTune($music, &$setting, &$tune, &$tuneCollection) { -// $setting -> set('music', trim($music)); -// $tune -> append('collection', $setting); -// $tuneCollection -> append('collection', $tune); -// } - -} diff --git a/tests/_data/abc/jigs.abc b/tests/_data/abc/jigs.abc index 1cd987a..071e46d 100644 --- a/tests/_data/abc/jigs.abc +++ b/tests/_data/abc/jigs.abc @@ -1,684 +1,684 @@ -%abc -%%abc-alias Jigs I Play -%%abc-creator ABCexplorer 1.3.7 [2010-06-20] -% Richard's Tune Book -% jigs.abc -%% to add -% ships in full sail - -X:14 -T:Emmett's Hedgehog -Z:robin.beech@mcgill.ca -R:jig -S:Niall Vallely - Beyond Words -M:6/8 -L:1/8 -K:Ador -A2e edB | A2A AGE | A2A AGE | GAG DEG | -A2e edB | A2A AGE | GAG DEG | BAG AEG :| -e2a ged | c2B BAG | B2B BAG | g2f edB | -e2a ged | c2B BAG | Bgf edB | EFG ABd :| - -X:21 -T: North Star, The -D: Flook - Rubai - Track 2 -C: Brian Finnegan -M: 6/8 -L: 1/8 -R: jig -K:Gmaj -G2D G B/2c/2d|cBG dBG|~E3 dBG|F2d cde| -G2D G B/2c/2d|cBG dBG|EGd ~F2d|1~G3 dBA:|2~G3 GAB|| -G2F G2d|ABF G2D|EFG Adc-|cBG ADB| -G2F G2d|ABF G2D|EFG ADF|G2B DAD| -G2F G2d|ABF G2D|EFG Adc-|cBG ADB| -G2F G2d|dcB G2D|EFG ADF|G2z dBA|| - -X:22 -T: Ghost Of Ballybrolly, The -D: Flook - Rubai - Track 2 -M: 6/8 -L: 1/8 -R: jig -K:Emin -ABB eze-|edB A3-|AGE ~G2B|E B/2c/2d edB| -~B3 eBe|edB ~A3|AGE ~G3|AED E2z| -ABB eBe|edB ~A3|AGE ~G2B|E B/2c/2d ~e3| -ged BAB|edB A2A|AGE ~G3|AED E2z| -cG ~E3 c|BGA E2d|AFD DEF|GAB dBe| -cG ~E3 c|BGA E2d|AFD DEF|~E3 FGA| -cG ~E3 c|BGA E2d|AFD DEF|GAB dBe-| -edB e2g|deB- Bed|BAA ABd|ez2 g3| - -X:1 -T:The Coming Of Spring -C:Paddy O'Brien -M:6/8 -L:1/8 -R:jig -K:Edor -|: BEE B2 A | (3Bcd B BAG | F3 DFA | dfe dBA | -BEE B2 A | Bef gfe | dBG FGA |1 BGE Ed=c :|2 BGE E2 F |: -GEF G2 A | B2 A Bec | dAA BAG | (3FGA F DEF | -GFE FGA | Bef gfe | dBG FGA |1 BEE E2 F :|2 BEE Eef || -g3 efe | Beg bag | f2 d dcd | AFA def | -g2 e efe | Beg bag | fed (3fga f | ge^d e2 f | -g2 e efe | Beg bag | f2 d dcd | AFA def | -g2 e fed | Bec dfe | dBG FGA | BGE Ed=c |] - -X:23 -T:The Dusty Windowsill -T:Austin Barratts -C:Sean Harling -R:jig -M:6/8 -L:1/8 -K:Ador -A2B cBA | eAB cBA | G3 EGG | DGG EGG | A2B cBA | e2d efg | -age dBe |1 ABA A2G :|2 ABA A2g |: aga bge| def g2f | g3 gfe | dBA G3 | -EGG DGG | EGG ABc | Bed BAG |1 BAG A2g :|2 BAG A2G |: A3 gAf | -A3 edB | G3 eGd | G3 edB | A3 gAf | ABA efg | age dBe | ABA A2G :| - -X:1 -T:Banish Misfortune -R:jig -M:6/8 -L:1/8 -K:Dmix -fed cAG | A2d cAG | F2F DED| F2F GFG | -A3 cAG | AGA cde | fed cAG | Ad^c d2e :| -|:f2d d^cd | f2g agf | e2c cBc | e2f gfe | -f2g agf | e2f gfe | fed cAG | Ad^c d2e :| -|:f2g e2f | d2e c2d | ABA GAG | FGE FED | -c3 cAG | AGA cde | fed cAG | Ad^c d2e :| - -X:2 -T:Banshee's Wail -C:Vincent Broderick -R:jig -M:6/8 -L:1/8 -K:G -GED DED | GBd ege | dBA AGA | BGE E2A | -GED DED | GBd ege | dBA AGA | BGF G2A :| -Bdd edd | gdd edB | BAG GAB | AGE E2G | -Bdd edd | gdd edB | BAG GAB | AGF G3 | -Bdd edd | gdd edB | BAG GAB | AGE E2A | -GED DED | GBd ege | dBA AGA | BGF G3 |] - -X:3 -T:The Battering Ram -R:jig -M:6/8 -L:1/8 -K:G -B | dBG BAG | dBG G2B | dBG AGE | GED D2B | dBG BAG | BdB BAG | -AGA BAB | GED D2 :: B | deg aga | bge edB | deg aga | bge ega | -bag age | ged ege | dBG AGE | GED D2 :: d/c/ | B2G A2G | B2D Ddc | -B2G AGE | GED Ddc | B2G A2G | BdB BAG | AGA BAB | GED D2 :| - -X:198 -T:Bending the Ferret -C:Doug Eunson -Z:Steve Beech 23/04/2008 -R:Jig -M:6/8 -L:1/8 -K:G -|: G2B ABA | GBd g2d | edc BAG |1 A2c cBA :|2 A2F G3 :| -|:e2e dcB | ABc dcd | e2e dcB | ABc def | -g2d BAG| ABc ABc | B2B cAF | G6:| - -X:5 -T:Blackthorne Stick -R:jig -M:6/8 -L:1/8 -K:G -d | gfg ege | dBG AGE | DGG FGA | BAG A2d | -gfg age | dBG AGE | DGG FGA | BGG G2 :| -|:d | edd gdd | edd gdd | ede gfe | dcB A2d | -gfg age | dBG AGE | DGG FGA | BGG G2 :| - -X:6 -T:The Blarney Pilgrim -Z:Transcribed by Frank Nordberg - http://www.musicaviva.com -R:jig -B:Francis O'Neill:"The Dance Music of Ireland" (1907) no. 291 -M:6/8 -L:1/8 -K:G -DED DEG | A2G ABc | BAG AGE | GEA GED | DED DEG | A2G ABc | -BAG AGE | GED D2z :: ded dBG | AGA BGE | ded dBG | AGA G3 | -g2e dBG | AGA BGE | B2G AGE | GED D2z :: A2D B2D | A2D ABc | -BAG AGE | GEA GED | A2D B2D | A2D ABc | BAG AGE | GED D2z :| - -X:10 -T:Butlers of Glen Avenue -C:Tom Sullivan -Z:Philippe Murphy -R:jig -N:Title changed from Christy Barry's number 2. Thanks to Stephen Rapp -M:6/8 -L:1/8 -K:G -DEG EDB | DEG B3 | DEG B2e | dBe dBA | -DEG EDB | DEG B3 | d (3B^cd gfe |1 dBA G3 :|2 dba g3 |: -gab age | deg B3 | gab gab | d (3B^cd e2d | -gab age | deg B3 | d (3B^cd gfe |1 dba g3 :|2 dBA G3 || - -X:176 -T:Calliope House -C:D Richardson -Z:John Chambers -R:jig -N:Calliope House is a folk center in Pittsburgh. -M:6/8 -L:1/8 -K:D -A | dAA fAA | eAA fAA | Bee e2d | efd BdB | -ABA A2F | A2B d2e |1 faf fed | e3- ez :|2 faf edB | d3- d |: -fg | a3 faa | eaa daa | g3 fgf | efe edB | -ABA A2F | A2B d2e |1 faf fed | e3- e :|2 faf edB | d3- d |] - -X:11 -T:Charlie Hunter -T:Charlie Stuart's Jig -C:Bobby MacLeod -Z:Nigel Gatherer -R:jig -S:Bobby MacLeod's Selection of Country Dance Tunes -M:6/8 -L:1/8 -K:D -DFA DGB | Adf a2g | fed Bcd | ecA GFE | -DFA DGB | Adf a2g | fef gec |1 edc d2A :|2 edc dfg |: -afd dcd | BGF G2F | E^GB e2d | cAA Aag | -fdA FDF | GBd g2g | fef gec |1 edc dfg :|2 edc d3 |] - -X:12 -T:Christy Barry's No. 1 -C:Christy Barry -Z:Philippe Murphy 2006-02-28 -R:jig -M:6/8 -L:1/8 -K:G -G3 BAG | AAB d2e | ged BGG | A3 BGE | -DGG BGG | AAB d2e | ged BGG |1 AGF G2D :|2 AGF G (3B^cd |: -g3 gfg | aag d2e | ged BGG | A3 BGE | -DGG BGG | AAB d2e | ged BGG |1 AGF G (3B^cd :|2 AGF G2D |] - -X:179 -T:Jim Ward's -T:Ciaran's Capers -Z:robin.beech@mcgill.ca -R:jig -S:Simon Granger -M:6/8 -L:1/8 -K:Amix -ed | c2A ABA |dcd e3 | Ace efg | BGB dcB | -cBA ABA | dcd e3 | Ace dde | A3 A :: -fg | agf gfe | fed ecA | def gfg | B2B Bfg | -agf gfe | fed ecA | Ace dde | A3 A :| - -X:13 -T:The Clare Jig -R:jig -M:6/8 -L:1/8 -K:Em -G3G2B | AGE GED | G3 AGE | GED D2E | -G3G2B | AGE GAB | c2A BGE |1 DED D3 :|2 DED D2B |: -c2A B2A | AGE GAB | cBA BGE | DED D2B | -c2A B2A | AGE GAB | c2A BGE |1 DED D2B :|2 DED D3 |] - -X:14 -T:The Cliffs of Moher -R:jig -M:6/8 -L:1/8 -K:Ador -aga bag | eaf ged | c2A BAG | EAF GED | aga bag | eaf ged | -c2A BAG | EFG A3 :| e2e dBA | e=fe dBA | GAB dBA | GAB dBd | -e2e dBA | e=fe dBA | GAB dBA | BAG A3 | e=fe dBA | e=fe dBA | -GAB dBA | GAB dBd | e2e dee | cee Bee | GAB dBA | EFG A3 |] - -X:148 -T:Condon's Frolics -R:jig -M:6/8 -L:1/8 -K:Ador -eAB c2d | edc Bcd | eAB c2d | e2d eag | -eAB c2d | edc AB2 | GBd gdB |1 A3 a2g :|2 A3 AB/c/d |: -eaa efg | dec BAG | cGe d2d | e2d efg | -eaa efg | dec BAB | GBd gdB |1 A3 AB/c/d :|2 A3 a2g |] - -X:15 -T:Connaught-Man's Ramble -Z:Contributed by Ray Davies, ray(at)davies99.freeserve.co.uk -R:jig -B:Ryan's Mammoth Collection -M:6/8 -L:1/8 -K:D -A/G/ | FAA dAA | BAB dAG | FAA dfe | dBB BAG | -FAA dAA | BAB def | gfe dfe | dBB B2 :| -|:g | fbb faa | fed deg | fbb faa | fed e2g | -fbb faa | fed def | gfe dfe | dBB B2 :| - -X:16 -T:Cook In the Kitchen -R:jig -M:6/8 -L:1/8 -K:G -DGG GAG | FDE F3 | DGG GFG | Add cAG | -DGG GAG | FDE =F2d | cAG FGA |1 BGF G3 :|2 BGF G2A |: -B3 BAG | A3 AGF | G3 GFG | Add cAG | -B3 BAG | A3 A2d | cAG FGA |1 BGF G2A :|2 BGF G3 |: -d2e f2g | a2g fed | cAG FGA | B3 cAG | -d2e f2g | a2g fed | cAG FGA | BGF G3 :| - -X:18 -T:Dingle Regatta -R:jig -M:6/8 -L:1/8 -K:D -dcd e2d | BAB d2B | ABA AGA | B2A G3 | dcd e2d | BAB d2B | -ABA B2A | G3- G3 :: d3 def | g3 gfg | a3 aga | b2a gfe | d3 def | -g3 gab | a2g f2e | def g3 :: gfg dgd | BdB GBG | FAF DEF| -GAB def | gfg dgd | BdB GBG | FAF DEF | G3 G3 :| - -X:19 -T:Doctor O'Neill -Z:Frank Nordberg - http://www.musicaviva.com -R:jig -B:Francis O'Neill:"The Dance Music of Ireland" (1907) no. 6 -M:6/8 -L:1/8 -K:D -A | d3 AFD | E2F G2A | BGB Bcd | AGF EFA | d3 AFD | E2F G2A | -BGB Bcd | AFD D2 :: A | d3 ceA | dfe dcB | AFA Bcd | AGF EFA | -d3 ceA | dfe dcB | AFA Bcd | AFD D2 :: g | fef afd | ded fed | -gbg faf | gee e2g | fef afd | ded fed | gbg fag | fdd d2 :| -|:g | fdf ece | dcB AFA | AFd AFd | AGF E2g | fdf ece | dcB AFA | -AFA Bcd | AFD D2 :: G | FAF GBG | FAG FED | FAF GBG | -AGF E2G | FAF GBG | FAG FED | BGB Bcd | AFD D2 :| - -X:20 -T:The Donegal Lass -C:Brian Finnegan -R:jig -D:Brian Finnegan - When the Party's Over -M:6/8 -L:1/8 -K:Amix -Ace aed | cdB A3 | GBd G3 | FAd F3 | Ace aed | cdB A2^g | aed cdB | A3 A3 :| -|:GBd G3 | FAd F3 | e3 ecA | e3 ecA | GBd G3 | FAd F2^g | aed cdB | A3 A3 :| - -X:136 -T:Emmett's Hedgehog -Z:robin.beech@mcgill.ca -R:jig -S:Niall Vallely - Beyond Words -M:6/8 -L:1/8 -K:Ador -A2e edB | A2A AGE | A2A AGE | GAG DEG | -A2e edB | A2A AGE | GAG DEG | BAG AEG :| -|:e2a ged | c2B BAG | B2B BAG | g2f edB | -e2a ged | c2B BAG | Bgf edB | EFG ABd :| - -X:200 -T:The False Proof -C:Jowan Merckx -R:jig -S:rubai (flook) -M:6/8 -L:1/8 -K:Bmin -|: Bdf fef | fed c2f | edc B2B | ABd cAF | -GBd f2a | fed c2f | edc B2A | BcA B3 :: -zdc BcA | GFE F2E- | EDE G2E- |EFG dcA | -Bdc BcA | GFE F2E- | EFG e2d | cBA B3 :| -|:BdB fBg | Bag fed | e2d c2f | ede edB | -BAB fBg | Baf bz2 | bag fag |1 fed ecA :|2 fed e2d |] - -X:26 -T:Father O'Flynn -T:Top of the Cork Road -R:jig -S:Gerry Strong -M:6/8 -L:1/8 -K:D -A | dAF DFA | ded cBA | dcd efg | fed cBA | -dAF DFA | ded cBA | dcd efg | fdd d2 :| -|:g | fdf fga | ecA ABc | dcd Bed | cAA A2c | -BGB Bcd | AFD DFA | dcd efg | fdd d2 :| - -X:27 -T:The Frost Is All Over -T:The Mist Of Clonmel -R:jig -M:6/8 -L:1/8 -K:D -A | def edB | AFD E2 D | FAA AFA | Bee edB | -def edB | AFD E2 D | FAA AFA | Bdc d2 :| -|:e | f3 afd | g3 bag | f3 afd | gfg efg | -f3 afd | g3 bag | fga efg | fdc d2 :| - -X:36 -T:Hag At the Churn -R:jig -M:6/8 -L:1/8 -K:G -A2G ADD | A2G Adc | A2G ADD | EFG EFG | A2G ADD | -A2G Adc | A2G ADD | EFG EFG |AdB c3 | Add efg | -AdB c2A | GEG AED | AdB c3 | Add efg | age dcA | GEG AED |] - -X:37 -T:The Halloween Jig -C:Jean Duval -Z:robin.beech@mcgill.ca -R:jig -M:6/8 -L:1/8 -K:D -F |: B2B Bcd | c2A ABc | B2G GAB | A2F FEF | B2B Bcd | c2A ABc | -def edc |1 B3 BAF :|2 B3 Bde |: f2f fed | cde Adc | Bcd dcB | -cFF Fde | f2f fed | cde Adc | Bcd cBA |1 B3 Bde :|2 B3 B3 |] - -X:38 -T:Hammy Hamilton's -R:jig -M:6/8 -L:1/8 -K:G -B | dBG cGE | DED GFG | BAB dBG | dcB ABc | dBG cGE | DED GFG | BAB dcA | -AGF G2 :: B | dBG ecA | fef gfg | ege dBG | dcB ABc |1 dBG ecA | fef gfg | -ege dcA | AGF G2 :|2 dBG cGE | DED GFG | BAB dcA | AGF G2 |] - -X:39 -T:Haste To the Wedding -R:jig -M:6/8 -L:1/8 -K:D -AFA Agf | ede fdB | AFA AGF | GFG EFG | -AFA Agf | ede fdB | A2a faf | ded d3 :| -|:afa afa | bgb bgb | afa agf | gfg efg | -a3 f3 | ede fdB | A2a faf | ded d3 :| - -X:40 -T:Haunted House -C:Vincent Broderick -R:jig -M:6/8 -L:1/8 -K:G -G3 AGA | BGE EDE | GBd egd | ege edB | -G3 AGA | BGE EDE | GBd ege | dBA G2D :| -GBd egd | ege edB | GBd ded | ded dBA | -GBd egd | ege edB | GBd ege | dBA G2D | -GBd egd | ege edB | GBd ded | ded dBA | -G3 AGA | BGE EDE | GBd ege | dBA G3 |] - -X:43 -T:Humours of Ballyloughlin -R:jig -M:6/8 -L:1/8 -K:Dmix -A | A3 AGE | GED EDE | c3 cAd | dcA AGE | -A3 AGE | GEG cGE | DED DFA | DED D2 :| -|:B | c3 cAB | cAG ABc | d3 ded | dAF DFA | -c2A d2B | cAG FGE | DED DFA | DED D2 :| -|:e | f2d ged | f2d ged | cde ged | cde ged | -f2d ged | f2d ged | cde gag | ed^c d2 :| -|:B | A3 ABG | F3 GED | E3 EFD | EFD EFG | -A3 dAG | F3 GEA | DED DFA | DED D2 :| - -X:44 -T:Humours of Ennistymon -Z:robin.beech@mcgill.ca -R:jig -M:6/8 -L:1/8 -K:G -BAB GBd | cBc ABc | BcB GBd | cAG FGA | -B2B GBd | cBc ABc | ded cAF | AGF G3 :| -|:fgf fed | cAG FGA | Bgg gfg | afd d2 e | -fgf fed | cAG FGA | BdB cAF | AGF GBd :| -|:gdB gdB | ecA ecA | BcB GBd | cAG FGA |1 -gdB gdB | ecA ecA | BAB cAF| AGF G3 :|2 -BAB GBd | cBc ABc | ded cAF | AGF G3 |] - -X:46 -T:Indian Point -C:Rick Mohr -Z:Kevin Alewine at kalewine:HOME.COM irtrad-l 2001-5-15 -R:jig -M:6/8 -L:1/8 -K:Em -B,EF G2A | BAG FED | CEF G2A | BAG BAG | FED A,2D | -FED AGF |1 EFG BAG | F2F GFE :|2 BAG FEF | E3 E2A |: -Bef gfe | cef gfe | dfg agf | gfe fed | Bef gfe | -ceg a2a |1 bag fef | e2f gfe :|2 bag fef | e3 ez2 |] - -X:47 -T:Ingonish -R:jig -M:6/8 -L:1/8 -K:Edor -Bee efg | fef dBA | Bee efg | fdc d3 | -Bee efg | fef dBA | BdB AFD | EFE E3 :| -|:BEE BEE | FEF DFA | BEE BEE | ABc dcd | -BEE BEE | FEF D2A | BdB AFD | EFE E3 :| - -X:48 -T:Irish Washerwoman -R:jig -M:6/8 -L:1/8 -K:G -dc | BGG DGG | BGB dcB | cAA EAA | cBc edc | -BGG DGG | BGB dcB | cBc Adc |1 BGG G :|2 BGG G2 |: -g | gdg gdg | gdg bag | fdf fdf | fdf agf | -egg dgg | cgg Bgg | cBc Adc |1 BGG G2 :|2 BGG G |] - -X:8 -T:I Buried my Wife and Danced on her Grave -R:jig -M:6/8 -L:1/8 -K:D -DED F2G | AdB =cAF | G2A BAG | F2F GEA | -DED F2G | AdB =cAF | G2A BAG | AFD D2A :| -|:d2e fed | faf gfe | d2e fed | d=cA d=cA | -d2e fed | faf gfe | d2A BAG | AFD D2A :| - -X:49 -T:The Jig of Slurs -R:jig -N:also known as the "Jug of Slugs" -M:6/8 -L:1/8 -K:D -Add (dcd) | Bdd Add | Bdd Add | Bee (edB) | Add (dcd) | Bdd Add | -Bdd cde |1 fdc d3 :|2 fdc d2 B|: Aff (fef) | aff (fed) | Bee (ede) | -fef (edB) | Aff (fef) | aff (fed) | Bdd cde |1 fdc d2B :|2 fdc d2B/A/ -K:G -|: Ggg (gfg) | age (gdB) | Ggg (gfg) | age (g2 B) | Ggg (gfg) | age (gdB) | -Bee egg |1 fdd e2 B/A/ :|2 fdd e3 |: GBB Bdd | dee (edB) | -GBB Bdd | dee egg | GBB Bdd | dee (edB) | Bee egg | fdd e3 :| - -X:50 -T:Jim Ward's -R:jig -M:6/8 -L:1/8 -K:G -EF | G3 GAB | AGE GED | G3 AGE | GED DEF | -G3 GAB | AGE GAB | cBA BGE |1 DED D :|2 DED D2 |: -B | cBA BAG | A3 AGE | cBA BGE | DED D2B | -cBA BAG | A3 ABc | dcB AGE |1 GED D2 :|2 GED D |] - -X:166 -T:Johnny O'Leary's -Z:robin.beech@mcgill.ca -R:jig -S:John Williams - Steam -M:6/8 -L:1/8 -K:EDor -B3 EGA | B2A BAd | B3EGA | BAG FED | -B3 EGA | B2B BAd | AFD DEF | A2G FED :| -|:g3 fed | edc d2A | B3EGA | BAG FED | -gbg fed | edc d2B | AFD DEF | A2G FED :| -|:DEE EFD | EFD EEE | DEE EFG | BAG FED | -EEE EFD | EFD EEE | AFD DEF | A2G FED :| - -X:1 -T: Gallagher's Frolics -M: 6/8 -L: 1/8 -R: jig -K:Edor -D |: E3 GFE | B3 dBA | BdB BAB | GBG AFD | -E3 GFE | BAB dBA | BAG FAF |1 GEE E2D :|2 GEE E2e |: -e2g gfe | g2b bge | dcd fed | fad fed | -e2f gfe | dfe dBA | BAG FAF |1 GEE E2e :|2 GEE E2D |] - -X:43 -T:Horizonto -C: Paul James -R:jig -M:6/8 -L:1/8 -K:Dmin -ABA GAF | GEF DEC | A,2A, DEF | E2E CDE | -F2F FGF | EDE CDE | FED EDC | A,=B,C D3 :| -B,2B, DEF | B,2B, DEF | A,2A, DEF |A,2A, DEF| -B,2B, DEF | B,2B, DEF | ABA GAF | GEF DEC | -B,2B, DEF | B,2B, DEF | A,2A, DEF | A,2A, DEF | -B,2B, DEF | B,2B, DEF | =B,2B, DEF | =B,2B, DEF | -B2A2GF | E3 EFG | A2G2FE | D3 DEF| -G2F2ED | ^C3 CDE | F2G2^G2 | A3 AGA| -B2c2B2 | E3 EFG | A2B2A2 | D3 DEF| -G2F2ED | ^C3 CDE| F2 D2 C2 | D2 Z4 |] - -X:44 -T:Horizonto -C: Paul James -R:jig -M:6/8 -L:1/8 -K:Bmin -fgf efd | ecd BcA | F2F Bcd | c2c ABc | -d2d ded | cBc ABc | dcB cBA | F^GA B3 :| -G2G Bcd | G2G Bcd | F2F Bcd |F2F Bcd| -G2G Bcd | G2G Bcd | fgf efd | ecd BcA | -G2G Bcd | G2G Bcd | F2F Bcd | F2F Bcd | -G2G Bcd | G2G Bcd | ^G2G Bcd | ^G2G Bcd | -g2f2ed | c3 cde | f2e2dc | B3 Bcd| -e2d2cB | ^A3 ABc | d2e2=f2 | f3 fef| -g2a2g2 | c3 cde | f2g2f2 | B3 Bcd| -e2d2cB | ^A3 ABc| d2 B2 A2 | B2 Z4 |] - -X:45 -T:The False Proof -C:Jowan Merckx -R:jig -S:rubai (flook) -M:6/8 -L:1/8 -K:Bmin -|: Bdf fef | fed c2f | edc B2B | ABd cAF | -GBd f2a | fed c2f | edc B2A | BcA B3 :| -|:zdc BcA | GFE F2E- | EDE G2E- |EFG dcA | -Bdc BcA | GFE F2E- | EFG e2d | cBA B3 :| -|:BdB fBg | Bag fed | e2d c2f | ede edB | -BAB fBg | Baf bz2 | bag fag |1 fed ecA :|2 fed e2d |] - -X:1 -T: Son Ar Rost -M: 12/8 -L: 1/8 -R: slide -K:Ador -|:A2A ABG AGE c2d|cBA B2c A2G EFG| -A2A ABG AGE c2d|cBA GAB A3 A2 E:| -|:A2B d3 cBA G2A|c2B A3 GAB E2D| -EAB d2e cBA G2A|c2B ABG A3 A2 E:| - -X:1 -T: Jig For John -M: 6/8 -L: 1/8 -R: jig -K:Dmaj -|:B | A2f c/d/ef | gec dfa | g2a fed | cBA G2A | -FAd GBd | Ace fdB | ~A3 B/c/de | edc d2 :| -|:c | ~B3 BgB| fBe Bdc | ~A3 fAg | age f2d | -~B3 BgB| fBe Bdc | ~A3 B/c/de | edc d2 :| - -X:1 -T: Mouse In The Kitchen -M: 6/8 -L: 1/8 -R: jig -K:Amaj -|: c3 cde | dcA F2A | E3 ABc | B3 BAB | -c3 cde | dcA F2a | afe fec | cBe Adc :| -|: B3 BAB | c3 cBA | B3 BAB | cea zdc | -B3 BAB | c3 cBA | afe fec | cBe Adc :| - -X:1 -T: John Brady's -M: 6/8 -L: 1/8 -R: jig -K:Edor -|:A|Bed B2G|AFD EFA|Bed B2G|Eag e2d| -eaf g2e|dBA G2A|Bed BAG|Bcd E2:| -|:F|GFG AGA|BAB e2f|gfe fed|Bcd e2f| -gfe fed|BAF DEF|~G3 ~F3|Bcd E2:| - -X:166 -T:Johnny O'Leary's -Z:robin.beech@mcgill.ca -R:jig -S:John Williams - Steam -M:6/8 -L:1/8 -K:EDor -B3 EGA | B2A BAd | B3EGA | BAG FED | -B3 EGA | B2B BAd | AFD DEF | A2G FED :| -|:g3 fed | edc d2A | B3EGA | BAG FED | -gbg fed | edc d2B | AFD DEF | A2G FED :| -|:DEE EFD | EFD EEE | DEE EFG | BAG FED | -EEE EFD | EFD EEE | AFD DEF | A2G FED :| - -X:1 -T: Deirdre Hurley's -M: 6/8 -L: 1/8 -R: jig -K:Edor -B2e edB|AB/c/d B2A|G3 GFE|FBA FED| -B2e edB|AB/c/d B2A|G3 GFE|FBD E2A:| -|:B2e ede|f2a afa|bag agf|g2e fed| -B2e ede|f2a afa|bag agf|efd ed=c:| -|:B3 BAG|A3 B2A|G3 GFE|FBA FED| -B3 BAG|A3 B2A|G3 GFE|FBD E2A:| - - +%abc +%%abc-alias Jigs I Play +%%abc-creator ABCexplorer 1.3.7 [2010-06-20] +% Richard's Tune Book +% jigs.abc +%% to add +% ships in full sail + +X:14 +T:Emmett's Hedgehog +Z:robin.beech@mcgill.ca +R:jig +S:Niall Vallely - Beyond Words +M:6/8 +L:1/8 +K:Ador +A2e edB | A2A AGE | A2A AGE | GAG DEG | +A2e edB | A2A AGE | GAG DEG | BAG AEG :| +e2a ged | c2B BAG | B2B BAG | g2f edB | +e2a ged | c2B BAG | Bgf edB | EFG ABd :| + +X:21 +T: North Star, The +D: Flook - Rubai - Track 2 +C: Brian Finnegan +M: 6/8 +L: 1/8 +R: jig +K:Gmaj +G2D G B/2c/2d|cBG dBG|~E3 dBG|F2d cde| +G2D G B/2c/2d|cBG dBG|EGd ~F2d|1~G3 dBA:|2~G3 GAB|| +G2F G2d|ABF G2D|EFG Adc-|cBG ADB| +G2F G2d|ABF G2D|EFG ADF|G2B DAD| +G2F G2d|ABF G2D|EFG Adc-|cBG ADB| +G2F G2d|dcB G2D|EFG ADF|G2z dBA|| + +X:22 +T: Ghost Of Ballybrolly, The +D: Flook - Rubai - Track 2 +M: 6/8 +L: 1/8 +R: jig +K:Emin +ABB eze-|edB A3-|AGE ~G2B|E B/2c/2d edB| +~B3 eBe|edB ~A3|AGE ~G3|AED E2z| +ABB eBe|edB ~A3|AGE ~G2B|E B/2c/2d ~e3| +ged BAB|edB A2A|AGE ~G3|AED E2z| +cG ~E3 c|BGA E2d|AFD DEF|GAB dBe| +cG ~E3 c|BGA E2d|AFD DEF|~E3 FGA| +cG ~E3 c|BGA E2d|AFD DEF|GAB dBe-| +edB e2g|deB- Bed|BAA ABd|ez2 g3| + +X:1 +T:The Coming Of Spring +C:Paddy O'Brien +M:6/8 +L:1/8 +R:jig +K:Edor +|: BEE B2 A | (3Bcd B BAG | F3 DFA | dfe dBA | +BEE B2 A | Bef gfe | dBG FGA |1 BGE Ed=c :|2 BGE E2 F |: +GEF G2 A | B2 A Bec | dAA BAG | (3FGA F DEF | +GFE FGA | Bef gfe | dBG FGA |1 BEE E2 F :|2 BEE Eef || +g3 efe | Beg bag | f2 d dcd | AFA def | +g2 e efe | Beg bag | fed (3fga f | ge^d e2 f | +g2 e efe | Beg bag | f2 d dcd | AFA def | +g2 e fed | Bec dfe | dBG FGA | BGE Ed=c |] + +X:23 +T:The Dusty Windowsill +T:Austin Barratts +C:Sean Harling +R:jig +M:6/8 +L:1/8 +K:Ador +A2B cBA | eAB cBA | G3 EGG | DGG EGG | A2B cBA | e2d efg | +age dBe |1 ABA A2G :|2 ABA A2g |: aga bge| def g2f | g3 gfe | dBA G3 | +EGG DGG | EGG ABc | Bed BAG |1 BAG A2g :|2 BAG A2G |: A3 gAf | +A3 edB | G3 eGd | G3 edB | A3 gAf | ABA efg | age dBe | ABA A2G :| + +X:1 +T:Banish Misfortune +R:jig +M:6/8 +L:1/8 +K:Dmix +fed cAG | A2d cAG | F2F DED| F2F GFG | +A3 cAG | AGA cde | fed cAG | Ad^c d2e :| +|:f2d d^cd | f2g agf | e2c cBc | e2f gfe | +f2g agf | e2f gfe | fed cAG | Ad^c d2e :| +|:f2g e2f | d2e c2d | ABA GAG | FGE FED | +c3 cAG | AGA cde | fed cAG | Ad^c d2e :| + +X:2 +T:Banshee's Wail +C:Vincent Broderick +R:jig +M:6/8 +L:1/8 +K:G +GED DED | GBd ege | dBA AGA | BGE E2A | +GED DED | GBd ege | dBA AGA | BGF G2A :| +Bdd edd | gdd edB | BAG GAB | AGE E2G | +Bdd edd | gdd edB | BAG GAB | AGF G3 | +Bdd edd | gdd edB | BAG GAB | AGE E2A | +GED DED | GBd ege | dBA AGA | BGF G3 |] + +X:3 +T:The Battering Ram +R:jig +M:6/8 +L:1/8 +K:G +B | dBG BAG | dBG G2B | dBG AGE | GED D2B | dBG BAG | BdB BAG | +AGA BAB | GED D2 :: B | deg aga | bge edB | deg aga | bge ega | +bag age | ged ege | dBG AGE | GED D2 :: d/c/ | B2G A2G | B2D Ddc | +B2G AGE | GED Ddc | B2G A2G | BdB BAG | AGA BAB | GED D2 :| + +X:198 +T:Bending the Ferret +C:Doug Eunson +Z:Steve Beech 23/04/2008 +R:Jig +M:6/8 +L:1/8 +K:G +|: G2B ABA | GBd g2d | edc BAG |1 A2c cBA :|2 A2F G3 :| +|:e2e dcB | ABc dcd | e2e dcB | ABc def | +g2d BAG| ABc ABc | B2B cAF | G6:| + +X:5 +T:Blackthorne Stick +R:jig +M:6/8 +L:1/8 +K:G +d | gfg ege | dBG AGE | DGG FGA | BAG A2d | +gfg age | dBG AGE | DGG FGA | BGG G2 :| +|:d | edd gdd | edd gdd | ede gfe | dcB A2d | +gfg age | dBG AGE | DGG FGA | BGG G2 :| + +X:6 +T:The Blarney Pilgrim +Z:Transcribed by Frank Nordberg - http://www.musicaviva.com +R:jig +B:Francis O'Neill:"The Dance Music of Ireland" (1907) no. 291 +M:6/8 +L:1/8 +K:G +DED DEG | A2G ABc | BAG AGE | GEA GED | DED DEG | A2G ABc | +BAG AGE | GED D2z :: ded dBG | AGA BGE | ded dBG | AGA G3 | +g2e dBG | AGA BGE | B2G AGE | GED D2z :: A2D B2D | A2D ABc | +BAG AGE | GEA GED | A2D B2D | A2D ABc | BAG AGE | GED D2z :| + +X:10 +T:Butlers of Glen Avenue +C:Tom Sullivan +Z:Philippe Murphy +R:jig +N:Title changed from Christy Barry's number 2. Thanks to Stephen Rapp +M:6/8 +L:1/8 +K:G +DEG EDB | DEG B3 | DEG B2e | dBe dBA | +DEG EDB | DEG B3 | d (3B^cd gfe |1 dBA G3 :|2 dba g3 |: +gab age | deg B3 | gab gab | d (3B^cd e2d | +gab age | deg B3 | d (3B^cd gfe |1 dba g3 :|2 dBA G3 || + +X:176 +T:Calliope House +C:D Richardson +Z:John Chambers +R:jig +N:Calliope House is a folk center in Pittsburgh. +M:6/8 +L:1/8 +K:D +A | dAA fAA | eAA fAA | Bee e2d | efd BdB | +ABA A2F | A2B d2e |1 faf fed | e3- ez :|2 faf edB | d3- d |: +fg | a3 faa | eaa daa | g3 fgf | efe edB | +ABA A2F | A2B d2e |1 faf fed | e3- e :|2 faf edB | d3- d |] + +X:11 +T:Charlie Hunter +T:Charlie Stuart's Jig +C:Bobby MacLeod +Z:Nigel Gatherer +R:jig +S:Bobby MacLeod's Selection of Country Dance Tunes +M:6/8 +L:1/8 +K:D +DFA DGB | Adf a2g | fed Bcd | ecA GFE | +DFA DGB | Adf a2g | fef gec |1 edc d2A :|2 edc dfg |: +afd dcd | BGF G2F | E^GB e2d | cAA Aag | +fdA FDF | GBd g2g | fef gec |1 edc dfg :|2 edc d3 |] + +X:12 +T:Christy Barry's No. 1 +C:Christy Barry +Z:Philippe Murphy 2006-02-28 +R:jig +M:6/8 +L:1/8 +K:G +G3 BAG | AAB d2e | ged BGG | A3 BGE | +DGG BGG | AAB d2e | ged BGG |1 AGF G2D :|2 AGF G (3B^cd |: +g3 gfg | aag d2e | ged BGG | A3 BGE | +DGG BGG | AAB d2e | ged BGG |1 AGF G (3B^cd :|2 AGF G2D |] + +X:179 +T:Jim Ward's +T:Ciaran's Capers +Z:robin.beech@mcgill.ca +R:jig +S:Simon Granger +M:6/8 +L:1/8 +K:Amix +ed | c2A ABA |dcd e3 | Ace efg | BGB dcB | +cBA ABA | dcd e3 | Ace dde | A3 A :: +fg | agf gfe | fed ecA | def gfg | B2B Bfg | +agf gfe | fed ecA | Ace dde | A3 A :| + +X:13 +T:The Clare Jig +R:jig +M:6/8 +L:1/8 +K:Em +G3G2B | AGE GED | G3 AGE | GED D2E | +G3G2B | AGE GAB | c2A BGE |1 DED D3 :|2 DED D2B |: +c2A B2A | AGE GAB | cBA BGE | DED D2B | +c2A B2A | AGE GAB | c2A BGE |1 DED D2B :|2 DED D3 |] + +X:14 +T:The Cliffs of Moher +R:jig +M:6/8 +L:1/8 +K:Ador +aga bag | eaf ged | c2A BAG | EAF GED | aga bag | eaf ged | +c2A BAG | EFG A3 :| e2e dBA | e=fe dBA | GAB dBA | GAB dBd | +e2e dBA | e=fe dBA | GAB dBA | BAG A3 | e=fe dBA | e=fe dBA | +GAB dBA | GAB dBd | e2e dee | cee Bee | GAB dBA | EFG A3 |] + +X:148 +T:Condon's Frolics +R:jig +M:6/8 +L:1/8 +K:Ador +eAB c2d | edc Bcd | eAB c2d | e2d eag | +eAB c2d | edc AB2 | GBd gdB |1 A3 a2g :|2 A3 AB/c/d |: +eaa efg | dec BAG | cGe d2d | e2d efg | +eaa efg | dec BAB | GBd gdB |1 A3 AB/c/d :|2 A3 a2g |] + +X:15 +T:Connaught-Man's Ramble +Z:Contributed by Ray Davies, ray(at)davies99.freeserve.co.uk +R:jig +B:Ryan's Mammoth Collection +M:6/8 +L:1/8 +K:D +A/G/ | FAA dAA | BAB dAG | FAA dfe | dBB BAG | +FAA dAA | BAB def | gfe dfe | dBB B2 :| +|:g | fbb faa | fed deg | fbb faa | fed e2g | +fbb faa | fed def | gfe dfe | dBB B2 :| + +X:16 +T:Cook In the Kitchen +R:jig +M:6/8 +L:1/8 +K:G +DGG GAG | FDE F3 | DGG GFG | Add cAG | +DGG GAG | FDE =F2d | cAG FGA |1 BGF G3 :|2 BGF G2A |: +B3 BAG | A3 AGF | G3 GFG | Add cAG | +B3 BAG | A3 A2d | cAG FGA |1 BGF G2A :|2 BGF G3 |: +d2e f2g | a2g fed | cAG FGA | B3 cAG | +d2e f2g | a2g fed | cAG FGA | BGF G3 :| + +X:18 +T:Dingle Regatta +R:jig +M:6/8 +L:1/8 +K:D +dcd e2d | BAB d2B | ABA AGA | B2A G3 | dcd e2d | BAB d2B | +ABA B2A | G3- G3 :: d3 def | g3 gfg | a3 aga | b2a gfe | d3 def | +g3 gab | a2g f2e | def g3 :: gfg dgd | BdB GBG | FAF DEF| +GAB def | gfg dgd | BdB GBG | FAF DEF | G3 G3 :| + +X:19 +T:Doctor O'Neill +Z:Frank Nordberg - http://www.musicaviva.com +R:jig +B:Francis O'Neill:"The Dance Music of Ireland" (1907) no. 6 +M:6/8 +L:1/8 +K:D +A | d3 AFD | E2F G2A | BGB Bcd | AGF EFA | d3 AFD | E2F G2A | +BGB Bcd | AFD D2 :: A | d3 ceA | dfe dcB | AFA Bcd | AGF EFA | +d3 ceA | dfe dcB | AFA Bcd | AFD D2 :: g | fef afd | ded fed | +gbg faf | gee e2g | fef afd | ded fed | gbg fag | fdd d2 :| +|:g | fdf ece | dcB AFA | AFd AFd | AGF E2g | fdf ece | dcB AFA | +AFA Bcd | AFD D2 :: G | FAF GBG | FAG FED | FAF GBG | +AGF E2G | FAF GBG | FAG FED | BGB Bcd | AFD D2 :| + +X:20 +T:The Donegal Lass +C:Brian Finnegan +R:jig +D:Brian Finnegan - When the Party's Over +M:6/8 +L:1/8 +K:Amix +Ace aed | cdB A3 | GBd G3 | FAd F3 | Ace aed | cdB A2^g | aed cdB | A3 A3 :| +|:GBd G3 | FAd F3 | e3 ecA | e3 ecA | GBd G3 | FAd F2^g | aed cdB | A3 A3 :| + +X:136 +T:Emmett's Hedgehog +Z:robin.beech@mcgill.ca +R:jig +S:Niall Vallely - Beyond Words +M:6/8 +L:1/8 +K:Ador +A2e edB | A2A AGE | A2A AGE | GAG DEG | +A2e edB | A2A AGE | GAG DEG | BAG AEG :| +|:e2a ged | c2B BAG | B2B BAG | g2f edB | +e2a ged | c2B BAG | Bgf edB | EFG ABd :| + +X:200 +T:The False Proof +C:Jowan Merckx +R:jig +S:rubai (flook) +M:6/8 +L:1/8 +K:Bmin +|: Bdf fef | fed c2f | edc B2B | ABd cAF | +GBd f2a | fed c2f | edc B2A | BcA B3 :: +zdc BcA | GFE F2E- | EDE G2E- |EFG dcA | +Bdc BcA | GFE F2E- | EFG e2d | cBA B3 :| +|:BdB fBg | Bag fed | e2d c2f | ede edB | +BAB fBg | Baf bz2 | bag fag |1 fed ecA :|2 fed e2d |] + +X:26 +T:Father O'Flynn +T:Top of the Cork Road +R:jig +S:Gerry Strong +M:6/8 +L:1/8 +K:D +A | dAF DFA | ded cBA | dcd efg | fed cBA | +dAF DFA | ded cBA | dcd efg | fdd d2 :| +|:g | fdf fga | ecA ABc | dcd Bed | cAA A2c | +BGB Bcd | AFD DFA | dcd efg | fdd d2 :| + +X:27 +T:The Frost Is All Over +T:The Mist Of Clonmel +R:jig +M:6/8 +L:1/8 +K:D +A | def edB | AFD E2 D | FAA AFA | Bee edB | +def edB | AFD E2 D | FAA AFA | Bdc d2 :| +|:e | f3 afd | g3 bag | f3 afd | gfg efg | +f3 afd | g3 bag | fga efg | fdc d2 :| + +X:36 +T:Hag At the Churn +R:jig +M:6/8 +L:1/8 +K:G +A2G ADD | A2G Adc | A2G ADD | EFG EFG | A2G ADD | +A2G Adc | A2G ADD | EFG EFG |AdB c3 | Add efg | +AdB c2A | GEG AED | AdB c3 | Add efg | age dcA | GEG AED |] + +X:37 +T:The Halloween Jig +C:Jean Duval +Z:robin.beech@mcgill.ca +R:jig +M:6/8 +L:1/8 +K:D +F |: B2B Bcd | c2A ABc | B2G GAB | A2F FEF | B2B Bcd | c2A ABc | +def edc |1 B3 BAF :|2 B3 Bde |: f2f fed | cde Adc | Bcd dcB | +cFF Fde | f2f fed | cde Adc | Bcd cBA |1 B3 Bde :|2 B3 B3 |] + +X:38 +T:Hammy Hamilton's +R:jig +M:6/8 +L:1/8 +K:G +B | dBG cGE | DED GFG | BAB dBG | dcB ABc | dBG cGE | DED GFG | BAB dcA | +AGF G2 :: B | dBG ecA | fef gfg | ege dBG | dcB ABc |1 dBG ecA | fef gfg | +ege dcA | AGF G2 :|2 dBG cGE | DED GFG | BAB dcA | AGF G2 |] + +X:39 +T:Haste To the Wedding +R:jig +M:6/8 +L:1/8 +K:D +AFA Agf | ede fdB | AFA AGF | GFG EFG | +AFA Agf | ede fdB | A2a faf | ded d3 :| +|:afa afa | bgb bgb | afa agf | gfg efg | +a3 f3 | ede fdB | A2a faf | ded d3 :| + +X:40 +T:Haunted House +C:Vincent Broderick +R:jig +M:6/8 +L:1/8 +K:G +G3 AGA | BGE EDE | GBd egd | ege edB | +G3 AGA | BGE EDE | GBd ege | dBA G2D :| +GBd egd | ege edB | GBd ded | ded dBA | +GBd egd | ege edB | GBd ege | dBA G2D | +GBd egd | ege edB | GBd ded | ded dBA | +G3 AGA | BGE EDE | GBd ege | dBA G3 |] + +X:43 +T:Humours of Ballyloughlin +R:jig +M:6/8 +L:1/8 +K:Dmix +A | A3 AGE | GED EDE | c3 cAd | dcA AGE | +A3 AGE | GEG cGE | DED DFA | DED D2 :| +|:B | c3 cAB | cAG ABc | d3 ded | dAF DFA | +c2A d2B | cAG FGE | DED DFA | DED D2 :| +|:e | f2d ged | f2d ged | cde ged | cde ged | +f2d ged | f2d ged | cde gag | ed^c d2 :| +|:B | A3 ABG | F3 GED | E3 EFD | EFD EFG | +A3 dAG | F3 GEA | DED DFA | DED D2 :| + +X:44 +T:Humours of Ennistymon +Z:robin.beech@mcgill.ca +R:jig +M:6/8 +L:1/8 +K:G +BAB GBd | cBc ABc | BcB GBd | cAG FGA | +B2B GBd | cBc ABc | ded cAF | AGF G3 :| +|:fgf fed | cAG FGA | Bgg gfg | afd d2 e | +fgf fed | cAG FGA | BdB cAF | AGF GBd :| +|:gdB gdB | ecA ecA | BcB GBd | cAG FGA |1 +gdB gdB | ecA ecA | BAB cAF| AGF G3 :|2 +BAB GBd | cBc ABc | ded cAF | AGF G3 |] + +X:46 +T:Indian Point +C:Rick Mohr +Z:Kevin Alewine at kalewine:HOME.COM irtrad-l 2001-5-15 +R:jig +M:6/8 +L:1/8 +K:Em +B,EF G2A | BAG FED | CEF G2A | BAG BAG | FED A,2D | +FED AGF |1 EFG BAG | F2F GFE :|2 BAG FEF | E3 E2A |: +Bef gfe | cef gfe | dfg agf | gfe fed | Bef gfe | +ceg a2a |1 bag fef | e2f gfe :|2 bag fef | e3 ez2 |] + +X:47 +T:Ingonish +R:jig +M:6/8 +L:1/8 +K:Edor +Bee efg | fef dBA | Bee efg | fdc d3 | +Bee efg | fef dBA | BdB AFD | EFE E3 :| +|:BEE BEE | FEF DFA | BEE BEE | ABc dcd | +BEE BEE | FEF D2A | BdB AFD | EFE E3 :| + +X:48 +T:Irish Washerwoman +R:jig +M:6/8 +L:1/8 +K:G +dc | BGG DGG | BGB dcB | cAA EAA | cBc edc | +BGG DGG | BGB dcB | cBc Adc |1 BGG G :|2 BGG G2 |: +g | gdg gdg | gdg bag | fdf fdf | fdf agf | +egg dgg | cgg Bgg | cBc Adc |1 BGG G2 :|2 BGG G |] + +X:8 +T:I Buried my Wife and Danced on her Grave +R:jig +M:6/8 +L:1/8 +K:D +DED F2G | AdB =cAF | G2A BAG | F2F GEA | +DED F2G | AdB =cAF | G2A BAG | AFD D2A :| +|:d2e fed | faf gfe | d2e fed | d=cA d=cA | +d2e fed | faf gfe | d2A BAG | AFD D2A :| + +X:49 +T:The Jig of Slurs +R:jig +N:also known as the "Jug of Slugs" +M:6/8 +L:1/8 +K:D +Add (dcd) | Bdd Add | Bdd Add | Bee (edB) | Add (dcd) | Bdd Add | +Bdd cde |1 fdc d3 :|2 fdc d2 B|: Aff (fef) | aff (fed) | Bee (ede) | +fef (edB) | Aff (fef) | aff (fed) | Bdd cde |1 fdc d2B :|2 fdc d2B/A/ +K:G +|: Ggg (gfg) | age (gdB) | Ggg (gfg) | age (g2 B) | Ggg (gfg) | age (gdB) | +Bee egg |1 fdd e2 B/A/ :|2 fdd e3 |: GBB Bdd | dee (edB) | +GBB Bdd | dee egg | GBB Bdd | dee (edB) | Bee egg | fdd e3 :| + +X:50 +T:Jim Ward's +R:jig +M:6/8 +L:1/8 +K:G +EF | G3 GAB | AGE GED | G3 AGE | GED DEF | +G3 GAB | AGE GAB | cBA BGE |1 DED D :|2 DED D2 |: +B | cBA BAG | A3 AGE | cBA BGE | DED D2B | +cBA BAG | A3 ABc | dcB AGE |1 GED D2 :|2 GED D |] + +X:166 +T:Johnny O'Leary's +Z:robin.beech@mcgill.ca +R:jig +S:John Williams - Steam +M:6/8 +L:1/8 +K:EDor +B3 EGA | B2A BAd | B3EGA | BAG FED | +B3 EGA | B2B BAd | AFD DEF | A2G FED :| +|:g3 fed | edc d2A | B3EGA | BAG FED | +gbg fed | edc d2B | AFD DEF | A2G FED :| +|:DEE EFD | EFD EEE | DEE EFG | BAG FED | +EEE EFD | EFD EEE | AFD DEF | A2G FED :| + +X:1 +T: Gallagher's Frolics +M: 6/8 +L: 1/8 +R: jig +K:Edor +D |: E3 GFE | B3 dBA | BdB BAB | GBG AFD | +E3 GFE | BAB dBA | BAG FAF |1 GEE E2D :|2 GEE E2e |: +e2g gfe | g2b bge | dcd fed | fad fed | +e2f gfe | dfe dBA | BAG FAF |1 GEE E2e :|2 GEE E2D |] + +X:43 +T:Horizonto +C: Paul James +R:jig +M:6/8 +L:1/8 +K:Dmin +ABA GAF | GEF DEC | A,2A, DEF | E2E CDE | +F2F FGF | EDE CDE | FED EDC | A,=B,C D3 :| +B,2B, DEF | B,2B, DEF | A,2A, DEF |A,2A, DEF| +B,2B, DEF | B,2B, DEF | ABA GAF | GEF DEC | +B,2B, DEF | B,2B, DEF | A,2A, DEF | A,2A, DEF | +B,2B, DEF | B,2B, DEF | =B,2B, DEF | =B,2B, DEF | +B2A2GF | E3 EFG | A2G2FE | D3 DEF| +G2F2ED | ^C3 CDE | F2G2^G2 | A3 AGA| +B2c2B2 | E3 EFG | A2B2A2 | D3 DEF| +G2F2ED | ^C3 CDE| F2 D2 C2 | D2 Z4 |] + +X:44 +T:Horizonto +C: Paul James +R:jig +M:6/8 +L:1/8 +K:Bmin +fgf efd | ecd BcA | F2F Bcd | c2c ABc | +d2d ded | cBc ABc | dcB cBA | F^GA B3 :| +G2G Bcd | G2G Bcd | F2F Bcd |F2F Bcd| +G2G Bcd | G2G Bcd | fgf efd | ecd BcA | +G2G Bcd | G2G Bcd | F2F Bcd | F2F Bcd | +G2G Bcd | G2G Bcd | ^G2G Bcd | ^G2G Bcd | +g2f2ed | c3 cde | f2e2dc | B3 Bcd| +e2d2cB | ^A3 ABc | d2e2=f2 | f3 fef| +g2a2g2 | c3 cde | f2g2f2 | B3 Bcd| +e2d2cB | ^A3 ABc| d2 B2 A2 | B2 Z4 |] + +X:45 +T:The False Proof +C:Jowan Merckx +R:jig +S:rubai (flook) +M:6/8 +L:1/8 +K:Bmin +|: Bdf fef | fed c2f | edc B2B | ABd cAF | +GBd f2a | fed c2f | edc B2A | BcA B3 :| +|:zdc BcA | GFE F2E- | EDE G2E- |EFG dcA | +Bdc BcA | GFE F2E- | EFG e2d | cBA B3 :| +|:BdB fBg | Bag fed | e2d c2f | ede edB | +BAB fBg | Baf bz2 | bag fag |1 fed ecA :|2 fed e2d |] + +X:1 +T: Son Ar Rost +M: 12/8 +L: 1/8 +R: slide +K:Ador +|:A2A ABG AGE c2d|cBA B2c A2G EFG| +A2A ABG AGE c2d|cBA GAB A3 A2 E:| +|:A2B d3 cBA G2A|c2B A3 GAB E2D| +EAB d2e cBA G2A|c2B ABG A3 A2 E:| + +X:1 +T: Jig For John +M: 6/8 +L: 1/8 +R: jig +K:Dmaj +|:B | A2f c/d/ef | gec dfa | g2a fed | cBA G2A | +FAd GBd | Ace fdB | ~A3 B/c/de | edc d2 :| +|:c | ~B3 BgB| fBe Bdc | ~A3 fAg | age f2d | +~B3 BgB| fBe Bdc | ~A3 B/c/de | edc d2 :| + +X:1 +T: Mouse In The Kitchen +M: 6/8 +L: 1/8 +R: jig +K:Amaj +|: c3 cde | dcA F2A | E3 ABc | B3 BAB | +c3 cde | dcA F2a | afe fec | cBe Adc :| +|: B3 BAB | c3 cBA | B3 BAB | cea zdc | +B3 BAB | c3 cBA | afe fec | cBe Adc :| + +X:1 +T: John Brady's +M: 6/8 +L: 1/8 +R: jig +K:Edor +|:A|Bed B2G|AFD EFA|Bed B2G|Eag e2d| +eaf g2e|dBA G2A|Bed BAG|Bcd E2:| +|:F|GFG AGA|BAB e2f|gfe fed|Bcd e2f| +gfe fed|BAF DEF|~G3 ~F3|Bcd E2:| + +X:166 +T:Johnny O'Leary's +Z:robin.beech@mcgill.ca +R:jig +S:John Williams - Steam +M:6/8 +L:1/8 +K:EDor +B3 EGA | B2A BAd | B3EGA | BAG FED | +B3 EGA | B2B BAd | AFD DEF | A2G FED :| +|:g3 fed | edc d2A | B3EGA | BAG FED | +gbg fed | edc d2B | AFD DEF | A2G FED :| +|:DEE EFD | EFD EEE | DEE EFG | BAG FED | +EEE EFD | EFD EEE | AFD DEF | A2G FED :| + +X:1 +T: Deirdre Hurley's +M: 6/8 +L: 1/8 +R: jig +K:Edor +B2e edB|AB/c/d B2A|G3 GFE|FBA FED| +B2e edB|AB/c/d B2A|G3 GFE|FBD E2A:| +|:B2e ede|f2a afa|bag agf|g2e fed| +B2e ede|f2a afa|bag agf|efd ed=c:| +|:B3 BAG|A3 B2A|G3 GFE|FBA FED| +B3 BAG|A3 B2A|G3 GFE|FBD E2A:| + + diff --git a/tests/unit/Application/PersonFactoryTest.php b/tests/unit/AbcParser/Application/PersonFactoryTest.php similarity index 85% rename from tests/unit/Application/PersonFactoryTest.php rename to tests/unit/AbcParser/Application/PersonFactoryTest.php index 8fa881f..c7357e6 100644 --- a/tests/unit/Application/PersonFactoryTest.php +++ b/tests/unit/AbcParser/Application/PersonFactoryTest.php @@ -1,12 +1,5 @@ getAbc(); + $tunes = ImportAbcFile::create()->import($abc); + + $extractor = ExtractTuneFromCollection::create($tunes); + + $this->assertInstanceOf(ExtractTuneFromCollection::class, $extractor); + } + + public function testExtractTuneByTitle() + { + $title = "Emmett's Hedgehog"; + + $abc = $this->getAbc('/abc/jigs.abc'); + $tunes = ImportAbcFile::create()->import($abc); + + $extractor = ExtractTuneFromCollection::create($tunes); + + $result = $extractor->extractTuneByTitle($title); + + $this->assertCount(1, $result); + $this->assertNotEquals($tunes, $result); + } +} diff --git a/tests/unit/AbcParser/Application/UseCases/ImportAbcFileTest.php b/tests/unit/AbcParser/Application/UseCases/ImportAbcFileTest.php new file mode 100644 index 0000000..f6e4175 --- /dev/null +++ b/tests/unit/AbcParser/Application/UseCases/ImportAbcFileTest.php @@ -0,0 +1,72 @@ +assertInstanceOf(ImportAbcFile::class, $importer); + } + + public function testCreateInjectingBuilder() + { + $builder = new Builder(); + $importer = ImportAbcFile::create($builder); + + $this->assertInstanceOf(ImportAbcFile::class, $importer); + } + + public function testImport() + { + $abc = $this->getAbc('/abc/jigs.abc'); + $importer = ImportAbcFile::create(); + + $result = $importer->import($abc); + + $this->assertInstanceOf(TuneCollection::class, $result); + $this->assertGreaterThan(1, $result->count()); + } + + public function testImport2FilesConsecutively() + { + $abc2 = $this->getAbc('/abc/valid_abc_2.abc'); + $abc3 = $this->getAbc('/abc/valid_abc_3.abc'); + $importer = ImportAbcFile::create(); + + $result1 = $importer->import($abc2); + $result2 = $importer->import($abc3); + + $this->assertNotEquals($result1, $result2); + } + + public function testImportMultiple() + { + $abc1 = $this->getAbc('/abc/valid_abc_1.abc'); + $abc2 = $this->getAbc('/abc/valid_abc_2.abc'); + $abc3 = $this->getAbc('/abc/valid_abc_3.abc'); + $importer = ImportAbcFile::create(); + + $result = $importer->importMultiple([$abc1, $abc2, $abc3]); + + $this->assertInstanceOf(TuneCollection::class, $result); + $this->assertGreaterThan(1, $result->count()); + } +} diff --git a/tests/unit/ParserCest.php b/tests/unit/ParserCest.php deleted file mode 100644 index 4f4f423..0000000 --- a/tests/unit/ParserCest.php +++ /dev/null @@ -1,81 +0,0 @@ -shouldReceive('newCollection')->once() - ->shouldreceive('getCollection')->once()->andreturn(true) - ->mock(); - - $parser = new Parser($builder); - - $I->assertInstanceOf(Parser::class, $parser); - } - - public function seeParseABCCallNewCollection(UnitTester $I) - { - $abc = ''; - $builder = \Mockery::mock(Builder::Class) - ->shouldReceive('newCollection')->once() - ->shouldreceive('getCollection')->once()->andreturn(true) - ->mock(); - - $parser = new Parser($builder); - - $result = $parser->parseABC($abc); - $I->assertTrue($result); - } - - public function seeParseABCExample1(UnitTester $I) - { - $abc = file_get_contents(__DIR__.'/../_data/abc/valid_abc_1.abc'); - $builder = \Mockery::mock(Builder::Class) - ->shouldReceive('newCollection')->once() - ->shouldReceive('newPerson')->once() - ->shouldReceive('newTune')->once() - ->shouldReceive('newSetting')->once() - ->shouldReceive('appendToSetting')->once() - ->shouldReceive('setOnSetting')->once() - ->shouldReceive('storeTune')->once() - ->shouldreceive('getCollection')->once()->andreturn(true); - $builder->shouldReceive('setOnTune') - ->with('X', '3') - ->atMost()->times(4); - $builder = $builder->mock(); - - - $parser = new Parser($builder); - - $result = $parser->parseABC($abc); - $I->assertTrue($result); - } -} diff --git a/tests/unit/arr/AbcCest.php b/tests/unit/arr/AbcCest.php deleted file mode 100644 index 1be0e26..0000000 --- a/tests/unit/arr/AbcCest.php +++ /dev/null @@ -1,156 +0,0 @@ -dataDir = codecept_data_dir(); - } - - public function _before(UnitTester $I) - { - $this->builder = new Abc(); - } - - public function _after(UnitTester $I) - { - unset($builder); - } - - // tests: trying to... - public function createParser(UnitTester $I) - { - $parser = new Parser($this->builder); - - $I->assertInstanceOf(Parser::class, $parser); - } - - public function seeParseEmptyAbcWithoutErrors(UnitTester $I) - { - $abc = ''; - $parser = new Parser($this->builder); - - $result = $parser->parseABC($abc); - $I->assertEmpty($result); - } - - public function seeParseABCExample1(UnitTester $I) - { - $abc = file_get_contents($this->dataDir . '/abc/valid_abc_1.abc'); - $parser = new Parser($this->builder); - $expected = [ - 1 => [ - 'X' => '3', - 'M' => '4/4', - 'K' => 'C', - 'music' => 'gaab babc :|', - ], - ]; - - $result = $parser->parseABC($abc); - $I->assertNotEmpty($result); - - $I->assertEquals($expected, $result); - } - - public function seeParseABCExample2(UnitTester $I) - { - $abc = file_get_contents($this->dataDir . '/abc/valid_abc_2.abc'); - $parser = new Parser($this->builder); - $expected = [ - 1 => [ - 'X' => '40', - 'T' => ['Abbotts Bromley Horn Dance'], - 'A' => ['trad'], - 'C' => ['trad.'], - 'D' => ['None'], - 'G' => ['lute'], - 'H' => [ - 'Thousand year old tradition', - 'The Horns live in the church and are removed for the dance once a year', - ], - 'R' => ['Jig'], - 'F' => ['none.abc'], - 'B' => ['Traditional English tunes'], - 'W' => ['None'], - 'Q' => '1/8=80', - 'L' => '1/8', - 'M' => '6/8', - 'N' => ['Traditional English'], - 'O' => ['England'], - 'Z' => ['Andy Hornby'], - 'S' => ['http://www.leeds.ac.uk/music/Info/RRTuneBk/gettune/00000dab.html'], - 'P' => 'ABC', - 'K' => 'G', - 'music' => 'e|B2e G2e|B2e E2G|FGA GAB|1AGF G2:|2AGF E2| -|e|c2e cde|A2c ABc|FGA GFE|_E=EF B,2g| -e2g efg|c2e cde|dcB AGF|E3E2 -|:A|BcB e3|BcB f3|BcB AGF|1G2F G2:|2E3-E2|]', - ], - ]; - - $result = $parser->parseABC($abc); - $I->assertNotEmpty($result); - - $I->assertEquals($expected, $result); - } - - - public function seeParseABCExample3(UnitTester $I) - { - $abc = file_get_contents($this->dataDir . '/abc/valid_abc_3.abc'); - $parser = new Parser($this->builder); - $expected = [ - 'A' => ['trad'], - 'C' => ['trad.'], - 'D' => ['None'], - 'H' => [ - 'Thousand year old tradition', - 'The Horns live in the church and are removed for the dance once a year', - ], - 'R' => ['Jig'], - 'F' => ['none.abc'], - 'B' => ['Traditional English tunes'], - 'L' => '1/8', - 'M' => '6/8', - 'N' => ['Traditional English'], - 'O' => ['England'], - 'S' => ['http://www.leeds.ac.uk/music/Info/RRTuneBk/gettune/00000dab.html'], - 'Z' => ['Andy Hornby'], - - 1 => [ - 'X' => '3', - 'M' => '4/4', - 'K' => 'C', - 'music' => 'gaab babc :|', - 'T' => ['Short and Sweet'] - ], - ]; - - $result = $parser->parseABC($abc); - $I->assertNotEmpty($result); - - $I->assertEquals($expected, $result); - } -} diff --git a/tests/unit/memory/AbcParserTest.php b/tests/unit/memory/AbcParserTest.php deleted file mode 100644 index 193a745..0000000 --- a/tests/unit/memory/AbcParserTest.php +++ /dev/null @@ -1,106 +0,0 @@ -shouldReceive('add')->once() - ->getMock(); - $this->facade = new AbcParser(new Abc($repository)); - } - - private function getValidAbc($filename = '/abc/valid_abc_1.abc') - { - return file_get_contents(codecept_data_dir($filename)); - } - - public function testNotHeaderDataNoCrash() - { - $result = $this->facade->parseABC($this->getValidAbc()); - $this->assertInstanceOf(\XaiCorp\AbcParser\Models\Memory\TuneCollection::class, $result); - } - - - public function testAllParametersForTune() - { - $result = $this->facade->parseABC($this->getValidAbc('/abc/valid_abc_2.abc')); - - // Tune details - $tune = $result[0]; - $this->assertEquals('40', $result[0]->get('X')); - $this->assertEquals('Abbotts Bromley Horn Dance', current($tune->get('T'))); - $this->assertEquals('England', current($tune->get('O'))); - $this->assertEquals(new Person(['name' => 'trad']), current($tune->get('A'))); - $this->assertEquals(new Person(['name' => 'trad.']), current($tune->get('C'))); - $this->assertEquals('England', current($tune->get('O'))); - $this->assertEquals('lute', current($tune->get('G'))); - $history = $tune->get('H'); - $this->assertEquals(2, count($history)); - $this->assertEquals('Thousand year old tradition', $history[0]); - $this->assertEquals('The Horns live in the church and are removed for the dance once a year', $history[1]); - $this->assertEquals('Jig', current($tune->get('R'))); - - // setting details - $setting = $tune[0]; - $this->assertEquals('Traditional English', current($setting->get('N'))); - $this->assertEquals('1/8', $setting->get('L')); - $this->assertEquals('6/8', $setting->get('M')); - $this->assertEquals('G', $setting->get('K')); - $expectedMusic = " -e|B2e G2e|B2e E2G|FGA GAB|1AGF G2:|2AGF E2| -|e|c2e cde|A2c ABc|FGA GFE|_E=EF B,2g| -e2g efg|c2e cde|dcB AGF|E3E2 -|:A|BcB e3|BcB f3|BcB AGF|1G2F G2:|2E3-E2|] - "; - $this->assertEquals(trim($expectedMusic), $setting->get('music'), "music strings should match"); - - $Z = new Person(['name' => 'Andy Hornby']); - $this->assertEquals($Z, current($setting->get('Z'))); - - $this->assertEquals('None', current($setting->get('D'))); - $this->assertEquals( - 'http://www.leeds.ac.uk/music/Info/RRTuneBk/gettune/00000dab.html', - current($setting->get('S')) - ); - $this->assertEquals('None', current($setting->get('W'))); - $this->assertEquals('Traditional English tunes', current($setting->get('B'))); - $this->assertEquals('none.abc', current($setting->get('F'))); - $this->assertEquals('ABC', $setting->get('P')); - $this->assertEquals('1/8=80', $setting->get('Q')); - } - - - public function testAllParametersForCollection() - { - $collection = $this->facade->parseABC($this->getValidAbc('/abc/valid_abc_3.abc')); - - $this->assertEquals(new Person(['name' => 'trad']), current($collection->get('A'))); - $this->assertEquals('Traditional English tunes', current($collection->get('B'))); - $this->assertEquals(new Person(['name' => 'trad.']), current($collection->get('C'))); - $this->assertEquals('None', current($collection->get('D'))); - $this->assertEquals('none.abc', current($collection->get('F'))); - $this->assertEquals('Thousand year old tradition', current($collection->get('H'))); - $this->assertEquals('1/8', $collection->get('L')); - $this->assertEquals('6/8', $collection->get('M')); - $this->assertEquals('Traditional English', current($collection->get('N'))); - $this->assertEquals('England', current($collection->get('O'))); - $this->assertEquals('Jig', $collection->get('R')); - $this->assertEquals( - 'http://www.leeds.ac.uk/music/Info/RRTuneBk/gettune/00000dab.html', - current($collection->get('S')) - ); - $this->assertEquals(new Person(['name' => 'Andy Hornby']), current($collection->get('Z'))); - } -} diff --git a/tests/unit/memory/PersonTest.php b/tests/unit/memory/PersonTest.php deleted file mode 100644 index ffd6b34..0000000 --- a/tests/unit/memory/PersonTest.php +++ /dev/null @@ -1,176 +0,0 @@ -person = new Person(); - } - - /** - * test the model contains the correct attributes - */ - public function testModelDefinition() - { - $this->assertClassHasAttribute('person_id', Person::class); - $this->assertClassHasAttribute('name', Person::class); - $this->assertClassHasAttribute('email', Person::class); - } - - public function testConstruct() - { - $params = ['person_id' => 5]; - $this->person = new Person($params); - - $this->assertEquals(5, $this->person->get('person_id')); - } - - /** - * @dataProvider providerSet - */ - public function testMagicSet($property, $value, $expected) - { - $this->testSet($property, $value, $expected); - } - - /** - * test the set property method - * - * @param (string) $property, the name of the property to set - * @param (mixed) value to set - * @param (Boolean) expected value for return value of set method - * - * @dataProvider providerSet - */ - public function testSet($property, $value, $expected) - { - $success = $this->person->set($property, $value); - $this->assertEquals($expected, $success); - if ($success) { - $this->assertEquals($value, $this->person->get($property)); - } - } - - public function providerSet() - { - return [ - ['Y', 'anything', false], - ['person_id', 'not', false], - ['person_id', 11, true], - ['person_id', '11', true], - ['name', null, false], - ['name', 1, false], - ['name', 'anything', true], - ['email', 'anything', false], - ['email', 1, false], - ['email', 'mail@example.com', true], - ]; - } - - /** - * @dataProvider providerPersonGet - */ - public function testPersonGet($key, $expected) - { - $result = $this->person->set($key, $expected); - $result = $this->person->get($key); - $this->assertEquals($expected, $result); - } - - public function providerPersonGet() - { - return [ - ['', false], - ['me', false], - [['of', 'me'], false], - [new Person(), false], - ['name', 'Richard Morgan'], - ['email', 'r_morgan@sympatico.ca'], - ['person_id', 0], - ]; - } - - public function testIsChanged() - { - $person = new Person(['name' => 'Richard Morgan']); - - $this->assertInstanceOf(Person::class, $person); - - $this->assertFalse($person->is_changed(), 'after load should be no changes'); - - $person->set('name', 'Richard Armitage'); - $this->assertTrue($person->is_changed(), 'updating the name changes the data'); - } - - /** - * test the static function equals - * returns true if the data properties of 2 Person objects - * are identical - * - * @param (array) $params list of properties to set on the objects - * @param (boolean) $expected result of running equals - * - * @dataProvider providerEquals - */ - public function testEquals($params) - { - $ob1 = new Person(); - $ob2 = new Person(); - - foreach ($params as $key => $val) { - if (is_array($ob1->get($key))) { - $ob1->append($key, $val); - $ob2->append($key, $val); - } else { - $ob1->set($key, $val); - $ob2->set($key, $val); - } - } - - $this->assertTrue(Person::equals($ob1, $ob2)); - } - - /** - * test the static function equals - * returns true if the data properties of 2 Person objects - * are identical - * - * @param (array) $params list of properties to set on the objects - * @param (boolean) $expected result of running equals - * - * @dataProvider providerEquals - */ - public function testEqualsFails($params) - { - $ob1 = new Person(); - $ob2 = new Person(); - - foreach ($params as $key => $val) { - if (is_array($ob1->get($key))) { - $ob1->append($key, $val); - $ob2->append($key, $val . " hello"); - } else { - $ob1->set($key, $val); - $ob2->set($key, $val + 1); - } - } - // print_r($ob1); print_r($ob2); die; - $this->assertFalse(Person::equals($ob1, $ob2)); - } - - public function providerEquals() - { - return [ - // array( array('person_id'=>'2') ), - [['name' => 'a title']], - [['email' => 'mail@example.com']], - ]; - } -} diff --git a/tests/unit/memory/SettingTest.php b/tests/unit/memory/SettingTest.php deleted file mode 100644 index 6ea796a..0000000 --- a/tests/unit/memory/SettingTest.php +++ /dev/null @@ -1,354 +0,0 @@ -setting = new Setting(); - } - - /** - * test the model contains the correct attributes - */ - public function testModelDefinition() - { - $this->assertClassHasAttribute('settingID', Setting::class); - $this->assertClassHasAttribute('tuneID', Setting::class); - - $this->assertClassHasAttribute('Z', Setting::class); - $this->assertClassHasAttribute('N', Setting::class); - $this->assertClassHasAttribute('D', Setting::class); - $this->assertClassHasAttribute('S', Setting::class); - $this->assertClassHasAttribute('W', Setting::class); - $this->assertClassHasAttribute('B', Setting::class); - - $this->assertClassHasAttribute('F', Setting::class); - $this->assertClassHasAttribute('P', Setting::class); - $this->assertClassHasAttribute('Q', Setting::class); - $this->assertClassHasAttribute('L', Setting::class); - $this->assertClassHasAttribute('M', Setting::class); - $this->assertClassHasAttribute('K', Setting::class); - $this->assertClassHasAttribute('music', Setting::class); - // $this->assertClassHasAttribute('music_hash', Setting::class); - - $this->assertClassHasAttribute('propertyNames', Setting::class); - } - - /** - * test the set property method - * - * also tests the validate_line protected method - * - * @param (string) $property, the name of the property to set - * @param (mixed) value to set - * @param (Boolean) expected value for return value of set method - * - * @dataProvider providerSet - */ - public function testSet($property, $value, $expected_success, $expected_value = false) - { - $success = $this->setting->set($property, $value); - $this->assertEquals($expected_success, $success); - if ($success) { - if (!$expected_value) { - $expected_value = $value; - } - $this->assertEquals($expected_value, $this->setting->get($property)); - } - } - - /** - * @dataProvider providerSet - */ - public function testMagicSet($property, $value, $expected_success, $expected_value = false) - { - $this->setting->$property = $value; - if ($expected_success) { - $this->assertEquals($value, $this->setting->get($property)); - } - } - - public function providerSet() - { - return [ - ['Y', 'anything', false], - ['settingID', 1, true], - ['tuneID', ['alpha'], false], - ['tuneID', 'alpha', false], - ['tuneID', '1', true], - ['tuneID', 1, true], - ['f', 1, false], - ['F', 1, false], - ['F', '1', false], - ['F', ['aplha'], true], - ['P', ['string'], false], - ['P', 10, false], - ['P', 'string', true], - ['Q', ['string'], false], - ['Q', 10, false], - ['Q', 'string', false], - ['Q', '1/8=200', true], - ['L', ['string'], false], - ['L', 10, false], - ['L', 'string', false], - ['L', '1/8', true], - ['M', ['string'], false], - ['M', 10, false], - ['M', 'string', false], - ['M', '6/8', true], - ['M', 'C', true], - ['M', 'c', true], - ['M', 'C|', true], - ['K', ['string'], false], - ['K', 10, false], - ['K', 'C', true], - ['K', 'Am', true], - ['K', 'A minor', true], - ['K', 'E dorian', true], - ['music', 'GABc:|\\', true], - ['Z', new Person(), false], - ['Z', [new Person(), 'not a person'], false], - ['Z', [new Person()], true], - ['Z', 111, false], - ['N', ['a string'], true], - ['D', ['a string'], true], - ['S', ['a string'], true], - ['W', ['a string'], true], - ['B', ['a string'], true], - ]; - } - - /** - * the settingID can only be set if it's value is currently 0 - * this ensures that we can't change a setting's id once it's set. - * the default, unset value for settingID is 0 - */ - public function testSetSettingID() - { - $success = $this->setting->set('settingID', 1); - $this->assertTrue($success, 'first attempt should succeed'); - - $success = $this->setting->set('settingID', 2); - $this->assertFalse($success, 'second attempt should fail'); - } - - - /** - * test the append value method - * - * @param (string) $property, the name of the property to set - * @param (mixed) value to append - * @param (Boolean) expected value for return value of append method - * - * @dataProvider providerAppend - */ - public function testAppend($property, $value, $expected) - { - $success = $this->setting->append($property, $value); - $this->assertEquals($expected, $success); - if ($success) { - $this->assertContains($value, $this->setting->get($property)); - } - } - - public function providerAppend() - { - return [ - ['Y', 'anything', false], - ['settingID', 1, false], - ['tuneID', ['alpha'], false], - ['tuneID', 'alpha', false], - ['tuneID', '1', false], - ['tuneID', 1, false], - ['f', 1, false], - ['F', 1, true], - ['F', '1', true], - ['F', ['aplha'], false], - ['P', ['string'], false], - ['P', 10, false], - ['P', 'string', false], - ['Q', ['string'], false], - ['Q', 10, false], - ['Q', 'string', false], - ['Q', '1/8=200', false], - ['L', ['string'], false], - ['L', 10, false], - ['L', 'string', false], - ['L', '1/8', false], - ['M', ['string'], false], - ['M', 10, false], - ['M', 'string', false], - ['M', '6/8', false], - ['M', 'C', false], - ['M', 'c', false], - ['M', 'C|', false], - ['K', ['string'], false], - ['K', 10, false], - ['K', 'C', false], - ['K', 'Am', false], - ['K', 'A minor', false], - ['K', 'E dorian', false], - ['music', 'GABc:|\\', false], - - ['Z', new Person(), true], - ['Z', [new Person()], false], - ['Z', 111, false], - ['N', ['a string'], false], - ['D', ['a string'], false], - ['S', ['a string'], false], - ['W', ['a string'], false], - ['B', ['a string'], false], - ['N', 'more notes', true], - ['D', 'another record', true], - ['S', 'another source', true], - ['W', 'words', true], - ['B', 'another book', true], - ]; - } - - /** - * @dataProvider providerGet - */ - public function testGet($key, $expected) - { - $result = $this->setting->set($key, $expected); - $result = $this->setting->get($key); - $this->assertEquals($expected, $result); - } - - public function providerGet() - { - return [ - ['', false], - ['me', false], - ['settingID', 1], - ['tuneID', 2], - ['Q', '1/8=100'], - ['L', '1/8'], - ['M', '6/8'], - ['K', 'Am'], - ['music', 'GABc:|\\'], - - ['Z', [new Person()]], - ['N', ['a string']], - ['D', ['a string']], - ['S', ['a string']], - ['W', ['a string']], - ['B', ['a string']], - ]; - } - - /** - * test the static function equals - * returns true if the data properties of 2 Setting Objects - * are identical - * - * @param (array) $params list of properties to set on the objects - * @param (boolean) $expected result of running equals - * - * @dataProvider providerEquals - */ - public function testEquals($params) - { - $ob1 = new Setting(); - $ob2 = new Setting(); - - foreach ($params as $key => $val) { - if (is_array($ob1->get($key))) { - $ob1->append($key, $val); - $ob2->append($key, $val); - } else { - $ob1->set($key, $val); - $ob2->set($key, $val); - } - } - - $this->assertTrue(Setting::equals($ob1, $ob2)); - } - - /** - * test the static function equals - * returns true if the data properties of 2 Abc_Tunes - * are identical - * - * @param (array) $params list of properties to set on the objects - * @param (boolean) $expected result of running equals - * - * @dataProvider providerEquals - */ - public function testEqualsFails($params) - { - $ob1 = new Setting(); - $ob2 = new Setting(); - - foreach ($params as $key => $val) { - if (is_array($ob1->get($key))) { - $ob1->append($key, $val); - // $ob2->append($key, $val); - } else { - $ob1->set($key, $val); - $ob2->set($key, $val + 1); - } - } - $this->assertFalse(Setting::equals($ob1, $ob2)); - } - - public function providerEquals() - { - return [ - [['settingID' => '2']], - [['tuneID' => '2']], - [['Z' => new Person()]], - [['N' => 'an author']], - [['D' => 'a composer']], - [['S' => 'a group']], - [['W' => 'some history']], - [['B' => 'Plymouth']], - [['F' => 'Jig']], - [['P' => 'ABB']], - [['Q' => '1/8=100']], - [['L' => '1/4']], - [['M' => '2/4']], - [['K' => 'G']], - [['music' => 'a|cab|']], - ]; - } - - public function testIsChanged() - { - $setting = new Setting(); - - $this->assertInstanceOf(Setting::class, $setting); - - $this->assertFalse($setting->is_changed(), 'after load should be no changes'); - - $setting->set('K', 'G'); - $this->assertTrue($setting->is_changed(), 'updating the name changes the data'); - } - - - public function testConstruct() - { - $params = [ - 'settingID' => 3, - 'Z' => [new Person()], - 'P' => 'ABC', - ]; - - $this->setting = new Setting($params); - - foreach ($params as $key => $val) { - $this->assertEquals($val, $this->setting->get($key)); - } - } -} diff --git a/tests/unit/memory/TuneCollectionTest.php b/tests/unit/memory/TuneCollectionTest.php deleted file mode 100644 index 3f688ac..0000000 --- a/tests/unit/memory/TuneCollectionTest.php +++ /dev/null @@ -1,203 +0,0 @@ -tunes = new TuneCollection(); - } - - - /** - * test the implementation of the Iterator interface - * 100% coverage! ;) - */ - public function testIterator() - { - $t = new Tune(); - $this->assertEquals(0, count($this->tunes)); - $this->tunes[] = $t; - $this->tunes->push($t); - $this->assertEquals(2, count($this->tunes)); - - $this->assertInstanceOf(Tune::class, $this->tunes[0], 'first tune'); - $this->assertInstanceOf(Tune::class, $this->tunes[1], 'second tune'); - - foreach ($this->tunes as $key => $val) { - $this->assertInternalType('scalar', $key); - $this->assertInstanceOf(Tune::class, $val); - $this->assertTrue(isset($this->tunes[$key]), 'key is set'); - - unset($this->tunes[$key]); - $this->assertFalse(isset($this->tunes[$key]), 'key should have been unset'); - } - } - - /** - * test the ability to remove the last tune from collection - * - * tests the implementation of the Countable interface - */ - public function testPop() - { - $this->assertEquals(0, count($this->tunes), 'no tunes in collection to begin with'); - - $t = new Tune(); - $this->tunes->push($t); - - $this->assertEquals(1, count($this->tunes), '1 tune added to collection'); - - $result = $this->tunes->pop(); - $this->assertEquals(0, count($this->tunes), 'no tunes left in collection'); - $this->assertInstanceOf(Tune::class, $result); - } - - // public function test_construct() - // { - // $params = array( - // 'tc_id' => 5, - // 'cOwner' => 'me', - // 'B' => array('my tune book'), - // 'R' => 'reel' - // ); -// - // $this->_tunes = new TuneCollection($params); -// - // foreach($params as $key => $val) - // { - // $this->assertEquals($val, $this->_tunes->get($key)); - // } - // } - - /** - * test the set property method - * - * @param (string) $property, the name of the property to set - * @param (mixed) value to set - * @param (Boolean) expected value for return value of set method - * - * @dataProvider providerSet - */ - public function testSet($property, $value, $expected) - { - $success = $this->tunes->set($property, $value); - $this->assertEquals($expected, $success); - if ($success) { - $this->assertEquals($value, $this->tunes->get($property)); - } - } - - /** - * test the set property method - * - * @param (string) $property, the name of the property to set - * @param (mixed) value to set - * @param (Boolean) expected value for return value of set method - * - * @dataProvider providerSet - */ - public function testMagicSetter($property, $value, $expected) - { - $this->tunes->$property = $value; - if ($expected) { - $this->assertEquals($value, $this->tunes->get($property)); - } - } - - public function providerSet() - { - return [ - ['Y', 'anything', false], - ['A', 10, false], - ['A', ['1', '2'], false], - ['A', [new Person(), new Person()], true], - ['C', 10, false], - ['C', ['1', '2'], false], - ['C', [new Person(), new Person()], true], - ['H', 10, false], - ['H', ['1', '2'], true], - ['O', 10, false], - ['O', ['1', '2'], true], - ['R', 10, false], - ['R', 'reel', true], - ['collection', 10, false], - ['collection', '10', false], - ['collection', [], false], - ['collection', ['1', '2'], false], - ['collection', [new Tune(), 'not a tune'], false], - ['collection', [new Tune()], true], - ['tc_id', 'abc', false], - ['tc_id', '11', true], - ['tc_id', 15, true], - ['cOwner', 'me', true], - ]; - } - - public function testSetTcId() - { - //we should start with tc_id = 0 - $this->assertEquals(0, $this->tunes->get('tc_id'), 'should start at 0'); - - //because tc_id == 0 we can change value - $this->tunes->set('tc_id', 4); - $this->assertEquals(4, $this->tunes->get('tc_id'), 'should have changed to 4'); - - //tc_id is not 0 so we cannot change value - $this->tunes->set('tc_id', 11); - $this->assertEquals(4, $this->tunes->get('tc_id'), 'should not have changed from 4'); - } - - - /** - * test the append value method - * - * @param (string) $property, the name of the property to set - * @param (mixed) value to append - * @param (Boolean) expected value for return value of append method - * - * @dataProvider providerAppend - */ - public function testAppend($property, $value, $expected) - { - $success = $this->tunes->append($property, $value); - $this->assertEquals($expected, $success); - if ($success) { - $this->assertContains($value, $this->tunes->get($property)); - } - } - - public function providerAppend() - { - return [ - ['Y', 1, false], - ['H', 'history', true], - ['R', 'reel', true], - ['r', 'reel', false], - ['collection', 'setting', false], - ['collection', new Tune(), true], - ['collection', [new Tune()], false], - ]; - } - - - public function testGet() - { - //R is a valid property so we should get it's value - $this->tunes->set('R', 'reel'); - $this->assertEquals('reel', $this->tunes->get('R')); - - //X is not a property, so we should get FALSE - $this->assertFalse($this->tunes->get('X')); - } -} diff --git a/tests/unit/memory/TuneTest.php b/tests/unit/memory/TuneTest.php deleted file mode 100644 index e455619..0000000 --- a/tests/unit/memory/TuneTest.php +++ /dev/null @@ -1,301 +0,0 @@ -tune = new Tune(); - } - - /** - * test the model contains the correct attributes - */ - public function testModelDefinition() - { - //Private attributes, probably shouldn't be tested - $this->assertClassHasAttribute('tuneID', Tune::class); - $this->assertClassHasAttribute('A', Tune::class); - $this->assertClassHasAttribute('C', Tune::class); - $this->assertClassHasAttribute('T', Tune::class); - $this->assertClassHasAttribute('G', Tune::class); - $this->assertClassHasAttribute('O', Tune::class); - $this->assertClassHasAttribute('R', Tune::class); - $this->assertClassHasAttribute('H', Tune::class); - $this->assertClassHasAttribute('X', Tune::class); - $this->assertClassHasAttribute('propertyNames', Tune::class); - } - - - /** - * test the set property method - * - * @param (string) $property, the name of the property to set - * @param (mixed) value to set - * @param (Boolean) expected value for return value of set method - * - * @dataProvider providerSet - */ - public function testSet($property, $value, $expected) - { - $success = $this->tune->set($property, $value); - $this->assertEquals($expected, $success); - if ($success) { - $this->assertEquals($value, $this->tune->get($property)); - } - } - - /** - * test the set property method - * - * @param (string) $property, the name of the property to set - * @param (mixed) value to set - * @param (Boolean) expected value for return value of set method - * - * @dataProvider providerSet - */ - public function testMagicSetter($property, $value, $expected) - { - $this->tune->$property = $value; - // $this->assertEquals($expected, $success); - if ($expected) { - $this->assertEquals($value, $this->tune->get($property)); - } - } - - /** - * @dataProvider providerSet - */ - public function testConstruct($property, $value, $expected) - { - $params = [$property => $value]; - $this->tune = new Tune($params); - - if ($expected) { - $this->assertEquals($value, $this->tune->get($property)); - } - } - - public function providerSet() - { - return [ - ['Y', 'anything', false], - ['x', 1, false], - ['X', 1, true], - ['X', 'aplha', false], - ['X', '2', true], - ['T', 'string', false], - ['T', 10, false], - ['T', ['1', '2'], true], - ['A', 10, false], - ['A', ['1', '2'], false], - ['A', [new Person(), new Person()], true], - ['C', 10, false], - ['C', ['1', '2'], false], - ['C', [new Person(), new Person()], true], - ['G', 10, false], - ['G', ['1', '2'], true], - ['H', 10, false], - ['H', ['1', '2'], true], - ['O', 10, false], - ['O', ['1', '2'], true], - ['R', 10, false], - ['R', ['1', '2'], true], - ['collection', 10, false], - ['collection', '10', false], - ['collection', [], false], - ['collection', ['1', '2'], false], - ['collection', [new Setting()], true], - ['tuneHash', 10, false], - ['tuneHash', '10', false], - ['tuneHash', [], false], - ['tuneHash', ['1', '2'], false], - ['tuneID', 'abc', false], - ['tuneID', '11', true], - ['tuneID', 15, true], - ]; - } - - public function testSetTuneID() - { - //we should start with tuneID = 0 - $this->assertEquals(0, $this->tune->get('tuneID'), 'should start at 0'); - - //because tuneID == 0 we can change value - $this->tune->set('tuneID', 4); - $this->assertEquals(4, $this->tune->get('tuneID'), 'should have changed to 4'); - - //tuneID is not 0 so we cannot change value - $this->tune->set('tuneID', 11); - $this->assertEquals(4, $this->tune->get('tuneID'), 'should not have changed from 4'); - } - - - /** - * test the append value method - * - * @param (string) $property, the name of the property to set - * @param (mixed) value to append - * @param (Boolean) expected value for return value of append method - * - * @dataProvider providerAppend - */ - public function testAppend($property, $value, $expected) - { - $success = $this->tune->append($property, $value); - $this->assertEquals($expected, $success); - if ($success) { - $this->assertContains($value, $this->tune->get($property)); - } - } - - public function providerAppend() - { - return [ - ['Y', 1, false], - ['X', 1, false], - ['T', 'title', true], - ['T', ['of', 'titles'], false], - ['A', 'author', true], - ['C', 'composer', true], - ['G', 'Group', true], - ['H', 'history', true], - ['O', 'Origin', true], - ['R', 'Rhythm', true], - ['collection', 'setting', false], - ['collection', new Setting(), true], - ['collection', [new Setting()], false], - ['tuneHash', 'tuneHash', false], - ['tuneHash', new Setting(), false], - ['tuneHash', [new Setting()], false], - ]; - } - - - /** - * test the static function equals - * returns true if the data properties of 2 Abc_Tunes - * are identical - * - * @param (array) $params list of properties to set on the objects - * @param (boolean) $expected result of running equals - * - * @dataProvider providerEquals - */ - public function testEquals($params) - { - // $this->markTestIncomplete(); - - $ob1 = new Tune(); - $ob2 = new Tune(); - - foreach ($params as $key => $val) { - if (is_array($ob1->get($key))) { - $ob1->append($key, $val); - $ob2->append($key, $val); - } else { - $ob1->set($key, $val); - $ob2->set($key, $val); - } - } - - $this->assertTrue(Tune::equals($ob1, $ob2)); - } - - /** - * test the static function equals - * returns true if the data properties of 2 Abc_Tunes - * are identical - * - * @param (array) $params list of properties to set on the objects - * @param (boolean) $expected result of running equals - * - * @dataProvider providerEquals - */ - public function testEqualsFails($params) - { - $ob1 = new Tune(); - $ob2 = new Tune(); - - foreach ($params as $key => $val) { - if ($key === 'collection') { - $ob1->set($key, $val); - } elseif (is_array($ob1->get($key))) { - $ob1->append($key, $val); - } else { - $ob1->set($key, $val); - } - } - $this->assertFalse(Tune::equals($ob1, $ob2)); - } - - public function providerEquals() - { - $setting1 = new Setting(['settingID' => 5, 'tuneID' => 444]); - $setting2 = new Setting(['settingID' => 3, 'tuneID' => 2244]); - return [ - [['X' => '2']], - [['T' => 'a title']], - [['A' => 'an author']], - [['C' => 'a composer']], - [['G' => 'a group']], - [['H' => 'some history']], - [['O' => 'Plymouth']], - [['R' => 'Jig']], - [['collection' => [$setting1, $setting2]]], - ]; - } - - - public function testIsChanged() - { - $tune = new Tune(); - - $this->assertInstanceOf(Tune::class, $tune); - - $this->assertFalse($tune->is_changed(), 'after load should be no changes'); - - $tune->set('X', '5'); - $this->assertTrue($tune->is_changed(), 'updating the name changes the data'); - } - - /** - * @dataProvider providerGet - */ - public function testGet($key, $expected) - { - $result = $this->tune->set($key, $expected); - $result = $this->tune->get($key); - $this->assertEquals($expected, $result); - } - - public function providerGet() - { - return [ - ['', false], - ['me', false], - ['tuneID', 2], - ['X', '2'], - ['T', ['1', '2']], - ['A', [new Person(), new Person()]], - ['C', [new Person(), new Person()]], - ['G', ['1', '2']], - ['H', ['1', '2']], - ['O', ['1', '2']], - ['R', ['1', '2']], - ['collection', [new Setting()]], - ]; - } -}