indexer 0.1.0 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (35) hide show
  1. data/.index +8 -4
  2. data/Gemfile.lock +29 -0
  3. data/HISTORY.md +18 -1
  4. data/README.md +5 -2
  5. data/data/indexer/{r2013/index.kwalify → index.kwalify} +0 -0
  6. data/data/indexer/{r2013/index.yes → index.yes} +0 -0
  7. data/data/indexer/{r2013/index.yesi → index.yesi} +0 -0
  8. data/data/indexer/{r2013/ruby.txt → ruby.txt} +0 -0
  9. data/data/indexer/{r2013/yaml.txt → yaml.txt} +0 -0
  10. data/lib/indexer/attributes.rb +7 -3
  11. data/lib/indexer/command.rb +18 -13
  12. data/lib/indexer/components.rb +1 -0
  13. data/lib/indexer/components/conflict.rb +7 -0
  14. data/lib/indexer/components/engine.rb +87 -0
  15. data/lib/indexer/components/requirement.rb +17 -15
  16. data/lib/indexer/conversion/gemspec.rb +9 -9
  17. data/lib/indexer/conversion/gemspec_exporter.rb +2 -1
  18. data/lib/indexer/core_ext/hash/rekey.rb +89 -0
  19. data/lib/indexer/core_ext/hash/to_h.rb +4 -0
  20. data/lib/indexer/core_ext/kernel/cli.rb +54 -0
  21. data/lib/indexer/importer/html.rb +5 -0
  22. data/lib/indexer/importer/markdown.rb +22 -4
  23. data/lib/indexer/metadata.rb +27 -10
  24. data/lib/indexer/validator.rb +7 -6
  25. data/lib/indexer/webui.rb +167 -0
  26. data/lib/indexer/webui/assets/dotruby_binding.js +41 -0
  27. data/lib/indexer/webui/assets/dotruby_model.js +203 -0
  28. data/lib/indexer/webui/assets/jquery-1.4.2.min.js +154 -0
  29. data/lib/indexer/webui/assets/json2.js +482 -0
  30. data/lib/indexer/webui/assets/knockout-2.0.0.js +97 -0
  31. data/lib/indexer/webui/assets/testdata.json +23 -0
  32. data/lib/indexer/webui/assets/underscore-min.js +31 -0
  33. data/lib/indexer/webui/index-old.html +92 -0
  34. data/lib/indexer/webui/index.html +286 -0
  35. metadata +53 -19
data/.index CHANGED
@@ -13,7 +13,10 @@ organizations: []
13
13
  requirements:
14
14
  - version: 1.5+
15
15
  name: nokogiri
16
+ - version: 0.14+
17
+ name: kramdown
16
18
  - version: 2.0+
19
+ optional: true
17
20
  name: redcarpet
18
21
  - groups:
19
22
  - test
@@ -40,15 +43,16 @@ resources:
40
43
  repositories: []
41
44
  categories:
42
45
  - metadata
43
- load_path:
44
- - lib
46
+ paths:
47
+ load:
48
+ - lib
45
49
  copyrights:
46
50
  - holder: Rubyworks
47
51
  year: '2012'
48
52
  license: BSD-2-Clause
49
- version: 0.1.0
53
+ version: 0.2.0
50
54
  summary: Enable Your Project's Metadata
51
55
  description: Indexer provides projects with a universal metadata format.
52
56
  name: indexer
53
57
  title: Indexer
54
- date: '2012-12-09'
58
+ date: '2012-12-27'
@@ -0,0 +1,29 @@
1
+ PATH
2
+ remote: pkg
3
+ specs:
4
+ indexer (0.1.0)
5
+ nokogiri (>= 1.5)
6
+ redcarpet (>= 2.0)
7
+
8
+ GEM
9
+ remote: http://rubygems.org/
10
+ specs:
11
+ ae (1.8.1)
12
+ ansi
13
+ ansi (1.4.3)
14
+ brass (1.2.1)
15
+ facets (2.9.3)
16
+ nokogiri (1.5.5)
17
+ qed (2.9.0)
18
+ ansi
19
+ brass
20
+ facets (>= 2.8)
21
+ redcarpet (2.2.2)
22
+
23
+ PLATFORMS
24
+ ruby
25
+
26
+ DEPENDENCIES
27
+ ae
28
+ indexer!
29
+ qed (>= 2.9)
data/HISTORY.md CHANGED
@@ -1,6 +1,23 @@
1
1
  # RELEASE HISTORY
