Module: Mono
- Defined in:
- lib/monofile.rb,
lib/monofile/version.rb,
lib/monofile/mononame.rb
Defined Under Namespace
Modules: Module
Class Method Summary collapse
-
.parse_name(line) ⇒ Object
shared parse/norm helper (for Name/Path) - find something better - why? why not?.
-
.root ⇒ Object
root of single (monorepo) source tree.
- .root=(path) ⇒ Object
Class Method Details
.parse_name(line) ⇒ Object
shared parse/norm helper (for Name/Path)
- find something better - why? why not?
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/monofile/mononame.rb', line 16 def self.parse_name( line ) if line.is_a?( String ) parts = line.split( '@' ) raise ArgumentError, "[Mononame] no @ found BUT required in name; got >#{line}<" if parts.size == 1 raise ArgumentError, "[Mononame] too many @ found (#{parts.size-1}) in name; got >#{line}<" if parts.size > 2 ## pass 1) rebuild (normalized) name/path name = String.new('') name << parts[1] ## add orgs path first - w/o leading @ - gets removed by split :-) if parts[0].length > 0 ## has leading repo name (w/ optional path) name << '/' name << parts[0] end ## pass 2) split (normalized) name/path into components (org/name/path) parts = name.split( '/' ) args = [parts[0], parts[1]] more_parts = parts[2..-1] ## check for any extra (optional) path parts args << more_parts.join( '/' ) if more_parts.size > 0 args else raise ArgumentError, "[Mononame] string with @ expected; got: #{line.pretty_inspect} of type #{line.class.name}" end end |
.root ⇒ Object
root of single (monorepo) source tree
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/monofile.rb', line 31 def self.root ## root of single (monorepo) source tree @@root ||= begin ## todo/fix: ## check if windows - otherwise use /sites ## check if root directory exists? if ENV['MOPATH'] ## use expand path to make (assure) absolute path - why? why not? File.( ENV['MOPATH'] ) elsif Dir.exist?( 'C:/Sites' ) 'C:/Sites' else '/sites' end end end |
.root=(path) ⇒ Object
47 48 49 50 |
# File 'lib/monofile.rb', line 47 def self.root=( path ) ## use expand path to make (assure) absolute path - why? why not? @@root = File.( path ) end |