ALD 0.1.0 → 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,136 @@
1
+ require 'semantic'
2
+
3
+ module ALD
4
+ class API
5
+ class Collection
6
+ # Internal: Used by ItemCollection/UserCollection#where to filter data
7
+ # locally if possible. All methods are module methods.
8
+ module LocalFilter
9
+ # Internal: Apply certain conditions on given data. This is a wrapper
10
+ # method that calls ::filter, ::sort (if necessary) and applies a :range
11
+ # condition (if specified).
12
+ #
13
+ # data - an Array of Hashes representing the entries to apply
14
+ # conditions upon
15
+ # conditions - the Hash of conditions to apply
16
+ #
17
+ # Returns the modified data Array.
18
+ #
19
+ # Raises ArgumentError if the conditions cannot be applied. This can be
20
+ # avoided by passing them to ::can_apply? beforehand.
21
+ def self.apply_conditions(data, conditions)
22
+ data = filter(data, conditions)
23
+ data = sort(data, conditions[:sort]) if conditions.key?(:sort)
24
+ data = data.slice(conditions[:range]) if conditions.key?(:range)
25
+ data
26
+ end
27
+
28
+ # Internal: Test if the given filter, sort and range conditions can be
29
+ # applied locally or need a request to the server.
30
+ #
31
+ # conditions - a Hash of conditions to test
32
+ # local_keys - an Array of Strings or Symbols, containing the key names
33
+ # that are available locally
34
+ # Related: CollectionEntry::initialized_attributes
35
+ #
36
+ # Returns a Boolean; true if local application is possible, false
37
+ # otherwise
38
+ def self.can_apply?(conditions, local_keys)
39
+ local_keys.map!(&:to_sym) # symbolize keys
40
+
41
+ conditions.all? do |key, value|
42
+ if key == :sort
43
+ sort_criteria(value).all? { |c| local_keys.include?(c) }
44
+ else
45
+ local_keys.include?(key) || key == :range # range is always supported
46
+ end
47
+ end
48
+ end
49
+
50
+ # Internal: Filter the given data locally. This does not support range
51
+ # or switch conditions. Array conditions also only work if the values
52
+ # are exactly the same, i.e. the same entries in the same order.
53
+ #
54
+ # data - an Array of Hashes representing the entries to filter
55
+ # conditions - a Hash of conditions to filter for
56
+ #
57
+ # Returns the filtered data array
58
+ #
59
+ # Raises ArgumentError if a filter is detected that cannot be handled
60
+ # locally. This can be prevented by calling ::can_filter? first.
61
+ def self.filter(data, conditions)
62
+ data.select do |entry|
63
+ conditions.all? do |key, value|
64
+ if [:sort, :range].include?(key)
65
+ true # must be done somewhere else
66
+ elsif entry.key?(key.to_s) # should be a locally available key
67
+ entry[key.to_s] == value
68
+ else
69
+ raise ArgumentError # should be prevented by can_filter?
70
+ end
71
+ end
72
+ end
73
+ end
74
+
75
+ # Internal: Sort the given data locally
76
+ #
77
+ # data - the Array of Hashes representing entries
78
+ # sort - either: a Hash, associating sorting criteria (symbols) to
79
+ # sorting direction (:asc ord :desc); or an Array of Symbols
80
+ # representing sorting criteria (direction defaults to :asc)
81
+ #
82
+ # Returns the sorted data array
83
+ def self.sort(data, sort)
84
+ sort = to_sort_hash(sort)
85
+ data.sort do |a, b|
86
+ sortings(sort, a, b).find { |s| s != 0 } || 0 # use highest-priority (i.e. first) sorting info != 0
87
+ end
88
+ end
89
+
90
+ # Internal: Get the sort order for given criteria.
91
+ #
92
+ # sort - a Hash as described in ::sort
93
+ # a, b - the Hashes to compare
94
+ #
95
+ # Returns an Array of Integers (-1, 0, +1), where each represents the
96
+ # sort order for one of the sort keys.
97
+ def self.sortings(sort, a, b)
98
+ sort.map do |key, dir|
99
+ key = key.to_s
100
+ if key == 'version'
101
+ result = Semantic::Version.new(a[key]) <=> Semantic::Version.new(b[key])
102
+ else
103
+ result = a[key] <=> b[key]
104
+ end
105
+ dir == :asc ? result : -result
106
+ end
107
+ end
108
+ private_class_method :sortings
109
+
110
+ # Internal: Create a sorting Hash from an Array.
111
+ #
112
+ # sort - a Hash or Array, in the format described in ::sort
113
+ #
114
+ # Returns a Hash, in the format described in ::sort.
115
+ def self.to_sort_hash(sort)
116
+ if sort.is_a?(Hash)
117
+ sort
118
+ else
119
+ Hash[sort.map { |c| [c, :asc] }]
120
+ end
121
+ end
122
+ private_class_method :to_sort_hash
123
+
124
+ # Internal: The inverse of ::to_sort_hash.
125
+ #
126
+ # sort - an Array or Hash, in the format described in ::sort
127
+ #
128
+ # Returns an Array, in the format described in ::sort.
129
+ def self.sort_criteria(sort)
130
+ sort.is_a?(Hash) ? sort.keys : sort
131
+ end
132
+ private_class_method :sort_criteria
133
+ end
134
+ end
135
+ end
136
+ end
@@ -0,0 +1,94 @@
1
+ require_relative 'collection_entry'
2
+ require 'date'
3
+
4
+ module ALD
5
+ class API
6
+ # Public: A user registered on an ALD server.
7
+ class User < CollectionEntry
8
+ # Public: Get the user's ID.
9
+ #
10
+ # Returns a 32-character string containing the user's GUID.
11
+ #
12
+ # Signature
13
+ #
14
+ # id()
15
+
16
+ # Public: Get the user's name
17
+ #
18
+ # Returns a String containing the user's name.
19
+ #
20
+ # Signature
21
+ #
22
+ # name()
23
+
24
+ # Public: Get the user's registration date. This method might trigger a
25
+ # HTTP request.
26
+ #
27
+ # Returns a DateTime containing the date and time of the user's
28
+ # registration on the ALD server.
29
+ #
30
+ # Signature
31
+ #
32
+ # joined()
33
+
34
+ # Public: Get the user's privileges on the ALD server. This method might
35
+ # trigger a HTTP request.
36
+ #
37
+ # Returns an Array of Symbols representing privileges the user has.
38
+ #
39
+ # Signature
40
+ #
41
+ # privileges()
42
+
43
+ # Internal: Create a new instance. This method is called by API#user and
44
+ # should not be called by library consumers.
45
+ #
46
+ # api - The ALD::API instance this user belongs to
47
+ # data - a Hash containing the user's data
48
+ # initialized - a Boolean indicating whether the given data is complete
49
+ # or further API requests are necessary.
50
+ def initialize(api, data, initialized = false)
51
+ super(api, data, initialized)
52
+ end
53
+
54
+ # todo: mail
55
+
56
+ # Public: Get the MD5 hash of the user's mail adress. This method might
57
+ # trigger a HTTP request.
58
+ #
59
+ # Returns a String with the hashed mail adress.
60
+ def mailMD5
61
+ request unless initialized?
62
+ @data['mail-md5']
63
+ end
64
+
65
+ private
66
+
67
+ # Internal: If the data given to the constructor was not complete, use
68
+ # the API to request further information from the server.
69
+ #
70
+ # Returns nothing.
71
+ def request
72
+ @data = @api.request("/users/#{id}")
73
+ @data['privileges'].map!(&:to_sym)
74
+ @data['joined'] = DateTime.parse(@data['joined'])
75
+ end
76
+
77
+ # Internal: Override of CollectionEntry#initialized_attributes to enable
78
+ # automatic method definition, in this case #id and #name.
79
+ #
80
+ # Returns an Array of attribute names (String)
81
+ def self.initialized_attributes
82
+ %w[id name]
83
+ end
84
+
85
+ # Internal: Override of CollectionEntry#requested_attributes to enable
86
+ # automatic method definition, in this case #joined and #privileges.
87
+ #
88
+ # Returns an Array of attribute names (String)
89
+ def self.requested_attributes
90
+ %w[joined privileges]
91
+ end
92
+ end
93
+ end
94
+ end
@@ -0,0 +1,140 @@
1
+ require_relative 'collection'
2
+ require_relative 'conditioned'
3
+
4
+ module ALD
5
+ class API
6
+ # Public: Represents a collection of users on an ALD server.
7
+ class UserCollection < Collection
8
+ include Conditioned
9
+
10
+ # Internal: Create a new collection instance. Library consumers should
11
+ # not directly call this, but instead obtain new instances from API#users
12
+ # or #where.
13
+ #
14
+ # api - the ALD::API instance this collection belongs to
15
+ # conditions - the Hash of conditions users in this collection must meet
16
+ # data - an Array of Hashes containing the data about the users in
17
+ # the collection. May be nil.
18
+ def initialize(api, conditions = {}, data = nil)
19
+ super(api, conditions, data)
20
+ end
21
+
22
+ # Public: Access an individual user in the collection.
23
+ #
24
+ # Examples
25
+ #
26
+ # puts api.users['Fred'].name # => 'Fred'
27
+ #
28
+ # Returns the ALD::API::User instance representing the user, or nil if
29
+ # not found.
30
+ #
31
+ # Signature
32
+ #
33
+ # [](name)
34
+ # [](id)
35
+ #
36
+ # name - a String containing the user's name
37
+ # id - a 32-character String containing the user's GUID
38
+
39
+ # Internal: filter conditions that allow specifying a range. See #where.
40
+ RANGE_CONDITIONS = %w[joined]
41
+
42
+ # Internal: filter conditions that allow specifying an array.
43
+ ARRAY_CONDITIONS = %w[privileges]
44
+
45
+ # Internal: filter conditions that can be handled locally.
46
+ LOCAL_CONDITIONS = %w[name]
47
+
48
+ # Public: Return a new collection containing a subset of the users in
49
+ # this collection.
50
+ #
51
+ # conditions - a Hash of conditions the users in the new collection must
52
+ # meet:
53
+ # :range - a zero-based Integer Range of users in this
54
+ # collection that should be in the new
55
+ # collection. Note that this is applied AFTER
56
+ # the other conditions.
57
+ # :joined - the date and time the user registered to the
58
+ # server. Instead of specifying an exact value,
59
+ # You can specify a comparison such as
60
+ # '>= 2013-03-04 13:00:00'.
61
+ # :privileges - an Array of privileges the user should have.
62
+ # :sort - an Array of sorting criteria, in descending
63
+ # order of precedence; or a Hash where the keys
64
+ # are the sorting criteria, and the values
65
+ # (:asc, :desc) indicate sorting order.
66
+ #
67
+ # Returns a new UserCollection or self if conditions is nil.
68
+ #
69
+ # Raises ArgumentError if the new conditions are incompatible with the
70
+ # current ones.
71
+ #
72
+ # Signature
73
+ #
74
+ # where(conditions)
75
+
76
+ private
77
+
78
+ # Internal: Make a HTTP request to the ALD server to get the list of user
79
+ # hashes matching this collection's conditions.
80
+ #
81
+ # Returns nothing.
82
+ def request
83
+ data = [
84
+ range_condition_queries(%w[joined]),
85
+ array_queries(%w[privileges]),
86
+ sort_query,
87
+ range_query
88
+ ].reduce({}, :merge)
89
+
90
+ url = "/items/#{data.empty? ? '' : '?'}#{URI.encode_www_form(data)}"
91
+ @data = @api.request(url).map do |hash|
92
+ hash['id'] = @api.normalize_id(hash['id'])
93
+ hash
94
+ end
95
+ end
96
+
97
+ # Internal: Make a HTTP request to the ALD server to get a single user.
98
+ # Used by Collection#[].
99
+ #
100
+ # filter - a filter Hash as returned by #entry_filter
101
+ #
102
+ # Returns a Hash with all information about the user.
103
+ #
104
+ # Raises ArgumentError if the filters cannot be handled.
105
+ def request_entry(filter)
106
+ url = if %w[id name].any? { |k| filter.key?(k.to_sym) }
107
+ "/users/#{filter[:id] || filter[:name]}"
108
+ else
109
+ raise ArgumentError
110
+ end
111
+
112
+ @api.request(url)
113
+ end
114
+
115
+ # Internal: Used by Collection#each and Collection#[] to create new users.
116
+ #
117
+ # hash - a Hash describing the item, with the keys 'id' and 'name'
118
+ # initialized - a Boolean indicating if the given Hash already contains
119
+ # all information about the user or only name and id.
120
+ def entry(hash, initialized = false)
121
+ @api.user(hash, initialized)
122
+ end
123
+
124
+ # Internal: Implements user access for #[]. See Collection#entry_filter
125
+ # for more information.
126
+ #
127
+ # UserCollection allows access by ID (String) or name (String).
128
+ def entry_filter(args)
129
+ unless args.length == 1 && args.first.is_a?(String)
130
+ raise ArgumentError
131
+ end
132
+ if /^[0-9a-fA-F]{32}$/ =~ args.first
133
+ { id: @api.normalize_id(args.first) }
134
+ else
135
+ { name: args.first }
136
+ end
137
+ end
138
+ end
139
+ end
140
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ALD
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - maul.esel
@@ -130,12 +130,20 @@ extensions: []
130
130
  extra_rdoc_files: []
