git-ds 0.9.2

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.
Files changed (51) hide show
  1. data/README.rdoc +795 -0
  2. data/doc/Examples.rdoc +36 -0
  3. data/doc/examples/key_value/kv_get.rb +29 -0
  4. data/doc/examples/key_value/kv_init.rb +20 -0
  5. data/doc/examples/key_value/kv_list.rb +28 -0
  6. data/doc/examples/key_value/kv_remove.rb +29 -0
  7. data/doc/examples/key_value/kv_set.rb +39 -0
  8. data/doc/examples/key_value/model.rb +156 -0
  9. data/doc/examples/key_value/test.rb +50 -0
  10. data/doc/examples/test_suite/model.rb +503 -0
  11. data/doc/examples/test_suite/test.rb +173 -0
  12. data/doc/examples/test_suite/ts_add_bug.rb +65 -0
  13. data/doc/examples/test_suite/ts_add_module.rb +74 -0
  14. data/doc/examples/test_suite/ts_add_module_to_test.rb +78 -0
  15. data/doc/examples/test_suite/ts_add_test.rb +77 -0
  16. data/doc/examples/test_suite/ts_add_test_suite.rb +65 -0
  17. data/doc/examples/test_suite/ts_add_test_to_bug.rb +76 -0
  18. data/doc/examples/test_suite/ts_init.rb +20 -0
  19. data/doc/examples/test_suite/ts_list.rb +118 -0
  20. data/doc/examples/test_suite/ts_perform_test.rb +104 -0
  21. data/doc/examples/test_suite/ts_update_bugs.rb +58 -0
  22. data/doc/examples/user_group/model.rb +265 -0
  23. data/doc/examples/user_group/test.rb +64 -0
  24. data/doc/examples/user_group/ug_add_group.rb +39 -0
  25. data/doc/examples/user_group/ug_add_group_user.rb +36 -0
  26. data/doc/examples/user_group/ug_add_user.rb +39 -0
  27. data/doc/examples/user_group/ug_init.rb +20 -0
  28. data/doc/examples/user_group/ug_list.rb +32 -0
  29. data/lib/git-ds.rb +14 -0
  30. data/lib/git-ds/config.rb +53 -0
  31. data/lib/git-ds/database.rb +289 -0
  32. data/lib/git-ds/exec_cmd.rb +107 -0
  33. data/lib/git-ds/index.rb +205 -0
  34. data/lib/git-ds/model.rb +136 -0
  35. data/lib/git-ds/model/db_item.rb +42 -0
  36. data/lib/git-ds/model/fs_item.rb +51 -0
  37. data/lib/git-ds/model/item.rb +428 -0
  38. data/lib/git-ds/model/item_list.rb +97 -0
  39. data/lib/git-ds/model/item_proxy.rb +128 -0
  40. data/lib/git-ds/model/property.rb +144 -0
  41. data/lib/git-ds/model/root.rb +46 -0
  42. data/lib/git-ds/repo.rb +455 -0
  43. data/lib/git-ds/shared.rb +17 -0
  44. data/lib/git-ds/transaction.rb +77 -0
  45. data/tests/ut_database.rb +304 -0
  46. data/tests/ut_git_grit_equiv.rb +195 -0
  47. data/tests/ut_index.rb +203 -0
  48. data/tests/ut_model.rb +360 -0
  49. data/tests/ut_repo.rb +260 -0
  50. data/tests/ut_user_group_model.rb +316 -0
  51. metadata +142 -0
