gitmethere 0.1.0 → 0.1.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 1a9e37922446adc92aac3e9d7f4d5757342f7399
4
- data.tar.gz: 8d1c993adcd6089e943a82d1879395082a60f491
3
+ metadata.gz: 49ea805052840c2b1178ac266fd630082582c77b
4
+ data.tar.gz: 5d0bbd16dbced3a15fb28cf0ec8fb41e1b49943e
5
5
  SHA512:
6
- metadata.gz: d5ad9bcd14a47774e5dcaea24dd11c43912398307794d858485e436e0842e7c4fbd0878e8077c0208891cd54c649b2cfbbeb77033b52033e7084665d278481d7
7
- data.tar.gz: d0d3dc30f37f5aa12fec4f21702cbc978116db01245321ca789c8667bcdf57cefd89f8770e840660390cb649641581a13a2de2156dc853fa8f557a5781686adc
6
+ metadata.gz: 2a4360076415dc645893f5cded03dc668b4ec72530a0dca0d98ec90dfe60a7f4aea9b31956a16349eaa760dbe5c722edf106763f8b647e7495917a0e48d3dfae
7
+ data.tar.gz: e59082cb5abaf3dbc267934c69ad4a54412096170a5475db3329a531be35ee914898a30884569401935bfeb1fbd486e24ca2e55c594fe4ca2b9935f60c669acb
data/README.md CHANGED
@@ -26,10 +26,13 @@ setup = {
26
26
  This repository demonstrates how merge conflicts occur."
27
27
  }
28
28
 
29
- scenario = GitMeThere::Scenario.new(name = setup['name'], explanation = setup['explanation'])
29
+ scenario = GitMeThere::Scenario.new(name = setup[:name], explanation = setup[:explanation])
30
+ other_author = GitMeThere::Author.new("Other Developer", "test@example.com")
30
31
 
31
32
  scenario.checkout_branch('feature')
32
33
 
