module Mono
mononame (e.g. @org/hello) machinery turn
-
@openfootball/england/2020-21
-
2020-21@openfootball/england
-
openfootball at
england/2020-21
=> into
-
openfootball/england/2020-21
Public Class Methods
parse_name( line )
click to toggle source
shared parse/norm helper (for Name/Path)
- find something better - why? why not?
# 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()
click to toggle source
# 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.expand_path( ENV['MOPATH'] ) elsif Dir.exist?( 'C:/Sites' ) 'C:/Sites' else '/sites' end end end
root=( path )
click to toggle source
# File lib/monofile.rb, line 47 def self.root=( path ) ## use expand path to make (assure) absolute path - why? why not? @@root = File.expand_path( path ) end