Class: Glean::Dataset
- Inherits:
-
Object
- Object
- Glean::Dataset
- 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.
5 6 7 8 9 |
# File 'lib/glean/dataset.rb', line 5 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.
3 4 5 |
# File 'lib/glean/dataset.rb', line 3 def identifier @identifier end |
Instance Method Details
#each ⇒ Object
33 34 35 36 37 |
# File 'lib/glean/dataset.rb', line 33 def each Dir.glob(File.join(path, "**", "*.toml")) do |f| yield Hashie::Mash.new(TOML.load_file(f)) end end |
#path ⇒ Object
15 16 17 |
# File 'lib/glean/dataset.rb', line 15 def path File.join(storage_path, identifier) end |
#repo_url ⇒ Object
19 20 21 |
# File 'lib/glean/dataset.rb', line 19 def repo_url "http://github.com/#{identifier}" end |
#storage_path ⇒ Object
11 12 13 |
# File 'lib/glean/dataset.rb', line 11 def storage_path File.join(File.(@dir), ".glean") end |
#sync ⇒ Object
23 24 25 26 27 28 29 30 31 |
# File 'lib/glean/dataset.rb', line 23 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 |