schacon-grit 0.9.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (47) hide show
  1. data/History.txt +13 -0
  2. data/Manifest.txt +57 -0
  3. data/README.txt +213 -0
  4. data/Rakefile +29 -0
  5. data/grit.gemspec +60 -0
  6. data/lib/grit.rb +53 -0
  7. data/lib/grit/actor.rb +36 -0
  8. data/lib/grit/blob.rb +117 -0
  9. data/lib/grit/commit.rb +221 -0
  10. data/lib/grit/commit_stats.rb +104 -0
  11. data/lib/grit/config.rb +44 -0
  12. data/lib/grit/diff.rb +70 -0
  13. data/lib/grit/errors.rb +7 -0
  14. data/lib/grit/git-ruby.rb +175 -0
  15. data/lib/grit/git-ruby/commit_db.rb +52 -0
  16. data/lib/grit/git-ruby/file_index.rb +186 -0
  17. data/lib/grit/git-ruby/git_object.rb +344 -0
  18. data/lib/grit/git-ruby/internal/loose.rb +136 -0
  19. data/lib/grit/git-ruby/internal/mmap.rb +59 -0
  20. data/lib/grit/git-ruby/internal/pack.rb +332 -0
  21. data/lib/grit/git-ruby/internal/raw_object.rb +37 -0
  22. data/lib/grit/git-ruby/object.rb +319 -0
  23. data/lib/grit/git-ruby/repository.rb +675 -0
  24. data/lib/grit/git.rb +130 -0
  25. data/lib/grit/head.rb +83 -0
  26. data/lib/grit/index.rb +102 -0
  27. data/lib/grit/lazy.rb +31 -0
  28. data/lib/grit/ref.rb +95 -0
  29. data/lib/grit/repo.rb +381 -0
  30. data/lib/grit/status.rb +149 -0
  31. data/lib/grit/tag.rb +71 -0
  32. data/lib/grit/tree.rb +100 -0
  33. data/test/test_actor.rb +35 -0
  34. data/test/test_blob.rb +79 -0
  35. data/test/test_commit.rb +184 -0
  36. data/test/test_config.rb +58 -0
  37. data/test/test_diff.rb +18 -0
  38. data/test/test_git.rb +70 -0
  39. data/test/test_grit.rb +32 -0
  40. data/test/test_head.rb +41 -0
  41. data/test/test_real.rb +19 -0
  42. data/test/test_reality.rb +17 -0
  43. data/test/test_remote.rb +14 -0
  44. data/test/test_repo.rb +277 -0
  45. data/test/test_tag.rb +25 -0
  46. data/test/test_tree.rb +96 -0
  47. metadata +110 -0
