Class: Canpe::Repository
- Inherits:
-
Object
- Object
- Canpe::Repository
- Defined in:
- lib/canpe/repository.rb
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#store ⇒ Object
readonly
Returns the value of attribute store.
Instance Method Summary collapse
- #binding_option_url ⇒ Object
- #binding_options ⇒ Object
- #file_paths(absolute_path: false) ⇒ Object
-
#initialize(name, store) ⇒ Repository
constructor
A new instance of Repository.
- #match?(query) ⇒ Boolean
-
#repository_url ⇒ Object
Directory which is root directory of this repository.
-
#templates_url ⇒ Object
Directory in which templates file exists.
- #to_s ⇒ Object
Constructor Details
#initialize(name, store) ⇒ Repository
Returns a new instance of Repository.
12 13 14 15 |
# File 'lib/canpe/repository.rb', line 12 def initialize(name, store) @name = name @store = store end |
Instance Attribute Details
#name ⇒ Object (readonly)
Returns the value of attribute name.
10 11 12 |
# File 'lib/canpe/repository.rb', line 10 def name @name end |
#store ⇒ Object (readonly)
Returns the value of attribute store.
10 11 12 |
# File 'lib/canpe/repository.rb', line 10 def store @store end |
Instance Method Details
#binding_option_url ⇒ Object
27 28 29 |
# File 'lib/canpe/repository.rb', line 27 def binding_option_url File.join(repository_url, 'binding.yml') end |
#binding_options ⇒ Object
31 32 33 |
# File 'lib/canpe/repository.rb', line 31 def @_binding_options ||= File.exists?(binding_option_url) ? YAML.load_file(binding_option_url) : {} end |
#file_paths(absolute_path: false) ⇒ Object
35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/canpe/repository.rb', line 35 def file_paths(absolute_path: false) files = Dir.glob(File.join(templates_url, '**', '*'), File::FNM_DOTMATCH) files = files.reject { |e| [".", ".."].any? { |s| s== File::basename(e) } } if absolute_path files.map { |file| Pathname.new(file) } else base = Pathname.new(templates_url) files.map { |file| Pathname.new(file).relative_path_from(base) } end end |
#match?(query) ⇒ Boolean
51 52 53 |
# File 'lib/canpe/repository.rb', line 51 def match?(query) /#{query}/ === to_s end |
#repository_url ⇒ Object
Directory which is root directory of this repository
18 19 20 |
# File 'lib/canpe/repository.rb', line 18 def repository_url File.join(store.repositories_root, name) end |
#templates_url ⇒ Object
Directory in which templates file exists
23 24 25 |
# File 'lib/canpe/repository.rb', line 23 def templates_url File.join(store.repositories_root, name, 'templates') end |
#to_s ⇒ Object
47 48 49 |
# File 'lib/canpe/repository.rb', line 47 def to_s "#{store.name}::#{name}" end |