prefix-cmd 0.1 → 0.2

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.
Files changed (5) hide show
  1. data/README.rdoc +12 -2
  2. data/Rakefile +1 -1
  3. data/bin/prefix-cmd +2 -2
  4. data/lib/prefix.rb +15 -3
  5. metadata +4 -4
@@ -9,6 +9,16 @@ What I really wanted is a way to query the knowledge base both on and offline.
9
9
 
10
10
  Prefix command provides you with a simple command-line tool to do exactly that.
11
11
 
12
+ INSTALLATION
13
+
14
+ [sudo] gem install prefix-cmd
15
+
16
+ Or grab the source and:
17
+
18
+ rake install
19
+
20
+ USAGE
21
+
12
22
  The command caches a local copy of the data available from:
13
23
 
14
24
  http://prefix.cc/popular/all
@@ -23,10 +33,10 @@ There are three options:
23
33
 
24
34
  To lookup a URI:
25
35
 
26
- prefix-cmd uri [prefix]
36
+ prefix-cmd uri [prefix|curie]
27
37
 
28
38
  To suggest a prefix:
29
39
 
30
40
  prefix-cmd prefix [uri]
31
41
 
32
- Thats all!
42
+ Thats all!
data/Rakefile CHANGED
@@ -9,7 +9,7 @@ require "redis"
9
9
  require "digest/md5"
10
10
 
11
11
  NAME = "prefix-cmd"
12
- VER = "0.1"
12
+ VER = "0.2"
13
13
 
14
14
  PKG_FILES = %w( README.rdoc Rakefile ) +
15
15
  Dir.glob("{bin,lib}/**/*")
@@ -17,8 +17,8 @@ MODE
17
17
  Initializes your local cache of data, or refreshes a previously cached copy
18
18
  The data is stored in ~/.prefix-cmd/prefixes.json
19
19
 
20
- uri [prefix]
21
- Lookup the uri for a given prefix
20
+ uri [prefix|curie]
21
+ Lookup the uri for a given prefix, or expand curie to uri
22
22
 
23
23
  prefix [uri]
24
24
  Lookup the prefix for a given vocabulary URI
@@ -27,10 +27,19 @@ class Prefix
27
27
 
28
28
  end
29
29
 
30
- def Prefix.uri(prefix)
30
+ def Prefix.uri(prefix_or_curie)
31
31
  init() unless test ?e, CONFIG_FILE
32
32
  json = JSON.load( File.open(CONFIG_FILE, "r") )
33
- puts json[prefix] || "Unknown prefix #{prefix}"
33
+ if Prefix.curie? prefix_or_curie
34
+ match = prefix_or_curie.match /([^:]*):(.*)/
35
+ if json[match[1]]
36
+ puts json[match[1]] + match[2]
37
+ else
38
+ puts "Unknown prefix #{match[1]}"
39
+ end
40
+ else
41
+ puts json[prefix_or_curie] || "Unknown prefix #{prefix_or_curie}"
42
+ end
34
43
  end
35
44
 
36
45
  def Prefix.prefix(uri)
@@ -41,4 +50,7 @@ class Prefix
41
50
  end
42
51
  end
43
52
 
44
- end
53
+ def Prefix.curie?(prefix_or_curie)
54
+ prefix_or_curie.include? ':'
55
+ end
56
+ end
metadata CHANGED
@@ -1,12 +1,12 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: prefix-cmd
3
3
  version: !ruby/object:Gem::Version
4
- hash: 9
4
+ hash: 15
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
- - 1
9
- version: "0.1"
8
+ - 2
9
+ version: "0.2"
10
10
  platform: ruby
11
11
  authors:
12
12
  - Leigh Dodds
@@ -14,7 +14,7 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2010-08-26 00:00:00 +01:00
17
+ date: 2010-09-20 00:00:00 +01:00
18
18
  default_executable:
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency