tachikoma_ai 0.1.0

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: 11572ef3fd46320f3546d409a6e88ce14b3207ea
4
+ data.tar.gz: f70c3e8f04a90d8c2cd98a2d5e205e5a51db1450
5
+ SHA512:
6
+ metadata.gz: 39c67b4874b6b9d2cb2ff4996b4e01df5ff73f654a89a82cb63b45160e2a1849ad4496c8f3a7aacb2b5a8f26534dd12fa698ec49cc83574eacfe95ecbe89b04a
7
+ data.tar.gz: 597edc7a82370ce435c80feafd830a5e7c2cce5d0b0f77c8c3e116ecba71e32274b02335b32c62acf4fcbe34deb4edb8706ccff78036b684791cec6395c2bc63
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,2 @@
1
+ --format documentation
2
+ --color
data/.rubocop.yml ADDED
@@ -0,0 +1,11 @@
1
+ AllCops:
2
+ DisplayCopNames: true
3
+
4
+ Metrics/AbcSize:
5
+ Max: 17
6
+
7
+ Metrics/LineLength:
8
+ Max: 120
9
+
10
+ Style/Documentation:
11
+ Enabled: false
data/.travis.yml ADDED
@@ -0,0 +1,9 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.0
4
+ - 2.1
5
+ - 2.2
6
+ - 2.3.0
7
+ before_install: gem install bundler -v 1.10.6
8
+ notifications:
9
+ email: false
@@ -0,0 +1,13 @@
1
+ # Contributor Code of Conduct
2
+
3
+ As contributors and maintainers of this project, we pledge to respect all people who contribute through reporting issues, posting feature requests, updating documentation, submitting pull requests or patches, and other activities.
4
+
5
+ We are committed to making participation in this project a harassment-free experience for everyone, regardless of level of experience, gender, gender identity and expression, sexual orientation, disability, personal appearance, body size, race, ethnicity, age, or religion.
6
+
7
+ Examples of unacceptable behavior by participants include the use of sexual language or imagery, derogatory comments or personal attacks, trolling, public or private harassment, insults, or other unprofessional conduct.
8
+
9
+ Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct. Project maintainers who do not follow the Code of Conduct may be removed from the project team.
10
+
11
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by opening an issue or contacting one or more of the project maintainers.
12
+
13
+ This Code of Conduct is adapted from the [Contributor Covenant](http://contributor-covenant.org), version 1.0.0, available at [http://contributor-covenant.org/version/1/0/0/](http://contributor-covenant.org/version/1/0/0/)
data/Gemfile ADDED
@@ -0,0 +1,6 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in tachikoma_ai.gemspec
4
+ gemspec
5
+
6
+ gem 'codecov', require: false
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2015 sinsoku
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,56 @@
1
+ # TachikomaAi
2
+
3
+ [![Build Status](https://travis-ci.org/sinsoku/tachikoma_ai.svg?branch=master)](https://travis-ci.org/sinsoku/tachikoma_ai)
4
+ [![codecov.io](https://codecov.io/github/sinsoku/tachikoma_ai/coverage.svg?branch=master)](https://codecov.io/github/sinsoku/tachikoma_ai?branch=master)
5
+
6
+ TachikomaAi is a artificial intelligence for [sanemat/tachikoma](https://github.com/sanemat/tachikoma).
7
+
8
+ ## Features
9
+
10
+ - Append comparing urls to Pull Request
11
+
12
+ ![](https://raw.github.com/sinsoku/tachikoma_ai/master/screenshots/pullreq.png)
13
+
14
+ ## Supported versions
15
+
16
+ - Ruby 2.0, 2.1.x, 2.2.x, 2.3.x
17
+
18
+ ## Supported strategies
19
+
20
+ - Bundler (Ruby)
21
+
22
+ ## Installation
23
+
24
+ Add this line to Gemfile:
25
+
26
+ ```ruby
27
+ gem 'tachikoma_ai'
28
+ ```
29
+
30
+ And then execute:
31
+
32
+ $ bundle
33
+
34
+ Load a TachikomaAi in `Rakefile`:
35
+
36
+ ```diff
37
+ require 'bundler/setup'
38
+ require 'tachikoma/tasks'
39
+ + require 'tachikoma_ai'
40
+ ```
41
+
42
+ ## Development
43
+
44
+ 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.
45
+
46
+ 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).
47
+
48
+ ## Contributing
49
+
50
+ Bug reports and pull requests are welcome on GitHub at https://github.com/sinsoku/tachikoma_ai. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](contributor-covenant.org) code of conduct.
51
+
52
+
53
+ ## License
54
+
55
+ The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
56
+
data/Rakefile ADDED
@@ -0,0 +1,9 @@
1
+ require 'bundler/gem_tasks'
2
+ require 'rspec/core/rake_task'
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ require 'rubocop/rake_task'
7
+ RuboCop::RakeTask.new
8
+
9
+ task default: [:rubocop, :spec]
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'bundler/setup'
4
+ require 'tachikoma_ai'
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,7 @@
1
+ #!/bin/bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+
5
+ bundle install
6
+
7
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,46 @@
1
+ require 'rubygems'
2
+
3
+ module TachikomaAi
4
+ module Bundler
5
+ class Gem
6
+ STRING_PATTERN = /[-|\+]\s+(\S+)\s\((.+?)\)/
7
+ major, minor = RUBY_VERSION.split('.')
8
+ SPECS_PATH = "vendor/bundle/ruby/#{major}.#{minor}.0/specifications/".freeze
9
+
10
+ attr_reader :name, :version
11
+ attr_accessor :from
12
+
13
+ def self.parse(s)
14
+ m = s.match STRING_PATTERN
15
+ new m[1], m[2]
16
+ end
17
+
18
+ def initialize(name, version)
19
+ @name = name
20
+ @version = version
21
+ end
22
+
23
+ def github?
24
+ homepage && homepage.include?('github')
25
+ end
26
+
27
+ def homepage
28
+ @homepage ||= spec.homepage
29
+ end
30
+
31
+ def compare_url
32
+ File.join homepage, 'compare', "v#{from}...v#{version}"
33
+ end
34
+
35
+ private
36
+
37
+ def spec
38
+ ::Gem::Specification.load(spec_path)
39
+ end
40
+
41
+ def spec_path
42
+ "#{SPECS_PATH}/#{name}-#{version}.gemspec"
43
+ end
44
+ end
45
+ end
46
+ end
@@ -0,0 +1,54 @@
1
+ require 'tachikoma_ai/bundler/gem'
2
+
3
+ module TachikomaAi
4
+ module Strategies
5
+ class Bundler
6
+ include TachikomaAi::Strategy
7
+
8
+ def pull_request_body
9
+ <<-EOF
10
+ ## Compare
11
+ #{compare_urls}
12
+
13
+ ## Not found
14
+ #{homepage_urls}
15
+ EOF
16
+ end
17
+
18
+ private
19
+
20
+ def updated_gems
21
+ return @updated_gems if @updated_gems
22
+
23
+ names = plus_gems.map(&:name) & minus_gems.map(&:name)
24
+ @updated_gems = plus_gems.select { |g| names.include? g.name }
25
+ @updated_gems.each do |g|
26
+ g.from = minus_gems.find { |mg| mg.name == g.name }.version
27
+ end
28
+ @updated_gems
29
+ end
30
+
31
+ def diff
32
+ @diff ||= `git show --format= HEAD`.split("\n")
33
+ end
34
+
35
+ def minus_gems
36
+ @minus_gems ||= diff.select { |s| s =~ /^- {4}\S/ }
37
+ .map { |s| TachikomaAi::Bundler::Gem.parse(s) }
38
+ end
39
+
40
+ def plus_gems
41
+ @plus_gems ||= diff.select { |s| s =~ /^\+ {4}\S/ }
42
+ .map { |s| TachikomaAi::Bundler::Gem.parse(s) }
43
+ end
44
+
45
+ def compare_urls
46
+ updated_gems.select(&:github?).map { |gem| gem.compare_url.gsub(/http:/, 'https:') }.join("\n")
47
+ end
48
+
49
+ def homepage_urls
50
+ updated_gems.reject(&:github?).map(&:homepage).join("\n")
51
+ end
52
+ end
53
+ end
54
+ end
@@ -0,0 +1,11 @@
1
+ module TachikomaAi
2
+ module Strategy
3
+ def self.included(base)
4
+ TachikomaAi.strategies << base
5
+ end
6
+
7
+ def pull_request_body
8
+ raise NotImplementedError
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,25 @@
1
+ module TachikomaAi
2
+ module TachikomaExtention
3
+ def run(strategy)
4
+ begin
5
+ @strategy = TachikomaAi::Strategies.const_get(strategy.capitalize).new
6
+ rescue NameError
7
+ raise LoadError, "Could not find matching strategy for #{strategy}."
8
+ end
9
+ super
10
+ end
11
+
12
+ def pull_request
13
+ @pull_request_body = @pull_request_body.to_s
14
+ if @strategy
15
+ Dir.chdir("#{Tachikoma.repos_path}/#{@build_for}") do
16
+ @pull_request_body += "\n\n" + @strategy.pull_request_body
17
+ end
18
+ end
19
+ rescue
20
+ p $ERROR_INFO
21
+ ensure
22
+ super
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,3 @@
1
+ module TachikomaAi
2
+ VERSION = '0.1.0'.freeze
3
+ end
@@ -0,0 +1,16 @@
1
+ require 'tachikoma_ai/strategy'
2
+ require 'tachikoma_ai/tachikoma_extention'
3
+ require 'tachikoma_ai/version'
4
+
5
+ module TachikomaAi
6
+ module Strategies
7
+ autoload :Bundler, 'tachikoma_ai/strategies/bundler'
8
+ end
9
+
10
+ def self.strategies
11
+ @strategies ||= []
12
+ end
13
+ end
14
+
15
+ require 'tachikoma/application'
16
+ Tachikoma::Application.send :prepend, TachikomaAi::TachikomaExtention
data/repos/.keep ADDED
File without changes
Binary file
@@ -0,0 +1,26 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'tachikoma_ai/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = 'tachikoma_ai'
8
+ spec.version = TachikomaAi::VERSION
9
+ spec.authors = ['sinsoku']
10
+ spec.email = ['sinsoku.listy@gmail.com']
11
+
12
+ spec.summary = 'A tachikoma will get a artificial intelligence, and will become a high-spec combat vehicles.'
13
+ spec.description = 'Give a comparing function on GitHub to tachikoma'
14
+ spec.homepage = 'https://github.com/sinsoku/tachikoma_ai'
15
+ spec.license = 'MIT'
16
+
17
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
18
+ spec.require_paths = ['lib']
19
+
20
+ spec.add_dependency 'tachikoma', '>= 4.2'
21
+
22
+ spec.add_development_dependency 'bundler', '~> 1.10'
23
+ spec.add_development_dependency 'rake', '~> 10.0'
24
+ spec.add_development_dependency 'rspec'
25
+ spec.add_development_dependency 'rubocop'
26
+ end
metadata ADDED
@@ -0,0 +1,135 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: tachikoma_ai
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - sinsoku
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2016-02-28 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: tachikoma
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '4.2'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '4.2'
27
+ - !ruby/object:Gem::Dependency
28
+ name: bundler
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '1.10'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '1.10'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rake
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '10.0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '10.0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rspec
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
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: rubocop
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ description: Give a comparing function on GitHub to tachikoma
84
+ email:
85
+ - sinsoku.listy@gmail.com
86
+ executables: []
87
+ extensions: []
88
+ extra_rdoc_files: []
89
+ files:
90
+ - ".gitignore"
91
+ - ".rspec"
92
+ - ".rubocop.yml"
93
+ - ".travis.yml"
94
+ - CODE_OF_CONDUCT.md
95
+ - Gemfile
96
+ - LICENSE.txt
97
+ - README.md
98
+ - Rakefile
99
+ - bin/console
100
+ - bin/setup
101
+ - lib/tachikoma_ai.rb
102
+ - lib/tachikoma_ai/bundler/gem.rb
103
+ - lib/tachikoma_ai/strategies/bundler.rb
104
+ - lib/tachikoma_ai/strategy.rb
105
+ - lib/tachikoma_ai/tachikoma_extention.rb
106
+ - lib/tachikoma_ai/version.rb
107
+ - repos/.keep
108
+ - screenshots/pullreq.png
109
+ - tachikoma_ai.gemspec
110
+ homepage: https://github.com/sinsoku/tachikoma_ai
111
+ licenses:
112
+ - MIT
113
+ metadata: {}
114
+ post_install_message:
115
+ rdoc_options: []
116
+ require_paths:
117
+ - lib
118
+ required_ruby_version: !ruby/object:Gem::Requirement
119
+ requirements:
120
+ - - ">="
121
+ - !ruby/object:Gem::Version
122
+ version: '0'
123
+ required_rubygems_version: !ruby/object:Gem::Requirement
124
+ requirements:
125
+ - - ">="
126
+ - !ruby/object:Gem::Version
127
+ version: '0'
128
+ requirements: []
129
+ rubyforge_project:
130
+ rubygems_version: 2.5.1
131
+ signing_key:
132
+ specification_version: 4
133
+ summary: A tachikoma will get a artificial intelligence, and will become a high-spec
134
+ combat vehicles.
135
+ test_files: []