2
2
 
3
- ## 0.1.0 / 2012-12-08
3
+ ## 0.2.0 / 2012-12-27
4
+
5
+ The `load_path` field has been deprecated and replaced with the `paths` field,
6
+ which holds a mapping of names to local path locations within the project. This
7
+ makes identifying paths completely generic. For Ruby projects use the 'load' entry.
8
+
9
+ This release also makes Kramdown the fallback for importing microformat data from
10
+ markdown documents if Redcarpet is not available. This makes it usable with JRuby.
11
+ (Kramdown may become the only support markdown render in the future.)
12
+
13
+ Changes:
14
+
15
+ * Deprecate `load_path` array in favor of `paths` hash.
16
+ * Support Kramdown as fallback Markdown renderer.
17
+ * Add requirement optional field support to microformat importer.
18
+
19
+
20
+ ## 0.1.0 / 2012-12-09
4
21
 
5
22
  Initial release of Indexer.
6
23
 
data/README.md CHANGED
@@ -1,4 +1,4 @@
1
- # <span class="ititle">Indexer</span> (v<span class="iversion">0.1.0</span>)
1
+ # <span class="ititle">Indexer</span> (v<span class="iversion">0.2.0</span>)
2
2
 
3
3
  <b class="isummary">Enable Your Project's Metadata<b>
4
4
 
@@ -106,7 +106,10 @@ and the Manpages.
106
106
  <a class="name" href="http://nokogiri.org/">nokogiri</a> <span class="version">1.5+</span></span>
107
107
  </li>
108
108
  <li class="irequirement">
109
- <a class="name" href="https://github.com/vmg/redcarpet">redcarpet</a> <span class="version">2.0+</span></span>
109
+ <a class="name" href="http://kramdown.rubyforge.org/">kramdown</a> <span class="version">0.14+</span>
110
+ </li>
111
+ <li class="irequirement">
112
+ <a class="name" href="https://github.com/vmg/redcarpet">redcarpet</a> <span class="version">2.0+</span> (<span class="optional">optional</span>)
110
113
  </li>
111
114
  <li class="irequirement">
112
115
  <a class="name" href="http://rubyworks.github.com/qed/">qed</a> <span class="version">2.9+</span> <span class="groups">(test)</span>
@@ -85,8 +85,12 @@ module Indexer
85
85
  # URI for linking to source code.
86
86
  attr_accessor :webcvs
87
87
 
88
- # The directories to search within the project when requiring files
89
- attr_accessor :load_path # :loadpath or :require_paths ?
88
+ # Map of path sets which can be used to identify paths within the project.
89
+ #
90
+ # For example, the `load` key is used by Ruby projectss to define which paths
91
+ # to search within the project when requiring files.
92
+ #
93
+ attr_accessor :paths
90
94
 
91
95
  # List of language engine/version family supported.
92
96
  attr_accessor :engines
@@ -162,7 +166,7 @@ module Indexer
162
166
  :repositories => [],
163
167
  :resources => [],
164
168
  :categories => [],
165
- :load_path => ['lib']
169
+ :paths => {'load' => ['lib']}
166
170
  }
167
171
  end
168
172
 
@@ -26,15 +26,15 @@ module Indexer
26
26
  def run(argv=ARGV)
27
27
  cmd = nil
