indexer 0.3.0 → 0.3.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: d0d4a32d311a17fc00a7e881a1c3b9e9395a327b
4
+ data.tar.gz: 6d4f2860f612060659a881ec3f85a08465c11974
5
+ SHA512:
6
+ metadata.gz: 397b691f3bb5e7c36a820b75d84549a9ed9a5fd13d2cbd1fd4d187f85cc462b95a342ffc7011d17b37e341174595cd3985eb3fd8ae2cdc0658e14d834ccb3075
7
+ data.tar.gz: 0a37f697701464701af20194f5c8b55b068fa4fa3c0609a32e7d5456895494adfcb3d33f7f7f5eb049d1163b66993b62e627fbf201093ef0138960e7765d7cf3
data/.index CHANGED
@@ -13,15 +13,6 @@ organizations:
13
13
  - name: Rubyworks
14
14
  website: http://rubyworks.github.com
15
15
  requirements:
16
- - version: 1.5+
17
- name: nokogiri
18
- - version: 0.14+
19
- name: kramdown
20
- - groups:
21
- - optional
22
- version: 2.0+
23
- development: true
24
- name: redcarpet
25
16
  - groups:
26
17
  - test
27
18
  version: 2.9+
@@ -58,10 +49,11 @@ customs:
58
49
  paths:
59
50
  lib:
60
51
  - lib
61
- summary: Enable Your Project's Metadata
62
- title: Indexer
63
- version: 0.3.0
64
52
  name: indexer
65
- example: This is just an example of custom metadata.
53
+ title: Indexer
54
+ summary: Enable Your Project's Metadata
55
+ created: '2011-06-01'
66
56
  description: Indexer provides projects with a universal metadata format.
67
- date: '2013-01-20'
57
+ example: This is just an example of custom metadata.
58
+ version: 0.3.1
59
+ date: '2013-08-07'
@@ -9,7 +9,7 @@ module Indexer
9
9
  LOCK_FILE = '.index'
10
10
 
11
11
  # Default metadata file name for use by end-developer.
12
- USER_FILES = '{Indexfile,Indexfile.rb,Metadata,Metadata.yml,Metadata.yaml}'
12
+ USER_FILES = '{Index,Indexfile,Metadata}{,.rb,.yml,.yaml}'
13
13
 
14
14
  # Indexer library directory.
15
15
  LIBDIR = File.dirname(__FILE__) + '/indexer'
@@ -18,17 +18,23 @@ module Indexer
18
18
  #
19
19
  # Require all import mixins.
20
20
  #
21
+ # This method calls `super` if it is defined which makes it easy
22
+ # for plugins to add new importers.
23
+ #
21
24
  def self.require_importers
22
25
  require_relative 'importer/file'
23
26
  require_relative 'importer/ruby'
24
27
  require_relative 'importer/yaml'
25
- require_relative 'importer/html'
26
- require_relative 'importer/markdown'
27
- #require_relative 'importer/rdoc'
28
- #require_relative 'importer/textile'
29
28
  require_relative 'importer/gemspec'
30
29
  require_relative 'importer/gemfile'
31
30
  require_relative 'importer/version'
31
+ #require_relative 'importer/html'
32
+ #require_relative 'importer/markdown'
33
+ #require_relative 'importer/rdoc'
34
+ #require_relative 'importer/textile'
35
+
36
+ # for plugins to easily add additional importers
37
+ super if defined?(super)
32
38
  end
33
39
 
34
40
  #
@@ -131,10 +131,10 @@ module Indexer
131
131
  if sources.empty?
132
132
  if file = exists?
133
133
  metadata = Metadata.open
134
- sources = metadata.sources
134
+ sources = metadata.sources
135
135
  else
136
- sources = Dir.glob(USER_FILES, File::FNM_CASEFOLD)
137
- raise Error.exception("could not find default sources") if sources.empty?
136
+ #sources = Dir.glob(USER_FILES, File::FNM_CASEFOLD)
137
+ raise Error.exception("Could not find a metadata source.") if sources.empty?
138
138
  end
139
139
  end
140
140
 
metadata CHANGED
@@ -1,8 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: indexer
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
5
- prerelease:
4
+ version: 0.3.1
6
5
  platform: ruby
7
6
  authors:
8
7
  - trans
@@ -10,86 +9,34 @@ authors:
10
9
  autorequire:
11
10
  bindir: bin
12
11
  cert_chain: []
13
- date: 2013-01-21 00:00:00.000000000 Z
12
+ date: 2013-08-07 00:00:00.000000000 Z
14
13
  dependencies:
15
- - !ruby/object:Gem::Dependency
16
- name: nokogiri
17
- requirement: !ruby/object:Gem::Requirement
18
- none: false
19
- requirements:
20
- - - ! '>='
21
- - !ruby/object:Gem::Version
22
- version: '1.5'
23
- type: :runtime
24
- prerelease: false
25
- version_requirements: !ruby/object:Gem::Requirement
26
- none: false
27
- requirements:
28
- - - ! '>='
29
- - !ruby/object:Gem::Version
30
- version: '1.5'
31
- - !ruby/object:Gem::Dependency
32
- name: kramdown
33
- requirement: !ruby/object:Gem::Requirement
34
- none: false
35
- requirements:
36
- - - ! '>='
37
- - !ruby/object:Gem::Version
38
- version: '0.14'
39
- type: :runtime
40
- prerelease: false
41
- version_requirements: !ruby/object:Gem::Requirement
42
- none: false
43
- requirements:
44
- - - ! '>='
45
- - !ruby/object:Gem::Version
46
- version: '0.14'
47
- - !ruby/object:Gem::Dependency
48
- name: redcarpet
49
- requirement: !ruby/object:Gem::Requirement
50
- none: false
51
- requirements:
52
- - - ! '>='
53
- - !ruby/object:Gem::Version
54
- version: '2.0'
55
- type: :development
56
- prerelease: false
57
- version_requirements: !ruby/object:Gem::Requirement
58
- none: false
59
- requirements:
60
- - - ! '>='
61
- - !ruby/object:Gem::Version
62
- version: '2.0'
63
14
  - !ruby/object:Gem::Dependency
64
15
  name: qed
65
16
  requirement: !ruby/object:Gem::Requirement
66
- none: false
67
17
  requirements:
68
- - - ! '>='
18
+ - - '>='
69
19
  - !ruby/object:Gem::Version
70
20
  version: '2.9'
71
21
  type: :development
72
22
  prerelease: false
73
23
  version_requirements: !ruby/object:Gem::Requirement
74
- none: false
75
24
  requirements:
76
- - - ! '>='
25
+ - - '>='
77
26
  - !ruby/object:Gem::Version
78
27
  version: '2.9'
79
28
  - !ruby/object:Gem::Dependency
80
29
  name: ae
81
30
  requirement: !ruby/object:Gem::Requirement
82
- none: false
83
31
  requirements:
84
- - - ! '>='
32
+ - - '>='
85
33
  - !ruby/object:Gem::Version
86
34
  version: '0'
87
35
  type: :development
88
36
  prerelease: false
89
37
  version_requirements: !ruby/object:Gem::Requirement
90
- none: false
91
38
  requirements:
92
- - - ! '>='
39
+ - - '>='
93
40
  - !ruby/object:Gem::Version
94
41
  version: '0'
95
42
  description: Indexer provides projects with a universal metadata format.
@@ -99,8 +46,8 @@ executables:
99
46
  - index
100
47
  extensions: []
101
48
  extra_rdoc_files:
102
- - HISTORY.md
103
49
  - README.md
50
+ - HISTORY.md
104
51
  files:
105
52
  - .index
106
53
  - .yardopts
@@ -135,8 +82,6 @@ files:
135
82
  - lib/indexer/importer/file.rb
136
83
  - lib/indexer/importer/gemfile.rb
137
84
  - lib/indexer/importer/gemspec.rb
138
- - lib/indexer/importer/html.rb
139
- - lib/indexer/importer/markdown.rb
140
85
  - lib/indexer/importer/ruby.rb
141
86
  - lib/indexer/importer/version.rb
142
87
  - lib/indexer/importer/yaml.rb
@@ -150,43 +95,31 @@ files:
150
95
  - lib/indexer/version/constraint.rb
151
96
  - lib/indexer/version/exceptions.rb
152
97
  - lib/indexer/version/number.rb
153
- - lib/indexer/webui/assets/dotruby_binding.js
154
- - lib/indexer/webui/assets/dotruby_model.js
155
- - lib/indexer/webui/assets/jquery-1.4.2.min.js
156
- - lib/indexer/webui/assets/json2.js
157
- - lib/indexer/webui/assets/knockout-2.0.0.js
158
- - lib/indexer/webui/assets/testdata.json
159
- - lib/indexer/webui/assets/underscore-min.js
160
- - lib/indexer/webui/index-old.html
161
- - lib/indexer/webui/index.html
162
- - lib/indexer/webui.rb
163
98
  - lib/indexer.rb
164
- - HISTORY.md
165
99
  - README.md
100
+ - HISTORY.md
166
101
  homepage: http://rubyworks.github.com/indexer
167
102
  licenses:
168
103
  - BSD-2-Clause
