0.0.6 • Published 9 years ago
alpinist v0.0.6
alpinist
ALPS (Application-Level Profile Semantics) processor
This is currently a work in progress.
Installation
$ npm install alpinist
Usage
See the example below.
Example
Suppose this ALPS profile were on http://example.com/Rubygem
{
"alps": {
"version": "1.0",
"doc": {
"format": "text",
"value": "RubyGem info"
},
"descriptor": [
{
"id": "RubyGem",
"type": "semantic",
"href": "http://alps.io/schema.org/SoftwareApplication#SoftwareApplication",
"descriptor": [
{
"id": "name",
"type": "semantic",
"href": "http://alps.io/schema.org/SoftwareApplication#name"
},
{
"id": "version",
"type": "semantic",
"href": "http://alps.io/schema.org/SoftwareApplication#version"
},
{
"id": "authors",
"type": "semantic",
"href": "http://alps.io/schema.org/SoftwareApplication#author"
},
{
"id": "info",
"type": "semantic",
"href": "http://alps.io/schema.org/SoftwareApplication#description"
},
{
"id": "licenses",
"type": "semantic",
"href": "http://alps.io/schema.org/SoftwareApplication#license"
},
{
"id": "project_uri",
"type": "safe",
"href": "http://alps.io/schema.org/SoftwareApplication#url"
},
{
"id": "gem_uri",
"type": "safe",
"href": "http://alps.io/schema.org/SoftwareApplication#downloadUrl"
},
{
"id": "homepage_uri",
"type": "safe",
"href": "http://alps.io/iana/relations#related"
},
{
"id": "source_code_uri",
"type": "safe"
},
{
"id": "dependencies",
"type": "semantic",
"href": "http://alps.io/schema.org/SoftwareApplication#requirements"
}
]
}
]
}
}
import {Profile, ProfileFetcher, Semantics} from 'alpinist';
var baseUrl = 'http://example.com/Rubygem';
var fetcher = new ProfileFetcher();
fetcher.fetch(baseUrl).then((doc) => {
return Profile.parse(doc, baseUrl);
}).then((profile) => {
return new Semantics(profile).build();
}).then((semantics) => {
semantics.printTree(); // for debug
});
* http://alps.io/schema.org/Thing
+---+ http://alps.io/schema.org/CreativeWork
+---+ http://alps.io/schema.org/SoftwareApplication#SoftwareApplication
+---> http://example.com/RubyGem#RubyGem
* http://alps.io/schema.org/Thing#name
+---+ http://alps.io/schema.org/SoftwareApplication#name
+---> http://example.com/RubyGem#name
* http://alps.io/schema.org/CreativeWork#version
+---+ http://alps.io/schema.org/SoftwareApplication#version
+---> http://example.com/RubyGem#version
* http://alps.io/schema.org/CreativeWork#author
+---+ http://alps.io/schema.org/SoftwareApplication#author
+---> http://example.com/RubyGem#authors
* http://alps.io/schema.org/Thing#description
+---+ http://alps.io/schema.org/SoftwareApplication#description
+---> http://example.com/RubyGem#info
* http://example.com/RubyGem#licenses
* http://alps.io/schema.org/Thing#url
+---+ http://alps.io/schema.org/SoftwareApplication#url
+---> http://example.com/RubyGem#project_uri
* http://alps.io/schema.org/SoftwareApplication#downloadUrl
+---> http://example.com/RubyGem#gem_uri
* http://alps.io/iana/relations#related
+---> http://example.com/RubyGem#homepage_uri
* http://example.com/RubyGem#source_code_uri
* http://alps.io/schema.org/SoftwareApplication#requirements
+---> http://example.com/RubyGem#dependencies
Contributing
- Fork it ( https://github.com/tkawa/alpinist-js/fork )
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Add some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create a new Pull Request