penseur 0.0.2

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: 0f749c0c386a9ab417eb5f610d40ba192d98b810
4
+ data.tar.gz: 3ca446da7794315cc7076206697fa9d54792f507
5
+ SHA512:
6
+ metadata.gz: 36e5e8b2586136bbe7857f4aab6da2068caa70af2b88744fe5e9ce0e8d20538125f0dce9b541204c92978fdd31887e7c1859495a7357cfef209c4423307b6919
7
+ data.tar.gz: 6ff00f23f4dace35677e76becf1c5830817f08690d184c9fa67d53f49f325ec05c0a45a4e9d95c062a41113578b6126f406b1bd8b8d0771e972c560d89d1668e
@@ -0,0 +1,14 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
10
+ *.bundle
11
+ *.so
12
+ *.o
13
+ *.a
14
+ mkmf.log
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in penseur.gemspec
4
+ gemspec
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2015 Jordi Polo
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,31 @@
1
+ # Penseur
2
+
3
+ TODO: Write a gem description
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ ```ruby
10
+ gem 'penseur'
11
+ ```
12
+
13
+ And then execute:
14
+
15
+ $ bundle
16
+
17
+ Or install it yourself as:
18
+
19
+ $ gem install penseur
20
+
21
+ ## Usage
22
+
23
+ TODO: Write usage instructions here
24
+
25
+ ## Contributing
26
+
27
+ 1. Fork it ( https://github.com/[my-github-username]/penseur/fork )
28
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
29
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
30
+ 4. Push to the branch (`git push origin my-new-feature`)
31
+ 5. Create a new Pull Request
@@ -0,0 +1,2 @@
1
+ require "bundler/gem_tasks"
2
+
@@ -0,0 +1,97 @@
1
+ #!/usr/bin/env ruby
2
+ $:.unshift(File.dirname(__FILE__) + '/../lib') unless $:.include?(File.dirname(__FILE__) + '/../lib')
3
+
4
+ begin
5
+ require 'bundler'
6
+ require 'bundler/cli'
7
+ require 'bundler/vendored_thor'
8
+ rescue LoadError
9
+ raise "Your version of bundler does not support Le penseur's good works. Please ugrade your bundler to >= 1.2"
10
+ end
11
+ require 'penseur'
12
+ require 'byebug'
13
+
14
+ def read_gemfile_lock(project)
15
+ file = File.join(project, "Gemfile.lock")
16
+ if !File.exist?(file)
17
+ raise "Project at #{project} does not have a gemfile.lock file"
18
+ end
19
+ Bundler::LockfileParser.new(File.read(file))
20
+ end
21
+
22
+ def our_specs(lockfile)
23
+ lockfile.specs.select{|spec| lockfile.dependencies.any?{|dependency| dependency.name == spec.name}}
24
+ end
25
+
26
+ def compare_lock(project_src, project_dest)
27
+ updated_gems = {}
28
+ old_lockfile = read_gemfile_lock(project_src)
29
+ new_lockfile = read_gemfile_lock(project_dest)
30
+ old_list = our_specs(old_lockfile)
31
+ new_list = our_specs(new_lockfile)
32
+ old_list.each do |old_spec|
33
+ new_list.each do |new_spec|
34
+ # skip stuff we have in the gemfile.lock but not in the gemfile
35
+ if old_spec.name == new_spec.name
36
+ if old_spec.version != new_spec.version
37
+ updated_gems[old_spec.name] = {
38
+ gem_name: old_spec.name,
39
+ old_rev: old_spec.version,
40
+ new_rev: new_spec.version,
41
+ old_project: project_src,
42
+ new_project: project_dest
43
+ }
44
+ end
45
+ end
46
+ end
47
+ end
48
+ updated_gems
49
+ end
50
+
51
+ def print_conclusions(project_name, changes)
52
+ if changes.empty?
53
+ puts "No changes needed for #{project_name}"
54
+ else
55
+ puts
56
+ puts
57
+ puts "Changes needed for #{project_name}:"
58
+ changes.each do |change|
59
+ small_version = [change[:old_rev], change[:new_rev]].min
60
+ big_version = [change[:old_rev], change[:new_rev]].max
61
+ puts "#{change[:gem_name]}:"
62
+ puts " Update #{change[:gem_name]} from #{small_version} to #{big_version} "
63
+ # puts " "
64
+ end
65
+ end
66
+
67
+ end
68
+
69
+ module Penseur
70
+ class CLI < Thor
71
+ check_unknown_options!
72
+
73
+ default_task :compare
74
+
75
+ desc 'compare PROJECT1 PROJECT2', 'compare two projects gems'
76
+ def compare(project_src, project_dest)
77
+ changed_gems = compare_lock(project_src, project_dest)
78
+ old_bigger = changed_gems.values.select{|change| change[:old_rev] > change[:new_rev]}
79
+ new_bigger = changed_gems.values.select{|change| change[:old_rev] < change[:new_rev]}
80
+ print_conclusions(project_src, old_bigger)
81
+ print_conclusions(project_dest, new_bigger)
82
+
83
+ changed_gems.values.each do |raw_change|
84
+ end
85
+
86
+
87
+ end
88
+
89
+ map '--version' => :version
90
+ desc 'version', 'Prints the current version'
91
+ def version
92
+ puts "Powered by thinkers at level #{VERSION}"
93
+ end
94
+ end
95
+ end
96
+
97
+ Penseur::CLI.start
@@ -0,0 +1,5 @@
1
+ require "penseur/version"
2
+
3
+ module Penseur
4
+ # Your code goes here...
5
+ end
@@ -0,0 +1,3 @@
1
+ module Penseur
2
+ VERSION = "0.0.2"
3
+ end
@@ -0,0 +1,23 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'penseur/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "penseur"
8
+ spec.version = Penseur::VERSION
9
+ spec.authors = ["Jordi Polo"]
10
+ spec.email = ["mumismo@gmail.com"]
11
+ spec.summary = %q{A tool to compare versions between two Gemlock files}
12
+ spec.description = %q{A tool to compare versions between two Gemlock files}
13
+ spec.homepage = ""
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_dependency "bundler", "~> 1.7"
22
+ spec.add_development_dependency "byebug", "~> 3.5"
23
+ end
metadata ADDED
@@ -0,0 +1,83 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: penseur
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.2
5
+ platform: ruby
6
+ authors:
7
+ - Jordi Polo
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-01-21 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.7'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.7'
27
+ - !ruby/object:Gem::Dependency
28
+ name: byebug
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '3.5'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '3.5'
41
+ description: A tool to compare versions between two Gemlock files
42
+ email:
43
+ - mumismo@gmail.com
44
+ executables:
45
+ - penseur
46
+ extensions: []
47
+ extra_rdoc_files: []
48
+ files:
49
+ - ".gitignore"
50
+ - Gemfile
51
+ - LICENSE.txt
52
+ - README.md
53
+ - Rakefile
54
+ - bin/penseur
55
+ - lib/penseur.rb
56
+ - lib/penseur/version.rb
57
+ - penseur.gemspec
58
+ homepage: ''
59
+ licenses:
60
+ - MIT
61
+ metadata: {}
62
+ post_install_message:
63
+ rdoc_options: []
64
+ require_paths:
65
+ - lib
66
+ required_ruby_version: !ruby/object:Gem::Requirement
67
+ requirements:
68
+ - - ">="
69
+ - !ruby/object:Gem::Version
70
+ version: '0'
71
+ required_rubygems_version: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ requirements: []
77
+ rubyforge_project:
78
+ rubygems_version: 2.2.2
79
+ signing_key:
80
+ specification_version: 4
81
+ summary: A tool to compare versions between two Gemlock files
82
+ test_files: []
83
+ has_rdoc: