monofile 0.2.0 → 0.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: b40761cdf41323e67c0f31dc5322ae1d33a73a40
4
- data.tar.gz: 69eebef7b4e3a036eaf45c2888fdaaaaae0b0dc8
3
+ metadata.gz: 972e45a2358abae2cc65d2689004ee6caeffc06a
4
+ data.tar.gz: 793fb0d5404a10dd22a1e3478785769683b5b25f
5
5
  SHA512:
6
- metadata.gz: b35816490aff623a84368d646fdb68ba9c999009210a613c6731f1636b0b00a7d23e6d5a99e9041700c067f4d929b54d1b780fa6081512d99b297a40c9db73f8
7
- data.tar.gz: dd939bbab36398a63340e2810f86774a077676f0bad3a91bee3220a9ecceb7f6a7828df64f2da41b5369249117424b5857d37a774da46aaecb2e9d6c18a3fa22
6
+ metadata.gz: 8c5e1a3399d7465f2fa94df7ec9c15cb38890928808850490edf07635a4b98b8e5b4010bf738d892cd5916b1d03a4e3c55187938cb82a32e8b3ac7a888d7db89
7
+ data.tar.gz: 95b41e6fd5b0950551b29c605524eba6ce0b59b95591ed148ae70ee205fc317739facfc89738a3dc42c2bac2fb515e9f78b2d8b313c13d63c3145b4a89a87c20
@@ -6,6 +6,7 @@ bin/monofile
6
6
  lib/monofile.rb
7
7
  lib/monofile/monofile.rb
8
8
  lib/monofile/mononame.rb
9
+ lib/monofile/tool.rb
9
10
  lib/monofile/version.rb
10
11
  test/helper.rb
11
12
  test/test_names.rb
data/README.md CHANGED
@@ -1,7 +1,7 @@
1
- # monofile - read in/ parse mono (source) tree defintions with git (and github) projects, and more
1
+ # monofile - read in / parse monorepo / mono source tree definitions - a list of git (and github) projects, and more
2
2
 
