ruby_patches_merger 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,15 @@
1
+ ---
2
+ !binary "U0hBMQ==":
3
+ metadata.gz: !binary |-
4
+ MWVlZDNmMThiNWI2NmZiYjM4ZTE5ZTcxNWZmZjRjZGU0MjIyODM2YQ==
5
+ data.tar.gz: !binary |-
6
+ MTU1MmE5YWE4NGNjYTk5M2VlZGE5YjQzN2JlMjcwYzI5YmUyMzlmNw==
7
+ SHA512:
8
+ metadata.gz: !binary |-
9
+ ZDRiMmQ5Yzk3NWUyMTMzODdjNzkyOTI1NzhjYTYyNjQ2M2IyMTkxMzllY2Zm
10
+ YzNiYTFiZjEwMGQ2NTU2ZTMxNmRjMTI3ODM5NGFkNmQyMzkxMzNiYzdmNzhl
11
+ ZDA0ODU1Nzk2YWUzMzdlOTZmNzEyOTAyZjI1NDM1MjQ2MDIwZjA=
12
+ data.tar.gz: !binary |-
13
+ YzNiYjU5NmU5ZGQ4ZjIyMGJiODMyYTQ4NjAxMzEzZTc5YmZkYmNhMGI0MjVk
14
+ NTA3Nzk2MTg2NWU0ZDkxNzUwNTc4NmNkNDg1ZjA2NGZiMjAyYmQ2NWZlYzE3
15
+ OWMwNTgxNWFkZjIxYjI2MGI0NWFhMGMzYTQ1ZDZiZjIxMjE2YmI=
data/.gitignore ADDED
@@ -0,0 +1 @@
1
+ patches/
data/LICENCE ADDED
@@ -0,0 +1,13 @@
1
+ Copyright (c) 2013 Michal Papis
2
+
3
+ Licensed under the Apache License, Version 2.0 (the "License");
4
+ you may not use this file except in compliance with the License.
5
+ You may obtain a copy of the License at
6
+
7
+ http://www.apache.org/licenses/LICENSE-2.0
8
+
9
+ Unless required by applicable law or agreed to in writing, software
10
+ distributed under the License is distributed on an "AS IS" BASIS,
11
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ See the License for the specific language governing permissions and
13
+ limitations under the License.
data/README.md ADDED
@@ -0,0 +1,19 @@
1
+ # Ruby Patches Manager
2
+
3
+ Help to manage ruby patches.
4
+
5
+ ## Installation
6
+
7
+ gem install ruby_patches_merger
8
+
9
+ ## Usage
10
+
11
+ So far only downloading patches for revisions is implemented:
12
+
13
+ ruby_patches_merger r39171,r39296,r39333,r39334
14
+
15
+ Will download patches for those revisions to `patches/`, thanks to https://bugs.ruby-lang.org/issues/7959#note-16
16
+
17
+ ## Testing
18
+
19
+ It's coming, for now run `bin/ruby_patches_merger ...`
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ lib_dir = File.expand_path("../../lib", __FILE__)
4
+ $:<<lib_dir unless $:.include?(lib_dir)
5
+
6
+ require 'ruby_patches_merger/cli'
7
+
8
+ RubyPatchesMerger::Cli.run(ARGV)
@@ -0,0 +1,23 @@
1
+ module RubyPatchesMerger
2
+ class Cli
3
+ attr_reader :args
4
+
5
+ def self.run(args)
6
+ cli = new(args)
7
+ cli.run
8
+ end
9
+
10
+ def initialize(args)
11
+ @args = args.map{|arg| arg.split(/[ ,]/)}.flatten
12
+ end
13
+
14
+ def run
15
+ if args.empty?
16
+ puts "No arguments given - try: ruby_patches_merger revision1 revision2,revision3"
17
+ else
18
+ require 'ruby_patches_merger/revisions'
19
+ RubyPatchesMerger::Revisions.new(args).save_to("patches")
20
+ end
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,72 @@
1
+ require 'nokogiri'
2
+ require 'open-uri'
3
+ require 'fileutils'
4
+
5
+ module RubyPatchesMerger
6
+ class Revisions
7
+
8
+ class Revision
9
+
10
+ class Link
11
+ # href => /cgi-bin/viewvc.cgi/trunk/common.mk?r1=41352&r2=41351&pathrev=41352
12
+ def initialize(href, base = 'http://svn.ruby-lang.org')
13
+ @href = href
14
+ @base = base
15
+ end
16
+ def name
17
+ @href.split(/trunk\/|\?/)[1].gsub("/", "_")
18
+ end
19
+ def file_url
20
+ "#{@base}#{@href}&view=patch"
21
+ end
22
+ def content
23
+ "" + open(file_url).lines.to_a.join("")
24
+ end
25
+ end
26
+
27
+ def initialize(revision, base = 'http://svn.ruby-lang.org')
28
+ @revision = revision
29
+ @revision = @revision[1..-1] if @revision.start_with?("r")
30
+ @base = base
31
+ end
32
+ def revision_url
33
+ "#{@base}/cgi-bin/viewvc.cgi?revision=#{@revision}&view=revision"
34
+ end
35
+ def content
36
+ @content ||= Nokogiri::HTML(open(revision_url))
37
+ end
38
+ def hrefs
39
+ content.css("a[title='View Diff']").map{|link| link["href"]}
40
+ end
41
+ def each_link(&block)
42
+ hrefs.each{|href| block.call(Link.new(href, @base))}
43
+ end
44
+ def to_s
45
+ @revision
46
+ end
47
+ end
48
+
49
+ def initialize(strings, base = 'http://svn.ruby-lang.org')
50
+ @strings = strings
51
+ @base = base
52
+ end
53
+ def each_revision(&block)
54
+ @strings.map{ |string| block.call(Revision.new(string, @base)) }
55
+ end
56
+
57
+ def save_to(path)
58
+ FileUtils.mkdir_p(path)
59
+ each_revision do |revision|
60
+ file_path = File.join(path,"#{revision}.patch")
61
+ puts file_path
62
+ File.open(file_path, "w+")do |f|
63
+ revision.each_link do |link|
64
+ puts "# #{link.name}"
65
+ f.write(link.content)
66
+ end
67
+ end
68
+ end
69
+ end
70
+
71
+ end
72
+ end
@@ -0,0 +1,3 @@
1
+ module RubyPatchesMerger
2
+ VERSION = '0.1.0'
3
+ end
@@ -0,0 +1,23 @@
1
+ #!/usr/bin/env ruby
2
+ # -*- encoding: utf-8 -*-
3
+
4
+ Kernel.load(File.expand_path("../lib/ruby_patches_merger/version.rb", __FILE__))
5
+
6
+ Gem::Specification.new do |s|
7
+ s.name = "ruby_patches_merger"
8
+ s.version = RubyPatchesMerger::VERSION
9
+ s.license = 'Apache 2.0'
10
+ s.authors = ["Michal Papis"]
11
+ s.email = ["mpapis@gmail.com"]
12
+ s.homepage = "https://github.com/mpapis/ruby_patches_merger"
13
+ s.summary = %q{
14
+ Help to manage ruby patches.
15
+ }
16
+
17
+ s.files = `git ls-files`.split("\n")
18
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
19
+ s.executables = %w( ruby_patches_merger )
20
+
21
+ #s.add_development_dependency "tf"
22
+ #s.add_development_dependency "smf-gem"
23
+ end
metadata ADDED
@@ -0,0 +1,53 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: ruby_patches_merger
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Michal Papis
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2013-09-15 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description:
14
+ email:
15
+ - mpapis@gmail.com
16
+ executables:
17
+ - ruby_patches_merger
18
+ extensions: []
19
+ extra_rdoc_files: []
20
+ files:
21
+ - .gitignore
22
+ - LICENCE
23
+ - README.md
24
+ - bin/ruby_patches_merger
25
+ - lib/ruby_patches_merger/cli.rb
26
+ - lib/ruby_patches_merger/revisions.rb
27
+ - lib/ruby_patches_merger/version.rb
28
+ - ruby_patches_merger.gemspec
29
+ homepage: https://github.com/mpapis/ruby_patches_merger
30
+ licenses:
31
+ - Apache 2.0
32
+ metadata: {}
33
+ post_install_message:
34
+ rdoc_options: []
35
+ require_paths:
36
+ - lib
37
+ required_ruby_version: !ruby/object:Gem::Requirement
38
+ requirements:
39
+ - - ! '>='
40
+ - !ruby/object:Gem::Version
41
+ version: '0'
42
+ required_rubygems_version: !ruby/object:Gem::Requirement
43
+ requirements:
44
+ - - ! '>='
45
+ - !ruby/object:Gem::Version
46
+ version: '0'
47
+ requirements: []
48
+ rubyforge_project:
49
+ rubygems_version: 2.1.3
50
+ signing_key:
51
+ specification_version: 4
52
+ summary: Help to manage ruby patches.
53
+ test_files: []