gitmethere 0.0.1

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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 13f7914789903c66d5f706790b4bb18a396174cc
4
+ data.tar.gz: 6079f2bc550342a0461f4b97ca0a2ad8b6b1a07f
5
+ SHA512:
6
+ metadata.gz: b5773eb0f5b5ea6626a2498a58878fc316d875246d4fdfd1c4b5d4668c4f243479333845caac95dc22a63b9961b80f8089a68865c12e5a6eded286beee8f00dc
7
+ data.tar.gz: 7d2baa766d8e5b50e9a2335c1d7e773b3a2eac7ddd97ced081dd05c2db21543861c1b1cf2691da8eb7de1fd7a80cbe8a05fbb0b66cafafd0d2828d0d7864fc06
data/.gitignore ADDED
@@ -0,0 +1,14 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
10
+ *.bundle
11
+ *.so
12
+ *.o
13
+ *.a
14
+ mkmf.log
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in gitmethere.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2015 Allen Smith
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,65 @@
1
+ # GitMeThere
2
+
3
+ This gem is a wrapper for Scott Chacon's [ruby-git](https://github.com/schacon/ruby-git) gem with commands that streamline the process of creating repositories in a given state. Its primary purpose is for demonstrating common Git scenarios, but it is handy for scripting basic repository operations.
4
+
5
+ ## Installation
6
+
7
+ ```
8
+ > gem install gitmethere
9
+ ```
10
+
11
+ ## Usage
12
+
13
+ Use this gem to write Ruby scripts that automate repository creation.
14
+
15
+ ```ruby
16
+
17
+ # A sample script for generating a repository with a merge-conflict on the horizon.
18
+
19
+ require 'gitmethere'
20
+
21
+ setup = {
22
+ name: "merge-conflict",
23
+ explanation:
24
+ "# Merge Conflicts
25
+
26
+ This repository demonstrates how merge conflicts occur."
27
+ }
28
+
29
+ scenario = GitMeThere::Scenario.new(setup['name'], explanation=setup['explanation'])
30
+
31
+ scenario.checkout_branch('feature')
32
+
33
+ scenario.append_to_file(
34
+ file="README.md",
35
+ content="A feature branch was created off of the `Initial commit`.
36
+ This line was added to the file on the feature branch."
37
+ )
38
+
39
+ scenario.stage_changes
40
+
41
+ scenario.commit('Add line to feature branch.')
42
+
43
+ scenario.checkout_branch('master')
44
+
45
+ scenario.append_to_file(
46
+ file="README.md",
47
+ content="A feature branch was created off of the initial commit.
48
+ However, work on `master` progressed in parallel to the work on `feature`.
49
+ Since both branches contain commits after their common ancestor, the `master` and `feature` branches have now diverged.
50
+ This is not always a problem, but since the same line (this line) was modified on both branches, Git does not know which version is the correct one.
51
+ At this point, if you try to merge `feature` into `master`, you will encounter a merge conflict.")
52
+
53
+ scenario.stage_changes
54
+
55
+ scenario.commit('Add line to master branch')
56
+
57
+ ```
58
+
59
+ ## Contributing
60
+
61
+ 1. Fork it ( https://github.com/loranallensmith/gitmethere/fork )
62
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
63
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
64
+ 4. Push to the branch (`git push origin my-new-feature`)
65
+ 5. Create a new Pull Request
data/Rakefile ADDED
@@ -0,0 +1,2 @@
1
+ require "bundler/gem_tasks"
2
+
@@ -0,0 +1,26 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'gitmethere/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "gitmethere"
8
+ spec.version = Gitmethere::VERSION
9
+ spec.authors = ["Allen Smith"]
10
+ spec.email = ["loranallensmith@github.com"]
11
+ spec.summary = "A tool for demonstrating Git scenarios"
12
+ spec.description = "This gem is a wrapper for Scott Chacon's ruby-git gem with commands that streamline the process of creating repositories in a given state. Its primary purpose is for demonstrating common Git scenarios, but it is handy for scripting basic repository operations."
13
+ spec.homepage = "https://github.com/loranallensmith/gitmethere"
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files -z`.split("\x0")
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.add_development_dependency "bundler", "~> 1.6"
22
+ spec.add_development_dependency "rake", "~> 10.0"
23
+
24
+ spec.add_runtime_dependency "git", "~> 1.2"
25
+
26
+ end
@@ -0,0 +1,3 @@
1
+ module Gitmethere
2
+ VERSION = "0.0.1"
3
+ end
data/lib/gitmethere.rb ADDED
@@ -0,0 +1,57 @@
1
+ require "gitmethere/version"
2
+
3
+ require 'git'
4
+
5
+ module GitMeThere
6
+
7
+ class Scenario
8
+
9
+ # All scenarios are automatically generated as a fresh repositorywith a README.md file
10
+ # and an initial commit on the master branch.
11
+ #
12
+ # If an explanation is specified, it will be included as README.md text in the first commit.
13
+ # If no name is specified, the repository will be created with the default name: `my-scenario`.
14
+ #
15
+ # Example:
16
+ # >> scenario = GitMeThere::Scenario.new(name="my-scenario", explanation="This is my scenario")
17
+ #
18
+ # Arguments:
19
+ # name: (String)
20
+ # explanation: (String)
21
+ #
22
+ def initialize(name="my-scenario", explanation="")
23
+ @name = name
24
+ @g = Git.init(name)
25
+
26
+ self.create_file(name='README.md', content=explanation)
27
+ @g.add
28
+ @g.commit("Initial commit")
29
+ end
30
+
31
+ def checkout_branch(branch)
32
+ @g.branch(branch).checkout
33
+ end
34
+
35
+ def stage_changes
36
+ @g.add
37
+ end
38
+
39
+ def create_file(name="my-file.md", content="")
40
+ File.open("#{@name}/#{name}", 'w') do | f |
41
+ f.puts content
42
+ end
43
+ end
44
+
45
+ def append_to_file(name="myfile.md", content="Adding a bit more content")
46
+ File.open("#{@name}/#{name}", 'a') do | f |
47
+ f.puts content
48
+ end
49
+ end
50
+
51
+ def commit(message)
52
+ @g.commit(message)
53
+ end
54
+
55
+ end
56
+
57
+ end
metadata ADDED
@@ -0,0 +1,97 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: gitmethere
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Allen Smith
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-11-03 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.6'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.6'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '10.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '10.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: git
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '1.2'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '1.2'
55
+ description: This gem is a wrapper for Scott Chacon's ruby-git gem with commands that
56
+ streamline the process of creating repositories in a given state. Its primary purpose
57
+ is for demonstrating common Git scenarios, but it is handy for scripting basic repository
58
+ operations.
59
+ email:
60
+ - loranallensmith@github.com
61
+ executables: []
62
+ extensions: []
63
+ extra_rdoc_files: []
64
+ files:
65
+ - ".gitignore"
66
+ - Gemfile
67
+ - LICENSE.txt
68
+ - README.md
69
+ - Rakefile
70
+ - gitmethere.gemspec
71
+ - lib/gitmethere.rb
72
+ - lib/gitmethere/version.rb
73
+ homepage: https://github.com/loranallensmith/gitmethere
74
+ licenses:
75
+ - MIT
76
+ metadata: {}
77
+ post_install_message:
78
+ rdoc_options: []
79
+ require_paths:
80
+ - lib
81
+ required_ruby_version: !ruby/object:Gem::Requirement
82
+ requirements:
83
+ - - ">="
84
+ - !ruby/object:Gem::Version
85
+ version: '0'
86
+ required_rubygems_version: !ruby/object:Gem::Requirement
87
+ requirements:
88
+ - - ">="
89
+ - !ruby/object:Gem::Version
90
+ version: '0'
91
+ requirements: []
92
+ rubyforge_project:
93
+ rubygems_version: 2.2.3
94
+ signing_key:
95
+ specification_version: 4
96
+ summary: A tool for demonstrating Git scenarios
97
+ test_files: []