Class: Vim::Flavor::FlavorFile

Inherits:
Object
  • Object
show all
Defined in:
lib/vim-flavor/flavorfile.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.load(flavorfile_path) ⇒ Object



23
24
25
26
27
# File 'lib/vim-flavor/flavorfile.rb', line 23

def self.load(flavorfile_path)
  ff = new()
  ff.load(flavorfile_path)
  ff
end

.load_or_new(flavorfile_path) ⇒ Object



17
18
19
20
21
# File 'lib/vim-flavor/flavorfile.rb', line 17

def self.load_or_new(flavorfile_path)
  ff = new()
  ff.load(flavorfile_path) if File.exists?(flavorfile_path)
  ff
end

Instance Method Details

#default_groupObject



13
14
15
# File 'lib/vim-flavor/flavorfile.rb', line 13

def default_group
  default_groups.last
end

#default_groupsObject



9
10
11
# File 'lib/vim-flavor/flavorfile.rb', line 9

def default_groups
  @default_groups ||= [:runtime]
end

#flavor(repo_name, *args) ⇒ Object

:call-seq:

flavor repo_name, version_constraint='>= 0', options={} -> a_flavor


38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
# File 'lib/vim-flavor/flavorfile.rb', line 38

def flavor(repo_name, *args)
  a = args.shift()
  if a.kind_of?(String)
    version_constraint = a
    a = args.shift()
  else
    version_constraint = '>= 0'
  end
  options = a.kind_of?(Hash) ? a : {}

  f = Flavor.new()
  f.repo_name = repo_name
  f.version_constraint = VersionConstraint.new(version_constraint)
  f.group = options[:group] || default_group
  flavor_table[f.repo_name] = f
end

#flavor_tableObject

repo_name -> flavor



5
6
7
# File 'lib/vim-flavor/flavorfile.rb', line 5

def flavor_table
  @flavor_table ||= {}
end

#group(group, &block) ⇒ Object



55
56
57
58
59
60
# File 'lib/vim-flavor/flavorfile.rb', line 55

def group(group, &block)
  default_groups.push(group)
  instance_eval &block
ensure
  default_groups.pop()
end

#load(flavorfile_path) ⇒ Object



29
30
31
32
33
34
# File 'lib/vim-flavor/flavorfile.rb', line 29

def load(flavorfile_path)
  instance_eval(
    File.open(flavorfile_path, 'r').read(),
    flavorfile_path
  )
end