verdi 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 542c2c0224984aa7fc37079d17ed02471b1fe7c6
4
+ data.tar.gz: bc2640fddbdbfdc808cd3e4774cc01d0e34993be
5
+ SHA512:
6
+ metadata.gz: e2dc3cc509a29635926b6200df796e3fbcc02d6ffc764dd4a9b220dafd617dc56639159bee281938ccb3273e1f816138d3dcb6ee0f45a33b34f8d7f4d2f0a02a
7
+ data.tar.gz: fe3a70e16e7e7ae25f94481fc6427985ce7efb053a37ee83a85c83ceedf2cc6b31b2e4ce085c2f53250c45ab55df6f9448fc08b222324400be9452d125c6f3db
@@ -0,0 +1,15 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
10
+ /vendor/
11
+ *.bundle
12
+ *.so
13
+ *.o
14
+ *.a
15
+ mkmf.log
@@ -0,0 +1,8 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.0.0
4
+ - 1.9.3
5
+ - jruby-18mode # JRuby in 1.8 mode
6
+ - jruby-19mode # JRuby in 1.9 mode
7
+ - rbx-2.1.1
8
+ - 1.8.7
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in verdi.gemspec
4
+ gemspec
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2014 Hrvoje Šimić
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.
@@ -0,0 +1,38 @@
1
+ # Verdi
2
+
3
+ ![](http://uploads5.wikiart.org/images/giovanni-boldini/portrait-of-guiseppe-verdi-1813-1901.jpg!Blog.jpg)
4
+
5
+ Gives you a diff between two versions of gems.
6
+
7
+ ## Installation
8
+
9
+ Add this line to your application's Gemfile:
10
+
11
+ ```ruby
12
+ gem 'verdi'
13
+ ```
14
+
15
+ And then execute:
16
+
17
+ $ bundle
18
+
19
+ Or install it yourself as:
20
+
21
+ $ gem install verdi
22
+
23
+ ## Usage
24
+
25
+ $ verdi minitest 5.4.0 5.3.5
26
+
27
+ ## Requirements
28
+
29
+ * git
30
+ * rubygems
31
+
32
+ ## Contributing
33
+
34
+ 1. Fork it ( https://github.com/shime/verdi/fork )
35
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
36
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
37
+ 4. Push to the branch (`git push origin my-new-feature`)
38
+ 5. Create a new Pull Request
@@ -0,0 +1,7 @@
1
+ require 'rake/testtask'
2
+
3
+ Rake::TestTask.new do |t|
4
+ t.pattern = "test/*_test.rb"
5
+ end
6
+
7
+ task :default => :test
@@ -0,0 +1,13 @@
1
+ #! /usr/bin/env ruby
2
+
3
+ require 'verdi'
4
+
5
+ def help_required?
6
+ ['--help', '-h'].include? ARGV[0]
7
+ end
8
+
9
+ if ARGV.length < 1 || help_required?
10
+ puts Verdi.usage
11
+ else
12
+ Verdi::Runner.new(ARGV).execute
13
+ end
@@ -0,0 +1,19 @@
1
+ require "verdi/version"
2
+ require "verdi/runner"
3
+
4
+ module Verdi
5
+ class GemNotFound < StandardError; end
6
+
7
+ def self.usage
8
+ <<-FIN.gsub /^( ){6}/, ""
9
+ USAGE: verdi gem_name [version_x] [version_y]
10
+
11
+ Outputs the diff between the provided gem versions.
12
+
13
+ OPTIONS:
14
+
15
+ -h, --help You're looking at it.
16
+
17
+ FIN
18
+ end
19
+ end
@@ -0,0 +1,52 @@
1
+ require 'rubygems'
2
+ require 'rubygems/package'
3
+
4
+ module Verdi
5
+ class Runner
6
+ def initialize(command)
7
+ @gem_name, *@versions = command
8
+ @platform = Gem.platforms.last
9
+
10
+ @versions ||= [Gem.requirement.default]
11
+ @names_and_versions = @versions.map {|version| "#{@gem_name}-#{version}"}
12
+ end
13
+
14
+ def execute
15
+ package_paths = @names_and_versions.map do |name_with_version|
16
+ path = fetch name_with_version
17
+ extract path, name_with_version
18
+ path
19
+ end
20
+
21
+ command = "git diff --color-words --no-index "+
22
+ "#{@names_and_versions.reverse.join(" ")}"
23
+ system(command)
24
+ FileUtils.rm_rf(package_paths + @names_and_versions)
25
+ end
26
+
27
+ def fetch(name_with_version)
28
+ dep = Gem::Dependency.new *name_with_version.split("-")
29
+
30
+ specs_and_sources, errors =
31
+ Gem::SpecFetcher.fetcher.spec_for_dependency dep
32
+
33
+ if @platform then
34
+ filtered = specs_and_sources.select { |s,| s.platform == @platform }
35
+ specs_and_sources = filtered unless filtered.empty?
36
+ end
37
+
38
+ spec, source = specs_and_sources.max_by { |s,| s.version }
39
+
40
+ if spec.nil? then
41
+ raise GemNotFound
42
+ end
43
+
44
+ source.download spec
45
+ end
46
+
47
+ def extract(path, name_with_version)
48
+ package = Gem::Package.new(path)
49
+ package.extract_files name_with_version
50
+ end
51
+ end
52
+ end
@@ -0,0 +1,3 @@
1
+ module Verdi
2
+ VERSION = "0.1.0"
3
+ end
@@ -0,0 +1,23 @@
1
+ require 'minitest/autorun'
2
+
3
+ require './test/helper'
4
+
5
+ describe 'CLI' do
6
+ describe 'when no arguments are provided' do
7
+ it 'outputs usage' do
8
+ `./bin/verdi`.must_equal Verdi.usage
9
+ end
10
+ end
11
+
12
+ describe 'when --help is the only argument' do
13
+ it 'outputs usage' do
14
+ `./bin/verdi --help`.must_equal Verdi.usage
15
+ end
16
+ end
17
+
18
+ describe 'when -h is the only argument' do
19
+ it 'outputs usage' do
20
+ `./bin/verdi -h`.must_equal Verdi.usage
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,4 @@
1
+ require "minitest/reporters"
2
+ Minitest::Reporters.use! Minitest::Reporters::SpecReporter.new
3
+
4
+ require 'pry'
@@ -0,0 +1,13 @@
1
+ require 'minitest/autorun'
2
+ require 'verdi'
3
+
4
+ require './test/helper'
5
+
6
+ describe 'Verdi::Runner' do
7
+ describe 'fetch' do
8
+ it 'saves the package to disk' do
9
+ runner = Verdi::Runner.new(['minitest'])
10
+ File.basename(runner.fetch('4.0')).must_equal('minitest-4.0.0.gem')
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,25 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'verdi/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "verdi"
8
+ spec.version = Verdi::VERSION
9
+ spec.authors = ["Hrvoje Šimić"]
10
+ spec.email = ["shime.ferovac@gmail.com"]
11
+ spec.summary = %q{Gives you a diff between two versions of gems.}
12
+ spec.description = %q{Gives you a diff between two versions of gems.}
13
+ spec.homepage = "https://github.com/shime/verdi"
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files -z`.split("\x0")
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_development_dependency "bundler", "~> 1.6"
22
+ spec.add_development_dependency "minitest"
23
+ spec.add_development_dependency "minitest-reporters"
24
+ spec.add_development_dependency "pry"
25
+ end
metadata ADDED
@@ -0,0 +1,118 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: verdi
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Hrvoje Šimić
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-08-11 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.6'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.6'
27
+ - !ruby/object:Gem::Dependency
28
+ name: minitest
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
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: minitest-reporters
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
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: pry
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
+ description: Gives you a diff between two versions of gems.
70
+ email:
71
+ - shime.ferovac@gmail.com
72
+ executables:
73
+ - verdi
74
+ extensions: []
75
+ extra_rdoc_files: []
76
+ files:
77
+ - ".gitignore"
78
+ - ".travis.yml"
79
+ - Gemfile
80
+ - LICENSE.txt
81
+ - README.md
82
+ - Rakefile
83
+ - bin/verdi
84
+ - lib/verdi.rb
85
+ - lib/verdi/runner.rb
86
+ - lib/verdi/version.rb
87
+ - test/basic_test.rb
88
+ - test/helper.rb
89
+ - test/runner_test.rb
90
+ - verdi.gemspec
91
+ homepage: https://github.com/shime/verdi
92
+ licenses:
93
+ - MIT
94
+ metadata: {}
95
+ post_install_message:
96
+ rdoc_options: []
97
+ require_paths:
98
+ - lib
99
+ required_ruby_version: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - ">="
102
+ - !ruby/object:Gem::Version
103
+ version: '0'
104
+ required_rubygems_version: !ruby/object:Gem::Requirement
105
+ requirements:
106
+ - - ">="
107
+ - !ruby/object:Gem::Version
108
+ version: '0'
109
+ requirements: []
110
+ rubyforge_project:
111
+ rubygems_version: 2.2.2
112
+ signing_key:
113
+ specification_version: 4
114
+ summary: Gives you a diff between two versions of gems.
115
+ test_files:
116
+ - test/basic_test.rb
117
+ - test/helper.rb
118
+ - test/runner_test.rb