method_log 0.0.6 → 0.0.7
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 +4 -4
- data/README.md +12 -4
- data/lib/method_log/api.rb +1 -0
- data/lib/method_log/version.rb +1 -1
- data/spec/api_spec.rb +58 -8
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d5660d61fbe34eb21e9a16dd770b6a3d75626377
|
4
|
+
data.tar.gz: 0927d7ead89d3bc2a39d6fe315898ef2568c0f8f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0e6fc68bda02985c28fd73977432feb8b5ab81c57732a4612644b42d5951d188a3df3cdf14c38518d0ce3cc1ebebfac7f2035dea433e724d280c8919ec3a7cb3
|
7
|
+
data.tar.gz: 5383fb07797d935f46b71f8685443ac5ac8c44e5e5d630d6c269cd24eec4d5d8308f2b2dffc873c4f891cfa997ed01a37c0e978bd9cc493872c7890ddbf94a67
|
data/README.md
CHANGED
@@ -1,8 +1,6 @@
|
|
1
1
|
## Method Log
|
2
2
|
|
3
|
-
Trace the history of an individual method in a git repository.
|
4
|
-
|
5
|
-
This is a work-in-progress and nowhere near production-ready.
|
3
|
+
Trace the history of an individual method in a git repository (experimental).
|
6
4
|
|
7
5
|
### Requirements
|
8
6
|
|
@@ -17,7 +15,17 @@ This is a work-in-progress and nowhere near production-ready.
|
|
17
15
|
|
18
16
|
### Run
|
19
17
|
|
20
|
-
method_log <method-signature>
|
18
|
+
$ method_log <options> <method-signature>
|
19
|
+
|
20
|
+
# options:
|
21
|
+
--patch, -p: Generate patch.
|
22
|
+
--ruby-version, -r <s>: Parser Ruby version (18, 19, 20, 21) (default: current)
|
23
|
+
--max-count, -n <i>: Limit the number of commits to output.
|
24
|
+
--stop-at-latest-introduction-of-method, -s: Stop at lastest introduction of method.
|
25
|
+
--help, -h: Show usage.
|
26
|
+
|
27
|
+
# method-signature
|
28
|
+
Uses the Ruby Index format e.g. Foo#bar, Bar::Baz#foo, Baz.foo.
|
21
29
|
|
22
30
|
### Todo
|
23
31
|
|
data/lib/method_log/api.rb
CHANGED
data/lib/method_log/version.rb
CHANGED
data/spec/api_spec.rb
CHANGED
@@ -49,11 +49,10 @@ module MethodLog
|
|
49
49
|
}))
|
50
50
|
end
|
51
51
|
|
52
|
-
it 'finds
|
52
|
+
it 'finds significant commits for definition of method' do
|
53
53
|
repository = Repository.new(repository_path)
|
54
54
|
commit_1 = repository.commit(source(path: 'foo.rb', source: %{
|
55
55
|
class Foo
|
56
|
-
def bar; end
|
57
56
|
end
|
58
57
|
}))
|
59
58
|
commit_2 = repository.commit(source(path: 'foo.rb', source: %{
|
@@ -70,21 +69,72 @@ module MethodLog
|
|
70
69
|
def bar; end
|
71
70
|
end
|
72
71
|
}))
|
72
|
+
commit_5 = repository.commit(source(path: 'foo.rb', source: %{
|
73
|
+
class Foo
|
74
|
+
def bar
|
75
|
+
# implementation
|
76
|
+
end
|
77
|
+
end
|
78
|
+
}))
|
73
79
|
|
74
80
|
method_commits, method_diffs = commits_and_diffs_for('Foo#bar')
|
75
81
|
|
82
|
+
expect(method_commits.map(&:sha)).to eq([commit_5.sha, commit_3.sha])
|
83
|
+
end
|
84
|
+
|
85
|
+
it 'continues past lastest introduction of method if required' do
|
86
|
+
repository = Repository.new(repository_path)
|
87
|
+
commit_1 = repository.commit(source(path: 'foo.rb', source: %{
|
88
|
+
class Foo
|
89
|
+
def bar; end
|
90
|
+
end
|
91
|
+
}))
|
92
|
+
commit_2 = repository.commit(source(path: 'foo.rb', source: %{
|
93
|
+
class Foo
|
94
|
+
end
|
95
|
+
}))
|
96
|
+
commit_3 = repository.commit(source(path: 'foo.rb', source: %{
|
97
|
+
class Foo
|
98
|
+
def bar; end
|
99
|
+
end
|
100
|
+
}))
|
101
|
+
|
102
|
+
method_commits, method_diffs = commits_and_diffs_for('Foo#bar', stop_at_latest_introduction_of_method: false)
|
103
|
+
|
76
104
|
expect(method_commits.map(&:sha)).to eq([commit_3.sha, commit_2.sha])
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
105
|
+
end
|
106
|
+
|
107
|
+
it 'continues past lastest introduction of method if required even if method not defined in latest commit' do
|
108
|
+
repository = Repository.new(repository_path)
|
109
|
+
commit_1 = repository.commit(source(path: 'foo.rb', source: %{
|
110
|
+
class Foo
|
111
|
+
def bar; end
|
112
|
+
end
|
113
|
+
}))
|
114
|
+
commit_2 = repository.commit(source(path: 'foo.rb', source: %{
|
115
|
+
class Foo
|
116
|
+
end
|
117
|
+
}))
|
118
|
+
commit_3 = repository.commit(source(path: 'foo.rb', source: %{
|
119
|
+
class Foo
|
120
|
+
def bar; end
|
121
|
+
end
|
122
|
+
}))
|
123
|
+
commit_4 = repository.commit(source(path: 'foo.rb', source: %{
|
124
|
+
class Foo
|
125
|
+
end
|
126
|
+
}))
|
127
|
+
|
128
|
+
method_commits, method_diffs = commits_and_diffs_for('Foo#bar', stop_at_latest_introduction_of_method: false)
|
129
|
+
|
130
|
+
expect(method_commits.map(&:sha)).to eq([commit_4.sha, commit_3.sha, commit_2.sha])
|
81
131
|
end
|
82
132
|
|
83
133
|
private
|
84
134
|
|
85
|
-
def commits_and_diffs_for(method_identifier)
|
135
|
+
def commits_and_diffs_for(method_identifier, options = {})
|
86
136
|
api = API.new(Repository.new(repository_path))
|
87
|
-
commits_and_diffs = api.diffs(method_identifier)
|
137
|
+
commits_and_diffs = api.diffs(method_identifier, options)
|
88
138
|
method_commits = commits_and_diffs.map(&:first)
|
89
139
|
method_diffs = commits_and_diffs.map(&:last)
|
90
140
|
[method_commits, method_diffs]
|