glean 0.0.12 → 0.0.13

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- glean (0.0.12)
4
+ glean (0.0.13)
5
5
  git (= 1.2.5)
6
6
  gli (= 2.5.4)
7
7
  hashie (= 2.0.3)
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.3
12
+ 0.0.12
13
13
 
14
14
  GLOBAL OPTIONS
15
- -f, --flagname=The name of the argument - Describe some flag here (default: the default)
16
- --help - Show this message
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
- out - Describe out here
24
- search - Describe search here
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[:name], :code => country[:code]
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
- puts datum
29
+ formatter = Glean::Formatter.format(options[:format])
30
+ puts formatter.format(datum)
27
31
  end
28
32
  end
29
33
  end
@@ -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
@@ -0,0 +1,9 @@
1
+ module Glean
2
+ module Formatter
3
+ module JSON
4
+ def self.format(obj)
5
+ obj.to_json
6
+ end
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,9 @@
1
+ module Glean
2
+ module Formatter
3
+ module YAML
4
+ def self.format(obj)
5
+ obj.to_yaml
6
+ end
7
+ end
8
+ end
9
+ end
@@ -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)
@@ -1,3 +1,3 @@
1
1
  module Glean
2
- VERSION = '0.0.12'
2
+ VERSION = '0.0.13'
3
3
  end
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.12
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-13 00:00:00.000000000 Z
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