Class: Glean::Dataset
- Inherits:
-
Object
- Object
- Glean::Dataset
- Includes:
- Enumerable
- Defined in:
- lib/glean/dataset.rb
Instance Attribute Summary collapse
-
#identifier ⇒ Object
readonly
Returns the value of attribute identifier.
Instance Method Summary collapse
- #each ⇒ Object
-
#initialize(identifier, dir = "~") ⇒ Dataset
constructor
A new instance of Dataset.
- #path ⇒ Object
- #repo_url ⇒ Object
- #storage_path ⇒ Object
- #sync ⇒ Object
Constructor Details
#initialize(identifier, dir = "~") ⇒ Dataset
Returns a new instance of Dataset.
7 8 9 10 11 |
# File 'lib/glean/dataset.rb', line 7 def initialize(identifier, dir="~") @identifier = Glean::Source.resolve_identifier(identifier) @dir = dir sync end |
Instance Attribute Details
#identifier ⇒ Object (readonly)
Returns the value of attribute identifier.
5 6 7 |
# File 'lib/glean/dataset.rb', line 5 def identifier @identifier end |
Instance Method Details
#each ⇒ Object
35 36 37 38 39 |
# File 'lib/glean/dataset.rb', line 35 def each Dir.glob(File.join(path, "**", "*.toml")) do |f| yield Hashie::Mash.new(TOML.load_file(f)) end end |
#path ⇒ Object
17 18 19 |
# File 'lib/glean/dataset.rb', line 17 def path File.join(storage_path, identifier) end |
#repo_url ⇒ Object
21 22 23 |
# File 'lib/glean/dataset.rb', line 21 def repo_url "http://github.com/#{identifier}" end |
#storage_path ⇒ Object
13 14 15 |
# File 'lib/glean/dataset.rb', line 13 def storage_path File.join(File.(@dir), ".glean") end |
#sync ⇒ Object
25 26 27 28 29 30 31 32 33 |
# File 'lib/glean/dataset.rb', line 25 def sync Dir.mkdir(storage_path) unless File.exists?(storage_path) begin g = Git.open(path) g.pull rescue Git.clone(repo_url, identifier, :path => storage_path) end end |