brown_noser 0.1.2
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 +7 -0
- data/.gitignore +1 -0
- data/Gemfile +10 -0
- data/Gemfile.lock +44 -0
- data/LICENSE.txt +21 -0
- data/Procfile +1 -0
- data/README.md +41 -0
- data/bin/pet +6 -0
- data/brown_noser.gemspec +27 -0
- data/lib/brown_noser/version.rb +3 -0
- data/lib/brown_noser.rb +41 -0
- data/lib/client_resolver.rb +27 -0
- data/lib/project_repo_searcher.rb +7 -0
- data/lib/project_repo_sync.rb +54 -0
- metadata +114 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 499cd85310b74f6cb80f4330be3f59fefd7c77f0
|
4
|
+
data.tar.gz: 0bc0ae8d96d9d849ba221430c3ad3d019369e65a
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 9f32139d5c73a6c8aaf4f5520d78071c8d7140d998ea2dbe2adb3953ed9329f11db8c00d807297f4064a2574f9c27e9f946c47c33be818e319ad890bc7dbc99d
|
7
|
+
data.tar.gz: dce5f18fbccca926d2432c681f4c89916e3ce708b75f0c8641efe0585f24481045577ec1f71573a2da1e5de15bc1b2647129d80a61f71afce70fad94af83bb94
|
data/.gitignore
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
.env
|
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,44 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
teachers_pet (0.1.0)
|
5
|
+
|
6
|
+
GEM
|
7
|
+
remote: https://rubygems.org/
|
8
|
+
specs:
|
9
|
+
addressable (2.3.8)
|
10
|
+
awesome_print (1.6.1)
|
11
|
+
coderay (1.1.0)
|
12
|
+
faraday (0.9.2)
|
13
|
+
multipart-post (>= 1.2, < 3)
|
14
|
+
foreman (0.78.0)
|
15
|
+
thor (~> 0.19.1)
|
16
|
+
method_source (0.8.2)
|
17
|
+
multipart-post (2.0.0)
|
18
|
+
octokit (4.2.0)
|
19
|
+
sawyer (~> 0.6.0, >= 0.5.3)
|
20
|
+
pry (0.9.12.6)
|
21
|
+
coderay (~> 1.0)
|
22
|
+
method_source (~> 0.8)
|
23
|
+
slop (~> 3.4)
|
24
|
+
rake (10.4.2)
|
25
|
+
sawyer (0.6.0)
|
26
|
+
addressable (~> 2.3.5)
|
27
|
+
faraday (~> 0.8, < 0.10)
|
28
|
+
slop (3.6.0)
|
29
|
+
thor (0.19.1)
|
30
|
+
|
31
|
+
PLATFORMS
|
32
|
+
ruby
|
33
|
+
|
34
|
+
DEPENDENCIES
|
35
|
+
awesome_print
|
36
|
+
bundler (~> 1.10)
|
37
|
+
foreman
|
38
|
+
octokit (~> 4.0)
|
39
|
+
pry
|
40
|
+
rake
|
41
|
+
teachers_pet!
|
42
|
+
|
43
|
+
BUNDLED WITH
|
44
|
+
1.10.6
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2016 Paul Scarrone
|
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/Procfile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
command_sync: rake sync
|
data/README.md
ADDED
@@ -0,0 +1,41 @@
|
|
1
|
+
# TeachersPet
|
2
|
+
|
3
|
+
Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/teachers_pet`. To experiment with that code, run `bin/console` for an interactive prompt.
|
4
|
+
|
5
|
+
TODO: Delete this and the text above, and describe your gem
|
6
|
+
|
7
|
+
## Installation
|
8
|
+
|
9
|
+
Add this line to your application's Gemfile:
|
10
|
+
|
11
|
+
```ruby
|
12
|
+
gem 'teachers_pet'
|
13
|
+
```
|
14
|
+
|
15
|
+
And then execute:
|
16
|
+
|
17
|
+
$ bundle
|
18
|
+
|
19
|
+
Or install it yourself as:
|
20
|
+
|
21
|
+
$ gem install teachers_pet
|
22
|
+
|
23
|
+
## Usage
|
24
|
+
|
25
|
+
TODO: Write usage instructions here
|
26
|
+
|
27
|
+
## Development
|
28
|
+
|
29
|
+
After checking out the repo, run `bin/setup` to install dependencies. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
30
|
+
|
31
|
+
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).
|
32
|
+
|
33
|
+
## Contributing
|
34
|
+
|
35
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/teachers_pet.
|
36
|
+
|
37
|
+
|
38
|
+
## License
|
39
|
+
|
40
|
+
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
41
|
+
|
data/bin/pet
ADDED
data/brown_noser.gemspec
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'brown_noser/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "brown_noser"
|
8
|
+
spec.version = BrownNoser::VERSION
|
9
|
+
spec.authors = ["Paul Scarrone"]
|
10
|
+
spec.email = ["paul.scarrone@gmail.com"]
|
11
|
+
|
12
|
+
spec.summary = %q{Helps with mundane tasks associated with grading github assignments}
|
13
|
+
spec.description = %q{Will organize repos using github workflow}
|
14
|
+
spec.homepage = "https://github.com/WCCCEDU/github_grading_tools_rb"
|
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 = "bin"
|
19
|
+
spec.executables = ['pet']
|
20
|
+
spec.require_paths = ["lib"]
|
21
|
+
|
22
|
+
|
23
|
+
spec.add_development_dependency "bundler", "~> 1.10"
|
24
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
25
|
+
spec.add_development_dependency "pry", "~> 0.10.3"
|
26
|
+
spec.add_development_dependency "awesome_print", "1.6.1"
|
27
|
+
end
|
data/lib/brown_noser.rb
ADDED
@@ -0,0 +1,41 @@
|
|
1
|
+
require 'optparse'
|
2
|
+
autoload :ClientResolver, File.expand_path(File.dirname(__FILE__)) + '/client_resolver.rb'
|
3
|
+
autoload :ProjectRepoSync, File.expand_path(File.dirname(__FILE__)) + '/project_repo_sync.rb'
|
4
|
+
autoload :ProjectRepoSearcher, File.expand_path(File.dirname(__FILE__)) + '/project_repo_searcher.rb'
|
5
|
+
|
6
|
+
class BrownNoser
|
7
|
+
attr_reader :options
|
8
|
+
|
9
|
+
def initialize
|
10
|
+
@options = {}
|
11
|
+
OptionParser.new do |opts|
|
12
|
+
opts.banner = "Usage: pet <USER> <REPO> [options]"
|
13
|
+
|
14
|
+
opts.on('-s', '--sync', 'Sync') { |v| @options[:sync_flag] = true }
|
15
|
+
opts.on('-f', '--find QUERY', 'Find') { |v| @options[:query] = v }
|
16
|
+
opts.on('-u', '--username USER', 'Source host') { |v| @options[:username] = v }
|
17
|
+
opts.on('-p', '--password PASS', 'Source port') { |v| @options[:password] = v }
|
18
|
+
|
19
|
+
end.parse!
|
20
|
+
end
|
21
|
+
|
22
|
+
def resolve_client
|
23
|
+
user = @options[:username]
|
24
|
+
pass = @options[:password]
|
25
|
+
if user && pass
|
26
|
+
ClientResolver.configure(user, pass)
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
def run
|
31
|
+
sync = @options[:sync_flag]
|
32
|
+
find = @options[:query]
|
33
|
+
resolve_client
|
34
|
+
if sync
|
35
|
+
repo_syncer = ProjectRepoSync.new ARGV[0], ARGV[1]
|
36
|
+
repo_syncer.sync_assignment_branches
|
37
|
+
elsif find
|
38
|
+
searcher = ProjectRepoSearcher.new.search find
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
require 'octokit'
|
2
|
+
|
3
|
+
class ClientResolver
|
4
|
+
def self.configure(login, password)
|
5
|
+
@login = login
|
6
|
+
@password = password
|
7
|
+
|
8
|
+
dirty = false
|
9
|
+
if @login != login
|
10
|
+
dirty = true
|
11
|
+
@login = login
|
12
|
+
end
|
13
|
+
|
14
|
+
if @password != password
|
15
|
+
dirty = true
|
16
|
+
@password = password
|
17
|
+
end
|
18
|
+
|
19
|
+
if dirty
|
20
|
+
@instance = nil
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
def self.client
|
25
|
+
@instance ||= Octokit::Client.new(:login => @login, :password => @password)
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,54 @@
|
|
1
|
+
class ProjectRepoSync
|
2
|
+
attr_reader :user, :repo
|
3
|
+
|
4
|
+
PULL_EXTRACTOR = ->(pull){ pull.head.label }
|
5
|
+
GIT_COMMAND_EXTRACTOR = ->(pull_info){ pull_info.split(':') }
|
6
|
+
|
7
|
+
def initialize(user, repo)
|
8
|
+
@client = ClientResolver.client
|
9
|
+
@user = user
|
10
|
+
@repo = repo
|
11
|
+
end
|
12
|
+
|
13
|
+
def sync_assignment_branches
|
14
|
+
pulls = @client.pulls "#{@user}/#{@repo}"
|
15
|
+
pull_details = pulls.map(&PULL_EXTRACTOR).map(&GIT_COMMAND_EXTRACTOR)
|
16
|
+
|
17
|
+
%x(git checkout -f master | git branch | grep -v "^..master$" | sed 's/^[ *]*//' | sed 's/^/git branch -D /' | bash)
|
18
|
+
|
19
|
+
git_commands = pull_details.map &git_command_orgnaizer()
|
20
|
+
git_commands.flatten.each do |command|
|
21
|
+
prepared_command = command.call
|
22
|
+
puts "EXEC #{prepared_command}" if @logging
|
23
|
+
`#{prepared_command}`
|
24
|
+
puts "\n" if @logging
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
private
|
29
|
+
def prep_repo(user, repo)
|
30
|
+
->(){ "https://github.com/#{user}/#{repo}.git" }
|
31
|
+
end
|
32
|
+
|
33
|
+
def git_checkout_new(user, branch)
|
34
|
+
->(){ "git checkout -B #{user}/#{branch} master" }
|
35
|
+
end
|
36
|
+
|
37
|
+
def git_checkout(branch)
|
38
|
+
->(){ "git checkout #{branch}" }
|
39
|
+
end
|
40
|
+
|
41
|
+
def git_pull(repo_url, branch)
|
42
|
+
->(){ "git pull #{repo_url} #{branch}" }
|
43
|
+
end
|
44
|
+
|
45
|
+
def git_command_orgnaizer
|
46
|
+
->(pull_context){
|
47
|
+
[
|
48
|
+
git_checkout_new( pull_context[0], pull_context[1] ),
|
49
|
+
git_pull( prep_repo(pull_context[0], @repo).call, pull_context[1] ),
|
50
|
+
git_checkout( 'master' )
|
51
|
+
]
|
52
|
+
}
|
53
|
+
end
|
54
|
+
end
|
metadata
ADDED
@@ -0,0 +1,114 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: brown_noser
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.2
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Paul Scarrone
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2016-02-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.10'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.10'
|
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: pry
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: 0.10.3
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: 0.10.3
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: awesome_print
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - '='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: 1.6.1
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - '='
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: 1.6.1
|
69
|
+
description: Will organize repos using github workflow
|
70
|
+
email:
|
71
|
+
- paul.scarrone@gmail.com
|
72
|
+
executables:
|
73
|
+
- pet
|
74
|
+
extensions: []
|
75
|
+
extra_rdoc_files: []
|
76
|
+
files:
|
77
|
+
- ".gitignore"
|
78
|
+
- Gemfile
|
79
|
+
- Gemfile.lock
|
80
|
+
- LICENSE.txt
|
81
|
+
- Procfile
|
82
|
+
- README.md
|
83
|
+
- bin/pet
|
84
|
+
- brown_noser.gemspec
|
85
|
+
- lib/brown_noser.rb
|
86
|
+
- lib/brown_noser/version.rb
|
87
|
+
- lib/client_resolver.rb
|
88
|
+
- lib/project_repo_searcher.rb
|
89
|
+
- lib/project_repo_sync.rb
|
90
|
+
homepage: https://github.com/WCCCEDU/github_grading_tools_rb
|
91
|
+
licenses:
|
92
|
+
- MIT
|
93
|
+
metadata: {}
|
94
|
+
post_install_message:
|
95
|
+
rdoc_options: []
|
96
|
+
require_paths:
|
97
|
+
- lib
|
98
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
99
|
+
requirements:
|
100
|
+
- - ">="
|
101
|
+
- !ruby/object:Gem::Version
|
102
|
+
version: '0'
|
103
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
104
|
+
requirements:
|
105
|
+
- - ">="
|
106
|
+
- !ruby/object:Gem::Version
|
107
|
+
version: '0'
|
108
|
+
requirements: []
|
109
|
+
rubyforge_project:
|
110
|
+
rubygems_version: 2.4.5.1
|
111
|
+
signing_key:
|
112
|
+
specification_version: 4
|
113
|
+
summary: Helps with mundane tasks associated with grading github assignments
|
114
|
+
test_files: []
|