bo_gitcw 0.1.2 → 0.1.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 763abebafa7f27d45524face0c950fa8ac69e2e7
4
- data.tar.gz: e5d7154f6aa2d637f7536d87a29134dca82737fd
3
+ metadata.gz: c8083841d151e60d9c19e3b6f256305ab951c717
4
+ data.tar.gz: 80ac6be914589aa1923a4354646dd0dc41594b03
5
5
  SHA512:
6
- metadata.gz: '084f6a28bf51d0218479b6696baadcb47dcc657b4460d62b33a48b8dddcde2aab2597365b25be123fe4a80865d6d9186f550bf871541f45f3bc790a85fdb8b90'
7
- data.tar.gz: e17b9f8624579134b4601b6d9e2d3d3ddf8f65d63c0e29668be477237f8b0dce99a03a88331c5d7d4d454d28b7ac9efc6233b5c561f06c85d285484c8169ae5e
6
+ metadata.gz: 528bea1a4745954359038ef8128bf0bd446ef9256c1717273c81170e9c3947f52449dcc0c296949e36eb6409f4cb3e365772be76dee94541a110529a74b6ef18
7
+ data.tar.gz: 555ef77138c31803c2a503b40c56b21b54f332e560f92576a183ee8b8e3ad38f1662ca23801294ba88cb26703f8c6bd4c9416e855861e364865b9edff8ed51ee
data/.gitignore ADDED
@@ -0,0 +1,8 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp/
@@ -0,0 +1,74 @@
1
+ # Contributor Covenant Code of Conduct
2
+
3
+ ## Our Pledge
4
+
5
+ In the interest of fostering an open and welcoming environment, we as
6
+ contributors and maintainers pledge to making participation in our project and
7
+ our community a harassment-free experience for everyone, regardless of age, body
8
+ size, disability, ethnicity, gender identity and expression, level of experience,
9
+ nationality, personal appearance, race, religion, or sexual identity and
10
+ orientation.
11
+
12
+ ## Our Standards
13
+
14
+ Examples of behavior that contributes to creating a positive environment
15
+ include:
16
+
17
+ * Using welcoming and inclusive language
18
+ * Being respectful of differing viewpoints and experiences
19
+ * Gracefully accepting constructive criticism
20
+ * Focusing on what is best for the community
21
+ * Showing empathy towards other community members
22
+
23
+ Examples of unacceptable behavior by participants include:
24
+
25
+ * The use of sexualized language or imagery and unwelcome sexual attention or
26
+ advances
27
+ * Trolling, insulting/derogatory comments, and personal or political attacks
28
+ * Public or private harassment
29
+ * Publishing others' private information, such as a physical or electronic
30
+ address, without explicit permission
31
+ * Other conduct which could reasonably be considered inappropriate in a
32
+ professional setting
33
+
34
+ ## Our Responsibilities
35
+
36
+ Project maintainers are responsible for clarifying the standards of acceptable
37
+ behavior and are expected to take appropriate and fair corrective action in
38
+ response to any instances of unacceptable behavior.
39
+
40
+ Project maintainers have the right and responsibility to remove, edit, or
41
+ reject comments, commits, code, wiki edits, issues, and other contributions
42
+ that are not aligned to this Code of Conduct, or to ban temporarily or
43
+ permanently any contributor for other behaviors that they deem inappropriate,
44
+ threatening, offensive, or harmful.
45
+
46
+ ## Scope
47
+
48
+ This Code of Conduct applies both within project spaces and in public spaces
49
+ when an individual is representing the project or its community. Examples of
50
+ representing a project or community include using an official project e-mail
51
+ address, posting via an official social media account, or acting as an appointed
52
+ representative at an online or offline event. Representation of a project may be
53
+ further defined and clarified by project maintainers.
54
+
55
+ ## Enforcement
56
+
57
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be
58
+ reported by contacting the project team at bo.panda.qt@gmail.com. All
59
+ complaints will be reviewed and investigated and will result in a response that
60
+ is deemed necessary and appropriate to the circumstances. The project team is
61
+ obligated to maintain confidentiality with regard to the reporter of an incident.
62
+ Further details of specific enforcement policies may be posted separately.
63
+
64
+ Project maintainers who do not follow or enforce the Code of Conduct in good
65
+ faith may face temporary or permanent repercussions as determined by other
66
+ members of the project's leadership.
67
+
68
+ ## Attribution
69
+
70
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
71
+ available at [http://contributor-covenant.org/version/1/4][version]
72
+
73
+ [homepage]: http://contributor-covenant.org
74
+ [version]: http://contributor-covenant.org/version/1/4/
data/Gemfile ADDED
@@ -0,0 +1,11 @@
1
+ source "https://rubygems.org"
2
+
3
+ git_source(:github) {|repo_name| "https://github.com/bo_gitcw" }
4
+
5
+ # Specify your gem's dependencies in bo_gitcw.gemspec
6
+ gemspec
7
+
8
+ gem "rest-client", "~> 1.8"
9
+ gem "rails", "5.0.2"
10
+ gem "spring", :group => :development
11
+ gem "pry"
data/Gemfile.lock ADDED
@@ -0,0 +1,141 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ bo_gitcw (0.1.3)
5
+
6
+ GEM
7
+ remote: https://rubygems.org/
8
+ specs:
9
+ actioncable (5.0.2)
10
+ actionpack (= 5.0.2)
11
+ nio4r (>= 1.2, < 3.0)
12
+ websocket-driver (~> 0.6.1)
13
+ actionmailer (5.0.2)
14
+ actionpack (= 5.0.2)
15
+ actionview (= 5.0.2)
16
+ activejob (= 5.0.2)
17
+ mail (~> 2.5, >= 2.5.4)
18
+ rails-dom-testing (~> 2.0)
19
+ actionpack (5.0.2)
20
+ actionview (= 5.0.2)
21
+ activesupport (= 5.0.2)
22
+ rack (~> 2.0)
23
+ rack-test (~> 0.6.3)
24
+ rails-dom-testing (~> 2.0)
25
+ rails-html-sanitizer (~> 1.0, >= 1.0.2)
26
+ actionview (5.0.2)
27
+ activesupport (= 5.0.2)
28
+ builder (~> 3.1)
29
+ erubis (~> 2.7.0)
30
+ rails-dom-testing (~> 2.0)
31
+ rails-html-sanitizer (~> 1.0, >= 1.0.3)
32
+ activejob (5.0.2)
33
+ activesupport (= 5.0.2)
34
+ globalid (>= 0.3.6)
35
+ activemodel (5.0.2)
36
+ activesupport (= 5.0.2)
37
+ activerecord (5.0.2)
38
+ activemodel (= 5.0.2)
39
+ activesupport (= 5.0.2)
40
+ arel (~> 7.0)
41
+ activesupport (5.0.2)
42
+ concurrent-ruby (~> 1.0, >= 1.0.2)
43
+ i18n (~> 0.7)
44
+ minitest (~> 5.1)
45
+ tzinfo (~> 1.1)
46
+ arel (7.1.4)
47
+ builder (3.2.3)
48
+ coderay (1.1.2)
49
+ concurrent-ruby (1.0.5)
50
+ crass (1.0.3)
51
+ domain_name (0.5.20170404)
52
+ unf (>= 0.0.5, < 1.0.0)
53
+ erubis (2.7.0)
54
+ globalid (0.4.1)
55
+ activesupport (>= 4.2.0)
56
+ http-cookie (1.0.3)
57
+ domain_name (~> 0.5)
58
+ i18n (0.9.1)
59
+ concurrent-ruby (~> 1.0)
60
+ loofah (2.1.1)
61
+ crass (~> 1.0.2)
62
+ nokogiri (>= 1.5.9)
63
+ mail (2.7.0)
64
+ mini_mime (>= 0.1.1)
65
+ method_source (0.9.0)
66
+ mime-types (2.99.3)
67
+ mini_mime (1.0.0)
68
+ mini_portile2 (2.3.0)
69
+ minitest (5.10.3)
70
+ netrc (0.11.0)
71
+ nio4r (2.1.0)
72
+ nokogiri (1.8.1)
73
+ mini_portile2 (~> 2.3.0)
74
+ pry (0.11.3)
75
+ coderay (~> 1.1.0)
76
+ method_source (~> 0.9.0)
77
+ rack (2.0.3)
78
+ rack-test (0.6.3)
79
+ rack (>= 1.0)
80
+ rails (5.0.2)
81
+ actioncable (= 5.0.2)
82
+ actionmailer (= 5.0.2)
83
+ actionpack (= 5.0.2)
84
+ actionview (= 5.0.2)
85
+ activejob (= 5.0.2)
86
+ activemodel (= 5.0.2)
87
+ activerecord (= 5.0.2)
88
+ activesupport (= 5.0.2)
89
+ bundler (>= 1.3.0, < 2.0)
90
+ railties (= 5.0.2)
91
+ sprockets-rails (>= 2.0.0)
92
+ rails-dom-testing (2.0.3)
93
+ activesupport (>= 4.2.0)
94
+ nokogiri (>= 1.6)
95
+ rails-html-sanitizer (1.0.3)
96
+ loofah (~> 2.0)
97
+ railties (5.0.2)
98
+ actionpack (= 5.0.2)
99
+ activesupport (= 5.0.2)
100
+ method_source
101
+ rake (>= 0.8.7)
102
+ thor (>= 0.18.1, < 2.0)
103
+ rake (10.5.0)
104
+ rest-client (1.8.0)
105
+ http-cookie (>= 1.0.2, < 2.0)
106
+ mime-types (>= 1.16, < 3.0)
107
+ netrc (~> 0.7)
108
+ spring (2.0.2)
109
+ activesupport (>= 4.2)
110
+ sprockets (3.7.1)
111
+ concurrent-ruby (~> 1.0)
112
+ rack (> 1, < 3)
113
+ sprockets-rails (3.2.1)
114
+ actionpack (>= 4.0)
115
+ activesupport (>= 4.0)
116
+ sprockets (>= 3.0.0)
117
+ thor (0.20.0)
118
+ thread_safe (0.3.6)
119
+ tzinfo (1.2.4)
120
+ thread_safe (~> 0.1)
121
+ unf (0.1.4)
122
+ unf_ext
123
+ unf_ext (0.0.7.4)
124
+ websocket-driver (0.6.5)
125
+ websocket-extensions (>= 0.1.0)
126
+ websocket-extensions (0.1.3)
127
+
128
+ PLATFORMS
129
+ ruby
130
+
131
+ DEPENDENCIES
132
+ bo_gitcw!
133
+ bundler (~> 1.16.a)
134
+ pry
135
+ rails (= 5.0.2)
136
+ rake (~> 10.0)
137
+ rest-client (~> 1.8)
138
+ spring
139
+
140
+ BUNDLED WITH
141
+ 1.16.0.pre.3
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2017 THANH LUAN
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,43 @@
1
+ # BoGitcw
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/bo_gitcw`. 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 'bo_gitcw'
13
+ ```
14
+
15
+ And then execute:
16
+
17
+ $ bundle
18
+
19
+ Or install it yourself as:
20
+
21
+ $ gem install bo_gitcw
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]/bo_gitcw. 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.
36
+
37
+ ## License
38
+
39
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
40
+
41
+ ## Code of Conduct
42
+
43
+ Everyone interacting in the BoGitcw project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/bo_gitcw/blob/master/CODE_OF_CONDUCT.md).
data/Rakefile ADDED
@@ -0,0 +1,2 @@
1
+ require "bundler/gem_tasks"
2
+ task :default => :spec
@@ -0,0 +1,23 @@
1
+ module BoGitcw
2
+ class GithubEventController
3
+ skip_before_filter :verify_authenticity_token
4
+
5
+ def call
6
+ p "co zo index roi nhe"
7
+ action = JSON.parse(request.raw_post)['action']
8
+ p action
9
+ case action
10
+ when 'created', 'submitted', 'edited'
11
+ return if params[:comment].nil?
12
+ body = BoGitcw::Chatwork.new_comment(params[:comment], params[:pull_request] || params[:issue])
13
+ when 'opened'
14
+ return if params[:pull_request].nil?
15
+ body = BoGitcw::Chatwork.new_pull(params[:pull_request])
16
+ else
17
+ render :json => {} and return
18
+ end
19
+ response = BoGitcw::Chatwork.send_message body
20
+ render :json => response
21
+ end
22
+ end
23
+ end
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "bo_gitcw"
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(__FILE__)
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/bo_gitcw.gemspec ADDED
@@ -0,0 +1,33 @@
1
+
2
+ lib = File.expand_path("../lib", __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require "bo_gitcw/version"
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "bo_gitcw"
8
+ spec.version = BoGitcw::VERSION
9
+ spec.authors = ["Bo Rie"]
10
+ spec.email = ["bo.panda.qt@gmail.com"]
11
+
12
+ spec.summary = "ChatWork-Github"
13
+ spec.description = "Message To Chatwork when github have event"
14
+ spec.homepage = "https://rubygems.org/gems/bo_gitcw"
15
+ spec.license = "MIT"
16
+
17
+ # Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
18
+ # to allow pushing to a single host or delete this section to allow pushing to any host.
19
+ # if spec.respond_to?(:metadata)
20
+ # spec.metadata["allowed_push_host"] = "TODO: Set to 'http://mygemserver.com'"
21
+ # else
22
+ # raise "RubyGems 2.0 or newer is required to protect against " \
23
+ # "public gem pushes."
24
+ # end
25
+
26
+ spec.files = `git ls-files`.split("\n")
27
+ spec.bindir = "exe"
28
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
29
+ spec.require_paths = ["lib"]
30
+
31
+ spec.add_development_dependency "bundler", "~> 1.16.a"
32
+ spec.add_development_dependency "rake", "~> 10.0"
33
+ end
data/config/routes.rb ADDED
@@ -0,0 +1,3 @@
1
+ BoGitcw::Engine.routes.draw do
2
+ post "bo_gitcw" => "bo_gitcw/github_events#call"
3
+ end
@@ -0,0 +1,78 @@
1
+ module BoGitcw
2
+ class Chatwork
3
+ USERS = [
4
+ {id: "89931124", login: "duykhanh21", cw_id: "728165"},
5
+ {id: "", login: "NguyenHoangAnhDung", cw_id: "2002615"},
6
+ {id: "", login: "quyenguyengoc", cw_id: "2110276"},
7
+ {id: "", login: "Huyliver6793", cw_id: "2031140"},
8
+ {id: "", login: "quynhqtvn", cw_id: "2031071"},
9
+ {id: "", login: "vovanhai193", cw_id: "2031123"},
10
+ {id: "", login: "linhnt", cw_id: "637915"},
11
+ {id: "", login: "octoberstorm", cw_id: "637888"},
12
+ {id: "", login: "RathanakSreang", cw_id: "1352084"},
13
+ {id: "", login: "", cw_id: "1889879"},
14
+ {id: "", login: "emily0604", cw_id: "1474365"},
15
+ {id: "", login: "khanhhd", cw_id: "638426"},
16
+ {id: "", login: "XuanVuPham", cw_id: "2035153"},
17
+ {id: "", login: "ledinhdoan", cw_id: "2031048"},
18
+ {id: "", login: "doanchinhat", cw_id: "2076195"},
19
+ {id: "", login: "nhatnkv", cw_id: "2261573"},
20
+ {id: "", login: "thanhmancity", cw_id: "2106645"},
21
+ {id: "", login: "nozayasu", cw_id: "2524618"},
22
+ {id: "", login: "rpm33", cw_id: "2523754"},
23
+ {id: "", login: "vantientu1703", cw_id: "1818099"},
24
+ {id: "", login: "DTPhuong", cw_id: "1385559"},
25
+ {id: "", login: "tuyenbq1911", cw_id: "1740585"}
26
+ ]
27
+ CW_URI = {
28
+ host: "https://api.chatwork.com/v2/",
29
+ port: ""
30
+ }
31
+ CW_TOKEN = '21036e086f55074a37badea84ebab3d6'
32
+ ROOM_ID = 91161317
33
+
34
+ class << self
35
+ def picon user
36
+ usr = USERS.select{|u| u[:login] == user}.first
37
+ if usr.blank?
38
+ ""
39
+ else
40
+ "[picon:#{usr[:cw_id]}]"
41
+ end
42
+ end
43
+
44
+ def to user
45
+ usr = USERS.select{|u| u[:login] == user}.first
46
+ if usr.blank?
47
+ ""
48
+ else
49
+ "[To:#{usr[:cw_id]}]"
50
+ end
51
+ end
52
+
53
+ def new_pull pr
54
+ "[info][title][NEW] Pull request created by #{picon(pr['user']['login'])}[/title] - Title: #{pr['title']} - Link: #{pr['html_url']}[/info]"
55
+ end
56
+
57
+ def new_comment comment, pr
58
+ pic = []
59
+ comment['body'].gsub(/@(\w+)/){|c| pic.push(c.gsub("@", ""))}
60
+ if pic.empty?
61
+ "[info][title][PR] #{pr['title']}[/title] #{picon(comment['user']['login'])}(commented)[code]#{comment['body']}[/code][hr]#{to(pr['user']['login'])} Link: #{comment['html_url']}[/info]"
62
+ else
63
+ "[info][title][PR] #{pr['title']}[/title] #{picon(comment['user']['login'])}(commented)[code]#{comment['body']}[/code][hr]#{to(pr['user']['login'])} Link: #{comment['html_url']}[hr] #{pic.map{|p| to(p)}.join()}[/info]"
64
+ end
65
+ end
66
+
67
+ def send_message body
68
+ post("rooms/#{ROOM_ID}/messages", body)
69
+ end
70
+
71
+ def post path, data
72
+ url = "#{CW_URI[:host]}#{path}"
73
+ res = RestClient.post url, {body: data}, {'X-ChatWorkToken' => CW_TOKEN}
74
+ p res
75
+ end
76
+ end
77
+ end
78
+ end
@@ -1,3 +1,3 @@
1
1
  module BoGitcw
2
- VERSION = "0.1.2"
2
+ VERSION = "0.1.4"
3
3
  end
@@ -0,0 +1,5 @@
1
+ class InstallGenerator < Rails::Generators::Base
2
+ def add
3
+ puts "Hello world!"
4
+ end
5
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bo_gitcw
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Bo Rie
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-12-06 00:00:00.000000000 Z
11
+ date: 2017-12-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -45,9 +45,22 @@ executables: []
45
45
  extensions: []
46
46
  extra_rdoc_files: []
47
47
  files:
48
+ - ".gitignore"
49
+ - CODE_OF_CONDUCT.md
50
+ - Gemfile
51
+ - Gemfile.lock
52
+ - LICENSE.txt
53
+ - README.md
54
+ - Rakefile
55
+ - app/controllers/bo_gitcw/github_events_controller.rb
56
+ - bin/console
57
+ - bin/setup
58
+ - bo_gitcw.gemspec
59
+ - config/routes.rb
48
60
  - lib/bo_gitcw.rb
61
+ - lib/bo_gitcw/chatwork.rb
49
62
  - lib/bo_gitcw/version.rb
50
- - lib/generators/init_generator.rb
63
+ - lib/generators/install_generator.rb
51
64
  homepage: https://rubygems.org/gems/bo_gitcw
52
65
  licenses:
53
66
  - MIT
@@ -1,5 +0,0 @@
1
- class InitGenerator
2
- def self.say_hello
3
- p "db"
4
- end
5
- end