monofile 0.2.1 → 0.2.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 972e45a2358abae2cc65d2689004ee6caeffc06a
4
- data.tar.gz: 793fb0d5404a10dd22a1e3478785769683b5b25f
3
+ metadata.gz: 547a6deaf1db0ea792b640dcf686fa5788d0de30
4
+ data.tar.gz: 01fdcf2b3cfc5ddb70eb68dec8a808f0a1edd2e1
5
5
  SHA512:
6
- metadata.gz: 8c5e1a3399d7465f2fa94df7ec9c15cb38890928808850490edf07635a4b98b8e5b4010bf738d892cd5916b1d03a4e3c55187938cb82a32e8b3ac7a888d7db89
7
- data.tar.gz: 95b41e6fd5b0950551b29c605524eba6ce0b59b95591ed148ae70ee205fc317739facfc89738a3dc42c2bac2fb515e9f78b2d8b313c13d63c3145b4a89a87c20
6
+ metadata.gz: e3358beae7a3a96107e13e4b01d0fa065acb629b131acca5031168b85331ff88463a8f9e5f7fac09de0e28eb18f2380322e6e481857a8ec077cb4e4355240298
7
+ data.tar.gz: 7c100f51fb8cb143202016b7d129b80fcf20acea7301c117263b09efec99fdf9ffede2ecb0d47cef266d86489e07de0053b6c586c8d572a0d720fb815d395534
@@ -48,24 +48,11 @@ module Mono
48
48
  ## use expand path to make (assure) absolute path - why? why not?
49
49
  @@root = File.expand_path( path )
50
50
  end
51
-
52
-
53
-
54
- def self.monofile
55
- path = Monofile.find
56
- Monofile.read( path )
57
-
58
- # if path
59
- # GitRepoSet.read( path )
60
- # else
61
- # puts "!! WARN: no mono configuration file found; looking for #{MONOFILES.join(', ')} in (#{Dir.getwd})"
62
- # GitRepoSet.new( {} ) ## return empty set -todo/check: return nil - why? why not?
63
- # end
64
- end
65
51
  end ## module Mono
66
52
 
67
53
 
68
54
 
55
+
69
56
  ###
70
57
  ## add some convenience alias for alternate spelling (CamelCase)
71
58
  MonoName = Mononame
@@ -51,15 +51,12 @@ class Mononame
51
51
  new( *values )
52
52
  end
53
53
 
54
-
55
54
  def self.real_path( line )
56
55
  ## add one-time (quick) usage convenience shortcut
57
- name = parse( line )
58
- name.real_path
56
+ mononame = parse( line )
57
+ mononame.real_path
59
58
  end
60
59
 
61
- ## todo/fix: add real_path
62
-
63
60
 
64
61
  ## note: org and name for now required
65
62
  ## - make name optional too - why? why not?!!!
@@ -76,8 +73,10 @@ class Mononame
76
73
  end
77
74
  end
78
75
 
79
- def to_path() "#{@org}/#{@name}"; end
80
- def to_s() "@#{to_path}"; end
76
+ def to_path() "#{@org}/#{@name}"; end
77
+ def to_s() "@#{to_path}"; end
78
+
79
+ def real_path() "#{Mono.root}/#{to_path}"; end
81
80
  end # class Mononame
82
81
 
83
82
 
@@ -103,6 +102,12 @@ class Monopath
103
102
  new( *values )
104
103
  end
105
104
 
105
+ def self.real_path( line )
106
+ monopath = parse( line )
107
+ monopath.real_path
108
+ end
109
+
110
+
106
111
  ## note: org and name AND path for now required
107
112
  ## - make name path optional too - why? why not?!!!
108
113
  attr_reader :org, :name, :path
@@ -124,8 +129,39 @@ class Monopath
124
129
  end
125
130
  end
126
131
 
127
- def to_path() "#{@org}/#{@name}/#{@path}"; end
128
- def to_s() "@#{to_path}"; end
132
+ def to_path() "#{@org}/#{@name}/#{@path}"; end
133
+ def to_s() "@#{to_path}"; end
134
+
135
+ def real_path() "#{Mono.root}/#{to_path}"; end
136
+
137
+
138
+ ## some File-like convenience helpers
139
+ ## e.g. File.exist? => Monopath.exist?
140
+ ## File.open => Monopath.open( ... ) { block }
141
+ ## etc.
142
+ def self.exist?( line )
143
+ File.exist?( real_path( line ) )
144
+ end
145
+
146
+
147
+ ## path always relative to Mono.root
148
+ ## todo/fix: use File.expand_path( path, Mono.root ) - why? why not?
149
+ ## or always enfore "absolut" path e.g. do NOT allow ../ or ./ or such
150
+ def self.open( line, mode='r:utf-8', &block )
151
+ path = real_path( line )
152
+ ## make sure path exists if we open for writing/appending - why? why not?
153
+ if mode[0] == 'w' || mode[0] == 'a'
154
+ FileUtils.mkdir_p( File.dirname( path ) ) ## make sure path exists
155
+ end
156
+
157
+ File.open( path, mode ) do |file|
158
+ block.call( file )
159
+ end
160
+ end
161
+
162
+ def self.read_utf8( line )
163
+ open( line, 'r:utf-8') { |file| file.read }
164
+ end
129
165
  end # class Monopath
130
166
  ## note: use Monopath - avoid confusion with Monofile (a special file with a list of mono projects)!!!!
131
167
 
@@ -5,7 +5,7 @@ module Monofile
5
5
 
6
6
  MAJOR = 0 ## todo: namespace inside version or something - why? why not??
7
7
  MINOR = 2
8
- PATCH = 1
8
+ PATCH = 2
9
9
  VERSION = [MAJOR,MINOR,PATCH].join('.')
10
10
 
11
11
  def self.version
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: monofile
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.2.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Gerald Bauer
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-10-31 00:00:00.000000000 Z
11
+ date: 2020-11-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rdoc