104
+ metadata: {}
169
105
  post_install_message:
170
106
  rdoc_options: []
171
107
  require_paths:
172
108
  - lib
173
109
  required_ruby_version: !ruby/object:Gem::Requirement
174
- none: false
175
110
  requirements:
176
- - - ! '>='
111
+ - - '>='
177
112
  - !ruby/object:Gem::Version
178
113
  version: '0'
179
114
  required_rubygems_version: !ruby/object:Gem::Requirement
180
- none: false
181
115
  requirements:
182
- - - ! '>='
116
+ - - '>='
183
117
  - !ruby/object:Gem::Version
184
118
  version: '0'
185
119
  requirements: []
186
120
  rubyforge_project:
187
- rubygems_version: 1.8.24
121
+ rubygems_version: 2.0.3
188
122
  signing_key:
189
- specification_version: 3
123
+ specification_version: 4
190
124
  summary: Enable Your Project's Metadata
191
125
  test_files: []
192
- has_rdoc:
@@ -1,294 +0,0 @@
1
- module Indexer
2
-
3
- class Importer
4
-
5
- # Import metadata from a HTML source using microformats.
6
- #
7
- # NOTE: The implementation using css selectors is fairly slow.
8
- # If we even think it important to speed up then we might
9
- # try traversing instead.
10
- #
11
- module HTMLImportation
12
-
13
- #
14
- # YAML import procedure.
15
- #
16
- def import(source)
17
- if File.file?(source)
18
- case File.extname(source)
19
- when '.html'
20
- load_html(source)
21
- return true
22
- end
23
- end
24
- super(source) if defined?(super)
25
- end
26
-
27
- #
28
- # Import metadata from HTML file.
29
- #
30
- def load_html(file)
31
- require 'nokogiri'
32
-
33
- case file
34
- when Nokogiri::XML::Document
35
- doc = file
36
- when File
37
- doc = Nokogiri::HTML(file)
38
- else
39
- doc = Nokogiri::HTML(File.new(file))
40
- end
41
-
42
- data = {}
43
-
44
- %w{version summary description created}.each do |field|
45
- load_html_simple(field, doc, data)
46
- end
47
-
48
- load_html_name(doc, data)
49
- load_html_title(doc, data)
50
- load_html_authors(doc, data)
51
- load_html_organizations(doc, data)
52
- load_html_requirements(doc, data)
53
- load_html_resources(doc, data)
54
- load_html_repositories(doc, data)
55
- load_html_copyrights(doc, data)
56
- load_html_categories(doc, data)
57
-
58
- metadata.merge!(data)
59
- end
60
-
61
- #
62
- # Load a simple field value.
63
- #
64
- def load_html_simple(field, doc, data)
65
- nodes = doc.css(".i#{field}")
66
- return if (nodes.nil? or nodes.empty?)
67
- text = nodes.first.content.strip
68
- data[field] = text
69
- end
70
-
71
- #
72
- # Load name, and use it for title too if not already set.
73
- #
74
- def load_html_name(doc, data)
75
- nodes = doc.css(".iname")
76
- return if (nodes.nil? or nodes.empty?)
77
- text = nodes.first.content.strip
78
-
79
- unless metadata.title
80
- data['title'] = text.capitalize
81
- end
82
-
83
- data['name'] = text
84
- end
85
-
86
- #
87
- # Load title, and use it for name too if not already set.
88
- #
89
- def load_html_title(doc, data)
90
- nodes = doc.css(".ititle")
91
- return if (nodes.nil? or nodes.empty?)
92
- text = nodes.first.content.strip
93
-
94
- unless metadata.name
95
- data['name'] = text.downcase.gsub(/\s+/, '_')
96
- end
97
-
98
- data['title'] = text
99
- end
100
-
101
- #
102
- #
103
- #
104
- def load_html_categories(doc, data)
105
- nodes = doc.css('.icategory')
106
- return if (nodes.nil? or nodes.empty?)
107
-
108
- data['categories'] ||= []
109
-
110
- nodes.each do |node|
111
- entry = node.content.strip
112
- data['categories'] << entry unless entry == ""
113
- end
114
- end
115
-
116
- #
117
- #
118
- #
119
- def load_html_resources(doc, data)
120
- nodes = doc.css('.iresource')
121
- return if (nodes.nil? or nodes.empty?)
122
-
123
- data['resources'] ||= []
124
-
125
- nodes.each do |node|
126
- entry = {}
127
-
128
- entry['uri'] = node.attr('href')
129
- entry['type'] = node.attr('name') || node.attr('title') # best choice for this?
130
- entry['label'] = node.content.strip
131
-
132
- data['resources'] << entry if entry['uri']
133
- end
134
- end
135
-
136
- #
137
- #
138
- #
139
- def load_html_requirements(doc, data)
140
- nodes = doc.css('.irequirement')
141
- return if (nodes.nil? or nodes.empty?)
142
-
143
- data['requirements'] ||= []
144
-
145
- nodes.each do |node|
146
- entry = {}
147
-
148
- if n = node.at_css('.name')
149
- entry['name'] = n.content.strip
150
- end
151
-
152
- if n = node.at_css('.version')
153
- entry['version'] = n.content.strip
154
- end
155
-
156
- # TODO: better approach to optional field?
157
- if n = node.at_css('.optional')
158
- entry['optional'] = true #n.content.strip != "false"
159
- end
160
-
161
- if n = (node.at_css('.groups') || node.at_css('.group'))
162
- text = n.content.strip
163
- text = text.sub(/^[(]/, '').sub(/[)]$/, '').strip
164
- entry['groups'] = text.split(/\s+/)
165
-
166
- if %w{test build document development}.any?{ |g| entry['groups'].include?(g) }
167
- entry['development'] = true
168
- end
169
- end
170
-
171
- data['requirements'] << entry if entry['name']
172
- end
173
- end
174
-
175
- #
176
- # Class is `iauthor`.
177
- #
178
- def load_html_authors(doc, data)
179
- nodes = doc.css('.iauthor')
180
- return if (nodes.nil? or nodes.empty?)
181
-
182
- data['authors'] ||= []
183
-
184
- nodes.each do |node|
185
- entry = {}
186
-
187
- if n = (node.at_css('.name') || node.at_css('.nickname'))
188
- entry['name'] = n.content.strip
189
- end
190
-
191
- if n = node.at_css('.email')
192
- text = n.attr(:href) || n.content.strip
193
- text = text.sub(/^mailto\:/i, '')
194
- entry['email'] = text
195
- end
196
-
197
- if n = node.at_css('.website') || node.at_css('.uri') || node.at_css('.url')
198
- text = n.attr(:href) || n.content.strip
199
- entry['website'] = text
200
- end
201
-
202
- data['authors'] << entry if entry['name']
203
- end
204
- end
205
-
206
- #
207
- # Class is `iorg`.
208
- #
209
- def load_html_organizations(doc, data)
210
- nodes = doc.css('.iorg')
211
- return if (nodes.nil? or nodes.empty?)
212
-
213
- data['organizations'] ||= []
214
-
215
- nodes.each do |node|
216
- entry = {}
217
-
218
- if n = node.at_css('.name')
219
- entry['name'] = n.content.strip
220
- end
221
-
222
- if n = node.at_css('.email')
223
- text = n.attr(:href) || n.content.strip
224
- text = text.sub(/^mailto\:/i, '')
225
- entry['email'] = text
226
- end
227
-
228
- if n = node.at_css('.website') || node.at_css('.uri') || node.at_css('.url')
229
- text = n.attr(:href) || n.content.strip
230
- entry['website'] = text
231
- end
232
-
233
- data['organizations'] << entry if entry['name']
234
- end
235
- end
236
-
237
- #
238
- # Class is `irepo`.
239
- #
240
- def load_html_repositories(doc, data)
241
- nodes = doc.css('.irepo')
242
- return if (nodes.nil? or nodes.empty?)
243
-
244
- data['repositories'] ||= []
245
-
246
- nodes.each do |node|
247
- entry = {}
248
-
249
- entry['uri'] = node.attr('href')
250
- entry['type'] = node.attr('name') || node.attr('title') # best choice for this?
251
- entry['label'] = node.content.strip
252
-
253
- data['resources'] << entry if entry['uri']
254
- end
255
- end
256
-
257
- #
258
- #
259
- #
260
- def load_html_copyrights(doc, data)
261
- nodes = doc.css('.icopyright')
262
- return if (nodes.nil? or nodes.empty?)
263
-
264
- data['copyrights'] ||= []
265
-
266
- nodes.each do |node|
267
- entry = {}
268
-
269
- if n = node.at_css('.holder')
270
- entry['holder'] = n.content.strip
271
- end
272
-
273
- if n = node.at_css('.year')
274
- entry['year'] = n.content.strip
275
- end
276
-
277
- if n = node.at_css('.license')
278
- text = n.content.strip
279
- text = text.sub(/license$/i,'').strip
280
- entry['license'] = text
281
- end
282
-
283
- data['copyrights'] << entry
284
- end
285
- end
286
-
287
- end
288
-
289
- # Include YAMLImportation mixin into Builder class.
290
- include HTMLImportation
291
-
292
- end
293
-
294
- end