drails_commons 0.0.8

  • README.md
  • CHANGELOG.md
  • Installing
  • Versions
  • 31

Drails Commons

Build Status

This library contains some utility methods to work with reflectable api.

Get Annotation Values of classes:

If you want to get the value of certain annotation that is over the class of an object, you can use GetValueOfAnnotation class. For example, lets say you have the class Person as fallows:

@myReflectable
@Table(name: 'person')
class Person {
    @Column(name: 'name', length: 50)
    String name;
}

then lets say you want to check if the annotation is over the class Person. In that case you could do:

var personClassMirror = myReflectable.reflectType(Person);
var isAnnotationOverPerson = new IsAnnotation<Table>().onClass(personClassMirror);
print(isAnnotationOverPerson); // should prints 'true'

Lets say in a different case you want to obtain the object containing all the attributes of @Table, then you can do:

var personClassMirror = myReflectable.reflectType(Person);
var annotationOverPerson = new GetAnnotation<Table>().fromClass(personClassMirror);
print(annotationOverPerson.name); // it should prints 'person'

Get Annotation Values of Instances:

If you want to get the value of certain annotation that is over the class of an object, you can use GetValueOfAnnotation class. For example, lets say you have the class Person as fallows:

@myReflectable
@Table(name: 'person')
class Person {
    @Column(name: 'name', length: 50)
    String name;
}

then lets say you want to check if the annotation is over an instance of class Person. In that case you could do:

var person = new Person();
var personInstanceMirror = myReflectable.reflect(person);
var isAnnotationOverPerson = new IsAnnotation<Table>().onInstance(personInstanceMirror);
print(isAnnotationOverPerson); // should prints 'true'

Lets say in a different case you want to obtain the object containing all the attributes of @Table, then you can do:

var person = new Person();
var personInstanceMirror = myReflectable.reflect(person);
var annotationOverPerson = new GetAnnotation<Table>().fromInstance(personClassMirror);
print(annotationOverPerson.name); // it should prints 'person'

Get Annotation Values of classes:

If you want to get the value of certain annotation that is over the class of an object, you can use GetValueOfAnnotation class. For example, lets say you have the class Person as fallows:

@myReflectable
@Table(name: 'person')
class Person {
    @Column(name: 'name', length: 50)
    String name;
}

then lets say you want to check if the annotation is over the attribute name. In that case you could do:

var nameDeclarationMirror = myReflectable.reflectType(Person).declarations[0];
var isAnnotationOverName = new IsAnnotation<Column>().onDeclaration(nameDeclarationMirror);
print(isAnnotationOverName); // should prints 'true'

Lets say you want to obtain the object containing all the attributes of @Column, then you can do:

var nameDeclarationMirror = myReflectable.reflectType(Person).declarations[0];
var annotationOverName = new GetAnnotation<Column>().fromDeclaration(nameDeclarationMirror);
print(annotationOverName.name); // it should prints 'person'
print(annotationOverPerson.length); // it should prints '20'

Get Public Variables from an object

Let's say you want to get all the public attributes from a class, then you need to do:

var personCM = myReflectable.reflectType(Person);
var publicAttributes = getPublicVariablesFromClass(personCM, myReflectable);

#TODO

  • add more tests

0.0.7

  • add SN_DOUBLE
  • _fromAnnotations methods make it to use List instead of List<InstanceMirror>

0.0.6+3

  • Upgrage to reflectable ^0.5.1

0.0.6+2

  • Upgrade to reflectable ^0.4.0

0.0.6+1

  • correct _getExtensionLevel method to use reflectable ^0.3.3

0.0.5+2

  • extend version support of reflectable package

0.0.4

  • add GetValuesOfAnnotations
  • add tests for GetValuesOfAnnotations
  • make GetValueOfAnnotation.fromAnnotations private

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:


dependencies:
  drails_commons: ^0.0.8

2. Install it

You can install packages from the command line:

with pub:


$ pub get

Alternatively, your editor might support pub get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:


import 'package:drails_commons/drails_commons.dart';
  
Version Uploaded Documentation Archive
0.0.8 Jun 14, 2016 Go to the documentation of drails_commons 0.0.8 Download drails_commons 0.0.8 archive
0.0.7 Mar 10, 2016 Go to the documentation of drails_commons 0.0.7 Download drails_commons 0.0.7 archive
0.0.6+3 Dec 31, 2015 Go to the documentation of drails_commons 0.0.6+3 Download drails_commons 0.0.6+3 archive
0.0.6+2 Dec 21, 2015 Go to the documentation of drails_commons 0.0.6+2 Download drails_commons 0.0.6+2 archive
0.0.6+1 Nov 4, 2015 Go to the documentation of drails_commons 0.0.6+1 Download drails_commons 0.0.6+1 archive
0.0.6 Oct 16, 2015 Go to the documentation of drails_commons 0.0.6 Download drails_commons 0.0.6 archive
0.0.5+1 Sep 5, 2015 Go to the documentation of drails_commons 0.0.5+1 Download drails_commons 0.0.5+1 archive
0.0.5 Aug 4, 2015 Go to the documentation of drails_commons 0.0.5 Download drails_commons 0.0.5 archive
0.0.4 Mar 21, 2015 Go to the documentation of drails_commons 0.0.4 Download drails_commons 0.0.4 archive
0.0.3 Jan 22, 2015 Go to the documentation of drails_commons 0.0.3 Download drails_commons 0.0.3 archive

All 12 versions...

Popularity:
Describes how popular the package is relative to other packages. [more]
3
Health:
Code health derived from static analysis. [more]
97
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
0
Overall:
Weighted score of the above. [more]
31
Learn more about scoring.

We analyzed this package on Jul 20, 2018, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.0.0-dev.69.0
  • pana: 0.11.7

Platforms

Detected platforms: web, other

Primary library: package:drails_commons/drails_commons.dart with components: mirrors.

Issues and suggestions

Package is too old.

The package was released more than two years ago.

Package is pre-v1 release.

While there is nothing inherently wrong with versions of 0.*.*, it usually means that the author is still experimenting with the general direction of the API.

Maintain an example.

Create a short demo in the example/ directory to show how to use this package. Common file name patterns include: main.dart, example.dart or you could also use drails_commons.dart.

Fix lib/src/scanners.dart.

Analysis of lib/src/scanners.dart reported 3 hints:

line 19 col 26: The generic type comment is being deprecated in favor of the real syntax.

line 41 col 36: The generic type comment is being deprecated in favor of the real syntax.

line 157 col 97: Unnecessary cast.

Format lib/drails_commons.dart.

Run dartfmt to format lib/drails_commons.dart.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=1.8.0
reflectable ^0.5.3 0.5.4 2.0.1
Transitive dependencies
analyzer 0.27.6 0.32.3
args 0.13.7 1.4.4
async 2.0.8
barback 0.15.2+16
charcode 1.1.2
cli_util 0.0.1+2 0.1.3+2
code_transformers 0.4.2+3 0.5.1+5
collection 1.14.11
convert 2.0.2
crypto 2.0.6
csslib 0.14.4 0.14.4+1
dart_style 0.2.11+1 1.1.3
glob 1.1.7
html 0.13.3+2
isolate 0.2.3 2.0.2
logging 0.11.3+2
package_config 1.0.5
path 1.6.2
plugin 0.2.0+3
pool 1.3.5
source_maps 0.10.7
source_span 1.4.1
stack_trace 1.9.3
string_scanner 1.0.3
typed_data 1.1.6
utf 0.9.0+5
watcher 0.9.7+10
when 0.2.0
which 0.1.3
yaml 2.1.15
Dev dependencies
test ^0.12.0