tachikoma 3.0.0 → 3.0.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 959855b32d57d8fc65b695bbe828aebdb721d7dd
4
- data.tar.gz: d87489d289f3f15d46865ce921654fc932269a65
3
+ metadata.gz: 5831a8f436e996a753de8fc6a391c7f372902725
4
+ data.tar.gz: b8355eba94d70b0902e4a313a3e9f9006f6a6dbc
5
5
  SHA512:
6
- metadata.gz: 2db323e982a2e86c168eeaaf854f28d942ff0c61a1f18bb0fb2cbe03b7468ef73fbfd4183984b653e68003b5e97fd0b495b369f82cf9aa9c909ef1f17e9931bc
7
- data.tar.gz: 4b5d8134ff072bbb2019f79746abbc3c5b671faf3aaa29b0a853296257e499704668008a34d36889ac91a6cfda0744410bca968597408297fc802775196497e9
6
+ metadata.gz: eacae9f226657cf252527f3266d91c8ace937182aed4514ed308aa90f4ae28e55aa0236e859c236bdfa3c9e5fd28373fd50455be4b44fd34b7b8bc25cfd8936e
7
+ data.tar.gz: e24be4920aabea89393a85c55427bd6cedefa52b8166097554c66da0103e996565a8af6f8e3dcd8733e74d9e5f4c3d50bc289dddf81ee0f61496a94ca2c77491
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --color
2
+ --format progress
data/.travis.yml ADDED
@@ -0,0 +1,12 @@
1
+ language: ruby
2
+ rvm:
3
+ - 1.9.3
4
+ - 2.0.0
5
+ before_install:
6
+ - gem update bundler
7
+ notifications:
8
+ email:
9
+ - ogataken@gmail.com
10
+ branches:
11
+ only:
12
+ - master
data/Gemfile CHANGED
@@ -1,5 +1,4 @@
1
1
  source 'https://rubygems.org'
2
- ruby '2.0.0'
3
2
  # Specify your gem's dependencies in tachikoma.gemspec
4
3
  gemspec
5
4
 
data/README.md CHANGED
@@ -1,6 +1,10 @@
1
1
  # Tachikoma
2
2
 
3
- Daily Pull Requester with bundle update
3
+ [![Gem Version](https://badge.fury.io/rb/tachikoma.png)](http://badge.fury.io/rb/tachikoma)
4
+ [![Build Status](https://api.travis-ci.org/sanemat/tachikoma.png?branch=master)](https://travis-ci.org/sanemat/tachikoma)
5
+ [![Code Climate](https://codeclimate.com/github/sanemat/tachikoma.png)](https://codeclimate.com/github/sanemat/tachikoma)
6
+
7
+ Daily Pull Requester with bundle update. [Actual pull request](https://github.com/mrtaddy/fenix-knight/pull/25)
4
8
 
5
9
  ## Usage as gem
6
10
 
@@ -26,6 +30,10 @@ $ export TOKEN_YOUR_REPOSITORY_NAME_THAT_IS_SAME_TO_YAML_FILENAME=xxxxxxxxxxxxxx
26
30
  $ bundle exec rake tachikoma:load tachikoma:fetch tachikoma:bundle tachikoma:pull_request
27
31
  ```
28
32
 
33
+ ### Build script example
34
+
35
+ - [cloudbees.com dev@cloud](https://gist.github.com/sanemat/5859031)
36
+
29
37
  ## Contributing
30
38
 
31
39
  1. Fork it
data/Rakefile CHANGED
@@ -1,6 +1,7 @@
1
1
  require 'bundler/setup'
2
2
  require "bundler/gem_tasks"
3
3
  require "bundler/gem_helper"
4
+ require 'rspec/core/rake_task'
4
5
 
5
6
  # http://qiita.com/kyanny/items/2de40ca0b5127a0f5c2a
6
7
  #Rake::Task[:release].clear
@@ -18,3 +19,10 @@ if ENV['APP_ENV'] && %w(development test).include?(ENV['APP_ENV'])
18
19
  require 'dotenv'
19
20
  Dotenv.load
20
21
  end
22
+
23
+ desc 'Run all specs in spec directory'
24
+ RSpec::Core::RakeTask.new(:spec) do |spec|
25
+ spec.rspec_opts = ['-cfd --backtrace']
26
+ end
27
+
28
+ task default: :spec
data/bin/tachikoma CHANGED
@@ -15,6 +15,10 @@ require 'tachikoma/tasks'
15
15
  EOS
16
16
  end
17
17
  FileUtils.mkdir_p('data')
18
+ File.open(File.join('data', '__user_config__.yaml'), 'w') do |f|
19
+ f << <<-EOS
20
+ EOS
21
+ end
18
22
  File.open(File.join('data', 'bot-motoko-tachikoma.yaml'), 'w') do |f|
19
23
  f << <<-EOS
20
24
  url:
data/data/default.yaml ADDED
@@ -0,0 +1,14 @@
1
+ commiter_name:
2
+ 'bot-motoko'
3
+ commiter_email:
4
+ 'bot-motoko@al.sane.jp'
5
+ github_account:
6
+ 'bot-motoko'
7
+ base_remote_branch:
8
+ 'origin/master'
9
+ timestamp_format:
10
+ '%Y%m%d%H%M%S'
11
+ pull_request_body:
12
+ ':hamster::hamster::hamster:'
13
+ pull_request_base:
14
+ 'master'
@@ -1,30 +1,42 @@
1
1
  require 'pathname'
2
2
 
3
3
  module Tachikoma
4
- # ~/users-tachikoma-dir
5
- def self.root_path
6
- @root_path ||= Pathname.new(Dir.pwd)
7
- end
4
+ class << self
5
+ # ~/users-tachikoma-dir
6
+ def root_path
7
+ @root_path ||= Pathname.new Dir.pwd
8
+ end
8
9
 
9
- def self.root_path=(root_path)
10
- @root_path = Pathname.new File.expand_path(root_path)
11
- end
10
+ def root_path=(root_path)
11
+ @root_path = Pathname.new File.expand_path(root_path)
12
+ end
12
13
 
13
- # ~/users-tachikoma-dir/data
14
- def self.data_path
15
- @data_path ||= root_path.join('data')
16
- end
14
+ # ~/users-tachikoma-dir/data
15
+ def data_path
16
+ @data_path ||= root_path.join('data')
17
+ end
17
18
 
18
- def self.data_path=(data_path)
19
- @data_path = Pathname.new File.expand_path(data_path)
20
- end
19
+ def data_path=(data_path)
20
+ @data_path = Pathname.new File.expand_path(data_path)
21
+ end
21
22
 
22
- # ~/users-tachikoma-dir/repos
23
- def self.repos_path
24
- @repos_path ||= root_path.join('repos')
25
- end
23
+ # ~/users-tachikoma-dir/repos
24
+ def repos_path
25
+ @repos_path ||= root_path.join('repos')
26
+ end
27
+
28
+ def repos_path=(repos_path)
29
+ @repos_path = Pathname.new File.expand_path(repos_path)
30
+ end
31
+
32
+ # /path/to/gem/tachikoma
33
+ def original_root_path
34
+ @original_root_path ||= Pathname.new File.expand_path(File.join(File.dirname(__FILE__), '..', '..'))
35
+ end
26
36
 
27
- def self.repos_path=(repos_path)
28
- @repos_path = Pathname.new File.expand_path(repos_path)
37
+ # /path/to/gem/tachikoma/data
38
+ def original_data_path
39
+ @original_data_path ||= original_root_path.join('data')
40
+ end
29
41
  end
30
42
  end
@@ -1,3 +1,3 @@
1
1
  module Tachikoma
2
- VERSION = "3.0.0"
2
+ VERSION = "3.0.1"
3
3
  end
data/lib/tasks/app.rake CHANGED
@@ -5,6 +5,7 @@ require 'uri'
5
5
  require 'tachikoma'
6
6
 
7
7
  namespace :tachikoma do
8
+ # deprecated, this will be removed v3.1.0
8
9
  @default_timestamp_format = '%Y%m%d%H%M%S'
9
10
 
10
11
  # build_for = fenix-knight, github_token_key = TOKEN_FENIX_KNIGHT
@@ -32,9 +33,9 @@ namespace :tachikoma do
32
33
  'https://api.github.com/repos/' + uri.path.sub(%r!^/(.*)\.git$!) { $1 } + '/pulls'
33
34
  end
34
35
 
35
- def target_repository_user(type, fetch_url, git_name)
36
+ def target_repository_user(type, fetch_url, github_account)
36
37
  if type == 'fork'
37
- git_name
38
+ github_account
38
39
  elsif type == 'shared'
39
40
  uri = URI.parse(fetch_url)
40
41
  uri.path.sub(%r!/([^/]+)/.*!) { $1 }
@@ -46,40 +47,54 @@ namespace :tachikoma do
46
47
  task :load do
47
48
  @build_for = ENV['BUILD_FOR']
48
49
  @github_token = ENV[github_token_key(@build_for)]
49
- @git_name = 'bot-motoko'
50
- @git_email = 'bot-motoko@al.sane.jp'
51
- @configure =
52
- YAML.safe_load_file(File.join(Tachikoma.data_path, "#{@build_for}.yaml"))
50
+
51
+ base_config_path = File.join(Tachikoma.original_data_path, 'default.yaml')
52
+ base_config = YAML.safe_load_file(base_config_path) || {}
53
+ user_config_path = File.join(Tachikoma.data_path, "__user_config__.yaml")
54
+ user_config = YAML.safe_load_file(user_config_path) if File.exist?(user_config_path)
55
+ user_config ||= {}
56
+ each_config_path = File.join(Tachikoma.data_path, "#{@build_for}.yaml")
57
+ each_config = YAML.safe_load_file(each_config_path) if File.exist?(each_config_path)
58
+ unless each_config
59
+ fail %Q!Something wrong, BUILD_FOR: #{@build_for}, your config_path: #{each_config_path}!
60
+ end
61
+
62
+ @configure = base_config.merge(user_config).merge(each_config)
63
+
64
+ @commiter_name = @configure['commiter_name']
65
+ @commiter_email = @configure['commiter_email']
66
+ @github_account = @configure['github_account']
53
67
  @fetch_url = @configure['url']
54
- @base_remote_branch = 'origin/master'
55
- @authorized_url = authorized_url_with_type(@fetch_url, @configure['type'], @github_token, @git_name)
56
- timestamp_format = @configure['timestamp_format'] || @default_timestamp_format # nil guard
57
- timestamp_format = @default_timestamp_format if timestamp_format.empty? # empty string: ""
58
- @readable_time = Time.now.utc.strftime(timestamp_format)
68
+ @base_remote_branch = @configure['base_remote_branch']
69
+ @authorized_url = authorized_url_with_type(@fetch_url, @configure['type'], @github_token, @github_account)
70
+ @timestamp_format = @configure['timestamp_format'] || @default_timestamp_format
71
+ @readable_time = Time.now.utc.strftime(@timestamp_format)
59
72
 
60
73
  @target_url = target_url(@fetch_url)
61
74
  @headers = {
62
- 'User-Agent' => "Tachikoma #{@git_name}",
75
+ 'User-Agent' => "Tachikoma #{@github_account}",
63
76
  'Authorization' => "token #{@github_token}",
64
77
  'Accept' => 'application/json',
65
78
  'Content-type' => 'application/json',
66
79
  }
67
- @target_head = target_repository_user(@configure['type'], @fetch_url, @git_name)
80
+ @target_head = target_repository_user(@configure['type'], @fetch_url, @github_account)
81
+ @pull_request_body = @configure['pull_request_body']
82
+ @pull_request_base = @configure['pull_request_base']
68
83
  @body = MultiJson.dump({
69
84
  title: "Bundle update #{@readable_time}",
70
- body: ':hamster::hamster::hamster:',
85
+ body: @pull_request_body,
71
86
  head: "#{@target_head}:feature/bundle-#{@readable_time}",
72
- base: 'master',
87
+ base: @pull_request_base,
73
88
  })
74
89
  end
75
90
 
76
91
  task :clean do
77
- rm_rf(Dir.glob(Tachikoma.repos_path.to_s))
92
+ mkdir_p(Tachikoma.repos_path)
93
+ rm_rf(Dir.glob(File.join(Tachikoma.repos_path, '*')))
78
94
  end
79
95
 
80
96
  desc 'fetch'
81
97
  task fetch: :clean do
82
- mkdir_p(Tachikoma.repos_path.to_s)
83
98
  sh "git clone #{@fetch_url} #{Tachikoma.repos_path.to_s}/#{@build_for}"
84
99
  end
85
100
 
@@ -87,9 +102,8 @@ namespace :tachikoma do
87
102
  task :bundle do
88
103
  Dir.chdir("#{Tachikoma.repos_path.to_s}/#{@build_for}") do
89
104
  Bundler.with_clean_env do
90
- sh %Q!sed -i -e 's/^ruby/#ruby/' Gemfile!
91
- sh "git config user.name #{@git_name}"
92
- sh "git config user.email #{@git_email}"
105
+ sh "git config user.name #{@commiter_name}"
106
+ sh "git config user.email #{@commiter_email}"
93
107
  sh "git checkout -b feature/bundle-#{@readable_time} #{@base_remote_branch}"
94
108
  sh 'bundle --gemfile Gemfile --no-deployment --without nothing'
95
109
  sh 'bundle update'
@@ -0,0 +1,19 @@
1
+ # This file was generated by the `rspec --init` command. Conventionally, all
2
+ # specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
3
+ # Require this file using `require "spec_helper"` to ensure that it is only
4
+ # loaded once.
5
+ #
6
+ # See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
7
+ RSpec.configure do |config|
8
+ config.treat_symbols_as_metadata_keys_with_true_values = true
9
+ config.run_all_when_everything_filtered = true
10
+ config.filter_run :focus
11
+
12
+ # Run specs in random order to surface order dependencies. If you find an
13
+ # order dependency and want to debug it, you can fix the order by providing
14
+ # the seed, which is printed after each run.
15
+ # --seed 1234
16
+ config.order = 'random'
17
+ end
18
+
19
+ require 'rspec/autorun'
@@ -0,0 +1,16 @@
1
+ require 'tachikoma/settings'
2
+ describe Tachikoma do
3
+ describe '.root_path' do
4
+ let(:somewhere) { '/path/to/somewhere' }
5
+ let(:datapath) { somewhere + '/data'}
6
+ let(:repospath) { somewhere + '/repos'}
7
+
8
+ before :each do
9
+ Dir.stub(:pwd).and_return(somewhere)
10
+ end
11
+
12
+ it { expect(described_class.root_path).to eq Pathname.new(somewhere) }
13
+ it { expect(described_class.data_path).to eq Pathname.new(datapath) }
14
+ it { expect(described_class.repos_path).to eq Pathname.new(repospath) }
15
+ end
16
+ end
data/tachikoma.gemspec CHANGED
@@ -25,4 +25,5 @@ Gem::Specification.new do |spec|
25
25
 
26
26
  spec.add_development_dependency "bundler", "~> 1.3"
27
27
  spec.add_development_dependency 'dotenv'
28
+ spec.add_development_dependency 'rspec', '>= 2.14.0.rc'
28
29
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tachikoma
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.0.0
4
+ version: 3.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - sanemat
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-07-02 00:00:00.000000000 Z
11
+ date: 2013-07-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: httparty
@@ -94,6 +94,20 @@ dependencies:
94
94
  - - '>='
95
95
  - !ruby/object:Gem::Version
96
96
  version: '0'
97
+ - !ruby/object:Gem::Dependency
98
+ name: rspec
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - '>='
102
+ - !ruby/object:Gem::Version
103
+ version: 2.14.0.rc
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - '>='
109
+ - !ruby/object:Gem::Version
110
+ version: 2.14.0.rc
97
111
  description: Interval pull requester with bundle update.
98
112
  email:
99
113
  - o.gata.ken@gmail.com
@@ -104,17 +118,22 @@ extra_rdoc_files: []
104
118
  files:
105
119
  - .env.example
106
120
  - .gitignore
121
+ - .rspec
122
+ - .travis.yml
107
123
  - Gemfile
108
124
  - LICENSE.txt
109
125
  - NOTE.txt
110
126
  - README.md
111
127
  - Rakefile
112
128
  - bin/tachikoma
129
+ - data/default.yaml
113
130
  - lib/tachikoma.rb
114
131
  - lib/tachikoma/settings.rb
115
132
  - lib/tachikoma/tasks.rb
116
133
  - lib/tachikoma/version.rb
117
134
  - lib/tasks/app.rake
135
+ - spec/spec_helper.rb
136
+ - spec/tachikoma/settings_spec.rb
118
137
  - tachikoma.gemspec
119
138
  homepage: https://github.com/sanemat/tachikoma
120
139
  licenses:
@@ -136,8 +155,10 @@ required_rubygems_version: !ruby/object:Gem::Requirement
136
155
  version: '0'
137
156
  requirements: []
138
157
  rubyforge_project:
139
- rubygems_version: 2.0.2
158
+ rubygems_version: 2.0.3
140
159
  signing_key:
141
160
  specification_version: 4
142
161
  summary: Update gem frequently gets less pain. Let's doing bundle update as a habit!
143
- test_files: []
162
+ test_files:
163
+ - spec/spec_helper.rb
164
+ - spec/tachikoma/settings_spec.rb