34
+ scenario.pause("Pausing between steps for an explanation...")
35
+
33
36
  scenario.append_to_file(
34
37
  file="README.md",
35
38
  content="A feature branch was created off of the `Initial commit`.
@@ -38,7 +41,7 @@ scenario.append_to_file(
38
41
 
39
42
  scenario.stage_changes
40
43
 
41
- scenario.commit('Add line to feature branch.')
44
+ scenario.commit('Add line to feature branch.', author=other_author)
42
45
 
43
46
  scenario.checkout_branch('master')
44
47
 
@@ -0,0 +1,14 @@
1
+ module GitMeThere
2
+ class Author
3
+ attr_reader :name, :email
4
+
5
+ def initialize(name, email)
6
+ @name = name
7
+ @email = email
8
+ end
9
+
10
+ def git_author
11
+ "#{name} <#{email}>"
12
+ end
13
+ end
14
+ end
@@ -1,3 +1,3 @@
1
1
  module Gitmethere
2
- VERSION = "0.1.0"
2
+ VERSION = "0.1.3"
3
3
  end
data/lib/gitmethere.rb CHANGED
@@ -1,12 +1,14 @@
1
1
  require "gitmethere/version"
2
+ require "gitmethere/author"
2
3
 
3
4
  require 'git'
5
+ require 'io/console'
4
6
 
5
7
  module GitMeThere
6
8
 
7
9
  class Scenario
8
10
 
9
- # All scenarios are automatically generated as a fresh repositorywith a README.md file
11
+ # All scenarios are automatically generated as a fresh repository with a README.md file
10
12
  # and an initial commit on the master branch.
11
13
  #
12
14
  # If an explanation is specified, it will be included as README.md text in the first commit.
@@ -19,6 +21,10 @@ module GitMeThere
19
21
  # name: (String)
20
22
  # explanation: (String)
21
23
  #
24
+
25
+ # Give direct access to the Git::Base object in a scenario
26
+ attr_accessor :g
27
+
22
28
  def initialize(name="my-scenario", explanation="")
23
29
  @name = name
24
30
  @g = Git.init(name)
@@ -50,8 +56,25 @@ module GitMeThere
50
56
  end
51
57
  end
52
58
 
53
- def commit(message)
54
- @g.commit(message)
59
+ def commit(message, author = nil)
60
+ if author.nil?
61
+ @g.commit(message)
62
+ else
63
+ @g.commit(message, author: author.git_author)
64
+ end
65
+ end
66
+
67
+ def pause(message = nil)
68
+ STDIN.echo = false
69
+ if message
70
+ puts message
71
+ end
72
+ puts "Press any key to continue..."
73
+ input = STDIN.getch
74
+
75
+ ensure
76
+ STDIN.ioflush
77
+ STDIN.echo = true
55
78
  end
56
79
 
57
80
  end
@@ -0,0 +1,27 @@
1
+ require 'gitmethere'
2
+ require 'fakefs/spec_helpers'
3
+
4
+ RSpec.describe GitMeThere::Author do
5
+
6
+ before(:each) do
7
+ @author = GitMeThere::Author.new("Test User", "test@example.com")
8
+ end
9
+
10
+ describe ".new()" do
11
+
12
+ it "should create an author with the specified name and email" do
13
+ expect(@author.name).to eq("Test User")
14
+ expect(@author.email).to eq("test@example.com")
15
+ end
16
+
17
+ end
18
+
19
+ describe ".git_author()" do
20
+
21
+ it 'should return a valid git author identifier (name <email>)' do
22
+ expect(@author.git_author).to eq("Test User <test@example.com>")
23
+ end
24
+
25
+ end
26
+
27
+ end
@@ -54,6 +54,18 @@ RSpec.describe GitMeThere::Scenario do
54
54
 
55
55
  end
56
56
 
57
+ describe ".g" do
58
+
59
+ before(:each) do
60
+ @scenario = GitMeThere::Scenario.new()
61
+ end
62
+
63
+ it 'should return Git::Base object' do
64
+ expect(@scenario.g.class).to eq(Git::Base)
65
+ end
66
+
67
+ end
68
+
57
69
  describe ".create_file()" do
58
70
 
59
71
  before(:each) do
@@ -149,6 +161,19 @@ RSpec.describe GitMeThere::Scenario do
149
161
  @scenario.commit("Testing the commit function")
150
162
  expect(@scenario.instance_variable_get(:@g).log.first.message).to eq("Testing the commit function")
151
163
  end
164
+
165
+ it "with message and author" do
166
+ author = GitMeThere::Author.new("Test User", "test@example.com")
167
+ @scenario.create_file(
168
+ name = "test-commit-file",
169
+ content = "commit this file."
170
+ )
171
+ @scenario.stage_changes
172
+ @scenario.commit("Testing the commit function with a different user", author)
173
+ expect(@scenario.instance_variable_get(:@g).log.first.message).to eq("Testing the commit function with a different user")
174
+ expect(@scenario.instance_variable_get(:@g).log.first.author.name).to eq(author.name)
175
+ expect(@scenario.instance_variable_get(:@g).log.first.author.email).to eq(author.email)
176
+ end
152
177
  end
153
178
 
154
179
  after(:each) do
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gitmethere
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Allen Smith
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-11-04 00:00:00.000000000 Z
11
+ date: 2017-10-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -98,7 +98,9 @@ files:
98
98
  - Rakefile
99
99
  - gitmethere.gemspec
100
100
  - lib/gitmethere.rb
101
+ - lib/gitmethere/author.rb
101
102
  - lib/gitmethere/version.rb
103
+ - spec/gitmethere/author_spec.rb
102
104
  - spec/scenario_spec.rb
103
105
  - spec/spec_helper.rb
104
106
  homepage: https://github.com/loranallensmith/gitmethere
@@ -121,10 +123,11 @@ required_rubygems_version: !ruby/object:Gem::Requirement
121
123
  version: '0'
122
124
  requirements: []
123
125
  rubyforge_project:
124
- rubygems_version: 2.2.3
126
+ rubygems_version: 2.5.1
125
127
  signing_key:
126
128
  specification_version: 4
127
129
  summary: A tool for demonstrating Git scenarios
128
130
  test_files:
131
+ - spec/gitmethere/author_spec.rb
129
132
  - spec/scenario_spec.rb
130
133
  - spec/spec_helper.rb