28
28
  args = cli(argv,
29
- '-d --debug' => lambda{ $DEBUG = true },
30
- '-w --warn' => lambda{ $VERBOSE = true },
31
- '-f --force' => lambda{ @force = true },
32
- '-o --stdout' => lambda{ @stdout = true },
33
- '-s --static' => lambda{ @static = true },
34
- '-u --using' => lambda{ no_cmd!(cmd); cmd = :using },
35
- '-a --adding' => lambda{ no_cmd!(cmd); cmd = :adding },
36
- '-g --generate' => lambda{ no_cmd!(cmd); cmd = :generate },
37
- '-h --help' => lambda{ no_cmd!(cmd); cmd = :help }
29
+ '-u --using' => lambda{ no_cmd!(cmd); cmd = :using },
30
+ '-a --adding' => lambda{ no_cmd!(cmd); cmd = :adding },
31
+ '-g --generate' => lambda{ no_cmd!(cmd); cmd = :generate },
32
+ '-w --webserver' => lambda{ no_cmd!(cmd); cmd = :webserver },
33
+ '-h --help' => lambda{ no_cmd!(cmd); cmd = :help },
34
+ '-d --debug' => lambda{ $DEBUG = true; $VERBOSE = true },
35
+ '-f --force' => lambda{ @force = true },
36
+ '-o --stdout' => lambda{ @stdout = true },
37
+ '-s --static' => lambda{ @static = true }
38
38
  )
39
39
  send(cmd || :show, *args)
40
40
  rescue => error
@@ -102,6 +102,12 @@ module Indexer
102
102
  end
103
103
  end
104
104
 
105
+ #
106
+ def webserver
107
+ require 'indexer/webui'
108
+ Indexer::WebUI::Server.start(ARGV)
109
+ end
110
+
105
111
  #
106
112
  def help
107
113
  puts <<-END
@@ -112,6 +118,7 @@ module Indexer
112
118
  -a --adding <sources...> update index appending additional information sources
113
119
  -r --remove <sources...> update index removing given information sources
114
120
  -g --generate <type> [fname] generate a file (gemspec, indexfile, metadata)
121
+ -w --webserver (experimental) edit .index file via web interface
115
122
  -h --help show this help message
116
123
 
117
124
  -o --stdout output to console instead of saving to file
@@ -132,8 +139,7 @@ module Indexer
132
139
  raise Error.exception("#{outfile} file already exists", IOError)
133
140
  end
134
141
 
135
- template_dir = File.join(DATADIR, "r#{REVISION}")
136
- template_file = File.join(template_dir, 'ruby.txt')
142
+ template_file = File.join(DATADIR, 'ruby.txt')
137
143
 
138
144
  if Metadata.exists?
139
145
  metadata = Metadata.open
@@ -168,8 +174,7 @@ module Indexer
168
174
  raise Error.exception("#{outfile} file already exists", IOError)
169
175
  end
170
176
 
171
- template_dir = File.join(DATADIR, "r#{REVISION}")
172
- template_file = File.join(template_dir, 'yaml.txt')
177
+ template_file = File.join(DATADIR, 'yaml.txt')
173
178
 
174
179
  if Metadata.exists?
175
180
  metadata = Metadata.open
@@ -5,4 +5,5 @@ require_relative 'components/conflict'
5
5
  require_relative 'components/resource'
6
6
  require_relative 'components/repository'
7
7
  require_relative 'components/requirement'
8
+ require_relative 'components/engine'
8
9
 
@@ -73,6 +73,13 @@ module Indexer
73
73
  @data[:version] = Version::Constraint.parse(version)
74
74
  end
75
75
 
76
+ #
77
+ #
78
+ #
79
+ def to_h
80
+ {'name'=>name, 'version'=>version.to_s}
81
+ end
82
+
76
83
  end
77
84
 
78
85
  end
