glean 0.0.12 → 0.0.13
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.
- data/Gemfile.lock +1 -1
- data/README.md +7 -8
- data/bin/glean +5 -1
- data/lib/glean.rb +7 -0
- data/lib/glean/formatter.rb +23 -0
- data/lib/glean/formatter/JSON.rb +9 -0
- data/lib/glean/formatter/YAML.rb +9 -0
- data/lib/glean/source.rb +1 -1
- data/lib/glean/version.rb +1 -1
- metadata +5 -2
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -9,19 +9,18 @@ SYNOPSIS
|
|
9
9
|
glean [global options] command [command options] [arguments...]
|
10
10
|
|
11
11
|
VERSION
|
12
|
-
0.0.
|
12
|
+
0.0.12
|
13
13
|
|
14
14
|
GLOBAL OPTIONS
|
15
|
-
|
16
|
-
--
|
17
|
-
-s, --[no-]switch - Describe some switch here
|
18
|
-
--version -
|
15
|
+
--help - Show this message
|
16
|
+
--version -
|
19
17
|
|
20
18
|
COMMANDS
|
19
|
+
export - Export a dataset
|
21
20
|
get - Download a dataset by name
|
22
21
|
help - Shows a list of commands or help for one command
|
23
|
-
|
24
|
-
search -
|
22
|
+
info - Show dataset information
|
23
|
+
search - Search for datasets
|
25
24
|
```
|
26
25
|
|
27
26
|
## Rails
|
@@ -36,7 +35,7 @@ db/seeds.rb:
|
|
36
35
|
if Country.count == 0
|
37
36
|
countries = Glean::Dataset.new('glean/countries')
|
38
37
|
countries.each do |country|
|
39
|
-
Country.create :name => country
|
38
|
+
Country.create :name => country.name, :code => country.code
|
40
39
|
end
|
41
40
|
end
|
42
41
|
```
|
data/bin/glean
CHANGED
@@ -20,10 +20,14 @@ end
|
|
20
20
|
desc 'Export a dataset'
|
21
21
|
arg_name '<dataset>'
|
22
22
|
command :export do |c|
|
23
|
+
c.desc 'Set the export format'
|
24
|
+
c.default_value "json"
|
25
|
+
c.flag [:f,:format], :type => String, :must_match => Glean::Formatter.available_formatters
|
23
26
|
c.action do |global_options,options,args|
|
24
27
|
dataset = Glean::Dataset.new(args[0])
|
25
28
|
dataset.each do |datum|
|
26
|
-
|
29
|
+
formatter = Glean::Formatter.format(options[:format])
|
30
|
+
puts formatter.format(datum)
|
27
31
|
end
|
28
32
|
end
|
29
33
|
end
|
data/lib/glean.rb
CHANGED
@@ -1,13 +1,20 @@
|
|
1
1
|
require 'glean/glean'
|
2
2
|
require 'glean/dataset'
|
3
|
+
|
4
|
+
require 'glean/formatter'
|
5
|
+
require 'glean/formatter/JSON'
|
6
|
+
require 'glean/formatter/YAML'
|
7
|
+
|
3
8
|
require 'glean/source'
|
4
9
|
require 'glean/source/core'
|
5
10
|
require 'glean/source/contrib'
|
6
11
|
require 'glean/source/user'
|
12
|
+
|
7
13
|
require 'glean/version'
|
8
14
|
|
9
15
|
require 'git'
|
10
16
|
require 'hashie/mash'
|
17
|
+
require 'json'
|
11
18
|
require 'octokit'
|
12
19
|
require 'toml'
|
13
20
|
# Add requires for other files you add to your project here, so
|
@@ -0,0 +1,23 @@
|
|
1
|
+
module Glean
|
2
|
+
module Formatter
|
3
|
+
def self.format(format)
|
4
|
+
submodules.detect do |submodule|
|
5
|
+
format == submodule.name.split("::").last.downcase
|
6
|
+
end
|
7
|
+
end
|
8
|
+
|
9
|
+
def self.available_formatters
|
10
|
+
submodules.collect do |submodule|
|
11
|
+
submodule.name.split("::").last.downcase
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
def self.submodules
|
16
|
+
constants.collect do |const_name|
|
17
|
+
const_get(const_name)
|
18
|
+
end.select do |const|
|
19
|
+
const.class == Module
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
data/lib/glean/source.rb
CHANGED
@@ -9,7 +9,7 @@ module Glean
|
|
9
9
|
end
|
10
10
|
|
11
11
|
def self.search(query)
|
12
|
-
(Core.search(query) + Contrib.search(query) + User.search(query)).sort
|
12
|
+
(Core.search(query) + Contrib.search(query) + User.search(query)).sort { |a, b| a.name <=> b.name }
|
13
13
|
end
|
14
14
|
|
15
15
|
def self.info(identifier)
|
data/lib/glean/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: glean
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.13
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-04-
|
12
|
+
date: 2013-04-19 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rake
|
@@ -220,6 +220,9 @@ files:
|
|
220
220
|
- glean.gemspec
|
221
221
|
- lib/glean.rb
|
222
222
|
- lib/glean/dataset.rb
|
223
|
+
- lib/glean/formatter.rb
|
224
|
+
- lib/glean/formatter/JSON.rb
|
225
|
+
- lib/glean/formatter/YAML.rb
|
223
226
|
- lib/glean/glean.rb
|
224
227
|
- lib/glean/source.rb
|
225
228
|
- lib/glean/source/contrib.rb
|