tachikoma 2.1.1.beta

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: 207833f5f325f2f24d37a7e07e1b1b0967b8fd3d
4
+ data.tar.gz: 08bd9e78449024411fad5928ce16b12959d9df1c
5
+ SHA512:
6
+ metadata.gz: 1beeacf63416547742143286a2ac247909ab53e575a33d6a979b619a2ceeb353fae1f1d4ca15956daf2c79e1a6fb8f440444c6eddbf0813dfe2fba435d9613cb
7
+ data.tar.gz: 7458d786f533a7106972c9f6a07bb63118c355d7e71936272672604e586a05154dd20b80a89fa3222f2e1ddbcac368819a445ea6da960a8418b9aff5a5a52ee5
data/.env.example ADDED
@@ -0,0 +1 @@
1
+ TOKEN_FENIX_KNIGHT=TOKEN_FENIX_KNIGHT
data/.gitignore ADDED
@@ -0,0 +1,24 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ # For heroku deploy
7
+ # Gemfile.lock
8
+ InstalledFiles
9
+ _yardoc
10
+ coverage
11
+ doc/
12
+ lib/bundler/man
13
+ pkg
14
+ rdoc
15
+ spec/reports
16
+ test/tmp
17
+ test/version_tmp
18
+ tmp
19
+
20
+ # Ignore checkout repos
21
+ /repos/
22
+
23
+ $ Ignore dotenv setting
24
+ /.env
data/Gemfile ADDED
@@ -0,0 +1,10 @@
1
+ source 'https://rubygems.org'
2
+ ruby '2.0.0'
3
+ # Specify your gem's dependencies in tachikoma.gemspec
4
+ gemspec
5
+
6
+ group :development, :test do
7
+ gem 'pry'
8
+ end
9
+
10
+ gem 'oj'
data/Gemfile.lock ADDED
@@ -0,0 +1,38 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ tachikoma (2.1.1.beta)
5
+ httparty
6
+ multi_json
7
+ safe_yaml
8
+
9
+ GEM
10
+ remote: https://rubygems.org/
11
+ specs:
12
+ coderay (1.0.9)
13
+ dotenv (0.8.0)
14
+ httparty (0.11.0)
15
+ multi_json (~> 1.0)
16
+ multi_xml (>= 0.5.2)
17
+ method_source (0.8.1)
18
+ multi_json (1.7.7)
19
+ multi_xml (0.5.4)
20
+ oj (2.1.2)
21
+ pry (0.9.12.2)
22
+ coderay (~> 1.0.5)
23
+ method_source (~> 0.8)
24
+ slop (~> 3.4)
25
+ rake (10.1.0)
26
+ safe_yaml (0.9.3)
27
+ slop (3.4.5)
28
+
29
+ PLATFORMS
30
+ ruby
31
+
32
+ DEPENDENCIES
33
+ bundler (~> 1.3)
34
+ dotenv
35
+ oj
36
+ pry
37
+ rake
38
+ tachikoma!
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2013 sanemat
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/NOTE.txt ADDED
@@ -0,0 +1,8 @@
1
+ #TODO
2
+ - heroku build pack (sqlite)
3
+ - Gem-ish usage (load tasks)
4
+
5
+ ## Feature Request
6
+ - Notify if fail
7
+ - Notify no change
8
+ - Frequency(whenever gem compatible)
data/README.md ADDED
@@ -0,0 +1,11 @@
1
+ # Tachikoma
2
+
3
+ Daily Pull Requester with bundle update
4
+
5
+ ## Contributing
6
+
7
+ 1. Fork it
8
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
9
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
10
+ 4. Push to the branch (`git push origin my-new-feature`)
11
+ 5. Create new Pull Request
data/Rakefile ADDED
@@ -0,0 +1,20 @@
1
+ require 'bundler/setup'
2
+ require "bundler/gem_tasks"
3
+ require "bundler/gem_helper"
4
+
5
+ # http://qiita.com/kyanny/items/2de40ca0b5127a0f5c2a
6
+ #Rake::Task[:release].clear
7
+
8
+ # http://qiita.com/kyanny/items/d3111ea76b2941d71ef5
9
+ t = Bundler::GemHelper.new
10
+ desc "Create tag #{t.send(:version_tag)}"
11
+ task :tag do
12
+ t.send(:tag_version) { t.send(:git_push) } unless t.send(:already_tagged?)
13
+ end
14
+
15
+ Dir['lib/tasks/*.rake'].each { |task| load(task) }
16
+
17
+ if ENV['APP_ENV'] && %w(development test).include?(ENV['APP_ENV'])
18
+ require 'dotenv'
19
+ Dotenv.load
20
+ end
@@ -0,0 +1,6 @@
1
+ require 'pathname'
2
+ module Tachikoma
3
+ def self.root
4
+ Pathname.new(File.dirname(File.dirname(File.dirname(__FILE__))))
5
+ end
6
+ end
@@ -0,0 +1,3 @@
1
+ module Tachikoma
2
+ VERSION = "2.1.1.beta"
3
+ end
data/lib/tachikoma.rb ADDED
@@ -0,0 +1,6 @@
1
+ require "tachikoma/version"
2
+ require 'tachikoma/settings'
3
+
4
+ module Tachikoma
5
+ # Your code goes here...
6
+ end
@@ -0,0 +1,110 @@
1
+ require 'httparty'
2
+ require 'multi_json'
3
+ require 'safe_yaml'
4
+ require 'uri'
5
+
6
+ namespace :tachikoma do
7
+ @readable_time = Time.now.utc.strftime('%Y%m%d%H%M%S')
8
+ @root_path = File.expand_path(File.join(__FILE__, '..', '..', '..'))
9
+ @data_path = File.join(@root_path, 'data')
10
+ @repos_path = File.join(@root_path, 'repos')
11
+
12
+ # build_for = fenix-knight, github_token_key = TOKEN_FENIX_KNIGHT
13
+ def github_token_key(build_for)
14
+ "TOKEN_#{build_for}".gsub(/-/, '_').upcase
15
+ end
16
+
17
+ def authorized_url_with_type(fetch_url, type, github_token, github_account)
18
+ uri = URI.parse(fetch_url)
19
+ if type == 'fork'
20
+ %Q!#{uri.scheme}://#{github_token}@#{uri.host}#{path_for_fork(uri.path, github_account)}!
21
+ elsif type == 'shared'
22
+ "#{uri.scheme}://#{github_token}@#{uri.host}#{uri.path}"
23
+ else
24
+ raise "Invalid type #{type}"
25
+ end
26
+ end
27
+
28
+ def path_for_fork(path, github_account)
29
+ path.sub(%r!^/[^/]+!) { '/' + github_account }
30
+ end
31
+
32
+ def target_url(fetch_url)
33
+ uri = URI.parse(fetch_url)
34
+ 'https://api.github.com/repos/' + uri.path.sub(%r!^/(.*)\.git$!) { $1 } + '/pulls'
35
+ end
36
+
37
+ def target_repository_user(type, fetch_url, git_name)
38
+ if type == 'fork'
39
+ git_name
40
+ elsif type == 'shared'
41
+ uri = URI.parse(fetch_url)
42
+ uri.path.sub(%r!/([^/]+)/.*!) { $1 }
43
+ else
44
+ raise "Invalid type #{type}"
45
+ end
46
+ end
47
+
48
+ task :load do
49
+ @build_for = ENV['BUILD_FOR']
50
+ @github_token = ENV[github_token_key(@build_for)]
51
+ @git_name = 'bot-motoko'
52
+ @git_email = 'bot-motoko@al.sane.jp'
53
+ @configure =
54
+ YAML.load_file(File.join(@data_path, "#{@build_for}.yaml"))
55
+ @fetch_url = @configure['url']
56
+ @base_remote_branch = 'origin/master'
57
+ @authorized_url = authorized_url_with_type(@fetch_url, @configure['type'], @github_token, @git_name)
58
+
59
+ @target_url = target_url(@fetch_url)
60
+ @headers = {
61
+ 'User-Agent' => "Tachikoma #{@git_name}",
62
+ 'Authorization' => "token #{@github_token}",
63
+ 'Accept' => 'application/json',
64
+ 'Content-type' => 'application/json',
65
+ }
66
+ @target_head = target_repository_user(@configure['type'], @fetch_url, @git_name)
67
+ @body = MultiJson.dump({
68
+ title: "Bundle update #{@readable_time}",
69
+ body: ':hamster::hamster::hamster:',
70
+ head: "#{@target_head}:feature/bundle-#{@readable_time}",
71
+ base: 'master',
72
+ })
73
+ end
74
+
75
+ task :clean do
76
+ rm_rf(Dir.glob('repos/*'))
77
+ end
78
+
79
+ desc 'fetch'
80
+ task fetch: :clean do
81
+ sh "git clone #{@fetch_url} repos/#{@build_for}"
82
+ end
83
+
84
+ desc 'bundle'
85
+ task :bundle do
86
+ Dir.chdir("repos/#{@build_for}") do
87
+ Bundler.with_clean_env do
88
+ sh %Q!sed -i -e 's/^ruby/#ruby/' Gemfile!
89
+ sh "git config user.name #{@git_name}"
90
+ sh "git config user.email #{@git_email}"
91
+ sh "git checkout -b feature/bundle-#{@readable_time} #{@base_remote_branch}"
92
+ sh 'bundle --gemfile Gemfile --no-deployment --without nothing'
93
+ sh 'bundle update'
94
+ sh 'git add Gemfile.lock'
95
+ sh %Q!git commit -m "Bundle update #{@readable_time}"!
96
+ sh "git push #{@authorized_url} feature/bundle-#{@readable_time}"
97
+ end
98
+ end
99
+ end
100
+
101
+ desc 'pull_request'
102
+ task :pull_request do
103
+ puts @headers
104
+ puts @body
105
+ response = HTTParty.post(@target_url, headers: @headers, body: @body)
106
+ unless response.created?
107
+ fail "Do not create pull request yet. #{response.code} #{response.message} #{response.body}"
108
+ end
109
+ end
110
+ end
data/tachikoma.gemspec ADDED
@@ -0,0 +1,28 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'tachikoma/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "tachikoma"
8
+ spec.version = Tachikoma::VERSION
9
+ spec.authors = ["sanemat"]
10
+ spec.email = ["o.gata.ken@gmail.com"]
11
+ spec.description = %q{Interval pull requester with bundle update.}
12
+ spec.summary = %q{Update gem frequently gets less pain. Let's doing bundle update as a habit!}
13
+ spec.homepage = "https://github.com/sanemat/tachikoma"
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files|grep -v 'data/.*'`.split($/)
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.add_dependency 'httparty'
22
+ spec.add_dependency 'multi_json'
23
+ spec.add_dependency 'safe_yaml'
24
+
25
+ spec.add_development_dependency "bundler", "~> 1.3"
26
+ spec.add_development_dependency "rake"
27
+ spec.add_development_dependency 'dotenv'
28
+ end
metadata ADDED
@@ -0,0 +1,141 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: tachikoma
3
+ version: !ruby/object:Gem::Version
4
+ version: 2.1.1.beta
5
+ platform: ruby
6
+ authors:
7
+ - sanemat
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2013-06-25 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: httparty
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: multi_json
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: safe_yaml
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: bundler
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ~>
60
+ - !ruby/object:Gem::Version
61
+ version: '1.3'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ~>
67
+ - !ruby/object:Gem::Version
68
+ version: '1.3'
69
+ - !ruby/object:Gem::Dependency
70
+ name: rake
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
+ - !ruby/object:Gem::Dependency
84
+ name: dotenv
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - '>='
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - '>='
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
97
+ description: Interval pull requester with bundle update.
98
+ email:
99
+ - o.gata.ken@gmail.com
100
+ executables: []
101
+ extensions: []
102
+ extra_rdoc_files: []
103
+ files:
104
+ - .env.example
105
+ - .gitignore
106
+ - Gemfile
107
+ - Gemfile.lock
108
+ - LICENSE.txt
109
+ - NOTE.txt
110
+ - README.md
111
+ - Rakefile
112
+ - lib/tachikoma.rb
113
+ - lib/tachikoma/settings.rb
114
+ - lib/tachikoma/version.rb
115
+ - lib/tasks/app.rake
116
+ - tachikoma.gemspec
117
+ homepage: https://github.com/sanemat/tachikoma
118
+ licenses:
119
+ - MIT
120
+ metadata: {}
121
+ post_install_message:
122
+ rdoc_options: []
123
+ require_paths:
124
+ - lib
125
+ required_ruby_version: !ruby/object:Gem::Requirement
126
+ requirements:
127
+ - - '>='
128
+ - !ruby/object:Gem::Version
129
+ version: '0'
130
+ required_rubygems_version: !ruby/object:Gem::Requirement
131
+ requirements:
132
+ - - '>'
133
+ - !ruby/object:Gem::Version
134
+ version: 1.3.1
135
+ requirements: []
136
+ rubyforge_project:
137
+ rubygems_version: 2.0.2
138
+ signing_key:
139
+ specification_version: 4
140
+ summary: Update gem frequently gets less pain. Let's doing bundle update as a habit!
141
+ test_files: []