makersinit 0.1.6

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 792e9d982b3aacaf550776963502147a24ea1026
4
+ data.tar.gz: 4d270d1e1bc96db86152f327a49c10007b838f46
5
+ SHA512:
6
+ metadata.gz: 5e10635d2e1f461881f1603ef0fa46e345035f96209719ca244fbaa0aba1b3f98a12105112e8d3a5f49b2452d317a7195ca83679edb5c15917eefdb54a06055e
7
+ data.tar.gz: f628af32913865411ec81a46885aeb430156fa4a37e1c4722fcd991453c3426eebe20b9f42468258847908e874cac44862aee51313f714e1e966613284bf04b6
data/.gitignore ADDED
@@ -0,0 +1,9 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --color
2
+ --require spec_helper
3
+ --format documentation
data/.travis.yml ADDED
@@ -0,0 +1,4 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.2.1
4
+ before_install: gem install bundler -v 1.11.2
@@ -0,0 +1,49 @@
1
+ # Contributor Code of Conduct
2
+
3
+ As contributors and maintainers of this project, and in the interest of
4
+ fostering an open and welcoming community, we pledge to respect all people who
5
+ contribute through reporting issues, posting feature requests, updating
6
+ documentation, submitting pull requests or patches, and other activities.
7
+
8
+ We are committed to making participation in this project a harassment-free
9
+ experience for everyone, regardless of level of experience, gender, gender
10
+ identity and expression, sexual orientation, disability, personal appearance,
11
+ body size, race, ethnicity, age, religion, or nationality.
12
+
13
+ Examples of unacceptable behavior by participants include:
14
+
15
+ * The use of sexualized language or imagery
16
+ * Personal attacks
17
+ * Trolling or insulting/derogatory comments
18
+ * Public or private harassment
19
+ * Publishing other's private information, such as physical or electronic
20
+ addresses, without explicit permission
21
+ * Other unethical or unprofessional conduct
22
+
23
+ Project maintainers have the right and responsibility to remove, edit, or
24
+ reject comments, commits, code, wiki edits, issues, and other contributions
25
+ that are not aligned to this Code of Conduct, or to ban temporarily or
26
+ permanently any contributor for other behaviors that they deem inappropriate,
27
+ threatening, offensive, or harmful.
28
+
29
+ By adopting this Code of Conduct, project maintainers commit themselves to
30
+ fairly and consistently applying these principles to every aspect of managing
31
+ this project. Project maintainers who do not follow or enforce the Code of
32
+ Conduct may be permanently removed from the project team.
33
+
34
+ This code of conduct applies both within project spaces and in public spaces
35
+ when an individual is representing the project or its community.
36
+
37
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be
38
+ reported by contacting a project maintainer at s_morgan@me.com. All
39
+ complaints will be reviewed and investigated and will result in a response that
40
+ is deemed necessary and appropriate to the circumstances. Maintainers are
41
+ obligated to maintain confidentiality with regard to the reporter of an
42
+ incident.
43
+
44
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage],
45
+ version 1.3.0, available at
46
+ [http://contributor-covenant.org/version/1/3/0/][version]
47
+
48
+ [homepage]: http://contributor-covenant.org
49
+ [version]: http://contributor-covenant.org/version/1/3/0/
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in makersinit.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2016 Sam Morgan
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,60 @@
1
+ # `makersinit`
2
+
3
+ Makers Academy's customer-facing command-line tool. Initializes tracking for use with [Hub](http://github.com/makersacademy/hub).
4
+
5
+ ## Installation
6
+
7
+ ### Production
8
+
9
+ Add this line to your application's Gemfile:
10
+
11
+ ```ruby
12
+ gem 'makersinit'
13
+ ```
14
+
15
+ And then execute:
16
+
17
+ $ bundle
18
+
19
+ Or install it yourself as:
20
+
21
+ $ gem install makersinit
22
+
23
+ ### Development
24
+
25
+ Navigate to the cloned directory, then:
26
+
27
+ ```sh
28
+ gem install `pwd`/makersinit-0.1.5.gem
29
+ ```
30
+
31
+ (if the current version of the gem is 0.1.5).
32
+
33
+ ## Usage
34
+
35
+ - Navigate to a directory.
36
+ - Run `makersinit`.
37
+ - Continue to work as normal. All your commits will be tracked.
38
+
39
+ ## Under the hood
40
+
41
+ This gem uses a git pre-push hook to push commit data to [Git Receiver](http://github.com/makersacademy/git_receiver), which then pushes well-formed data into a Firebase.
42
+
43
+ This data is then pushed across to [Hub](http://github.com/makersacademy/hub), which displays commit data, live, to coaches.
44
+
45
+ The average time between pushing a commit to being displayed on Hub is around 0.5 seconds.
46
+
47
+ ## Development
48
+
49
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rspec features` to run feature tests. Also, run `rspec spec` to run unit tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
50
+
51
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
52
+
53
+ ## Contributing
54
+
55
+ Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/makersinit. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
56
+
57
+ ## License
58
+
59
+ The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
60
+
data/Rakefile ADDED
@@ -0,0 +1,6 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task :default => :spec
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "makersinit"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start
data/bin/setup ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
data/exe/makersinit ADDED
@@ -0,0 +1,9 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'makersinit'
4
+
5
+ Kernel.system('git init')
6
+ Makersinit.initialize_pre_push_script
7
+ # Make the script executable
8
+ Kernel.system('chmod +x .git/hooks/pre-push')
9
+ `echo 'Initialized Makers Academy Tracking'`
@@ -0,0 +1,3 @@
1
+ module Makersinit
2
+ VERSION = "0.1.6"
3
+ end
data/lib/makersinit.rb ADDED
@@ -0,0 +1,29 @@
1
+ require "makersinit/version"
2
+
3
+ module Makersinit
4
+ GIT_HOOKS_PATH = ".git/hooks"
5
+
6
+ def self.initialize_pre_push_script
7
+ copy_script_to_hook
8
+ remove_sample_hook
9
+ end
10
+
11
+ private
12
+
13
+ def self.script_path
14
+ File.join(File.dirname(File.expand_path(__FILE__)), '../scripts/pre-push')
15
+ end
16
+
17
+ def self.copy_script_to_hook
18
+ IO.copy_stream(script_path, target_path)
19
+ end
20
+
21
+ def self.remove_sample_hook
22
+ file = target_path + '.sample'
23
+ File.delete(file) if File.exist? file
24
+ end
25
+
26
+ def self.target_path
27
+ "#{GIT_HOOKS_PATH}/pre-push"
28
+ end
29
+ end
@@ -0,0 +1,25 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'makersinit/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "makersinit"
8
+ spec.version = Makersinit::VERSION
9
+ spec.authors = ["Sam Morgan", "Ben Forrest"]
10
+ spec.email = ["samm@makersacademy.com", "ben@makersacademy.com"]
11
+
12
+ spec.summary = %q{Makers Academy's customer-facing command-line tool.}
13
+ spec.description = %q{A command-line tool for enabling tracking in collaboration with Makers Academy Hub, Firebase, and Makers Academy Git Receiver.}
14
+ spec.homepage = "http://makersacademy.com"
15
+ spec.license = "MIT"
16
+
17
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
18
+ spec.bindir = "exe"
19
+ spec.executables = ["makersinit"]
20
+ spec.require_paths = ["lib"]
21
+
22
+ spec.add_development_dependency "bundler", "~> 1.11"
23
+ spec.add_development_dependency "rake", "~> 10.0"
24
+ spec.add_development_dependency "rspec", "~> 3.0"
25
+ end
data/scripts/pre-push ADDED
@@ -0,0 +1,78 @@
1
+ #!/bin/sh
2
+ echo 'Pushing details to Tracker'
3
+ # Notifies a webhook on attempted "git push". Called by "git
4
+ # push" after it has checked the remote status, but before anything has been
5
+ # pushed. If this script exits with a non-zero status nothing will be pushed.
6
+ #
7
+ # This hook is called with the following parameters:
8
+ #
9
+ # $1 -- Name of the remote to which the push is being done
10
+ # $2 -- URL to which the push is being done
11
+ #
12
+ # If pushing without using a named remote those arguments will be equal.
13
+ #
14
+ # Information about the commits which are being pushed is supplied as lines to
15
+ # the standard input in the form:
16
+ #
17
+ # <local ref> <local sha1> <remote ref> <remote sha1>
18
+ #
19
+
20
+ # Utility functions
21
+ # Webhook-posting function
22
+
23
+ function posthook {
24
+ curl "git-receiver.herokuapp.com/commits" \
25
+ -X POST \
26
+ -H "Content-type: application/json" \
27
+ -d "{\"email\": \""$1"\", \"commits\": ["$2"], \"remote_url\": \""$3"\"}"
28
+ }
29
+
30
+ # Join function in the style of Pascal Pilz
31
+
32
+ function join { local IFS="$1"; shift; echo "$*"; }
33
+
34
+ remote="$1"
35
+ url="$2"
36
+
37
+ z40=0000000000000000000000000000000000000000
38
+
39
+ IFS=' '
40
+ while read local_ref local_sha remote_ref remote_sha
41
+ do
42
+ if [ "$local_sha" = $z40 ]
43
+ then
44
+ # Handle delete
45
+ echo 'Local SHA is $z40'
46
+ :
47
+ else
48
+ if [ "$remote_sha" = $z40 ]
49
+ then
50
+ # New branch, examine all commits
51
+ range="$local_sha"
52
+ else
53
+ # Update to existing branch, examine new commits
54
+ range="$remote_sha..$local_sha"
55
+ fi
56
+
57
+ # Get all commits in the relevant range
58
+ commits=`git rev-list "$range"`
59
+ commits_array=()
60
+ if [ -n "$commits" ]
61
+ then
62
+ # Construct an array of the commit SHAs
63
+ while read -r line; do
64
+ commits_array+=(\""$line"\")
65
+ done <<< "$commits"
66
+ # Construct the joined string for JSON
67
+ commits_string=`join , "${commits_array[@]}"`
68
+ email=`git config user.email`
69
+ # Post the commits to the webhook along with the user
70
+ posthook "$email" "$commits_string" "$url"
71
+ exit 0
72
+ else
73
+ echo "Commit is empty"
74
+ fi
75
+ fi
76
+ done
77
+
78
+ exit 0
metadata ADDED
@@ -0,0 +1,105 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: makersinit
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.6
5
+ platform: ruby
6
+ authors:
7
+ - Sam Morgan
8
+ - Ben Forrest
9
+ autorequire:
10
+ bindir: exe
11
+ cert_chain: []
12
+ date: 2016-02-03 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: bundler
16
+ requirement: !ruby/object:Gem::Requirement
17
+ requirements:
18
+ - - "~>"
19
+ - !ruby/object:Gem::Version
20
+ version: '1.11'
21
+ type: :development
22
+ prerelease: false
23
+ version_requirements: !ruby/object:Gem::Requirement
24
+ requirements:
25
+ - - "~>"
26
+ - !ruby/object:Gem::Version
27
+ version: '1.11'
28
+ - !ruby/object:Gem::Dependency
29
+ name: rake
30
+ requirement: !ruby/object:Gem::Requirement
31
+ requirements:
32
+ - - "~>"
33
+ - !ruby/object:Gem::Version
34
+ version: '10.0'
35
+ type: :development
36
+ prerelease: false
37
+ version_requirements: !ruby/object:Gem::Requirement
38
+ requirements:
39
+ - - "~>"
40
+ - !ruby/object:Gem::Version
41
+ version: '10.0'
42
+ - !ruby/object:Gem::Dependency
43
+ name: rspec
44
+ requirement: !ruby/object:Gem::Requirement
45
+ requirements:
46
+ - - "~>"
47
+ - !ruby/object:Gem::Version
48
+ version: '3.0'
49
+ type: :development
50
+ prerelease: false
51
+ version_requirements: !ruby/object:Gem::Requirement
52
+ requirements:
53
+ - - "~>"
54
+ - !ruby/object:Gem::Version
55
+ version: '3.0'
56
+ description: A command-line tool for enabling tracking in collaboration with Makers
57
+ Academy Hub, Firebase, and Makers Academy Git Receiver.
58
+ email:
59
+ - samm@makersacademy.com
60
+ - ben@makersacademy.com
61
+ executables:
62
+ - makersinit
63
+ extensions: []
64
+ extra_rdoc_files: []
65
+ files:
66
+ - ".gitignore"
67
+ - ".rspec"
68
+ - ".travis.yml"
69
+ - CODE_OF_CONDUCT.md
70
+ - Gemfile
71
+ - LICENSE.txt
72
+ - README.md
73
+ - Rakefile
74
+ - bin/console
75
+ - bin/setup
76
+ - exe/makersinit
77
+ - lib/makersinit.rb
78
+ - lib/makersinit/version.rb
79
+ - makersinit.gemspec
80
+ - scripts/pre-push
81
+ homepage: http://makersacademy.com
82
+ licenses:
83
+ - MIT
84
+ metadata: {}
85
+ post_install_message:
86
+ rdoc_options: []
87
+ require_paths:
88
+ - lib
89
+ required_ruby_version: !ruby/object:Gem::Requirement
90
+ requirements:
91
+ - - ">="
92
+ - !ruby/object:Gem::Version
93
+ version: '0'
94
+ required_rubygems_version: !ruby/object:Gem::Requirement
95
+ requirements:
96
+ - - ">="
97
+ - !ruby/object:Gem::Version
98
+ version: '0'
99
+ requirements: []
100
+ rubyforge_project:
101
+ rubygems_version: 2.4.6
102
+ signing_key:
103
+ specification_version: 4
104
+ summary: Makers Academy's customer-facing command-line tool.
105
+ test_files: []