@@ -0,0 +1,87 @@
1
+ module Indexer
2
+
3
+ # The Engine class models the name and version of a
4
+ # the language necessray to run the software.
5
+ #
6
+ class Engine < Model
7
+
8
+ # Parse `data` into a Dependency instance.
9
+ #
10
+ # TODO: What about respond_to?(:to_str) for String, etc.
11
+ def self.parse(data)
12
+ case data
13
+ when Engine
14
+ data
15
+ when String
16
+ parse_string(data)
17
+ when Array
18
+ parse_array(data)
19
+ when Hash
20
+ parse_hash(data)
21
+ else
22
+ raise(ValidationError, "Engine")
23
+ end
24
+ end
25
+
26
+ private
27
+
28
+ #
29
+ #
30
+ def self.parse_string(data)
31
+ name, version = data.split(/\s+/)
32
+ new(:name=>name, :version=>version)
33
+ end
34
+
35
+ #
36
+ #
37
+ def self.parse_array(data)
38
+ name, version = *data
39
+ new(:name=>name, :version=>version)
40
+ end
41
+
42
+ #
43
+ #
44
+ def self.parse_hash(data)
45
+ new(data)
46
+ end
47
+
48
+ public
49
+
50
+ #
51
+ # The name of the package that causes the conflict.
52
+ #
53
+ # Yea it's *ALWAYS* THEIR fault ;-)
54
+ #
55
+ attr :name
56
+
57
+ #
58
+ # Set the name of the package.
59
+ #
60
+ def name=(name)
61
+ @data[:name] = name.to_s
62
+ end
63
+
64
+ #
65
+ # The versions constraint of the conflicting package.
66
+ # This is used when only certain versions of the package
67
+ # are the problem.
68
+ #
69
+ attr_reader :version
70
+
71
+ #
72
+ # Set the version constraint.
73
+ #
74
+ def version=(version)
75
+ @data[:version] = Version::Constraint.parse(version)
76
+ end
77
+
78
+ #
79
+ #
80
+ #
81
+ def to_h
82
+ {'name'=>name, 'version'=>version.to_s}
83
+ end
84
+
85
+ end
86
+
87
+ end
@@ -254,21 +254,22 @@ module Indexer
254
254
  # ]
255
255
  #
256
256
  def engines=(engines)
257
- @data['engines'] = Array(engines).map do |engine|
258
- case engine
259
- when String
260
- name, vers = engine.strip.split(/\s+/)
261
- vers = nil if vers.empty?
262
- when Array
263
- name, vers = *engine
264
- when Hash
265
- name = engine['name']
266
- vers = engine['version']
267
- end
268
- e = {}
269
- e['name'] = name
270
- e['version'] = Version::Constraint.parse(vers) if vers
271
- e
257
+ @data[:engines] = Array(engines).map do |engine|
258
+ Engine.parse(engine)
259
+ #case engine
260
+ #when String
261
+ # name, vers = engine.strip.split(/\s+/)
262
+ # vers = nil if vers.empty?
263
+ #when Array
264
+ # name, vers = *engine
265
+ #when Hash
266
+ # name = engine['name']
267
+ # vers = engine['version']
268
+ #end
269
+ #e = {}
270
+ #e['name'] = name
271
+ #e['version'] = Version::Constraint.parse(vers) if vers
272
+ #e
272
273
  end
273
274
  end
274
275
 
@@ -334,6 +335,7 @@ module Indexer
334
335
 
335
336
  h['version'] = version.to_s if version
336
337
  h['repository'] = repository.to_h if repository
338
+ h['engines'] = engines.map{ |e| e.to_h }
337
339
 
338
340
  h.delete('groups') if h['groups'] && h['groups'].empty?
339
341
  h.delete('engines') if h['engines'] && h['engines'].empty?
@@ -65,15 +65,15 @@ module Indexer
65
65
 
66
66
  # TODO: how to handle license(s) ?
67
67
 
68
- self.name = gemspec.name
69
- self.version = gemspec.version.to_s
70
- self.date = gemspec.date
71
- self.title = gemspec.name.capitalize
72
- self.summary = gemspec.summary
73
- self.description = gemspec.description || gemspec.summary
74
- self.authors = authors
75
- self.load_path = gemspec.require_paths
76
- self.homepage = gemspec.homepage
68
+ self.name = gemspec.name
69
+ self.version = gemspec.version.to_s
70
+ self.date = gemspec.date
71
+ self.title = gemspec.name.capitalize
72
+ self.summary = gemspec.summary
73
+ self.description = gemspec.description || gemspec.summary
74
+ self.authors = authors
75
+ self.paths['load'] = gemspec.require_paths
76
+ self.homepage = gemspec.homepage
77
77
 
