gemfile19 1.0.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.
Files changed (4) hide show
  1. data/README.md +43 -0
  2. data/bin/gemfile19 +7 -0
  3. data/lib/gemfile19.rb +111 -0
  4. metadata +71 -0
data/README.md ADDED
@@ -0,0 +1,43 @@
1
+ What is gemfile19
2
+ =================
3
+
4
+ gemfile19 is simple command line tool for figuring out whether your gems are Ruby 1.9 compatible using [isitruby19.com](http://isitruby19.com/).
5
+
6
+ # Installation
7
+
8
+ $ gem install gemfile19
9
+
10
+ # Usage
11
+
12
+ $ gemfile19
13
+
14
+ # Meta
15
+
16
+ * Author : Mitko Kostov
17
+ * Mail : mitko.kostov@gmail.com
18
+ * Blog : [http://fireinside.me](http://fireinside.me/)
19
+ * Twitter : [mytrile](https://twitter.com/mytrile)
20
+ * Company : [eMerchantPay](http://emerchantpay.com/)
21
+
22
+ # License
23
+
24
+ Copyright (c) 2011 Mitko Kostov
25
+
26
+ Permission is hereby granted, free of charge, to any person obtaining
27
+ a copy of this software and associated documentation files (the
28
+ "Software"), to deal in the Software without restriction, including
29
+ without limitation the rights to use, copy, modify, merge, publish,
30
+ distribute, sublicense, and/or sell copies of the Software, and to
31
+ permit persons to whom the Software is furnished to do so, subject to
32
+ the following conditions:
33
+
34
+ The above copyright notice and this permission notice shall be
35
+ included in all copies or substantial portions of the Software.
36
+
37
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
38
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
39
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
40
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
41
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
42
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
43
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/bin/gemfile19 ADDED
@@ -0,0 +1,7 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ $:.unshift File.expand_path("../../lib", __FILE__)
4
+
5
+ require 'gemfile19'
6
+
7
+ Gemfile19.run
data/lib/gemfile19.rb ADDED
@@ -0,0 +1,111 @@
1
+ require 'json'
2
+ require 'open-uri'
3
+ require 'term/ansicolor'
4
+
5
+ class String
6
+ include Term::ANSIColor
7
+ end
8
+
9
+
10
+ module Gemfile19
11
+ extend self
12
+
13
+ ISIT19_URL = "http://isitruby19.com"
14
+ ISIT19_FILE = "comments.json"
15
+ VERSION_REGEXP = /^[>=~]*\s*(\d.+)$/
16
+ GEMNAME_REGEXP = /^gem\s*["|'](.*.?)["|']s*/
17
+
18
+ def run
19
+ begin
20
+ open_and_parse_gemfile
21
+ parse_gem_comments
22
+ create_and_print_report
23
+ rescue Errno::ENOENT
24
+ puts 'Missing Gemfile. Please run gemfil19 in your Ruby/Rails project root dir'
25
+ end
26
+ end
27
+
28
+ def open_and_parse_gemfile
29
+ @gems_to_check = []
30
+ gemfile ||= File.read('Gemfile').split(/\n/)
31
+ gemfile.each do |line|
32
+ line = line.split(",")
33
+ name, version = line[0], line[1]
34
+ @gems_to_check << $1 if (name && name.strip.match(GEMNAME_REGEXP))
35
+ end
36
+ end
37
+
38
+ def parse_gem_comments
39
+ @tested_gems = []
40
+ @untested_gems = []
41
+ @missing_gems = []
42
+ @will_work = []
43
+ @may_work = []
44
+ @will_fail = []
45
+
46
+ @gems_to_check.each do |gem_name|
47
+ url = "#{ISIT19_URL}/#{gem_name}/#{ISIT19_FILE}"
48
+ begin
49
+ json_data = open(url).read
50
+ rescue
51
+ @missing_gems << gem_name
52
+ next
53
+ end
54
+
55
+ gem_comments = JSON.parse(json_data)
56
+ if gem_comments.size == 0
57
+ @untested_gems << gem_name
58
+ else
59
+ sum = 0
60
+ gem_comments.each do |c|
61
+ sum += 1 if c["comment"]["works_for_me"]
62
+ end
63
+ calculate_compatability_ratio(sum, gem_comments.size, gem_name)
64
+ end
65
+ end
66
+ end
67
+
68
+ def create_and_print_report
69
+ puts ""
70
+ puts "Gemfile19 v0.1.0".negative
71
+ puts "================"
72
+ puts ""
73
+ puts "Gems that will work - #{@will_work.size}".green
74
+ puts "------------------------".green
75
+ puts ""
76
+ puts @will_work
77
+ puts ""
78
+ puts "Gems that may work - #{@may_work.size}".yellow
79
+ puts "-----------------------".yellow
80
+ puts ""
81
+ puts @may_work
82
+ puts ""
83
+ puts "Gems that will fail - #{@will_fail.size}".red
84
+ puts "-----------------------".red
85
+ puts ""
86
+ puts @will_fail
87
+ puts ""
88
+ puts "Untested gems - #{@will_fail.size}"
89
+ puts "-----------------"
90
+ puts ""
91
+ puts @untested_gems
92
+ puts ""
93
+ puts "Missing gems - #{@missing_gems.size}"
94
+ puts "-----------------"
95
+ puts ""
96
+ puts @missing_gems
97
+ puts ""
98
+ end
99
+
100
+ def calculate_compatability_ratio(works_for_me, count, name)
101
+ rate = works_for_me/count.to_f
102
+ if rate > 0.80
103
+ @will_work << name #{:name => name, :rate => rate }
104
+ elsif rate >= 0.40
105
+ @may_work << name #{ :name => name, :rate => rate }
106
+ else
107
+ @will_fail << name #{ :name => name, :rate => rate }
108
+ end
109
+ end
110
+
111
+ end
metadata ADDED
@@ -0,0 +1,71 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: gemfile19
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Mitko Kostov
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2012-01-08 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: json
16
+ requirement: &70364010025440 !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ~>
20
+ - !ruby/object:Gem::Version
21
+ version: 1.6.1
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: *70364010025440
25
+ - !ruby/object:Gem::Dependency
26
+ name: term-ansicolor
27
+ requirement: &70364010024960 !ruby/object:Gem::Requirement
28
+ none: false
29
+ requirements:
30
+ - - ~>
31
+ - !ruby/object:Gem::Version
32
+ version: 1.0.7
33
+ type: :runtime
34
+ prerelease: false
35
+ version_requirements: *70364010024960
36
+ description: ! 'Simple command line tool for '
37
+ email:
38
+ - mitko.kostov@gmail.com
39
+ executables:
40
+ - gemfile19
41
+ extensions: []
42
+ extra_rdoc_files: []
43
+ files:
44
+ - README.md
45
+ - lib/gemfile19.rb
46
+ - bin/gemfile19
47
+ homepage: https://github.com/mytrile/gemfile19
48
+ licenses: []
49
+ post_install_message:
50
+ rdoc_options: []
51
+ require_paths:
52
+ - lib
53
+ required_ruby_version: !ruby/object:Gem::Requirement
54
+ none: false
55
+ requirements:
56
+ - - ! '>='
57
+ - !ruby/object:Gem::Version
58
+ version: '0'
59
+ required_rubygems_version: !ruby/object:Gem::Requirement
60
+ none: false
61
+ requirements:
62
+ - - ! '>='
63
+ - !ruby/object:Gem::Version
64
+ version: '0'
65
+ requirements: []
66
+ rubyforge_project:
67
+ rubygems_version: 1.8.10
68
+ signing_key:
69
+ specification_version: 3
70
+ summary: Simple command line tool for
71
+ test_files: []