131
131
  files:
132
132
  - lib/ALD.rb
133
- - lib/ALD/package.rb
133
+ - lib/ALD/local_filter.rb
134
134
  - lib/ALD/definition.rb
135
+ - lib/ALD/collection.rb
136
+ - lib/ALD/item.rb
137
+ - lib/ALD/package.rb
138
+ - lib/ALD/user.rb
135
139
  - lib/ALD/package_generator.rb
136
- - lib/ALD/definition_generator.rb
140
+ - lib/ALD/user_collection.rb
141
+ - lib/ALD/api.rb
137
142
  - lib/ALD/exceptions.rb
138
- - lib/ALD/schema.xsd
143
+ - lib/ALD/definition_generator.rb
144
+ - lib/ALD/collection_entry.rb
145
+ - lib/ALD/item_collection.rb
146
+ - lib/ALD/conditioned.rb
139
147
  homepage: https://github.com/Library-Distribution/ALD.rb
140
148
  licenses:
141
149
  - MIT
@@ -1,340 +0,0 @@
1
- <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
2
- xmlns:ald="ald://package/schema/2014"
3
- attributeFormDefault="qualified" elementFormDefault="qualified"
4
- targetNamespace="ald://package/schema/2014">
5
-
6
- <xsd:simpleType name="guid-type"> <!-- defines the type of a GUID -->
7
- <xsd:restriction base="xsd:string">
8
- <xsd:pattern value="[a-fA-F0-9]{32}"/> <!-- update: do not use any format, just the raw number -->
9
- </xsd:restriction>
10
- </xsd:simpleType>
11
-
12
- <xsd:simpleType name="internetURL">
13
- <xsd:restriction base="xsd:anyURI">
14
- <xsd:pattern value="https?://.*"/>
15
- </xsd:restriction>
16
- </xsd:simpleType>
17
-
18
- <xsd:simpleType name="schemaURL">
19
- <xsd:restriction base="xsd:anyURI">
20
- <xsd:pattern value="(https?|ald)://.*"/>
21
- </xsd:restriction>
22
- </xsd:simpleType>
23
-
24
- <xsd:simpleType name="word-string">
25
- <xsd:restriction base="xsd:string">
26
- <xsd:pattern value="(\w|_)+"/>
27
- </xsd:restriction>
28
- </xsd:simpleType>
29
-
30
- <xsd:simpleType name="architecture">
31
- <xsd:restriction base="xsd:string">
32
- <xsd:enumeration value="x32"/>
33
- <xsd:enumeration value="x64"/>
34
- <xsd:enumeration value="x128"/>
35
- </xsd:restriction>
36
- </xsd:simpleType>
37
-
38
- <xsd:simpleType name="encoding">
39
- <xsd:restriction base="xsd:string">
40
- <xsd:enumeration value="ANSI"/>
41
- <xsd:enumeration value="Unicode"/>
42
- </xsd:restriction>
43
- </xsd:simpleType>
44
-
45
- <xsd:simpleType name="access">
46
- <xsd:restriction base="xsd:string">
47
- <xsd:enumeration value="read"/>
48
- <xsd:enumeration value="write"/>
49
- <xsd:enumeration value="read+write"/>
50
- </xsd:restriction>
51
- </xsd:simpleType>
52
-
53
- <!-- I. VERSIONING -->
54
- <!-- a. semantic versioning -->
55
- <xsd:simpleType name="semverType">
56
- <xsd:restriction base="xsd:string">
57
- <xsd:pattern value="(\d+)\.(\d+)\.(\d+)(\-([0-9A-Za-z\-]+\.)*([0-9A-Za-z\-]+))?(\+([0-9A-Za-z\-]+\.)*([0-9A-Za-z\-]+))?"/>
58
- </xsd:restriction>
59
- </xsd:simpleType>
60
-
61
- <xsd:complexType name="semanticVersion"> <!-- defines a version of a dependency -->
62
- <xsd:sequence>
63
- <xsd:element name="customdata" type="ald:customDataType" minOccurs="0" maxOccurs="unbounded"/>
64
- </xsd:sequence>
65
-
66
- <xsd:attribute use="required" name="value" type="ald:semverType"/>
67
- </xsd:complexType>
68
-
69
- <xsd:group name="semantic-version-switch"> <!-- defines several ways to validate a version -->
70
- <xsd:choice>
71
- <xsd:element name="version" type="ald:semanticVersion"/> <!-- the only accepted version number -->
72
- <xsd:element name="version-list"> <!-- a list of accepted version numbers -->
73
- <xsd:complexType>
74
- <xsd:sequence>
75
- <xsd:element name="version" type="ald:semanticVersion" minOccurs="1" maxOccurs="unbounded"/>
76
- </xsd:sequence>
77
- </xsd:complexType>
78
- </xsd:element>
79
- <xsd:element name="version-range"> <!-- a range of accepted version numbers -->
80
- <xsd:complexType>
81
- <xsd:sequence>
82
- <xsd:element name="customdata" type="ald:customDataType" minOccurs="0" maxOccurs="unbounded"/>
83
- </xsd:sequence>
84
-
85
- <xsd:attribute use="required" type="ald:semverType" name="min-version"/> <!-- the lower bound of a range of accepted version numbers for the item. -->
86
- <xsd:attribute use="required" type="ald:semverType" name="max-version"/> <!-- the upper bound of a range of accepted version numbers for the item. -->
87
- </xsd:complexType>
88
- </xsd:element>
89
- </xsd:choice>
90
- </xsd:group>
91
-
92
- <!-- b. lax versioning -->
93
- <!-- defines a version of a requirement -->
94
- <xsd:complexType name="laxVersion">
95
- <xsd:sequence>
96
- <xsd:element name="customdata" type="ald:customDataType" minOccurs="0" maxOccurs="unbounded"/>
97
- </xsd:sequence>
98
-
99
- <xsd:attribute use="required" type="xsd:string" name="value"/> <!-- carries the version number -->
100
- </xsd:complexType>
101
-
102
- <xsd:group name="version-switch"> <!-- defines several ways to validate a version -->
103
- <xsd:choice>
104
- <xsd:element name="version" type="ald:laxVersion"/> <!-- the only accepted version number -->
105
- <xsd:element name="version-list"> <!-- a list of accepted version numbers -->
106
- <xsd:complexType>
107
- <xsd:sequence>
108
- <xsd:element name="version" type="ald:laxVersion" minOccurs="1" maxOccurs="unbounded"/>
109
- </xsd:sequence>
110
- </xsd:complexType>
111
- </xsd:element>
112
- <xsd:element name="version-range"> <!-- a range of accepted version numbers -->
113
- <xsd:complexType>
114
- <xsd:sequence>
115
- <xsd:element name="customdata" type="ald:customDataType" minOccurs="0" maxOccurs="unbounded"/>
116
- </xsd:sequence>
117
-
118
- <xsd:attribute use="required" type="xsd:string" name="min-version"/> <!-- the lower bound of a range of accepted version numbers for the item. -->
119
- <xsd:attribute use="required" type="xsd:string" name="max-version"/> <!-- the upper bound of a range of accepted version numbers for the item. -->
120
- </xsd:complexType>
121
- </xsd:element>
122
- </xsd:choice>
123
- </xsd:group>
124
- <!-- END OF VERSIONING -->
125
-
126
- <!-- defines data of an author who wrote this item -->
127
- <xsd:complexType name="authorType">
128
- <xsd:sequence>
129
- <xsd:element name="customdata" type="ald:customDataType" minOccurs="0" maxOccurs="unbounded"/>
130
- </xsd:sequence>
131
-
132
- <xsd:attribute use="required" type="xsd:string" name="name"/> <!-- the name to identify the author. Can be same as user-name -->
133
- <xsd:attribute use="optional" type="xsd:string" name="user-name"/> <!-- the AHK forums user name -->
134
- <xsd:attribute use="optional" type="ald:internetURL" name="homepage"/> <!-- an URL to a homepage of the author -->
135
- <xsd:attribute use="optional" type="xsd:string" name="email"/> <!-- an email address of the author -->
136
- <xsd:anyAttribute/>
137
- </xsd:complexType>
138
-
139
- <!-- defines a library required for this item to work -->
140
- <xsd:complexType name="dependencyType">
141
- <xsd:sequence>
142
- <xsd:group ref="ald:semantic-version-switch" minOccurs="1" maxOccurs="1"/> <!-- defines the version(s) of this dependency that are accepted -->
143
- </xsd:sequence>
144
-
145
- <xsd:attribute use="required" type="xsd:string" name="name"/> <!-- the name of the required item -->
146
- <xsd:anyAttribute/>
147
- </xsd:complexType>
148
-
149
- <!-- specifies that the item can run on the given system -->
150
- <xsd:complexType name="targetType">
151
- <xsd:sequence>
152
- <xsd:element name="language-version" minOccurs="0" maxOccurs="1">
153
- <xsd:complexType>
154
- <xsd:group ref="ald:version-switch" minOccurs="1" maxOccurs="1"/>
155
- </xsd:complexType>
156
- </xsd:element>
157
- <xsd:element name="target" type="ald:targetType" minOccurs="0" maxOccurs="unbounded"/>
158
- </xsd:sequence>
159
-
160
- <xsd:attribute use="optional" type="xsd:string" name="message"/>
161
- <xsd:attribute use="optional" type="xsd:NCName" name="id"/>
162
-
163
- <xsd:attribute use="optional" type="ald:architecture" name="language-architecture"/>
164
- <xsd:attribute use="optional" type="ald:encoding" name="language-encoding"/>
165
- <xsd:attribute use="optional" type="ald:architecture" name="system-architecture"/>
166
- <xsd:attribute use="optional" type="xsd:string" name="system-version"/>
167
- <xsd:attribute use="optional" type="xsd:string" name="system-type"/>
168
-
169
- <xsd:anyAttribute/>
170
- </xsd:complexType>
171
-
172
- <!-- specifies different files for different platforms -->
173
- <xsd:complexType name="fileSetType">
174
- <xsd:sequence>
175
- <xsd:choice minOccurs="1" maxOccurs="unbounded">
176
- <xsd:element name="file" type="ald:fileType"/>
177
- <xsd:element name="file-set" type="ald:fileSetType"/>
178
- </xsd:choice>
179
- <xsd:element name="target" minOccurs="0" maxOccurs="unbounded">
180
- <xsd:complexType>
181
- <xsd:attribute use="required" type="xsd:NCName" name="ref"/>
182
- </xsd:complexType>
183
- </xsd:element>
184
- </xsd:sequence>
185
-
186
- <xsd:attribute use="required" type="xsd:string" name="src"/>
187
- <xsd:anyAttribute/>
188
- </xsd:complexType>
189
-
190
- <!-- defines a file being included -->
191
- <xsd:complexType name="fileType">
192
- <xsd:sequence>
193
- <xsd:element name="customdata" type="ald:customDataType" minOccurs="0" maxOccurs="unbounded"/>
194
- </xsd:sequence>
195
-
196
- <xsd:attribute name="path" use="required" type="xsd:string"/> <!-- the (internal) path to the file -->
197
- <xsd:anyAttribute/>
198
- </xsd:complexType>
199
-
200
- <!-- defines a tag for the package -->
201
- <xsd:complexType name="tagType">
202
- <xsd:sequence>
203
- <xsd:element name="customdata" type="ald:customDataType" minOccurs="0" maxOccurs="unbounded"/>
204
- </xsd:sequence>
205
-
206
- <xsd:attribute name="name" use="required" type="ald:word-string"/> <!-- the name of the tag -->
207
- <xsd:anyAttribute/>
208
- </xsd:complexType>
209
-
210
- <!-- defines a link related to the package -->
211
- <xsd:complexType name="linkType">
212
- <xsd:sequence>
213
- <xsd:element name="customdata" type="ald:customDataType" minOccurs="0" maxOccurs="unbounded"/>
214
- </xsd:sequence>
215
-
216
- <xsd:attribute use="required" type="xsd:string" name="name"/> <!-- a short name for what the link points to -->
217
- <xsd:attribute use="required" type="xsd:string" name="description"/> <!-- a description of what the link points to -->
218
- <xsd:attribute use="required" type="ald:internetURL" name="href"/> <!-- the URL the link points to -->
219
- <xsd:anyAttribute/>
220
- </xsd:complexType>
221
-
222
- <!-- allows users to include custom data in the package which can be read by ALD clients -->
223
- <xsd:complexType name="customDataType" mixed="true">
224
- <xsd:sequence>
225
- <xsd:any minOccurs="0" maxOccurs="unbounded" processContents="lax"/>
226
- </xsd:sequence>
227
-
228
- <xsd:attribute use="required" type="xsd:string" name="namespace"/> <!-- a string identifying the client using this or the usage for the included data -->
229
- <xsd:attribute use="optional" type="ald:schemaURL" name="schema"/> <!-- an optional schema URL which can be used for checking the content -->
230
- <xsd:anyAttribute/>
231
- </xsd:complexType>
232
-
233
- <xsd:complexType name="file-list-type">
234
- <xsd:sequence minOccurs="0" maxOccurs="unbounded">
235
- <xsd:choice>
236
- <xsd:element name="file" type="ald:fileType"/>
237
- <xsd:element name="file-set" type="ald:fileSetType"/>
238
- </xsd:choice>
239
- </xsd:sequence>
240
- </xsd:complexType>
241
-
242
- <xsd:complexType name="repositoryType">
243
- <xsd:sequence minOccurs="1" maxOccurs="unbounded">
244
- <xsd:element name="url">
245
- <xsd:complexType>
246
- <xsd:simpleContent>
247
- <xsd:extension base="xsd:anyURI">
248
- <xsd:attribute use="required" type="ald:access" name="access"/>
249
- </xsd:extension>
250
- </xsd:simpleContent>
251
- </xsd:complexType>
252
- </xsd:element>
253
- </xsd:sequence>
254
- <xsd:attribute use="required" type="xsd:string" name="type"/>
255
- <xsd:attribute use="required" type="ald:internetURL" name="view-url"/>
256
- </xsd:complexType>
257
-
258
- <!-- root -->
259
- <xsd:element name="package">
260
- <xsd:complexType>
261
- <xsd:sequence>
262
- <xsd:element name="description" minOccurs="1" maxOccurs="1" type="xsd:string"/>
263
- <xsd:element name="authors" minOccurs="1" maxOccurs="1"> <!-- the list of authors being involved in this item -->
264
- <xsd:complexType>
265
- <xsd:sequence>
266
- <xsd:element name="author" type="ald:authorType" minOccurs="1" maxOccurs="unbounded"/>
267
- </xsd:sequence>
268
- </xsd:complexType>
269
- </xsd:element>
270
- <xsd:element name="dependencies" minOccurs="0" maxOccurs="1"> <!-- the list of dependencies this package has -->
271
- <xsd:complexType>
272
- <xsd:sequence>
273
- <xsd:element name="dependency" type="ald:dependencyType" minOccurs="0" maxOccurs="unbounded"/>
274
- </xsd:sequence>
275
- </xsd:complexType>
276
- </xsd:element>
277
- <xsd:element name="targets" minOccurs="1" maxOccurs="1">
278
- <xsd:complexType>
279
- <xsd:sequence>
280
- <xsd:element name="target" type="ald:targetType" minOccurs="0" maxOccurs="unbounded"/>
281
- </xsd:sequence>
282
- </xsd:complexType>
283
-
284
- <xsd:unique name="targetID">
285
- <xsd:selector xpath=".//ald:target"/>
286
- <xsd:field xpath="@ald:id"/>
287
- </xsd:unique>
288
- </xsd:element>
289
- <xsd:element name="files" minOccurs="1" maxOccurs="1"> <!-- holds the lists of files to include -->
290
- <xsd:complexType>
291
- <xsd:sequence>
292
- <xsd:element name="doc" type="ald:file-list-type" minOccurs="1" maxOccurs="1"/> <!-- the list of documentation files -->
293
- <xsd:element name="src" type="ald:file-list-type" minOccurs="1" maxOccurs="1"/> <!-- the list of source files -->
294
- </xsd:sequence>
295
- </xsd:complexType>
296
- </xsd:element>
297
- <xsd:element name="development" minOccurs="0" maxOccurs="1">
298
- <xsd:complexType>
299
- <xsd:sequence>
300
- <xsd:element name="repository" type="ald:repositoryType" minOccurs="1" maxOccurs="unbounded"/>
301
- </xsd:sequence>
302
- </xsd:complexType>
303
- </xsd:element>
304
- <xsd:element name="tags" minOccurs="0" maxOccurs="1"> <!-- the list of tags for the package -->
305
- <xsd:complexType>
306
- <xsd:sequence>
307
- <xsd:element name="tag" type="ald:tagType" minOccurs="1" maxOccurs="unbounded"/>
308
- </xsd:sequence>
309
- </xsd:complexType>
310
- </xsd:element>
311
- <!-- todo: triggers
312
- Triggers can be run after installation, before and after update and before uninstall.
313
- They consist of a command line to execute.
314
- -->
315
- <xsd:element name="links" minOccurs="1" maxOccurs="1"> <!-- the list of related links -->
316
- <xsd:complexType>
317
- <xsd:sequence>
318
- <xsd:element name="link" type="ald:linkType" minOccurs="0" maxOccurs="unbounded"/>
319
- </xsd:sequence>
320
- </xsd:complexType>
321
- </xsd:element>
322
- <xsd:any minOccurs="0"/>
323
- </xsd:sequence>
324
-
325
- <xsd:attribute use="required" type="ald:guid-type" name="id"/> <!-- the unique ID of the package -->
326
- <xsd:attribute use="required" type="xsd:string" name="type"/> <!-- the type of the package -->
327
- <xsd:attribute use="required" type="xsd:string" name="summary"/>
328
- <xsd:attribute use="required" type="xsd:string" name="name"/> <!-- the name of the package -->
329
- <xsd:attribute use="required" type="ald:semverType" name="version"/> <!-- the current version of the package -->
330
- <xsd:attribute use="optional" type="xsd:string" name="logo-image"/> <!-- the relative path to a logo image, if one is included -->
331
- <xsd:attribute use="optional" type="ald:internetURL" name="homepage"/>
332
- <xsd:anyAttribute/>
333
- </xsd:complexType>
334
-
335
- <xsd:keyref name="target-ref" refer="ald:targetID">
336
- <xsd:selector xpath=".//ald:file-set/ald:target"/>
337
- <xsd:field xpath="@ald:ref"/>
338
- </xsd:keyref>
339
- </xsd:element>
340
- </xsd:schema>