78
78
  #self.engines = gemspec.platform
79
79
  #self.extensions = gemspec.extensions
@@ -155,7 +155,8 @@ module Indexer
155
155
  end
156
156
 
157
157
  def require_paths
158
- metadata['load_path'] || ['lib']
158
+ paths = metadata['paths'] || {}
159
+ paths['load'] || ['lib']
159
160
  end
160
161
 
161
162
  #
@@ -0,0 +1,89 @@
1
+ class Hash
2
+
3
+ unless method_defined?(:rekey)
4
+
5
+ # Rekey a hash:
6
+ #
7
+ # rekey()
8
+ # rekey(from_key => to_key, ...)
9
+ # rekey{|from_key| to_key}
10
+ # rekey{|from_key, value| to_key}
11
+ #
12
+ # If a key map is given, then the first key is changed to the second key.
13
+ #
14
+ # foo = { :a=>1, :b=>2 }
15
+ # foo.rekey(:a=>'a') #=> { 'a'=>1, :b=>2 }
16
+ # foo.rekey(:b=>:x) #=> { :a =>1, :x=>2 }
17
+ # foo.rekey('foo'=>'bar') #=> { :a =>1, :b=>2 }
18
+ #
19
+ # If a block is given, converts all keys in the Hash accroding to the
20
+ # given block procedure. If the block returns +NA+ for a given key,
21
+ # then that key will be left intact.
22
+ #
23
+ # foo = { :name=>'Gavin', :wife=>:Lisa }
24
+ # foo.rekey{ |k| k.to_s } #=> { "name"=>"Gavin", "wife"=>:Lisa }
25
+ # foo #=> { :name =>"Gavin", :wife=>:Lisa }
26
+ #
27
+ # If no key map or block is given, then all keys are converted
28
+ # to Symbols.
29
+ #
30
+ # Note that if both a +key_map+ and a block are given, the +key_map+ is
31
+ # applied first then the block.
32
+ #
33
+ # CREDIT: Trans, Gavin Kistner
34
+
35
+ def rekey(key_map=nil, &block)
36
+ if !(key_map or block)
37
+ block = lambda{|k| k.to_sym}
38
+ end
39
+
40
+ key_map ||= {}
41
+
42
+ hash = dup.replace({}) # to keep default_proc
43
+
44
+ (keys - key_map.keys).each do |key|
45
+ hash[key] = self[key]
46
+ end
47
+
48
+ key_map.each do |from, to|
49
+ hash[to] = self[from] if key?(from)
50
+ end
51
+
52
+ if block
53
+ hash2 = dup.replace({})
54
+ case block.arity
55
+ when 2 # TODO: is this condition needed?
56
+ hash.each do |k, v|
57
+ nk = block.call(k,v)
58
+ nk = (nk ? nk : k)
59
+ hash2[nk] = v
60
+ end
61
+ else
62
+ hash.each do |k, v|
63
+ nk = block.call(k)
64
+ nk = (nk ? nk : k)
65
+ hash2[nk] = v
66
+ end
67
+ end
68
+ else
69
+ hash2 = hash
70
+ end
71
+
72
+ hash2
73
+ end
74
+
75
+ # Synonym for Hash#rekey, but modifies the receiver in place (and returns it).
76
+ #
77
+ # foo = { :name=>'Gavin', :wife=>:Lisa }
78
+ # foo.rekey!{ |k| k.to_s } #=> { "name"=>"Gavin", "wife"=>:Lisa }
79
+ # foo #=> { "name"=>"Gavin", "wife"=>:Lisa }
80
+ #
81
+ # CREDIT: Trans, Gavin Kistner
82
+
83
+ def rekey!(key_map=nil, &block)
84
+ replace(rekey(key_map, &block))
85
+ end
86
+
87
+ end
88
+
89
+ end