tachikoma_ai 0.2.0 → 0.3.0

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: cc0cd6bfa090e7f7697d74242b8c633db258ed15
4
- data.tar.gz: b0090a4694f8ea83516e5d8c51c7bd51d3587aa3
3
+ metadata.gz: 57446d98a983297938aacb973884a7c46c4ac7fc
4
+ data.tar.gz: cc41502034a9dc63de29b10c1d32e563a4cba7c9
5
5
  SHA512:
6
- metadata.gz: bd852c603703e0a452c63c36b4c9e5e97c6fbbf6a2047cc3bfa82fdb2d2004b91e120eb3ad3cf523052b0967a90c9e20d0ceca273d8dbca0e27e6dfb0e138b91
7
- data.tar.gz: f9d0bcfd9ce893b880330f15c4eb03efe5163cb086d673a878e2ab37aec7a68df6675a018611e6ea812585d397de24f8aaa5cfab3f9f5983e5f43108df88f051
6
+ metadata.gz: e359165c3aad51aa63a70ccb92facc111c2cbe0304607b8d14d5676e1fb8b9c925e5cee6d738e76d61f29c995701234a7c6091e23bce6e4e6d8c385a91e52d84
7
+ data.tar.gz: c9d70bdf10302e27795d0712f1c3e1be039a865fcf07b164284fffabfa8556142eff8247cefcb8e85c5cd3b2a1e66161cad89c41713b77fe502926ac471704af
data/CHANGELOG.md ADDED
@@ -0,0 +1,13 @@
1
+ ## master (unreleased)
2
+
3
+ - :bug: Fix crash when specify a github repository in Gemfile
4
+ - :sparkles: Support gems that have the official page
5
+ - [lib/tachikoma_ai/strategies/bundler/urls.json](https://github.com/sinsoku/tachikoma_ai/blob/master/lib/tachikoma_ai/strategies/bundler/urls.json)
6
+
7
+ ## v0.2.0
8
+
9
+ - :sparkles: Support version tag without 'v' prefix
10
+
11
+ ## v0.1.0
12
+
13
+ - Initial release :tada:
data/lib/tachikoma_ai.rb CHANGED
@@ -1,3 +1,4 @@
1
+ require 'tachikoma_ai/repository'
1
2
  require 'tachikoma_ai/strategy'
2
3
  require 'tachikoma_ai/tachikoma_extention'
3
4
  require 'tachikoma_ai/version'
@@ -0,0 +1,37 @@
1
+ require 'net/http'
2
+ require 'json'
3
+
4
+ module TachikomaAi
5
+ class Repository
6
+ attr_reader :url, :owner, :repo
7
+
8
+ def initialize(url)
9
+ @url = url.gsub(/http:/, 'https:')
10
+ @owner, @repo = URI.parse(@url).path.split('/').drop(1)
11
+ end
12
+
13
+ def compare(start, endd)
14
+ s = find_tag(start)
15
+ e = find_tag(endd)
16
+ "https://github.com/#{owner}/#{repo}/compare/#{s}...#{e}"
17
+ end
18
+
19
+ private
20
+
21
+ def api_tags_url
22
+ "https://api.github.com/repos/#{owner}/#{repo}/git/refs/tags"
23
+ end
24
+
25
+ def find_tag(tag)
26
+ tags.find { |t| t == "v#{tag}" || t == tag }
27
+ end
28
+
29
+ def tags
30
+ return @tags if @tags
31
+
32
+ res = Net::HTTP.get_response URI.parse(api_tags_url)
33
+ json = JSON.parse(res.body)
34
+ @tags = json.map { |tag| tag['ref'].gsub('refs/tags/', '') }
35
+ end
36
+ end
37
+ end
@@ -1,4 +1,4 @@
1
- require 'tachikoma_ai/bundler/gem'
1
+ require 'tachikoma_ai/strategies/bundler/gem'
2
2
 
3
3
  module TachikomaAi
4
4
  module Strategies
@@ -34,20 +34,20 @@ module TachikomaAi
34
34
 
35
35
  def minus_gems
36
36
  @minus_gems ||= diff.select { |s| s =~ /^- {4}\S/ }
37
- .map { |s| TachikomaAi::Bundler::Gem.parse(s) }
37
+ .map { |s| Gem.parse(s) }
38
38
  end
39
39
 
40
40
  def plus_gems
41
41
  @plus_gems ||= diff.select { |s| s =~ /^\+ {4}\S/ }
42
- .map { |s| TachikomaAi::Bundler::Gem.parse(s) }
42
+ .map { |s| Gem.parse(s) }
43
43
  end
44
44
 
45
45
  def compare_urls
46
- updated_gems.select(&:github?).map { |gem| gem.compare_url.gsub(/http:/, 'https:') }.join("\n")
46
+ updated_gems.select(&:github_url?).map(&:compare_url).join("\n")
47
47
  end
48
48
 
49
49
  def homepage_urls
50
- updated_gems.reject(&:github?).map(&:homepage).join("\n")
50
+ updated_gems.reject(&:github_url?).map(&:homepage).join("\n")
51
51
  end
52
52
  end
53
53
  end
@@ -0,0 +1,62 @@
1
+ require 'rubygems'
2
+ require 'json'
3
+
4
+ module TachikomaAi
5
+ module Strategies
6
+ class Bundler
7
+ class Gem
8
+ STRING_PATTERN = /[-|\+]\s+(\S+)\s\((.+?)\)/
9
+ major, minor = RUBY_VERSION.split('.')
10
+ SPECS_PATH = "vendor/bundle/ruby/#{major}.#{minor}.0/specifications/".freeze
11
+ URLS = JSON.parse(File.read(File.expand_path('urls.json', __dir__)))
12
+
13
+ attr_reader :name, :version
14
+ attr_accessor :from
15
+
16
+ def self.parse(s)
17
+ m = s.match STRING_PATTERN
18
+ new m[1], m[2]
19
+ end
20
+
21
+ def initialize(name, version)
22
+ @name = name
23
+ @version = version
24
+ end
25
+
26
+ def github_url?
27
+ !github_url.nil?
28
+ end
29
+
30
+ def github_url
31
+ if homepage.include?('github.com')
32
+ homepage
33
+ elsif URLS.key?(name)
34
+ URLS[name]
35
+ end
36
+ end
37
+
38
+ def homepage
39
+ @homepage ||= if spec
40
+ spec.homepage
41
+ else
42
+ "#{name}-#{version}"
43
+ end
44
+ end
45
+
46
+ def compare_url
47
+ Repository.new(github_url).compare(from, version)
48
+ end
49
+
50
+ private
51
+
52
+ def spec
53
+ ::Gem::Specification.load(spec_path)
54
+ end
55
+
56
+ def spec_path
57
+ "#{SPECS_PATH}/#{name}-#{version}.gemspec"
58
+ end
59
+ end
60
+ end
61
+ end
62
+ end
@@ -0,0 +1,17 @@
1
+ {
2
+ "action_args": "https://github.com/asakusarb/action_args",
3
+ "airbrake": "https://github.com/airbrake/airbrake",
4
+ "capistrano": "https://github.com/capistrano/capistrano",
5
+ "coderay": "https://github.com/rubychan/coderay",
6
+ "concurrent-ruby": "https://github.com/ruby-concurrency/concurrent-ruby",
7
+ "eventmachine": "https://github.com/eventmachine/eventmachine",
8
+ "logging": "https://github.com/TwP/logging",
9
+ "nokogiri": "https://github.com/sparklemotion/nokogiri",
10
+ "rails_best_practices": "https://github.com/railsbp/rails_best_practices",
11
+ "rack-mini-profiler": "https://github.com/MiniProfiler/rack-mini-profiler",
12
+ "sass": "https://github.com/sass/sass",
13
+ "sidekiq": "https://github.com/mperham/sidekiq",
14
+ "thin": "https://github.com/macournoyer/thin",
15
+ "unicorn": "https://github.com/defunkt/unicorn",
16
+ "uniform_notifier": "https://github.com/flyerhzm/uniform_notifier"
17
+ }
@@ -1,3 +1,3 @@
1
1
  module TachikomaAi
2
- VERSION = '0.2.0'.freeze
2
+ VERSION = '0.3.0'.freeze
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tachikoma_ai
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - sinsoku
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-07-12 00:00:00.000000000 Z
11
+ date: 2016-07-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: tachikoma
@@ -91,6 +91,7 @@ files:
91
91
  - ".rspec"
92
92
  - ".rubocop.yml"
93
93
  - ".travis.yml"
94
+ - CHANGELOG.md
94
95
  - CODE_OF_CONDUCT.md
95
96
  - Gemfile
96
97
  - LICENSE.txt
@@ -99,8 +100,10 @@ files:
99
100
  - bin/console
100
101
  - bin/setup
101
102
  - lib/tachikoma_ai.rb
102
- - lib/tachikoma_ai/bundler/gem.rb
103
+ - lib/tachikoma_ai/repository.rb
103
104
  - lib/tachikoma_ai/strategies/bundler.rb
105
+ - lib/tachikoma_ai/strategies/bundler/gem.rb
106
+ - lib/tachikoma_ai/strategies/bundler/urls.json
104
107
  - lib/tachikoma_ai/strategy.rb
105
108
  - lib/tachikoma_ai/tachikoma_extention.rb
106
109
  - lib/tachikoma_ai/version.rb
@@ -1,60 +0,0 @@
1
- require 'rubygems'
2
- require 'net/http'
3
- require 'json'
4
-
5
- module TachikomaAi
6
- module Bundler
7
- class Gem
8
- STRING_PATTERN = /[-|\+]\s+(\S+)\s\((.+?)\)/
9
- major, minor = RUBY_VERSION.split('.')
10
- SPECS_PATH = "vendor/bundle/ruby/#{major}.#{minor}.0/specifications/".freeze
11
-
12
- attr_reader :name, :version
13
- attr_accessor :from
14
-
15
- def self.parse(s)
16
- m = s.match STRING_PATTERN
17
- new m[1], m[2]
18
- end
19
-
20
- def initialize(name, version)
21
- @name = name
22
- @version = version
23
- end
24
-
25
- def github?
26
- homepage && homepage.include?('github')
27
- end
28
-
29
- def homepage
30
- @homepage ||= spec.homepage
31
- end
32
-
33
- def compare_url
34
- before_tag = tags.find { |tag| tag == "v#{from}" || tag == from }
35
- after_tag = tags.find { |tag| tag == "v#{version}" || tag == version }
36
- File.join homepage, 'compare', "#{before_tag}...#{after_tag}"
37
- end
38
-
39
- def tags
40
- return @tags if @tags
41
-
42
- owner, repo = URI.parse(homepage).path.split('/').drop(1)
43
- url = "https://api.github.com/repos/#{owner}/#{repo}/git/refs/tags"
44
- res = Net::HTTP.get_response URI.parse(url)
45
- json = JSON.parse(res.body)
46
- @tags = json.map { |tag| tag['ref'].gsub('refs/tags/', '') }
47
- end
48
-
49
- private
50
-
51
- def spec
52
- ::Gem::Specification.load(spec_path)
53
- end
54
-
55
- def spec_path
56
- "#{SPECS_PATH}/#{name}-#{version}.gemspec"
57
- end
58
- end
59
- end
60
- end