popper 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +14 -0
- data/.rspec +2 -0
- data/.travis.yml +7 -0
- data/Gemfile +4 -0
- data/README.md +89 -0
- data/Rakefile +8 -0
- data/bin/console +14 -0
- data/bin/setup +7 -0
- data/exe/popper +4 -0
- data/lib/popper.rb +20 -0
- data/lib/popper/action.rb +6 -0
- data/lib/popper/action/base.rb +50 -0
- data/lib/popper/action/ghe.rb +21 -0
- data/lib/popper/action/git.rb +28 -0
- data/lib/popper/action/slack.rb +37 -0
- data/lib/popper/cli.rb +39 -0
- data/lib/popper/config.rb +80 -0
- data/lib/popper/init.rb +18 -0
- data/lib/popper/pop.rb +111 -0
- data/lib/popper/sample/config.txt +26 -0
- data/lib/popper/sync.rb +18 -0
- data/lib/popper/version.rb +3 -0
- data/popper.gemspec +30 -0
- metadata +184 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 0927bfbef3ae3c758bb5cb2defcc3bc716ec12f3
|
4
|
+
data.tar.gz: a3b08fc03f8c622c31e421521ae89fb3d5c47977
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 43a8d35f3808c303cb0a2bedae7bb3814e00a3d07bd46581509c97ea984f274ed7991f797f5498271aa645b996f61554b728a6d2d2645ae4a61749a5e7cb4812
|
7
|
+
data.tar.gz: 62108f190c671f63bc9a4decdddc7764a6c23afff534bbf78564a0a0326cc1a39f5eb9f9717ea6a844d58a7eff45467dca247e2d95084d2cbfc74a9e64d8c775
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/README.md
ADDED
@@ -0,0 +1,89 @@
|
|
1
|
+
# popper
|
2
|
+
|
3
|
+
[![Build Status](https://travis-ci.org/pyama86/popper.svg)](https://travis-ci.org/pyama86/popper)
|
4
|
+
[![Code Climate](https://codeclimate.com/github/pyama86/popper/badges/gpa.svg)](https://codeclimate.com/github/pyama86/popper)
|
5
|
+
[![Code Climate](https://codeclimate.com/github/pyama86/popper/badges/gpa.svg)](https://codeclimate.com/github/pyama86/popper)
|
6
|
+
|
7
|
+
To post a variety of services by analyzing the email
|
8
|
+
* slack notification
|
9
|
+
* create issue to github.com or ghe
|
10
|
+
|
11
|
+
# install
|
12
|
+
$ gem install popper
|
13
|
+
|
14
|
+
# usage
|
15
|
+
```
|
16
|
+
# create ~/popper/popper.conf
|
17
|
+
$ popper init
|
18
|
+
|
19
|
+
# edit popper.conf
|
20
|
+
$ vi ~/popper/popper.conf
|
21
|
+
|
22
|
+
# pop uidl prefetch
|
23
|
+
# to avoid duplication and to fetch the uidl
|
24
|
+
$ popper prepop
|
25
|
+
|
26
|
+
$ popper
|
27
|
+
```
|
28
|
+
`crontab -l`
|
29
|
+
```
|
30
|
+
* * * * * /path/to/popper
|
31
|
+
```
|
32
|
+
|
33
|
+
# configure(toml)
|
34
|
+
## ~/popper/popper.conf
|
35
|
+
```
|
36
|
+
[default.condition]
|
37
|
+
|
38
|
+
subject = ["^(?!.*Re:).+$"]
|
39
|
+
|
40
|
+
[default.action.slack]
|
41
|
+
|
42
|
+
webhook_url = "webhook_url"
|
43
|
+
user = "slack"
|
44
|
+
channel = "#default_channel"
|
45
|
+
message = "default message"
|
46
|
+
|
47
|
+
# [config_name].login
|
48
|
+
[example.login]
|
49
|
+
|
50
|
+
server = "example.com"
|
51
|
+
user = "example@example.com"
|
52
|
+
password = "password"
|
53
|
+
port = 110(default)
|
54
|
+
|
55
|
+
# [config_name].default.condition
|
56
|
+
[example.default.condition]
|
57
|
+
subject = [".*default.*"]
|
58
|
+
|
59
|
+
# [config_name].default.action.[action_name]
|
60
|
+
[example.default.action.slack]
|
61
|
+
channel = "#account default"
|
62
|
+
|
63
|
+
# [config_name].rules.[rule_name].condition
|
64
|
+
[example.rules.normal_log.condition]
|
65
|
+
|
66
|
+
subject = [".*Webmailer Exception.*"]
|
67
|
+
|
68
|
+
# [config_name].rules.[rule_name].action.[action_name]
|
69
|
+
[example.rules.normal_log.action.slack]
|
70
|
+
|
71
|
+
channel = "#channel"
|
72
|
+
mentions = ["@user"]
|
73
|
+
message = "webmailer error mail"
|
74
|
+
|
75
|
+
[example.rules.normal_log.action.git]
|
76
|
+
|
77
|
+
repo = "example/fuu"
|
78
|
+
|
79
|
+
[example2.login]
|
80
|
+
user = "example2@example.com"
|
81
|
+
...
|
82
|
+
```
|
83
|
+
|
84
|
+
# option
|
85
|
+
* config_file `--config or -c`
|
86
|
+
* log_file(default=/var/log/popper.log) `--log or -l`
|
87
|
+
|
88
|
+
# author
|
89
|
+
* pyama
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "popper"
|
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
data/exe/popper
ADDED
data/lib/popper.rb
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
require 'pp'
|
2
|
+
require "popper/version"
|
3
|
+
require "popper/cli"
|
4
|
+
require 'popper/pop'
|
5
|
+
require "popper/config"
|
6
|
+
require "popper/action"
|
7
|
+
require "popper/init"
|
8
|
+
require "popper/sync"
|
9
|
+
|
10
|
+
module Popper
|
11
|
+
def self.init_logger(options)
|
12
|
+
log_path = options[:log] || File.join(Dir.home, "popper", "popper.log")
|
13
|
+
log_path = STDOUT if ENV["POPPER_TEST"]
|
14
|
+
@_logger = Logger.new(log_path)
|
15
|
+
end
|
16
|
+
|
17
|
+
def self.log
|
18
|
+
@_logger
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,50 @@
|
|
1
|
+
module Popper::Action
|
2
|
+
class Base
|
3
|
+
@next_action = nil
|
4
|
+
@action = nil
|
5
|
+
@_config = nil
|
6
|
+
|
7
|
+
def self.run(config, mail, params={})
|
8
|
+
set_config(config)
|
9
|
+
if action?
|
10
|
+
begin
|
11
|
+
Popper.log.info "run action #{self.action}"
|
12
|
+
params = task(config, mail, params)
|
13
|
+
Popper.log.info "exit action #{self.action}"
|
14
|
+
rescue => e
|
15
|
+
Popper.log.warn e
|
16
|
+
Popper.log.warn e.backtrace
|
17
|
+
end
|
18
|
+
end
|
19
|
+
next_run(config, mail, params)
|
20
|
+
end
|
21
|
+
|
22
|
+
def self.next_action(action=nil)
|
23
|
+
@next_action = action if action
|
24
|
+
@next_action
|
25
|
+
end
|
26
|
+
|
27
|
+
def self.action(action=nil)
|
28
|
+
@action = action if action
|
29
|
+
@action
|
30
|
+
end
|
31
|
+
|
32
|
+
def self.next_run(config, mail, params={})
|
33
|
+
@next_action.run(config, mail, params) if @next_action
|
34
|
+
end
|
35
|
+
|
36
|
+
def self.action?
|
37
|
+
my_config && check_params
|
38
|
+
end
|
39
|
+
|
40
|
+
def self.set_config(config)
|
41
|
+
@_config = config.send(self.action) if config.respond_to?(self.action)
|
42
|
+
end
|
43
|
+
|
44
|
+
def self.my_config
|
45
|
+
@_config
|
46
|
+
end
|
47
|
+
|
48
|
+
def self.check_params(config); end
|
49
|
+
end
|
50
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
require 'octokit'
|
3
|
+
module Popper::Action
|
4
|
+
class Ghe < Git
|
5
|
+
def self.octkit
|
6
|
+
Octokit.reset!
|
7
|
+
Octokit.configure do |c|
|
8
|
+
c.web_endpoint = my_config.url
|
9
|
+
c.api_endpoint = File.join(my_config.url, "api/v3")
|
10
|
+
end
|
11
|
+
Octokit::Client.new(:access_token => my_config.token)
|
12
|
+
end
|
13
|
+
|
14
|
+
def self.check_params
|
15
|
+
my_config.respond_to?(:url) && super
|
16
|
+
end
|
17
|
+
|
18
|
+
next_action(Slack)
|
19
|
+
action(:ghe)
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
require 'octokit'
|
3
|
+
module Popper::Action
|
4
|
+
class Git < Base
|
5
|
+
def self.task(config, mail, params={})
|
6
|
+
url = octkit.create_issue(
|
7
|
+
my_config.repo,
|
8
|
+
mail.subject,
|
9
|
+
mail.body
|
10
|
+
)
|
11
|
+
params["#{self.action}_url".to_sym] = url[:html_url] if url
|
12
|
+
params
|
13
|
+
end
|
14
|
+
|
15
|
+
def self.octkit
|
16
|
+
Octokit.reset!
|
17
|
+
Octokit::Client.new(:access_token => my_config.token)
|
18
|
+
end
|
19
|
+
|
20
|
+
def self.check_params
|
21
|
+
my_config.respond_to?(:repo) &&
|
22
|
+
my_config.respond_to?(:token)
|
23
|
+
end
|
24
|
+
|
25
|
+
next_action(Ghe)
|
26
|
+
action(:git)
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
require 'slack-notifier'
|
2
|
+
module Popper::Action
|
3
|
+
class Slack < Base
|
4
|
+
def self.task(config, mail, params={})
|
5
|
+
notifier = ::Slack::Notifier.new(
|
6
|
+
my_config.webhook_url,
|
7
|
+
channel: my_config.channel,
|
8
|
+
username: my_config.user || 'popper',
|
9
|
+
link_names: 1
|
10
|
+
)
|
11
|
+
|
12
|
+
note = {
|
13
|
+
pretext: mail.date.to_s,
|
14
|
+
text: mail.subject,
|
15
|
+
color: "good"
|
16
|
+
}
|
17
|
+
|
18
|
+
body = my_config.message || "popper mail notification"
|
19
|
+
body += " #{my_config.mentions.join(" ")}" if my_config.mentions
|
20
|
+
%w(
|
21
|
+
git
|
22
|
+
ghe
|
23
|
+
).each do |name|
|
24
|
+
body += " #{name}:#{params[(name + '_url').to_sym]}" if params[(name + '_url').to_sym]
|
25
|
+
end
|
26
|
+
|
27
|
+
notifier.ping body, attachments: [note]
|
28
|
+
end
|
29
|
+
|
30
|
+
def self.check_params
|
31
|
+
my_config.respond_to?(:channel) &&
|
32
|
+
my_config.respond_to?(:webhook_url)
|
33
|
+
end
|
34
|
+
|
35
|
+
action(:slack)
|
36
|
+
end
|
37
|
+
end
|
data/lib/popper/cli.rb
ADDED
@@ -0,0 +1,39 @@
|
|
1
|
+
require 'popper'
|
2
|
+
require 'thor'
|
3
|
+
|
4
|
+
module Popper
|
5
|
+
class CLI < Thor
|
6
|
+
class_option :config, type: :string, aliases: '-c'
|
7
|
+
class_option :log, type: :string, aliases: '-l'
|
8
|
+
default_task :pop
|
9
|
+
desc "pop", "from pop3"
|
10
|
+
def pop
|
11
|
+
Popper.load_config(options)
|
12
|
+
Popper.init_logger(options)
|
13
|
+
Popper::Pop.run
|
14
|
+
rescue => e
|
15
|
+
Popper.log.fatal(e)
|
16
|
+
Popper.log.fatal(e.backtrace)
|
17
|
+
end
|
18
|
+
|
19
|
+
desc "prepop", "get current mailbox all uidl"
|
20
|
+
def prepop
|
21
|
+
Popper.load_config(options)
|
22
|
+
Popper::Pop.prepop
|
23
|
+
end
|
24
|
+
|
25
|
+
desc "init", "create home dir"
|
26
|
+
def init
|
27
|
+
Popper::Init.run(options)
|
28
|
+
rescue => e
|
29
|
+
puts e
|
30
|
+
puts e.backtrace
|
31
|
+
end
|
32
|
+
|
33
|
+
map %w[--version -v] => :__print_version
|
34
|
+
desc "--version, -v", "print the version"
|
35
|
+
def __print_version
|
36
|
+
puts "Popper version:#{Popper::VERSION}"
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
@@ -0,0 +1,80 @@
|
|
1
|
+
require 'toml'
|
2
|
+
require 'ostruct'
|
3
|
+
require 'logger'
|
4
|
+
module Popper
|
5
|
+
class Config
|
6
|
+
attr_reader :default, :accounts
|
7
|
+
def initialize(config_path)
|
8
|
+
raise "configure not fond #{config_path}" unless File.exist?(config_path)
|
9
|
+
|
10
|
+
config = TOML.load_file(config_path)
|
11
|
+
@default = AccountAttributes.new(config["default"]) if config["default"]
|
12
|
+
@accounts = []
|
13
|
+
|
14
|
+
config.select {|k,v| !%w(default).include?(k) }.each do |account|
|
15
|
+
_account = AccountAttributes.new(account[1])
|
16
|
+
_account.name = account[0]
|
17
|
+
@accounts << _account
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
end
|
22
|
+
|
23
|
+
class AccountAttributes < OpenStruct
|
24
|
+
def initialize(hash=nil)
|
25
|
+
@table = {}
|
26
|
+
@hash_table = {}
|
27
|
+
|
28
|
+
if hash
|
29
|
+
hash.each do |k,v|
|
30
|
+
@table[k.to_sym] = (v.is_a?(Hash) ? self.class.new(v) : v)
|
31
|
+
@hash_table[k.to_sym] = v
|
32
|
+
new_ostruct_member(k)
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
def to_h
|
38
|
+
@hash_table
|
39
|
+
end
|
40
|
+
|
41
|
+
%w(
|
42
|
+
condition
|
43
|
+
action
|
44
|
+
).each do |name|
|
45
|
+
define_method("global_default_#{name}") {
|
46
|
+
begin
|
47
|
+
Popper.configure.default.send(name).to_h
|
48
|
+
rescue
|
49
|
+
{}
|
50
|
+
end
|
51
|
+
}
|
52
|
+
|
53
|
+
define_method("account_default_#{name}") {
|
54
|
+
begin
|
55
|
+
self.default.send(name).to_h
|
56
|
+
rescue
|
57
|
+
{}
|
58
|
+
end
|
59
|
+
}
|
60
|
+
|
61
|
+
define_method("#{name}_by_rule") do |rule|
|
62
|
+
hash = self.send("global_default_#{name}")
|
63
|
+
hash = hash.deep_merge(self.send("account_default_#{name}").to_h) if self.send("account_default_#{name}")
|
64
|
+
hash = hash.deep_merge(self.rules.send(rule).send(name).to_h) if rules.send(rule).respond_to?(name.to_sym)
|
65
|
+
AccountAttributes.new(hash)
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
|
70
|
+
end
|
71
|
+
|
72
|
+
def self.load_config(options)
|
73
|
+
config_path = options[:config] || File.join(Dir.home, "popper", "popper.conf")
|
74
|
+
@_config = Config.new(config_path)
|
75
|
+
end
|
76
|
+
|
77
|
+
def self.configure
|
78
|
+
@_config
|
79
|
+
end
|
80
|
+
end
|
data/lib/popper/init.rb
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
module Popper
|
2
|
+
class Init
|
3
|
+
def self.run(options)
|
4
|
+
dirname = options[:config] || File.join(Dir.home, "popper")
|
5
|
+
unless FileTest.exist?(dirname)
|
6
|
+
FileUtils.mkdir_p(dirname)
|
7
|
+
open("#{dirname}/popper.conf","w") do |e|
|
8
|
+
e.puts sample_config
|
9
|
+
end if FileTest.exist?(dirname)
|
10
|
+
puts "create directry ~/popper"
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
def self.sample_config
|
15
|
+
File.read('lib/popper/sample/config.txt')
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
data/lib/popper/pop.rb
ADDED
@@ -0,0 +1,111 @@
|
|
1
|
+
require 'net/pop'
|
2
|
+
require 'mail'
|
3
|
+
require 'kconv'
|
4
|
+
module Popper
|
5
|
+
class Pop
|
6
|
+
def self.run
|
7
|
+
begin
|
8
|
+
Popper::Sync.synchronized do
|
9
|
+
Popper.configure.accounts.each do |account|
|
10
|
+
uidls = pop(account)
|
11
|
+
last_uidl(account.name, uidls)
|
12
|
+
end
|
13
|
+
end
|
14
|
+
rescue Locked
|
15
|
+
puts "There will be a running process"
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
def self.pop(account)
|
20
|
+
uidls = []
|
21
|
+
Popper.log.info "start popper #{account.name}"
|
22
|
+
|
23
|
+
connection(account) do |pop|
|
24
|
+
pop.mails.reject {|m| last_uidl(account.name).include?(m.uidl) }.each do |m|
|
25
|
+
begin
|
26
|
+
mail = EncodeMail.new(m.mail)
|
27
|
+
Popper.log.info "check mail:#{mail.date.to_s} #{mail.subject}"
|
28
|
+
if rule = matching?(account, mail)
|
29
|
+
Popper.log.info "do action:#{mail.subject}"
|
30
|
+
Popper::Action::Git.run(account.action_by_rule(rule), mail) if account.action_by_rule(rule)
|
31
|
+
end
|
32
|
+
uidls << m.uidl
|
33
|
+
rescue Net::POPError => e
|
34
|
+
Popper.log.warn e
|
35
|
+
end
|
36
|
+
end
|
37
|
+
Popper.log.info "success popper #{account.name}"
|
38
|
+
end
|
39
|
+
uidls
|
40
|
+
end
|
41
|
+
|
42
|
+
def self.connection(account, &block)
|
43
|
+
pop = Net::POP3.new(account.login.server, account.login.port || 110)
|
44
|
+
pop.open_timeout = ENV['POP_TIMEOUT'] || 120
|
45
|
+
pop.read_timeout = ENV['POP_TIMEOUT'] || 120
|
46
|
+
pop.start(
|
47
|
+
account.login.user,
|
48
|
+
account.login.password
|
49
|
+
) do |pop|
|
50
|
+
block.call(pop)
|
51
|
+
end
|
52
|
+
rescue => e
|
53
|
+
Popper.log.warn e
|
54
|
+
end
|
55
|
+
|
56
|
+
def self.matching?(account, mail)
|
57
|
+
account.rules.to_h.keys.find do |rule|
|
58
|
+
account.condition_by_rule(rule).to_h.all? do |header,conditions|
|
59
|
+
conditions.all? do |condition|
|
60
|
+
mail.respond_to?(header) && mail.send(header).to_s.match(/#{condition}/)
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
def self.last_uidl(account, uidl=nil)
|
67
|
+
path = File.join(Dir.home, "popper", ".#{account}.uidl")
|
68
|
+
@_uidl ||= {}
|
69
|
+
|
70
|
+
File.write(File.join(path), uidl.join("\n")) if uidl
|
71
|
+
|
72
|
+
@_uidl[account] ||= File.exist?(path) ? File.read(path).split(/\r?\n/) : []
|
73
|
+
@_uidl[account]
|
74
|
+
end
|
75
|
+
|
76
|
+
def self.prepop
|
77
|
+
Popper.configure.accounts.each do |account|
|
78
|
+
puts "start prepop #{account.name}"
|
79
|
+
connection(account) do |pop|
|
80
|
+
uidls = pop.mails.map(&:uidl)
|
81
|
+
last_uidl(
|
82
|
+
account.name,
|
83
|
+
uidls
|
84
|
+
)
|
85
|
+
puts "success prepop #{account.name} mail count:#{uidls.count}"
|
86
|
+
end
|
87
|
+
end
|
88
|
+
end
|
89
|
+
end
|
90
|
+
end
|
91
|
+
|
92
|
+
class ::Hash
|
93
|
+
def deep_merge(second)
|
94
|
+
merger = proc { |key, v1, v2| Hash === v1 && Hash === v2 ? v1.merge(v2, &merger) : Array === v1 && Array === v2 ? v1 | v2 : [:undefined, nil, :nil].include?(v2) ? v1 : v2 }
|
95
|
+
self.merge(second.to_h, &merger)
|
96
|
+
end
|
97
|
+
|
98
|
+
def deep_merge!(second)
|
99
|
+
self.merge!(deep_merge(second))
|
100
|
+
end
|
101
|
+
end
|
102
|
+
|
103
|
+
class EncodeMail < Mail::Message
|
104
|
+
def subject
|
105
|
+
Kconv.toutf8(self[:Subject].value) if self[:Subject]
|
106
|
+
end
|
107
|
+
|
108
|
+
def body
|
109
|
+
super.decoded.encode("UTF-8", self.charset)
|
110
|
+
end
|
111
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
[popper]
|
2
|
+
slack_webhook_url = "https://test.slack.com"
|
3
|
+
slack_user = "popper"
|
4
|
+
git_token = "test"
|
5
|
+
ghe_token = "test"
|
6
|
+
ghe_url = "http://ghe.example.com"
|
7
|
+
|
8
|
+
[example.login]
|
9
|
+
server = "mail.examplejp"
|
10
|
+
user = "examplle_user"
|
11
|
+
password = "examplle_pass"
|
12
|
+
|
13
|
+
[example.rules.normal_log.condition]
|
14
|
+
subject = ".*example.*"
|
15
|
+
body = ".*example.*"
|
16
|
+
|
17
|
+
[example.rules.normal_log.action.slack]
|
18
|
+
channel = "#test"
|
19
|
+
mentions = ["@test"]
|
20
|
+
message = "test message"
|
21
|
+
|
22
|
+
[example.rules.normal_log.action.git]
|
23
|
+
repo = "test/example"
|
24
|
+
|
25
|
+
[example.rules.normal_log.action.ghe]
|
26
|
+
repo = "test/example"
|
data/lib/popper/sync.rb
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
module Popper
|
2
|
+
class Locked < StandardError; end
|
3
|
+
class Sync
|
4
|
+
def self.synchronized
|
5
|
+
File.open(lockfile, 'w') do |_lockfile|
|
6
|
+
if _lockfile.flock(File::LOCK_EX|File::LOCK_NB)
|
7
|
+
yield
|
8
|
+
else
|
9
|
+
raise Locked
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
def self.lockfile
|
15
|
+
File.join(Dir.home, "popper", "popper.lock")
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
data/popper.gemspec
ADDED
@@ -0,0 +1,30 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'popper/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "popper"
|
8
|
+
spec.version = Popper::VERSION
|
9
|
+
spec.authors = ["pyama86"]
|
10
|
+
spec.email = ["pyama@pepabo.com"]
|
11
|
+
|
12
|
+
spec.summary = %q{email notification tool}
|
13
|
+
spec.description = %q{email notification tool}
|
14
|
+
spec.homepage = "http://ten-snapon.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 = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
20
|
+
spec.require_paths = ["lib"]
|
21
|
+
|
22
|
+
spec.add_dependency 'thor'
|
23
|
+
spec.add_dependency 'slack-notifier'
|
24
|
+
spec.add_dependency 'toml'
|
25
|
+
spec.add_dependency 'mail'
|
26
|
+
spec.add_dependency 'octokit'
|
27
|
+
spec.add_development_dependency "bundler", "~> 1.9"
|
28
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
29
|
+
spec.add_development_dependency "rspec"
|
30
|
+
end
|
metadata
ADDED
@@ -0,0 +1,184 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: popper
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- pyama86
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2015-09-14 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: thor
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: slack-notifier
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: toml
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: mail
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :runtime
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: octokit
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :runtime
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: bundler
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - "~>"
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '1.9'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - "~>"
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '1.9'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: rake
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - "~>"
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '10.0'
|
104
|
+
type: :development
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - "~>"
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '10.0'
|
111
|
+
- !ruby/object:Gem::Dependency
|
112
|
+
name: rspec
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - ">="
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '0'
|
118
|
+
type: :development
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - ">="
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: '0'
|
125
|
+
description: email notification tool
|
126
|
+
email:
|
127
|
+
- pyama@pepabo.com
|
128
|
+
executables:
|
129
|
+
- popper
|
130
|
+
extensions: []
|
131
|
+
extra_rdoc_files: []
|
132
|
+
files:
|
133
|
+
- ".gitignore"
|
134
|
+
- ".rspec"
|
135
|
+
- ".travis.yml"
|
136
|
+
- Gemfile
|
137
|
+
- Gemfile.lock
|
138
|
+
- README.md
|
139
|
+
- Rakefile
|
140
|
+
- bin/console
|
141
|
+
- bin/setup
|
142
|
+
- coverage/.last_run.json
|
143
|
+
- coverage/.resultset.json
|
144
|
+
- coverage/.resultset.json.lock
|
145
|
+
- exe/popper
|
146
|
+
- lib/popper.rb
|
147
|
+
- lib/popper/action.rb
|
148
|
+
- lib/popper/action/base.rb
|
149
|
+
- lib/popper/action/ghe.rb
|
150
|
+
- lib/popper/action/git.rb
|
151
|
+
- lib/popper/action/slack.rb
|
152
|
+
- lib/popper/cli.rb
|
153
|
+
- lib/popper/config.rb
|
154
|
+
- lib/popper/init.rb
|
155
|
+
- lib/popper/pop.rb
|
156
|
+
- lib/popper/sample/config.txt
|
157
|
+
- lib/popper/sync.rb
|
158
|
+
- lib/popper/version.rb
|
159
|
+
- popper.gemspec
|
160
|
+
homepage: http://ten-snapon.com
|
161
|
+
licenses:
|
162
|
+
- MIT
|
163
|
+
metadata: {}
|
164
|
+
post_install_message:
|
165
|
+
rdoc_options: []
|
166
|
+
require_paths:
|
167
|
+
- lib
|
168
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
169
|
+
requirements:
|
170
|
+
- - ">="
|
171
|
+
- !ruby/object:Gem::Version
|
172
|
+
version: '0'
|
173
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
174
|
+
requirements:
|
175
|
+
- - ">="
|
176
|
+
- !ruby/object:Gem::Version
|
177
|
+
version: '0'
|
178
|
+
requirements: []
|
179
|
+
rubyforge_project:
|
180
|
+
rubygems_version: 2.4.8
|
181
|
+
signing_key:
|
182
|
+
specification_version: 4
|
183
|
+
summary: email notification tool
|
184
|
+
test_files: []
|