metafrazo 0.1.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 +7 -0
- data/.gitignore +9 -0
- data/.rspec +2 -0
- data/.travis.yml +4 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +21 -0
- data/README.md +41 -0
- data/Rakefile +6 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/lib/metafrazo/config.rb +5 -0
- data/lib/metafrazo/git.rb +49 -0
- data/lib/metafrazo/git_diff_generator.rb +42 -0
- data/lib/metafrazo/version.rb +3 -0
- data/lib/metafrazo.rb +87 -0
- data/metafrazo-0.1.0.gem +0 -0
- data/metafrazo.gemspec +23 -0
- metadata +116 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: d6be364f46693647cb676ba8d6c6246dc3911760
|
4
|
+
data.tar.gz: 10b3c7a020a893d68269e00db9a21657240f1d5e
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: d3dc00c48572fc2c96e86b8468c7b27e08e0cbe1f00651f5747c4bb8c0e8e6dab302a8112b4bf328c81299fa73576f1cd3bd19f40e0b0bd38e0bdd4b1ff68d30
|
7
|
+
data.tar.gz: 07902f701bbf88e4b753186cd74422e094715fd884b857394a97329d00d201be4ba40a686afdcd878d1b5107516e41af7a6831693acb74c378b39f8961220178
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2016 Mike Kavouras
|
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,41 @@
|
|
1
|
+
# Metafrazo
|
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/metafrazo`. 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 'metafrazo'
|
13
|
+
```
|
14
|
+
|
15
|
+
And then execute:
|
16
|
+
|
17
|
+
$ bundle
|
18
|
+
|
19
|
+
Or install it yourself as:
|
20
|
+
|
21
|
+
$ gem install metafrazo
|
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. Then, run `rake spec` to run the tests. 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]/metafrazo.
|
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/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "metafrazo"
|
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,49 @@
|
|
1
|
+
require 'octokit'
|
2
|
+
|
3
|
+
module Metafrazo
|
4
|
+
class Git
|
5
|
+
|
6
|
+
def initialize(token, payload, repo=nil)
|
7
|
+
@pull_request = payload["pull_request"]
|
8
|
+
@token = token
|
9
|
+
@repo = repo
|
10
|
+
end
|
11
|
+
|
12
|
+
def comment(comment)
|
13
|
+
client.add_comment(repo_name, issue_id, comment)
|
14
|
+
end
|
15
|
+
|
16
|
+
def add_label(label)
|
17
|
+
client.add_labels_to_an_issue(repo_name, issue_id, ["translations"])
|
18
|
+
end
|
19
|
+
|
20
|
+
def remote_origin
|
21
|
+
"https://#{@token}:x-oauth-basic@github.com/#{repo_name}.git"
|
22
|
+
end
|
23
|
+
|
24
|
+
def repo_name
|
25
|
+
@pull_request["head"]["repo"]["full_name"]
|
26
|
+
end
|
27
|
+
|
28
|
+
def sha
|
29
|
+
@pull_request["head"]["sha"]
|
30
|
+
end
|
31
|
+
|
32
|
+
def master_branch
|
33
|
+
@master_branch ||= begin
|
34
|
+
(@repo && @repo[:compare_branch]) || "master"
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
private
|
39
|
+
|
40
|
+
def issue_id
|
41
|
+
@pull_request["number"]
|
42
|
+
end
|
43
|
+
|
44
|
+
def client
|
45
|
+
@client ||= Octokit::Client.new(access_token: @token)
|
46
|
+
end
|
47
|
+
|
48
|
+
end
|
49
|
+
end
|
@@ -0,0 +1,42 @@
|
|
1
|
+
module Metafrazo
|
2
|
+
class GitDiffGenerator
|
3
|
+
require 'fileutils'
|
4
|
+
|
5
|
+
def initialize(git)
|
6
|
+
@git = git
|
7
|
+
end
|
8
|
+
|
9
|
+
def generate
|
10
|
+
init_git unless git_init?
|
11
|
+
get_diff
|
12
|
+
end
|
13
|
+
|
14
|
+
private
|
15
|
+
|
16
|
+
def get_diff
|
17
|
+
Dir.chdir(local_repo_dir)
|
18
|
+
`git fetch`
|
19
|
+
"#{`git diff --name-only origin/#{@git.master_branch}...#{@git.sha}`}".split("\n")
|
20
|
+
end
|
21
|
+
|
22
|
+
def init_git
|
23
|
+
tmp = Dir.pwd
|
24
|
+
FileUtils.mkdir_p(local_repo_dir)
|
25
|
+
Dir.chdir(local_repo_dir)
|
26
|
+
puts "initializing git repository..."
|
27
|
+
`git init`
|
28
|
+
puts "adding remote origin at #{@git.remote_origin}"
|
29
|
+
`git remote add origin #{@git.remote_origin}`
|
30
|
+
Dir.chdir(tmp);
|
31
|
+
end
|
32
|
+
|
33
|
+
def git_init?
|
34
|
+
Dir.exist?(local_repo_dir)
|
35
|
+
end
|
36
|
+
|
37
|
+
def local_repo_dir
|
38
|
+
"#{Dir.pwd}/git/#{@git.repo_name}"
|
39
|
+
end
|
40
|
+
|
41
|
+
end
|
42
|
+
end
|
data/lib/metafrazo.rb
ADDED
@@ -0,0 +1,87 @@
|
|
1
|
+
require_relative 'metafrazo/version'
|
2
|
+
require_relative 'metafrazo/config'
|
3
|
+
require_relative 'metafrazo/git'
|
4
|
+
require_relative 'metafrazo/git_diff_generator'
|
5
|
+
|
6
|
+
module Metafrazo
|
7
|
+
|
8
|
+
class << self
|
9
|
+
attr_writer :config
|
10
|
+
end
|
11
|
+
|
12
|
+
# returns true if your files
|
13
|
+
def self.run(payload)
|
14
|
+
token = config.token
|
15
|
+
repo = subject_repo(payload)
|
16
|
+
|
17
|
+
git = Git.new(token, payload, repo)
|
18
|
+
diff = GitDiffGenerator.new(git).generate
|
19
|
+
changes = local_changes(diff, diff_paths(repo))
|
20
|
+
|
21
|
+
unless changes.empty?
|
22
|
+
git.comment(message(changes))
|
23
|
+
# git.add_label("bug")
|
24
|
+
end
|
25
|
+
|
26
|
+
!changes.empty?
|
27
|
+
end
|
28
|
+
|
29
|
+
def self.config
|
30
|
+
@config ||= Config.new
|
31
|
+
end
|
32
|
+
|
33
|
+
def self.configure
|
34
|
+
yield(config)
|
35
|
+
end
|
36
|
+
|
37
|
+
private
|
38
|
+
|
39
|
+
def self.local_changes(diffs, paths)
|
40
|
+
changes = []
|
41
|
+
paths.each do |path|
|
42
|
+
diffs.each do |diff|
|
43
|
+
if diff.match(/^#{path}/)
|
44
|
+
changes << diff
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
return changes
|
50
|
+
end
|
51
|
+
|
52
|
+
def self.diff_paths(repo)
|
53
|
+
paths = config.paths || []
|
54
|
+
paths = [config.path] if config.path
|
55
|
+
paths = [repo[:path]] if repo && repo[:path]
|
56
|
+
paths = repo[:paths] if repo && repo[:paths]
|
57
|
+
paths
|
58
|
+
end
|
59
|
+
|
60
|
+
def self.subject_repo(payload)
|
61
|
+
return nil unless config.repos
|
62
|
+
|
63
|
+
name = payload["pull_request"]["head"]["repo"]["full_name"].downcase
|
64
|
+
parts = name.split('/')
|
65
|
+
|
66
|
+
names = config.repos.keys.select do |key|
|
67
|
+
key = key.downcase
|
68
|
+
key == name || (parts.count > 1 && parts[1] == key)
|
69
|
+
end
|
70
|
+
|
71
|
+
config.repos[names.first]
|
72
|
+
end
|
73
|
+
|
74
|
+
def self.message(changes)
|
75
|
+
messages = [
|
76
|
+
"ci sono nuove stringhe que sono in disperato bisogno di traduzione",
|
77
|
+
"hay nuevas cadenas que están en desesperada necesidad de la traducción",
|
78
|
+
"Que há novas cordas estão em necessidade desesperada de tradução",
|
79
|
+
"il y a des nouvelles chaînes Que sont dans le besoin désespéré de la traduction",
|
80
|
+
"gibt es neue Saiten que sind in einer verzweifelten Notwendigkeit Übersetzung"
|
81
|
+
]
|
82
|
+
|
83
|
+
message = "#{config.usernames.join(' ')}: #{messages.sample} – "
|
84
|
+
message += changes.map { |change| "`#{change}`" }.join(' ')
|
85
|
+
end
|
86
|
+
|
87
|
+
end
|
data/metafrazo-0.1.0.gem
ADDED
Binary file
|
data/metafrazo.gemspec
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'metafrazo/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "metafrazo"
|
8
|
+
spec.version = Metafrazo::VERSION
|
9
|
+
spec.authors = ["Mike Kavouras"]
|
10
|
+
spec.email = ["kavourasm@gmail.com"]
|
11
|
+
spec.summary = %q{Notifies specific users if certain files have been changed}
|
12
|
+
spec.license = "MIT"
|
13
|
+
|
14
|
+
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
15
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
16
|
+
spec.require_paths = ["lib"]
|
17
|
+
|
18
|
+
spec.add_development_dependency "bundler", "~> 1.11"
|
19
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
20
|
+
spec.add_development_dependency "rspec", "~> 3.0"
|
21
|
+
spec.add_runtime_dependency "octokit", "~> 4.0"
|
22
|
+
|
23
|
+
end
|
metadata
ADDED
@@ -0,0 +1,116 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: metafrazo
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Mike Kavouras
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2016-05-20 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.11'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.11'
|
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: rspec
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '3.0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '3.0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: octokit
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '4.0'
|
62
|
+
type: :runtime
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '4.0'
|
69
|
+
description:
|
70
|
+
email:
|
71
|
+
- kavourasm@gmail.com
|
72
|
+
executables: []
|
73
|
+
extensions: []
|
74
|
+
extra_rdoc_files: []
|
75
|
+
files:
|
76
|
+
- ".gitignore"
|
77
|
+
- ".rspec"
|
78
|
+
- ".travis.yml"
|
79
|
+
- Gemfile
|
80
|
+
- LICENSE.txt
|
81
|
+
- README.md
|
82
|
+
- Rakefile
|
83
|
+
- bin/console
|
84
|
+
- bin/setup
|
85
|
+
- lib/metafrazo.rb
|
86
|
+
- lib/metafrazo/config.rb
|
87
|
+
- lib/metafrazo/git.rb
|
88
|
+
- lib/metafrazo/git_diff_generator.rb
|
89
|
+
- lib/metafrazo/version.rb
|
90
|
+
- metafrazo-0.1.0.gem
|
91
|
+
- metafrazo.gemspec
|
92
|
+
homepage:
|
93
|
+
licenses:
|
94
|
+
- MIT
|
95
|
+
metadata: {}
|
96
|
+
post_install_message:
|
97
|
+
rdoc_options: []
|
98
|
+
require_paths:
|
99
|
+
- lib
|
100
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
101
|
+
requirements:
|
102
|
+
- - ">="
|
103
|
+
- !ruby/object:Gem::Version
|
104
|
+
version: '0'
|
105
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
106
|
+
requirements:
|
107
|
+
- - ">="
|
108
|
+
- !ruby/object:Gem::Version
|
109
|
+
version: '0'
|
110
|
+
requirements: []
|
111
|
+
rubyforge_project:
|
112
|
+
rubygems_version: 2.4.5
|
113
|
+
signing_key:
|
114
|
+
specification_version: 4
|
115
|
+
summary: Notifies specific users if certain files have been changed
|
116
|
+
test_files: []
|