glean 0.0.3 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +44 -0
- data/bin/glean +0 -1
- data/lib/glean/dataset.rb +24 -4
- data/lib/glean/version.rb +1 -1
- data/lib/glean.rb +0 -1
- metadata +2 -2
- data/lib/glean/datum.rb +0 -13
data/README.md
ADDED
@@ -0,0 +1,44 @@
|
|
1
|
+
# Glean - A data management tool for humans
|
2
|
+
|
3
|
+
## Command line
|
4
|
+
```
|
5
|
+
NAME
|
6
|
+
glean - A data management tool for humans
|
7
|
+
|
8
|
+
SYNOPSIS
|
9
|
+
glean [global options] command [command options] [arguments...]
|
10
|
+
|
11
|
+
VERSION
|
12
|
+
0.0.3
|
13
|
+
|
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 -
|
19
|
+
|
20
|
+
COMMANDS
|
21
|
+
get - Download a dataset by name
|
22
|
+
help - Shows a list of commands or help for one command
|
23
|
+
out - Describe out here
|
24
|
+
search - Describe search here
|
25
|
+
```
|
26
|
+
|
27
|
+
## Rails
|
28
|
+
|
29
|
+
Gemfile:
|
30
|
+
```ruby
|
31
|
+
gem 'glean'
|
32
|
+
```
|
33
|
+
|
34
|
+
db/seeds.rb:
|
35
|
+
```ruby
|
36
|
+
countries = Glean::Dataset.new('glean/countries')
|
37
|
+
countries.each do |country|
|
38
|
+
Country.create :name => country[:name], :code => country[:code]
|
39
|
+
end
|
40
|
+
```
|
41
|
+
|
42
|
+
## Other Frameworks
|
43
|
+
|
44
|
+
I'm not sure how you'd do it, but I want to make it easy. Open an issue, or better yet drop some code in a Pull Request.
|
data/bin/glean
CHANGED
data/lib/glean/dataset.rb
CHANGED
@@ -4,6 +4,7 @@ module Glean
|
|
4
4
|
|
5
5
|
def initialize(identifier)
|
6
6
|
@identifier = identifier
|
7
|
+
sync
|
7
8
|
end
|
8
9
|
|
9
10
|
def storage_path
|
@@ -14,14 +15,33 @@ module Glean
|
|
14
15
|
File.join(storage_path, identifier)
|
15
16
|
end
|
16
17
|
|
17
|
-
def
|
18
|
-
|
18
|
+
def sync
|
19
|
+
begin
|
20
|
+
g = Git.open(path)
|
21
|
+
g.pull
|
22
|
+
rescue
|
23
|
+
Git.clone("http://github.com/#{identifier}", identifier, :path => storage_path)
|
24
|
+
end
|
19
25
|
end
|
20
26
|
|
21
|
-
def
|
27
|
+
def each
|
22
28
|
Dir.glob(File.join(path, "*")) do |d|
|
23
|
-
yield
|
29
|
+
yield directory_hash(d)
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
def directory_hash(path)
|
34
|
+
data = {}
|
35
|
+
Dir.foreach(path) do |entry|
|
36
|
+
next if (entry == '..' || entry == '.')
|
37
|
+
full_path = File.join(path, entry)
|
38
|
+
if File.directory?(full_path)
|
39
|
+
data[entry.to_sym] = directory_hash(full_path)
|
40
|
+
else
|
41
|
+
data[entry.to_sym] = File.read(full_path).chomp
|
42
|
+
end
|
24
43
|
end
|
44
|
+
return data
|
25
45
|
end
|
26
46
|
end
|
27
47
|
end
|
data/lib/glean/version.rb
CHANGED
data/lib/glean.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.4
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -103,6 +103,7 @@ files:
|
|
103
103
|
- .gitignore
|
104
104
|
- Gemfile
|
105
105
|
- Gemfile.lock
|
106
|
+
- README.md
|
106
107
|
- README.rdoc
|
107
108
|
- Rakefile
|
108
109
|
- bin/glean
|
@@ -113,7 +114,6 @@ files:
|
|
113
114
|
- glean.rdoc
|
114
115
|
- lib/glean.rb
|
115
116
|
- lib/glean/dataset.rb
|
116
|
-
- lib/glean/datum.rb
|
117
117
|
- lib/glean/version.rb
|
118
118
|
- test/default_test.rb
|
119
119
|
- test/test_helper.rb
|