data/test/test_tag.rb ADDED
@@ -0,0 +1,25 @@
1
+ require File.dirname(__FILE__) + '/helper'
2
+
3
+ class TestTag < Test::Unit::TestCase
4
+ def setup
5
+ @r = Repo.new(GRIT_REPO)
6
+ end
7
+
8
+ # list_from_string
9
+
10
+ def test_list_from_string
11
+ tags = @r.tags
12
+
13
+ assert_equal 1, tags.size
14
+ assert_equal 'v0.7.0', tags.first.name
15
+ assert_equal 'f0055fda16c18fd8b27986dbf038c735b82198d7', tags.first.commit.id
16
+ end
17
+
18
+ # inspect
19
+
20
+ def test_inspect
21
+ tag = @r.tags.first
22
+
23
+ assert_equal %Q{#<Grit::Tag "#{tag.name}">}, tag.inspect
24
+ end
25
+ end
data/test/test_tree.rb ADDED
@@ -0,0 +1,96 @@
1
+ require File.dirname(__FILE__) + '/helper'
2
+
3
+ class TestTree < Test::Unit::TestCase
4
+ def setup
5
+ @r = Repo.new(GRIT_REPO)
6
+ @t = Tree.allocate
7
+ end
8
+
9
+ # contents
10
+ def test_nosuch_tree
11
+ t = @r.tree('blahblah')
12
+ assert t.contents.is_a?(Array)
13
+ assert t.is_a?(Tree)
14
+ end
15
+
16
+ def test_contents_should_cache
17
+ Git.any_instance.expects(:ls_tree).returns(
18
+ fixture('ls_tree_a'),
19
+ fixture('ls_tree_b')
20
+ ).times(2)
21
+ tree = @r.tree('master')
22
+
23
+ child = tree.contents.last
24
+
25
+ child.contents
26
+ child.contents
27
+ end
28
+
29
+ # content_from_string
30
+
31
+ def test_content_from_string_tree_should_return_tree
32
+ text = fixture('ls_tree_a').split("\n").last
33
+
34
+ tree = @t.content_from_string(nil, text)
35
+
36
+ assert_equal Tree, tree.class
37
+ assert_equal "650fa3f0c17f1edb4ae53d8dcca4ac59d86e6c44", tree.id
38
+ assert_equal "040000", tree.mode
39
+ assert_equal "test", tree.name
40
+ end
41
+
42
+ def test_content_from_string_tree_should_return_blob
43
+ text = fixture('ls_tree_b').split("\n").first
44
+
45
+ tree = @t.content_from_string(nil, text)
46
+
47
+ assert_equal Blob, tree.class
48
+ assert_equal "aa94e396335d2957ca92606f909e53e7beaf3fbb", tree.id
49
+ assert_equal "100644", tree.mode
50
+ assert_equal "grit.rb", tree.name
51
+ end
52
+
53
+ def test_content_from_string_tree_should_return_commit
54
+ text = fixture('ls_tree_commit').split("\n")[1]
55
+
56
+ tree = @t.content_from_string(nil, text)
57
+
58
+ assert_nil tree
59
+ end
60
+
61
+ def test_content_from_string_invalid_type_should_raise
62
+ assert_raise(RuntimeError) do
63
+ @t.content_from_string(nil, "040000 bogus 650fa3f0c17f1edb4ae53d8dcca4ac59d86e6c44 test")
64
+ end
65
+ end
66
+
67
+ # /
68
+
69
+ def test_slash
70
+ Git.any_instance.expects(:ls_tree).returns(
71
+ fixture('ls_tree_a')
72
+ )
73
+ tree = @r.tree('master')
74
+
75
+ assert_equal 'aa06ba24b4e3f463b3c4a85469d0fb9e5b421cf8', (tree/'lib').id
76
+ assert_equal '8b1e02c0fb554eed2ce2ef737a68bb369d7527df', (tree/'README.txt').id
77
+ end
78
+
79
+ def test_slash_with_commits
80
+ Git.any_instance.expects(:ls_tree).returns(
81
+ fixture('ls_tree_commit')
82
+ )
83
+ tree = @r.tree('master')
84
+
85
+ assert_nil tree/'bar'
86
+ assert_equal '2afb47bcedf21663580d5e6d2f406f08f3f65f19', (tree/'foo').id
87
+ assert_equal 'f623ee576a09ca491c4a27e48c0dfe04be5f4a2e', (tree/'baz').id
88
+ end
89
+
90
+ # inspect
91
+
92
+ def test_inspect
93
+ @t = Tree.create(@r, :id => 'abc')
94
+ assert_equal %Q{#<Grit::Tree "abc">}, @t.inspect
95
+ end
96
+ end
metadata ADDED
@@ -0,0 +1,110 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: schacon-grit
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.9.1
5
+ platform: ruby
6
+ authors:
7
+ - Tom Preston-Werner
8
+ - Scott Chacon
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+
13
+ date: 2008-04-24 00:00:00 -07:00
14
+ default_executable:
15
+ dependencies:
16
+ - !ruby/object:Gem::Dependency
17
+ name: mime-types
18
+ version_requirement:
19
+ version_requirements: !ruby/object:Gem::Requirement
20
+ requirements:
21
+ - - ">"
22
+ - !ruby/object:Gem::Version
23
+ version: 0.0.0
24
+ version:
25
+ description: Grit is a Ruby library for extracting information from a git repository in and object oriented manner.
26
+ email: tom@rubyisawesome.com
27
+ executables: []
28
+
29
+ extensions: []
30
+
31
+ extra_rdoc_files:
32
+ - History.txt
33
+ - Manifest.txt
34
+ - README.txt
35
+ files:
36
+ - History.txt
37
+ - Manifest.txt
38
+ - README.txt
39
+ - Rakefile
40
+ - grit.gemspec
41
+ - lib/grit/actor.rb
42
+ - lib/grit/blob.rb
43
+ - lib/grit/commit.rb
44
+ - lib/grit/commit_stats.rb
45
+ - lib/grit/config.rb
46
+ - lib/grit/diff.rb
47
+ - lib/grit/errors.rb
48
+ - lib/grit/git-ruby/commit_db.rb
49
+ - lib/grit/git-ruby/file_index.rb
50
+ - lib/grit/git-ruby/git_object.rb
51
+ - lib/grit/git-ruby/internal
52
+ - lib/grit/git-ruby/internal/loose.rb
53
+ - lib/grit/git-ruby/internal/mmap.rb
54
+ - lib/grit/git-ruby/internal/pack.rb
55
+ - lib/grit/git-ruby/internal/raw_object.rb
56
+ - lib/grit/git-ruby/object.rb
57
+ - lib/grit/git-ruby/repository.rb
58
+ - lib/grit/git-ruby.rb
59
+ - lib/grit/git.rb
60
+ - lib/grit/head.rb
61
+ - lib/grit/index.rb
62
+ - lib/grit/lazy.rb
63
+ - lib/grit/ref.rb
64
+ - lib/grit/repo.rb
65
+ - lib/grit/status.rb
66
+ - lib/grit/tag.rb
67
+ - lib/grit/tree.rb
68
+ - lib/grit.rb
69
+ has_rdoc: true
70
+ homepage: http://github.com/schacon/grit
71
+ post_install_message:
72
+ rdoc_options:
73
+ - --main
74
+ - README.txt
75
+ require_paths:
76
+ - lib
77
+ required_ruby_version: !ruby/object:Gem::Requirement
78
+ requirements:
79
+ - - ">="
80
+ - !ruby/object:Gem::Version
81
+ version: "0"
82
+ version:
83
+ required_rubygems_version: !ruby/object:Gem::Requirement
84
+ requirements:
85
+ - - ">="
86
+ - !ruby/object:Gem::Version
87
+ version: "0"
88
+ version:
89
+ requirements: []
90
+
91
+ rubyforge_project:
92
+ rubygems_version: 1.2.0
93
+ signing_key:
94
+ specification_version: 2
95
+ summary: Object model interface to a git repo
96
+ test_files:
97
+ - test/test_actor.rb
98
+ - test/test_blob.rb
99
+ - test/test_commit.rb
100
+ - test/test_config.rb
101
+ - test/test_diff.rb
102
+ - test/test_git.rb
103
+ - test/test_grit.rb
104
+ - test/test_head.rb
105
+ - test/test_real.rb
106
+ - test/test_reality.rb
107
+ - test/test_remote.rb
108
+ - test/test_repo.rb
109
+ - test/test_tag.rb
110
+ - test/test_tree.rb