ed 0.4.0 → 0.5.0
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.
- data/README.md +1 -1
- data/examples/benchmark.rb +7 -11
- data/examples/pry.rb +3 -3
- data/lib/ed.rb +21 -18
- data/lib/ed/config.rb +10 -10
- data/lib/ed/core_ext/object.rb +7 -7
- data/lib/ed/{context.rb → delegator.rb} +13 -10
- data/lib/ed/env.rb +2 -1
- data/lib/ed/version.rb +1 -1
- data/test/test_ed.rb +6 -6
- metadata +12 -12
data/README.md
CHANGED
@@ -13,7 +13,7 @@ __DESCRIPTION__
|
|
13
13
|
|
14
14
|
A Domain Specific Language(DSL) that you can use to talk to Git from Ruby.
|
15
15
|
It isn't intended to be a full interface to Git, but a very small subset of
|
16
|
-
one that you can use to check out commits and then run Ruby code in the
|
16
|
+
one that you can use to check out commits and then run Ruby code in the
|
17
17
|
context of those commits.
|
18
18
|
|
19
19
|
So, for example, you might want to check out tag 'v0.1.0' and tag 'v0.2.0' to
|
data/examples/benchmark.rb
CHANGED
@@ -1,25 +1,21 @@
|
|
1
1
|
require "ed"
|
2
2
|
require "benchmark"
|
3
3
|
|
4
|
-
Repository "git://github.com/robgleeson/barney.git" do
|
5
|
-
before do |path|
|
4
|
+
Repository "git://github.com/robgleeson/barney.git" do
|
5
|
+
before :each do |path|
|
6
6
|
$: << File.join(path, "lib/")
|
7
|
-
require "barney"
|
7
|
+
require "barney"
|
8
8
|
end
|
9
9
|
|
10
10
|
tag "0.1.0" do
|
11
|
-
Benchmark.bm do |r|
|
12
|
-
r.report("0.1.0") {
|
13
|
-
Barney::Share.new
|
14
|
-
}
|
11
|
+
Benchmark.bm do |r|
|
12
|
+
r.report("0.1.0") { Barney::Share.new }
|
15
13
|
end
|
16
14
|
end
|
17
15
|
|
18
16
|
tag "0.2.0" do
|
19
|
-
Benchmark.bm do |r|
|
20
|
-
r.report("0.2.0") {
|
21
|
-
Barney::Share.new
|
22
|
-
}
|
17
|
+
Benchmark.bm do |r|
|
18
|
+
r.report("0.2.0") { Barney::Share.new }
|
23
19
|
end
|
24
20
|
end
|
25
21
|
end
|
data/examples/pry.rb
CHANGED
@@ -1,10 +1,10 @@
|
|
1
1
|
require "ed"
|
2
2
|
require "pry"
|
3
3
|
|
4
|
-
Repository "git://github.com/robgleeson/barney.git" do
|
5
|
-
before do |path|
|
4
|
+
Repository "git://github.com/robgleeson/barney.git" do
|
5
|
+
before :each do |path|
|
6
6
|
$: << File.join(path, "lib/")
|
7
|
-
require "barney"
|
7
|
+
require "barney"
|
8
8
|
end
|
9
9
|
|
10
10
|
tag "0.1.0" do
|
data/lib/ed.rb
CHANGED
@@ -3,13 +3,13 @@ require 'ed/version'
|
|
3
3
|
require 'ed/env'
|
4
4
|
require 'ed/config'
|
5
5
|
require 'ed/repository'
|
6
|
-
require 'ed/
|
6
|
+
require 'ed/delegator'
|
7
7
|
require 'ed/core_ext/object'
|
8
8
|
|
9
9
|
class Ed
|
10
10
|
|
11
11
|
include Observe
|
12
|
-
|
12
|
+
|
13
13
|
#
|
14
14
|
# @example
|
15
15
|
# Ed.configure do |config|
|
@@ -17,7 +17,7 @@ class Ed
|
|
17
17
|
# end
|
18
18
|
#
|
19
19
|
# @yieldparam config
|
20
|
-
# (see Ed::Config.change)
|
20
|
+
# (see Ed::Config.change)
|
21
21
|
#
|
22
22
|
# @return [void]
|
23
23
|
#
|
@@ -32,52 +32,55 @@ class Ed
|
|
32
32
|
# @yieldparam [Ed] _self
|
33
33
|
# Yields self, if a block is given.
|
34
34
|
#
|
35
|
-
# @return [Ed]
|
35
|
+
# @return [Ed]
|
36
36
|
#
|
37
37
|
def initialize path
|
38
38
|
@repo = Ed::Repository.new(path)
|
39
39
|
|
40
|
-
if block_given?
|
40
|
+
if block_given?
|
41
41
|
yield self
|
42
42
|
end
|
43
43
|
end
|
44
44
|
|
45
45
|
#
|
46
46
|
# @param [Proc] block
|
47
|
-
#
|
47
|
+
# Executed before the block for {#commit}, {#tag} or #{branch} is run.
|
48
48
|
#
|
49
49
|
# @yieldparam [String] path
|
50
50
|
# The path to the repository on local disk.
|
51
51
|
#
|
52
52
|
# @return [void]
|
53
53
|
#
|
54
|
-
def before &block
|
54
|
+
def before stage, &block
|
55
55
|
add_observer(:before_filter, &block)
|
56
56
|
end
|
57
57
|
|
58
58
|
#
|
59
|
-
# @param [String] commit
|
60
|
-
# A
|
59
|
+
# @param [String] commit
|
60
|
+
# A valid git commit, or git commit reference(tag or branch name).
|
61
61
|
#
|
62
62
|
# @param [Proc] block
|
63
|
-
#
|
63
|
+
# Executed while the repository has switched to 'commit'.
|
64
64
|
#
|
65
65
|
# @yieldparam [String] path
|
66
66
|
# The path to the repository on local disk.
|
67
67
|
#
|
68
|
-
# @return [void]
|
68
|
+
# @return [void]
|
69
69
|
#
|
70
70
|
def commit commit, &block
|
71
|
-
if Ed::Config.fork?
|
72
|
-
pid = fork
|
73
|
-
|
71
|
+
if Ed::Config.fork?
|
72
|
+
pid = fork do
|
73
|
+
switch(commit, &block)
|
74
|
+
end
|
75
|
+
|
76
|
+
Process.wait(pid)
|
74
77
|
else
|
75
78
|
switch(commit, &block)
|
76
79
|
end
|
77
80
|
end
|
78
81
|
alias_method :tag , :commit
|
79
82
|
alias_method :branch, :commit
|
80
|
-
|
83
|
+
|
81
84
|
#
|
82
85
|
# Switches to 'commit', and runs &block.
|
83
86
|
#
|
@@ -87,10 +90,10 @@ class Ed
|
|
87
90
|
# @param block
|
88
91
|
# (see Ed#commit)
|
89
92
|
#
|
90
|
-
def switch
|
91
|
-
@repo.checkout '-q', commit
|
93
|
+
def switch commit, &block
|
94
|
+
@repo.checkout '-q', commit
|
92
95
|
notify_observers(:before_filter, @repo.path)
|
93
|
-
block.call(@repo.path)
|
96
|
+
block.call(@repo.path)
|
94
97
|
end
|
95
98
|
private :switch
|
96
99
|
|
data/lib/ed/config.rb
CHANGED
@@ -1,21 +1,21 @@
|
|
1
1
|
require 'pathname'
|
2
2
|
|
3
|
-
module Ed::Config
|
4
|
-
|
5
|
-
class << self
|
3
|
+
module Ed::Config
|
4
|
+
|
5
|
+
class << self
|
6
6
|
|
7
7
|
#
|
8
8
|
# @yieldparam [Ed::Config] config
|
9
9
|
# Yields {Ed::Config}.
|
10
10
|
#
|
11
11
|
# @example
|
12
|
-
#
|
12
|
+
#
|
13
13
|
# Ed::Config.change do |config|
|
14
14
|
# config.fork = false
|
15
15
|
# end
|
16
16
|
#
|
17
|
-
def change
|
18
|
-
yield self
|
17
|
+
def change
|
18
|
+
yield self
|
19
19
|
end
|
20
20
|
|
21
21
|
#
|
@@ -29,16 +29,16 @@ module Ed::Config
|
|
29
29
|
end
|
30
30
|
|
31
31
|
#
|
32
|
-
# @return [Pathname]
|
32
|
+
# @return [Pathname]
|
33
33
|
# The path being used to store cloned repositories.
|
34
34
|
#
|
35
35
|
def repo_dir
|
36
36
|
@repo_dir
|
37
37
|
end
|
38
|
-
|
38
|
+
|
39
39
|
#
|
40
40
|
# @param [Boolean] value
|
41
|
-
# Enable or disable the creation of a subprocess
|
41
|
+
# Enable or disable the creation of a subprocess to check out a commit.
|
42
42
|
#
|
43
43
|
# @return [Boolean]
|
44
44
|
#
|
@@ -52,7 +52,7 @@ module Ed::Config
|
|
52
52
|
|
53
53
|
#
|
54
54
|
# @return [Boolean]
|
55
|
-
# Returns true if a subprocess is created
|
55
|
+
# Returns true if a subprocess is created to check out a commit.
|
56
56
|
#
|
57
57
|
def fork
|
58
58
|
@fork
|
data/lib/ed/core_ext/object.rb
CHANGED
@@ -1,13 +1,12 @@
|
|
1
1
|
#
|
2
|
-
# @param [String] path
|
3
|
-
# The
|
2
|
+
# @param [String] path
|
3
|
+
# The URI to a git repository.
|
4
4
|
#
|
5
|
-
# @param [Proc] block
|
6
|
-
#
|
5
|
+
# @param [Proc] &block
|
6
|
+
# Executed in the calling scope, or within the scope of {Ed::Delegator}.
|
7
7
|
#
|
8
8
|
# @yieldparam [Ed] repo
|
9
|
-
#
|
10
|
-
# If not given, 'block' is run through instance_eval on {Ed::Context} instead.
|
9
|
+
# Optionally yields an instance of {Ed}.
|
11
10
|
#
|
12
11
|
# @return [void]
|
13
12
|
#
|
@@ -15,7 +14,8 @@ def Repository path, &block
|
|
15
14
|
if block.arity == 1
|
16
15
|
block.call Ed.new(path)
|
17
16
|
else
|
18
|
-
Ed::
|
17
|
+
delegator = Ed::Delegator.new Ed.new(path)
|
18
|
+
delegator.instance_eval(&block)
|
19
19
|
end
|
20
20
|
end
|
21
21
|
|
@@ -1,19 +1,22 @@
|
|
1
|
-
class Ed::
|
1
|
+
class Ed::Delegator
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
|
3
|
+
#
|
4
|
+
# @param [Ed] delegate
|
5
|
+
# An instance of {Ed}.
|
6
|
+
#
|
7
|
+
def initialize delegate
|
8
|
+
@__delegate__ = delegate
|
6
9
|
end
|
7
10
|
|
8
11
|
#
|
9
12
|
# @param block
|
10
13
|
# (see Ed#before)
|
11
14
|
#
|
12
|
-
# @return
|
13
|
-
# (see Ed#before)
|
15
|
+
# @return
|
16
|
+
# (see Ed#before)
|
14
17
|
#
|
15
18
|
def before &block
|
16
|
-
@
|
19
|
+
@__delegate__.before(&block)
|
17
20
|
end
|
18
21
|
|
19
22
|
#
|
@@ -23,11 +26,11 @@ class Ed::Context
|
|
23
26
|
# @param block
|
24
27
|
# (see Ed#commit)
|
25
28
|
#
|
26
|
-
# @return
|
27
|
-
# (see Ed#commit)
|
29
|
+
# @return
|
30
|
+
# (see Ed#commit)
|
28
31
|
#
|
29
32
|
def commit commit, &block
|
30
|
-
@
|
33
|
+
@__delegate__.commit(commit, &block)
|
31
34
|
end
|
32
35
|
alias_method :tag , :commit
|
33
36
|
alias_method :branch, :commit
|
data/lib/ed/env.rb
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
module Ed::Env
|
2
2
|
|
3
3
|
class << self
|
4
|
+
|
4
5
|
#
|
5
6
|
# @return [Boolean]
|
6
7
|
# Are we on Windows?
|
@@ -8,7 +9,7 @@ module Ed::Env
|
|
8
9
|
def windows?
|
9
10
|
RUBY_PLATFORM['mswin32'] ||
|
10
11
|
RUBY_PLATFORM['mingw'] ||
|
11
|
-
RUBY_PLATFORM['cygwin']
|
12
|
+
RUBY_PLATFORM['cygwin']
|
12
13
|
end
|
13
14
|
|
14
15
|
#
|
data/lib/ed/version.rb
CHANGED
data/test/test_ed.rb
CHANGED
@@ -1,20 +1,20 @@
|
|
1
1
|
context Ed do
|
2
2
|
|
3
3
|
context 'When given a git:// URI.' do
|
4
|
-
before do
|
5
|
-
@ed = Ed.new "git://github.com/robgleeson/
|
6
|
-
@repo = @ed.instance_variable_get(:@repo)
|
4
|
+
before do
|
5
|
+
@ed = Ed.new "git://github.com/robgleeson/IProcess.git"
|
6
|
+
@repo = @ed.instance_variable_get(:@repo)
|
7
7
|
end
|
8
8
|
|
9
9
|
it 'must clone and store the repository locally.' do
|
10
|
-
File.exists?(@repo.path).must_equal(true)
|
10
|
+
File.exists?(@repo.path).must_equal(true)
|
11
11
|
end
|
12
12
|
|
13
13
|
it 'must checkout the "0.1.0" tag.' do
|
14
14
|
Tempfile.open "assertion" do |tmpfile|
|
15
|
-
@ed.before do |path|
|
15
|
+
@ed.before :each do |path|
|
16
16
|
$: << File.join(path, "lib")
|
17
|
-
require 'thread'
|
17
|
+
require 'thread'
|
18
18
|
require 'barney'
|
19
19
|
end
|
20
20
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ed
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.5.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-01-
|
12
|
+
date: 2012-01-21 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: observe
|
16
|
-
requirement: &
|
16
|
+
requirement: &70336276945460 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ~>
|
@@ -21,10 +21,10 @@ dependencies:
|
|
21
21
|
version: 0.2.0
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *70336276945460
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: rake
|
27
|
-
requirement: &
|
27
|
+
requirement: &70336276944900 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ~>
|
@@ -32,10 +32,10 @@ dependencies:
|
|
32
32
|
version: 0.9.2
|
33
33
|
type: :development
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *70336276944900
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: minitest
|
38
|
-
requirement: &
|
38
|
+
requirement: &70336276944340 !ruby/object:Gem::Requirement
|
39
39
|
none: false
|
40
40
|
requirements:
|
41
41
|
- - ~>
|
@@ -43,7 +43,7 @@ dependencies:
|
|
43
43
|
version: '2.6'
|
44
44
|
type: :development
|
45
45
|
prerelease: false
|
46
|
-
version_requirements: *
|
46
|
+
version_requirements: *70336276944340
|
47
47
|
description: A Domain Specific Language(DSL) that you can use to talk to Git from
|
48
48
|
Ruby.
|
49
49
|
email:
|
@@ -64,8 +64,8 @@ files:
|
|
64
64
|
- examples/test-suite.rb
|
65
65
|
- lib/ed.rb
|
66
66
|
- lib/ed/config.rb
|
67
|
-
- lib/ed/context.rb
|
68
67
|
- lib/ed/core_ext/object.rb
|
68
|
+
- lib/ed/delegator.rb
|
69
69
|
- lib/ed/env.rb
|
70
70
|
- lib/ed/repository.rb
|
71
71
|
- lib/ed/version.rb
|
@@ -85,7 +85,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
85
85
|
version: '0'
|
86
86
|
segments:
|
87
87
|
- 0
|
88
|
-
hash:
|
88
|
+
hash: 4104525377091588512
|
89
89
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
90
90
|
none: false
|
91
91
|
requirements:
|
@@ -94,10 +94,10 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
94
94
|
version: '0'
|
95
95
|
segments:
|
96
96
|
- 0
|
97
|
-
hash:
|
97
|
+
hash: 4104525377091588512
|
98
98
|
requirements: []
|
99
99
|
rubyforge_project: Ed
|
100
|
-
rubygems_version: 1.8.
|
100
|
+
rubygems_version: 1.8.15
|
101
101
|
signing_key:
|
102
102
|
specification_version: 3
|
103
103
|
summary: A Domain Specific Language(DSL) that you can use to talk to Git from Ruby.
|