@@ -0,0 +1,65 @@
1
+ #!/usr/bin/env ruby
2
+ # Add a TestSuite to a TestSuite database repo
3
+ # Copyright 2011 Thoughtgang <http://www.thoughtgang.org>
4
+
5
+ # Add examples dir and lib/git-ds to ruby path
6
+ BASE=File.dirname(File.expand_path(__FILE__)\
7
+ ).split(File::SEPARATOR)[0..-4].join(File::SEPARATOR)
8
+ $: << BASE + File::SEPARATOR + 'lib'
9
+ $: << BASE + File::SEPARATOR + 'doc' + File::SEPARATOR + 'examples'
10
+
11
+ require 'test_suite/model'
12
+ require 'optparse'
13
+ require 'ostruct'
14
+
15
+ def get_options(args)
16
+ options = OpenStruct.new
17
+
18
+ options.db = nil
19
+ options.auto = false
20
+ options.ident = nil
21
+ options.descr = ''
22
+
23
+ opts = OptionParser.new do |opts|
24
+ opts.banner = "Usage: #{$0} [-p db_path] IDENT [DESCR]"
25
+ opts.separator 'Add a TestSuite to database'
26
+ opts.separator 'Options:'
27
+
28
+ opts.on( '-p', '--db-path PATH', 'Path to TestSuite GitDS' ) do |path|
29
+ options.db = path
30
+ options.auto = true
31
+ end
32
+
33
+ opts.on_tail( '-?', '--help', 'Show this message') do
34
+ puts opts
35
+ exit -1
36
+ end
37
+ end
38
+
39
+ opts.parse!(args)
40
+
41
+ options.db = GitDS::Database.top_level if not options.db
42
+ raise "Invalid database" if not options.db
43
+
44
+ if args.count >= 1
45
+ options.ident = args.shift
46
+ options.descr = args.shift if args.count > 0
47
+ else
48
+ puts opts.banner
49
+ exit -2
50
+ end
51
+
52
+ options
53
+ end
54
+
55
+ # ----------------------------------------------------------------------
56
+ if __FILE__ == $0
57
+ options = get_options(ARGV)
58
+
59
+ model = TestSuiteModel.new(GitDS::Database.connect(options.db, options.auto))
60
+ raise "Could not connect to Model!" if not model
61
+
62
+ model.add_test_suite(options.ident, options.descr)
63
+
64
+ exit 0
65
+ end
@@ -0,0 +1,76 @@
1
+ #!/usr/bin/env ruby
2
+ # Add a Test to a Bug in a TestSuite database repo
3
+ # Copyright 2011 Thoughtgang <http://www.thoughtgang.org>
4
+
5
+ # Add examples dir and lib/git-ds to ruby path
6
+ BASE=File.dirname(File.expand_path(__FILE__)\
7
+ ).split(File::SEPARATOR)[0..-4].join(File::SEPARATOR)
8
+ $: << BASE + File::SEPARATOR + 'lib'
9
+ $: << BASE + File::SEPARATOR + 'doc' + File::SEPARATOR + 'examples'
10
+
11
+ require 'test_suite/model'
12
+ require 'optparse'
13
+ require 'ostruct'
14
+
15
+ def get_options(args)
16
+ options = OpenStruct.new
17
+
18
+ options.db = nil
19
+ options.auto = false
20
+ options.bug = nil
21
+ options.suite = nil
22
+ options.ident = nil
23
+
24
+ opts = OptionParser.new do |opts|
25
+ opts.banner = "Usage: #{$0} [-p db_path] BUG_IDENT SUITE_IDENT TEST_IDENT"
26
+ opts.separator 'Add a Test to Bug Report in database'
27
+ opts.separator 'Options:'
28
+
29
+ opts.on( '-p', '--db-path PATH', 'Path to TestSuite GitDS' ) do |path|
30
+ options.db = path
31
+ options.auto = true
32
+ end
33
+
34
+ opts.on_tail( '-?', '--help', 'Show this message') do
35
+ puts opts
36
+ exit -1
37
+ end
38
+ end
39
+
40
+ opts.parse!(args)
41
+
42
+ options.db = GitDS::Database.top_level if not options.db
43
+ raise "Invalid database" if not options.db
44
+
45
+ if args.count == 3
46
+ options.bug = args.shift
47
+ options.suite = args.shift
48
+ options.ident = args.shift
49
+ else
50
+ puts opts.banner
51
+ exit -2
52
+ end
53
+
54
+ options
55
+ end
56
+
57
+ # ----------------------------------------------------------------------
58
+ if __FILE__ == $0
59
+ options = get_options(ARGV)
60
+
61
+ model = TestSuiteModel.new(GitDS::Database.connect(options.db, options.auto))
62
+ raise "Could not connect to Model!" if not model
63
+
64
+ b = model.bug(options.bug)
65
+ raise "Could not find Bug #{options.bug}" if not b
66
+
67
+ s = model.test_suite(options.suite)
68
+ raise "Could not find TestSuite #{options.suite}" if not s
69
+
70
+ t = s.test(options.ident)
71
+ raise "Could not find Test #{options.ident}" if not t
72
+
73
+ b.add_test(t)
74
+
75
+ exit 0
76
+ end
@@ -0,0 +1,20 @@
1
+ #!/usr/bin/env ruby
2
+ # Initialize a user/group database repo
3
+ # Copyright 2011 Thoughtgang <http://www.thoughtgang.org>
4
+
5
+ BASE=File.dirname(File.expand_path(__FILE__)\
6
+ ).split(File::SEPARATOR)[0..-4].join(File::SEPARATOR)
7
+ $: << BASE + File::SEPARATOR + 'lib'
8
+ $: << BASE + File::SEPARATOR + 'doc' + File::SEPARATOR + 'examples'
9
+
10
+ require 'test_suite/model'
11
+
12
+ if __FILE__ == $0
13
+ if ARGV.count != 1
14
+ puts "Usage : #{$0} FILENAME"
15
+ exit -1
16
+ end
17
+
18
+ TestSuiteModel.new(GitDS::Database.connect(ARGV.shift, true))
19
+ exit 0
20
+ end
@@ -0,0 +1,118 @@
1
+ #!/usr/bin/env ruby
2
+ # List contents of a TestSuite database repo
3
+ # Copyright 2011 Thoughtgang <http://www.thoughtgang.org>
4
+
5
+ # Add examples dir and lib/git-ds to ruby path
6
+ BASE=File.dirname(File.expand_path(__FILE__)\
7
+ ).split(File::SEPARATOR)[0..-4].join(File::SEPARATOR)
8
+ $: << BASE + File::SEPARATOR + 'lib'
9
+ $: << BASE + File::SEPARATOR + 'doc' + File::SEPARATOR + 'examples'
10
+
11
+ require 'test_suite/model'
12
+ require 'optparse'
13
+ require 'ostruct'
14
+
15
+ def get_options(args)
16
+ options = OpenStruct.new
17
+
18
+ options.db = nil
19
+ options.suites = false
20
+ options.modules = false
21
+ options.bugs = false
22
+ options.details = false
23
+
24
+ opts = OptionParser.new do |opts|
25
+ opts.banner = "Usage: #{$0} [-p db_path] [-bdsm]"
26
+ opts.separator 'Add a TestSuite to database'
27
+ opts.separator 'Options:'
28
+
29
+ opts.on( '-p', '--db-path PATH', 'Path to TestSuite GitDS' ) do |path|
30
+ options.db = path
31
+ end
32
+
33
+ opts.on( '-b', '--bugs', 'List bugs' ) { options.bugs = true }
34
+ opts.on( '-d', '--details', 'Show details' ) { options.details = true }
35
+ opts.on( '-s', '--suites', 'List test suites' ) { options.suites = true }
36
+ opts.on( '-m', '--modules', 'List modules' ) { options.modules = true }
37
+
38
+ opts.on_tail( '-?', '--help', 'Show this message') do
39
+ puts opts
40
+ exit -1
41
+ end
42
+ end
43
+
44
+ opts.parse!(args)
45
+
46
+ options.db = GitDS::Database.top_level if not options.db
47
+ raise "Invalid database" if not options.db
48
+
49
+ # by default show all
50
+ if (! options.bugs) && (! options.modules) && (! options.suites)
51
+ options.bugs = options.modules = options.suites = true
52
+ end
53
+
54
+ options
55
+ end
56
+
57
+ def list_modules(model, details)
58
+ puts "Modules:"
59
+ model.modules.each do |ident|
60
+ puts "\t" + ident
61
+ if details
62
+ m = model.module(ident)
63
+ puts "\t\t" + m.name
64
+ puts "\t\t" + m.path
65
+ puts "\t\tContents:"
66
+ puts "\t\t" + m.data[0,60] + (m.data.length > 60 ? '...' : '')
67
+ end
68
+ end
69
+ end
70
+
71
+ def list_suites(model, details)
72
+ puts "Test Suites:"
73
+ model.test_suites.each do |ident|
74
+ puts "\t" + ident
75
+ if details
76
+ s = model.test_suite(ident)
77
+ puts "\t\t" + s.description
78
+ puts "\t\tTests:"
79
+ s.tests.each do |ident|
80
+ t = s.test(ident)
81
+ puts "\t\t\t" + ident
82
+ puts "\t\t\t" + ((t.pass?) ? 'Passed' : 'Failed')
83
+ puts "\t\t\t" + t.timestamp.to_s
84
+ puts "\t\t\tModules:"
85
+ t.modules.each { |ident| puts "\t\t\t\t" + ident }
86
+ puts "\t\t\tLog:\n" + t.log
87
+ end
88
+ end
89
+ end
90
+ end
91
+
92
+ def list_bugs(model, details)
93
+ puts "Bugs:"
94
+ model.bugs.each do |ident|
95
+ puts "\t" + ident
96
+ if details
97
+ b = model.bug(ident)
98
+ puts "\t\t" + b.description
99
+ puts "\t\t" + ((b.open?) ? 'Open' : 'Closed')
100
+ puts "\t\tTests:"
101
+ b.tests.each { |ident| puts "\t\t\t" + ident }
102
+ end
103
+ end
104
+ end
105
+
106
+ # ----------------------------------------------------------------------
107
+ if __FILE__ == $0
108
+ options = get_options(ARGV)
109
+
110
+ model = TestSuiteModel.new(GitDS::Database.connect(options.db, options.auto))
111
+ raise "Could not connect to Model!" if not model
112
+
113
+ list_modules(model, options.details) if options.modules
114
+ list_suites(model, options.details) if options.suites
115
+ list_bugs(model, options.details) if options.bugs
116
+
117
+ exit 0
118
+ end
@@ -0,0 +1,104 @@
1
+ #!/usr/bin/env ruby
2
+ # Set results for performing a Test in a TestSuite database repo
3
+ # Copyright 2011 Thoughtgang <http://www.thoughtgang.org>
4
+
5
+ # Add examples dir and lib/git-ds to ruby path
6
+ BASE=File.dirname(File.expand_path(__FILE__)\
7
+ ).split(File::SEPARATOR)[0..-4].join(File::SEPARATOR)
8
+ $: << BASE + File::SEPARATOR + 'lib'
9
+ $: << BASE + File::SEPARATOR + 'doc' + File::SEPARATOR + 'examples'
10
+
11
+ require 'test_suite/model'
12
+ require 'optparse'
13
+ require 'ostruct'
14
+
15
+ def get_options(args)
16
+ options = OpenStruct.new
17
+
18
+ options.db = nil
19
+ options.auto = false
20
+ options.user = nil
21
+ options.email = nil
22
+ options.ident = nil
23
+ options.suite = nil
24
+ options.passed = nil
25
+ options.log = ''
26
+
27
+ opts = OptionParser.new do |opts|
28
+ opts.banner = "Usage: #{$0} [-tf] [-elpu arg] SUITE_IDENT TEST_IDENT " +
29
+ "[0|1]"
30
+ opts.separator 'Set results for performing a Test'
31
+ opts.separator 'Note: A trailing arg of 0 (success) or nonzero (failure)'
32
+ opts.separator ' is expected if neither -t nor -f is present.'
33
+ opts.separator 'Options:'
34
+
35
+ opts.on( '-p', '--db-path PATH', 'Path to TestSuite GitDS' ) do |path|
36
+ options.db = path
37
+ options.auto = true
38
+ end
39
+
40
+ opts.on( '-l', '--log str', 'Log entry for test' ) do |str|
41
+ options.log = str
42
+ end
43
+
44
+ opts.on( '-u', '--user name', 'Name of Git user' ) do |name|
45
+ options.user = name
46
+ end
47
+
48
+ opts.on( '-e', '--email str', 'Email of Git user' ) do |str|
49
+ options.email = str
50
+ end
51
+
52
+ opts.on( '-t', '--true', 'Test succeeded') { options.passed = true }
53
+ opts.on( '-f', '--false', 'Test failed') { options.passed = false }
54
+
55
+ opts.on_tail( '-?', '--help', 'Show this message') do
56
+ puts opts
57
+ exit -1
58
+ end
59
+ end
60
+
61
+ opts.parse!(args)
62
+
63
+ options.db = GitDS::Database.top_level if not options.db
64
+ raise "Invalid database" if not options.db
65
+
66
+ if args.count >= 2
67
+ options.suite = args.shift
68
+ options.ident = args.shift
69
+
70
+ if options.passed == nil
71
+ if args.count == 0
72
+ puts opts.banner
73
+ exit -3
74
+ end
75
+ options.passed = (args.shift.to_i == 0)
76
+ end
77
+ else
78
+ puts opts.banner
79
+ exit -2
80
+ end
81
+
82
+ options
83
+ end
84
+
85
+ # ----------------------------------------------------------------------
86
+ if __FILE__ == $0
87
+ options = get_options(ARGV)
88
+
89
+ model = TestSuiteModel.new(GitDS::Database.connect_as(options.db,
90
+ options.user,
91
+ options.email,
92
+ options.auto))
93
+ raise "Could not connect to Model!" if not model
94
+
95
+ s = model.test_suite(options.suite)
96
+ raise "Could not find TestSuite #{options.suite}" if not s
97
+
98
+ t = s.test(options.ident)
99
+ raise "Could not find Test #{options.ident}" if not t
100
+
101
+ t.perform( options.passed, options.log )
102
+
103
+ exit 0
104
+ end
@@ -0,0 +1,58 @@
1
+ #!/usr/bin/env ruby
2
+ # Update Bugs in a TestSuite database repo based on status of Tests
3
+ # Copyright 2011 Thoughtgang <http://www.thoughtgang.org>
4
+
5
+ # Add examples dir and lib/git-ds to ruby path
6
+ BASE=File.dirname(File.expand_path(__FILE__)\
7
+ ).split(File::SEPARATOR)[0..-4].join(File::SEPARATOR)
8
+ $: << BASE + File::SEPARATOR + 'lib'
9
+ $: << BASE + File::SEPARATOR + 'doc' + File::SEPARATOR + 'examples'
10
+
11
+ require 'test_suite/model'
12
+ require 'optparse'
13
+ require 'ostruct'
14
+
15
+ def get_options(args)
16
+ options = OpenStruct.new
17
+
18
+ options.db = nil
19
+
20
+ opts = OptionParser.new do |opts|
21
+ opts.banner = "Usage: #{$0} [-p db_path]"
22
+ opts.separator 'Update all bugs in database'
23
+ opts.separator 'Options:'
24
+
25
+ opts.on( '-p', '--db-path PATH', 'Path to TestSuite GitDS' ) do |path|
26
+ options.db = path
27
+ end
28
+
29
+ opts.on_tail( '-?', '--help', 'Show this message') do
30
+ puts opts
31
+ exit -1
32
+ end
33
+ end
34
+
35
+ opts.parse!(args)
36
+
37
+ options.db = GitDS::Database.top_level if not options.db
38
+ raise "Invalid database" if not options.db
39
+
40
+ # by default show all
41
+ if (! options.bugs) && (! options.modules) && (! options.suites)
42
+ options.bugs = options.modules = options.suites = true
43
+ end
44
+
45
+ options
46
+ end
47
+
48
+ # ----------------------------------------------------------------------
49
+ if __FILE__ == $0
50
+ options = get_options(ARGV)
51
+
52
+ model = TestSuiteModel.new(GitDS::Database.connect(options.db, options.auto))
53
+ raise "Could not connect to Model!" if not model
54
+
55
+ model.update_bugs
56
+
57
+ exit 0
58
+ end