3
- * home :: [github.com/rubycoco/git](https://github.com/rubycoco/git)
4
- * bugs :: [github.com/rubycoco/git/issues](https://github.com/rubycoco/git/issues)
3
+ * home :: [github.com/rubycoco/monos](https://github.com/rubycoco/monos)
4
+ * bugs :: [github.com/rubycoco/monos/issues](https://github.com/rubycoco/monos/issues)
5
5
  * gem :: [rubygems.org/gems/monofile](https://rubygems.org/gems/monofile)
6
6
  * rdoc :: [rubydoc.info/gems/monofile](http://rubydoc.info/gems/monofile)
7
7
 
@@ -9,7 +9,127 @@
9
9
 
10
10
  ## Usage
11
11
 
12
- To be done
12
+
13
+ Use `Monofile.read` to read in / parse monorepo / mono source tree definitions - supporting a ruby or a yaml format.
14
+
15
+
16
+ Example - `Monofile`:
17
+ ``` ruby
18
+ project "@openfootball/england"
19
+ project "@openfootball/world-cup"
20
+ project "@geraldb/austria"
21
+ project "@geraldb/geraldb.github.io"
22
+
23
+ project "geraldb", "catalog"
24
+ project "openfootball", "europe"
25
+ project "openfootball", "south-america"
26
+ ```
27
+
28
+ or
29
+
30
+ Example - `monofile.yml`:
31
+
32
+ ``` yaml
33
+ geraldb:
34
+ - austria
35
+ - catalog
36
+ - geraldb.github.io
37
+
38
+ openfootball:
39
+ - england
40
+ - europe
41
+ - south-america
42
+ - world-cup
43
+ ```
44
+
45
+
46
+ To read use.
47
+
48
+ ``` ruby
49
+ monofile = Monofile.read( "./Monofile" )
50
+ # -or-
51
+ monofile = Monofile.read( "./monofile.yml" )
52
+ pp monofile.to_a
53
+ #=> ["@openfootball/england",
54
+ # "@openfootball/world-cup",
55
+ # "@geraldb/austria",
56
+ # "@geraldb/geraldb.github.io",
57
+ # "@geraldb/catalog",
58
+ # "@openfootball/europe"]
59
+ # "@openfootball/south-america"]
60
+
61
+ pp monofile.to_h
62
+ #=> {"openfootball"=>["england", "world-cup", "europe", "south-america"],
63
+ # "geraldb" =>["austria", "geraldb.github.io", "catalog"]}
64
+
65
+ monofile.each do |proj|
66
+ puts " #{proj}"
67
+ end
68
+ #=> @openfootball/england
69
+ # @openfootball/world-cup
70
+ # @geraldb/austria
71
+ # @geraldb/geraldb.github.io
72
+ # @geraldb/catalog
73
+ # @openfootball/europe
74
+ # @openfootball/south-america
75
+
76
+ monofile.size
77
+ #=> 7
78
+ ```
79
+
80
+ and so on. That's it for now.
81
+
82
+
83
+
84
+ ### Troubleshooting / Debugging
85
+
86
+ Use the `monofile` command line tool to test reading in of
87
+ monorepo / mono source tree definitions.
88
+ Example:
89
+
90
+ ``` shell
91
+ # option 1) try to find default name (e.g. Monofile, Monofile.rb, etc.)
92
+ $ monofile
93
+
94
+ # option 2) pass in monofiles
95
+ $ monofile ./Monofile
96
+ $ monofile ./monfile.yml
97
+ # ...
98
+ ```
99
+
100
+ Printing the normalized / canonical names of the repo sources. Example.
101
+
102
+ ```
103
+ @openfootball/england
104
+ @openfootball/world-cup
105
+ @geraldb/austria
106
+ @geraldb/geraldb.github.io
107
+ @geraldb/catalog
108
+ @openfootball/europe
109
+ @openfootball/south-america
110
+ ```
111
+
112
+
113
+
114
+
115
+ ## Real-World Usage
116
+
117
+ See the [`monos`](https://github.com/rubycoco/monos/tree/master/monos) package that incl. the `mono` (or short `mo`)
118
+ command line tool lets you run
119
+ git commands on multiple repo(sitories) with a single command.
120
+
121
+
122
+ ## Installation
123
+
124
+ Use
125
+
126
+ gem install monofile
127
+
128
+ or add to your Gemfile
129
+
130
+ gem 'monofile'
131
+
132
+
13
133
 
14
134
  ## License
15
135
 
data/Rakefile CHANGED
@@ -6,10 +6,10 @@ Hoe.spec 'monofile' do
6
6
 
7
7
  self.version = Mono::Module::Monofile::VERSION
8
8
 
9
- self.summary = "monofile - read in/ parse mono (source) tree defintions with git (and github) projects, and more"
9
+ self.summary = "monofile - read in / parse monorepo / mono source tree definitions - a list of git (and github) projects, and more"
10
10
  self.description = summary
11
11
 
12
- self.urls = { home: 'https://github.com/rubycoco/git' }
12
+ self.urls = { home: 'https://github.com/rubycoco/monos' }
13
13
 
14
14
  self.author = 'Gerald Bauer'
15
15
  self.email = 'opensport@googlegroups.com'
@@ -13,7 +13,7 @@ require 'net/http'
13
13
  require 'net/https'
14
14
 
15
15
 
16
- require 'optparse'
16
+ require 'optparse' ## used by monofile (built-in test/debug) command line tool
17
17
 
18
18
 
19
19
 
@@ -22,7 +22,7 @@ require 'optparse'
22
22
  require 'monofile/version' # note: let version always go first
23
23
  require 'monofile/mononame'
24
24
  require 'monofile/monofile'
25
-
25
+ require 'monofile/tool'
26
26
 
27
27
 
28
28
 
@@ -73,41 +73,5 @@ MonoPath = Monopath
73
73
  MonoFile = Monofile
74
74
 
75
75
 
76
-
77
- class Monofile
78
- class Tool
79
- def self.main( args=ARGV )
80
-
81
- ## todo/fix:
82
- ## check args - if any, use/read monofiles in args!!!
83
-
84
- path = Monofile.find
85
- if path.nil?
86
- puts "!! ERROR: no mono configuration file found; looking for #{Monofile::NAMES.join(', ')} in (#{Dir.getwd})"
87
- exit 1
88
- end
89
-
90
- ## add check for auto-require (e.g. ./config.rb)
91
- config_path = "./config.rb"
92
- if File.exist?( config_path )
93
- puts "[monofile] auto-require >#{config_path}<..."
94
- require( config_path )
95
- end
96
-
97
- puts "[monofile] reading >#{path}<..."
98
- monofile=Monofile.read( path )
99
- pp monofile
100
-
101
- ## print one project per line
102
- puts "---"
103
- monofile.each do |proj|
104
- puts proj.to_s
105
- end
106
- end
107
- end # (nested) class Tool
108
- end # class Monofile
109
-
110
-
111
-
112
- Mono::Module::Monofile.banner
76
+ puts Mono::Module::Monofile.banner ## say hello
113
77
 
@@ -198,12 +198,11 @@ class Monofile
198
198
  ## - austria
199
199
  ## - catalog
200
200
  ## - geraldb.github.io
201
- ## - logos
202
- ## yorobot:
203
- ## - auto
204
- ## - backup
205
- ## - football.json
206
- ## - logs
201
+ ## openfootball:
202
+ ## - england
203
+ ## - europe
204
+ ## - south-america
205
+ ## - world-cup
207
206
  ##
208
207
  def to_h
209
208
  h = {}
@@ -1,11 +1,11 @@
1
1
  #####
2
2
  # mononame (e.g. @org/hello) machinery
3
3
  # turn
4
- # - @yorobot/stage/one
5
- # - one@yorobot/stage
6
- # - stage/one@yorobot
4
+ # - @openfootball/england/2020-21
5
+ # - 2020-21@openfootball/england
6
+ # - england/2020-21@openfootball
7
7
  # => into
8
- # - yorobot/stage/one
8
+ # - openfootball/england/2020-21
9
9
 
10
10
 
11
11
 
@@ -52,6 +52,14 @@ class Mononame
52
52
  end
53
53
 
54
54
 
55
+ def self.real_path( line )
56
+ ## add one-time (quick) usage convenience shortcut
57
+ name = parse( line )
58
+ name.real_path
59
+ end
60
+
61
+ ## todo/fix: add real_path
62
+
55
63
 
56
64
  ## note: org and name for now required
57
65
  ## - make name optional too - why? why not?!!!
@@ -0,0 +1,59 @@
1
+ class Monofile
2
+ class Tool
3
+ def self.main( args=ARGV )
4
+
5
+ options = {}
6
+ OptionParser.new do |parser|
7
+ ## note:
8
+ ## you can add many/multiple modules
9
+ ## e.g. -r gitti -r mono etc.
10
+ parser.on( '-r NAME', '--require NAME') do |name|
11
+ options[:requires] ||= []
12
+ options[:requires] << name
13
+ end
14
+ ## todo/fix:
15
+ ## add --verbose
16
+ ## add -d/--debug
17
+ end.parse!( args )
18
+
19
+
20
+ if args.size == 0 ## auto-add default arg (monofile)
21
+ monofile_path = Monofile.find
22
+ if monofile_path.nil?
23
+ puts "!! ERROR: no mono configuration file found; looking for #{Monofile::NAMES.join(', ')} in (#{Dir.getwd})"
24
+ exit 1
25
+ end
26
+ args << monofile_path
27
+ end
28
+
29
+
30
+ ## add check for auto-require (e.g. ./config.rb)
31
+ if options[:requires] ## use custom (auto-)requires
32
+ options[:requires].each do |path|
33
+ puts "[monofile] auto-require >#{path}<..."
34
+ require( path )
35
+ end
36
+ else ## use/try defaults
37
+ config_path = "./config.rb"
38
+ if File.exist?( config_path )
39
+ puts "[monofile] auto-require (default) >#{config_path}<..."
40
+ require( config_path )
41
+ end
42
+ end
43
+
44
+
45
+ args.each do |path|
46
+ puts "[monofile] reading >#{path}<..."
47
+ monofile=Monofile.read( path )
48
+ pp monofile
49
+
50
+ ## print one project per line
51
+ puts "---"
52
+ monofile.each do |proj|
53
+ puts proj.to_s
54
+ end
55
+ end
56
+ end # method self.main
57
+ end # (nested) class Tool
58
+ end # class Monofile
59
+
@@ -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 = 0
8
+ PATCH = 1
9
9
  VERSION = [MAJOR,MINOR,PATCH].join('.')
10
10
 
11
11
  def self.version
@@ -10,85 +10,86 @@ class TestNames < MiniTest::Test
10
10
 
11
11
  def test_parse
12
12
  %w[
13
- @yorobot/stage
14
- stage@yorobot
13
+ @openfootball/england
14
+ england@openfootball
15
15
  ].each do |line|
16
16
  mono = Mononame.parse( line )
17
17
 
18
- assert_equal '@yorobot/stage', mono.to_s
19
- assert_equal 'yorobot/stage', mono.to_path
18
+ assert_equal '@openfootball/england', mono.to_s
19
+ assert_equal 'openfootball/england', mono.to_path
20
20
 
21
- assert_equal 'yorobot', mono.org
22
- assert_equal 'stage', mono.name
21
+ assert_equal 'openfootball', mono.org
22
+ assert_equal 'england', mono.name
23
23
  end
24
24
 
25
25
 
26
26
  %w[
27
- @yorobot/stage/one
28
- one@yorobot/stage
29
- stage/one@yorobot
27
+ @openfootball/england/2020-21
28
+ 2020-21@openfootball/england
29
+ england/2020-21@openfootball
30
30
  ].each do |line|
31
31
  mono = Monopath.parse( line )
32
32
 
33
- assert_equal '@yorobot/stage/one', mono.to_s
34
- assert_equal 'yorobot/stage/one', mono.to_path
33
+ assert_equal '@openfootball/england/2020-21', mono.to_s
34
+ assert_equal 'openfootball/england/2020-21', mono.to_path
35
35
 
36
- assert_equal 'yorobot', mono.org
37
- assert_equal 'stage', mono.name
38
- assert_equal 'one', mono.path
36
+ assert_equal 'openfootball', mono.org
37
+ assert_equal 'england', mono.name
38
+ assert_equal '2020-21', mono.path
39
39
  end
40
40
 
41
41
  %w[
42
- @yorobot/stage/one/hello.txt
43
- hello.txt@yorobot/stage/one
44
- stage/one/hello.txt@yorobot
42
+ @openfootball/england/2020-21/premierleague.txt
43
+ 2020-21/premierleague.txt@openfootball/england
44
+ england/2020-21/premierleague.txt@openfootball
45
45
  ].each do |line|
46
46
  mono = Monopath.parse( line )
47
47
 
48
- assert_equal '@yorobot/stage/one/hello.txt', mono.to_s
49
- assert_equal 'yorobot/stage/one/hello.txt', mono.to_path
48
+ assert_equal '@openfootball/england/2020-21/premierleague.txt', mono.to_s
49
+ assert_equal 'openfootball/england/2020-21/premierleague.txt', mono.to_path
50
50
 
51
- assert_equal 'yorobot', mono.org
52
- assert_equal 'stage', mono.name
53
- assert_equal 'one/hello.txt', mono.path
51
+ assert_equal 'openfootball', mono.org
52
+ assert_equal 'england', mono.name
53
+ assert_equal '2020-21/premierleague.txt', mono.path
54
54
  end
55
55
  end # method test_parse
56
56
 
57
57
 
58
+
58
59
  def test_init
59
- mono = Mononame.new( 'yorobot','stage' )
60
+ mono = Mononame.new( 'openfootball','england' )
60
61
 
61
- assert_equal '@yorobot/stage', mono.to_s
62
- assert_equal 'yorobot/stage', mono.to_path
62
+ assert_equal '@openfootball/england', mono.to_s
63
+ assert_equal 'openfootball/england', mono.to_path
63
64
 
64
- assert_equal 'yorobot', mono.org
65
- assert_equal 'stage', mono.name
65
+ assert_equal 'openfootball', mono.org
66
+ assert_equal 'england', mono.name
66
67
 
67
68
 
68
- mono = Monopath.new( 'yorobot', 'stage', 'one' )
69
+ mono = Monopath.new( 'openfootball', 'england', '2020-21' )
69
70
 
70
- assert_equal '@yorobot/stage/one', mono.to_s
71
- assert_equal 'yorobot/stage/one', mono.to_path
71
+ assert_equal '@openfootball/england/2020-21', mono.to_s
72
+ assert_equal 'openfootball/england/2020-21', mono.to_path
72
73
 
73
- assert_equal 'yorobot', mono.org
74
- assert_equal 'stage', mono.name
75
- assert_equal 'one', mono.path
74
+ assert_equal 'openfootball', mono.org
75
+ assert_equal 'england', mono.name
76
+ assert_equal '2020-21', mono.path
76
77
 
77
78
 
78
79
  ## !!!!todo/check/fix!!!!!:
79
- ## - support 'one', 'hello.txt' too (or only) - why? why not?
80
+ ## - support '2020-21', 'premierleague.txt' too (or only) - why? why not?
80
81
  ##
81
82
  ## todo/check/fix:
82
83
  ## find a better name for path/path? component / part - why? why not?
83
84
  ## to_path and path/path? to confusing!!!
84
- mono = Monopath.new( 'yorobot', 'stage', 'one/hello.txt' )
85
+ mono = Monopath.new( 'openfootball', 'england', '2020-21/premierleague.txt' )
85
86
 
86
- assert_equal '@yorobot/stage/one/hello.txt', mono.to_s
87
- assert_equal 'yorobot/stage/one/hello.txt', mono.to_path
87
+ assert_equal '@openfootball/england/2020-21/premierleague.txt', mono.to_s
88
+ assert_equal 'openfootball/england/2020-21/premierleague.txt', mono.to_path
88
89
 
89
- assert_equal 'yorobot', mono.org
90
- assert_equal 'stage', mono.name
91
- assert_equal 'one/hello.txt', mono.path
90
+ assert_equal 'openfootball', mono.org
91
+ assert_equal 'england', mono.name
92
+ assert_equal '2020-21/premierleague.txt', mono.path
92
93
  end # method test_init
93
94
 
94
95
 
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.0
4
+ version: 0.2.1
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-30 00:00:00.000000000 Z
11
+ date: 2020-10-31 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rdoc
@@ -44,8 +44,8 @@ dependencies:
44
44
  - - "~>"
45
45
  - !ruby/object:Gem::Version
46
46
  version: '3.22'
47
- description: monofile - read in/ parse mono (source) tree defintions with git (and
48
- github) projects, and more
47
+ description: monofile - read in / parse monorepo / mono source tree definitions -
48
+ a list of git (and github) projects, and more
49
49
  email: opensport@googlegroups.com
50
50
  executables:
51
51
  - monofile
@@ -63,10 +63,11 @@ files:
63
63
  - lib/monofile.rb
64
64
  - lib/monofile/monofile.rb
65
65
  - lib/monofile/mononame.rb
66
+ - lib/monofile/tool.rb
66
67
  - lib/monofile/version.rb
67
68
  - test/helper.rb
68
69
  - test/test_names.rb
69
- homepage: https://github.com/rubycoco/git
70
+ homepage: https://github.com/rubycoco/monos
70
71
  licenses:
71
72
  - Public Domain
72
73
  metadata: {}
@@ -91,6 +92,6 @@ rubyforge_project:
91
92
  rubygems_version: 2.5.2
92
93
  signing_key:
93
94
  specification_version: 4
94
- summary: monofile - read in/ parse mono (source) tree defintions with git (and github)
95
- projects, and more
95
+ summary: monofile - read in / parse monorepo / mono source tree definitions - a list
96
+ of git (and github) projects, and more
96
97
  test_files: []