Class: Chino::Chinofile

Inherits:
Object
  • Object
show all
Defined in:
lib/chino/chinofile.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(path: `pwd`.chomp.to_s, &block) ⇒ Chinofile

Returns a new instance of Chinofile.



7
8
9
10
11
# File 'lib/chino/chinofile.rb', line 7

def initialize(path: `pwd`.chomp.to_s, &block)
  @information = defaults(path)

  instance_eval(&block)
end

Instance Attribute Details

#informationObject

Returns the value of attribute information.



5
6
7
# File 'lib/chino/chinofile.rb', line 5

def information
  @information
end

Instance Method Details

#author(value) ⇒ Object



21
22
23
# File 'lib/chino/chinofile.rb', line 21

def author(value)
  @information[:author] = value
end

#author_email(value) ⇒ Object



25
26
27
# File 'lib/chino/chinofile.rb', line 25

def author_email(value)
  @information[:author_email] = value
end

#company_name(value) ⇒ Object



29
30
31
# File 'lib/chino/chinofile.rb', line 29

def company_name(value)
  @information[:company_name] = value
end

#created_at(value) ⇒ Object



37
38
39
# File 'lib/chino/chinofile.rb', line 37

def created_at(value)
  @information[:created_at] = value
end

#exports(filename) ⇒ Object



41
42
43
# File 'lib/chino/chinofile.rb', line 41

def exports(filename)
  @information[:exports][filename] = File.join(@information[:path], filename)
end

#find_file(filename) ⇒ Object



52
53
54
55
56
# File 'lib/chino/chinofile.rb', line 52

def find_file(filename)
  return @information[:exports][filename] if @information[:exports][filename]

  @information[:dependencies].map { |_k, v| v.find_file(filename) }.select { |x| x }.first
end

#identifier(value) ⇒ Object



33
34
35
# File 'lib/chino/chinofile.rb', line 33

def identifier(value)
  @information[:identifier] = value
end

#imports(hash = {}) ⇒ Object



45
46
47
48
49
50
# File 'lib/chino/chinofile.rb', line 45

def imports(hash = {})
  driver = hash.keys.first
  location = hash[driver]
  version = hash[:version]
  @information[:dependencies] << { driver: driver.to_s, version: version, location: location }
end

#name(value) ⇒ Object



13
14
15
# File 'lib/chino/chinofile.rb', line 13

def name(value)
  @information[:name] = value
end

#version(value) ⇒ Object



17
18
19
# File 'lib/chino/chinofile.rb', line 17

def version(value)
  @information[:version] = value
end