Module: Propro::Package
- Defined in:
- lib/propro/package.rb
Constant Summary collapse
- EXTRACT_NAME_RE =
%r{/ext/bash/([a-z0-9_\-/]+)\.sh}
- SORTED_NAMES =
%w[ lib/propro lib/ubuntu lib/system lib/pg lib/rvm lib/nginx lib/node lib/redis lib/ffmpeg vps/system app app/rvm app/pg app/nginx app/sidekiq app/monit app/ffmpeg app/puma app/puma/nginx app/node app/unicorn app/unicorn/nginx app/unicorn/monit db/pg db/redis vagrant vagrant/system vagrant/pg vagrant/redis vagrant/rvm vagrant/node vagrant/nginx vagrant/ffmpeg lib/extras ]
Class Method Summary collapse
- .resort!(ary) ⇒ Object
- .root ⇒ Object
- .source_files ⇒ Object
- .sources ⇒ Object
- .sources_for_path(path) ⇒ Object
- .sources_for_paths(*paths) ⇒ Object
Class Method Details
.resort!(ary) ⇒ Object
70 71 72 73 |
# File 'lib/propro/package.rb', line 70 def resort!(ary) ary.sort_by! { |source| SORTED_NAMES.index(source.name) } ary end |
.root ⇒ Object
43 44 45 |
# File 'lib/propro/package.rb', line 43 def root File.join(Propro.root, 'ext/bash') end |
.source_files ⇒ Object
47 48 49 |
# File 'lib/propro/package.rb', line 47 def source_files @source_files ||= Dir[File.join(root, '**/*.sh')] end |
.sources ⇒ Object
51 52 53 54 55 56 57 58 59 60 |
# File 'lib/propro/package.rb', line 51 def sources @sources ||= begin names = SORTED_NAMES.dup source_files.each do |file| name = EXTRACT_NAME_RE.match(file)[1] names.push(name) unless names.include?(name) end names.map { |name| Source.new(name) } end end |
.sources_for_path(path) ⇒ Object
62 63 64 |
# File 'lib/propro/package.rb', line 62 def sources_for_path(path) resort! sources.select { |source| /\A#{path}/ =~ source.name } end |
.sources_for_paths(*paths) ⇒ Object
66 67 68 |
# File 'lib/propro/package.rb', line 66 def sources_for_paths(*paths) resort! paths.flatten.map { |path| sources_for_path(path) }.flatten end |