Class: Allen::MetaData
- Inherits:
-
Object
- Object
- Allen::MetaData
- Defined in:
- lib/allen/meta_data.rb
Defined Under Namespace
Classes: NullCommit
Instance Attribute Summary collapse
-
#root_dir ⇒ Object
readonly
Returns the value of attribute root_dir.
-
#webroot ⇒ Object
readonly
Returns the value of attribute webroot.
Instance Method Summary collapse
- #allen ⇒ Object
- #build ⇒ Object
- #commit ⇒ Object
-
#initialize(settings) ⇒ MetaData
constructor
A new instance of MetaData.
- #save! ⇒ Object
- #to_json ⇒ Object
Constructor Details
Instance Attribute Details
#root_dir ⇒ Object (readonly)
Returns the value of attribute root_dir.
5 6 7 |
# File 'lib/allen/meta_data.rb', line 5 def root_dir @root_dir end |
#webroot ⇒ Object (readonly)
Returns the value of attribute webroot.
5 6 7 |
# File 'lib/allen/meta_data.rb', line 5 def webroot @webroot end |
Instance Method Details
#allen ⇒ Object
38 39 40 |
# File 'lib/allen/meta_data.rb', line 38 def allen { :version => Allen::VERSION } end |
#build ⇒ Object
24 25 26 |
# File 'lib/allen/meta_data.rb', line 24 def build { :date => Time.now.to_s } end |
#commit ⇒ Object
28 29 30 31 32 33 34 35 36 |
# File 'lib/allen/meta_data.rb', line 28 def commit repo = Grit::Repo.new(@root_dir) commit = repo.commits.first || NullCommit.new { :id => commit.id, :date => commit.committed_date, :author => commit., :message => commit. } end |
#save! ⇒ Object
12 13 14 15 16 |
# File 'lib/allen/meta_data.rb', line 12 def save! file = File.open("#{@webroot}/meta.json","w") file.print(self.to_json) file.close end |
#to_json ⇒ Object
18 19 20 21 22 |
# File 'lib/allen/meta_data.rb', line 18 def to_json { :build => build, :commit => commit, :allen => allen }.to_json end |