rubygems-isitrubinius 1.0

Sign up to get free protection for your applications and to get access to all the features.
data/.autotest ADDED
@@ -0,0 +1,23 @@
1
+ # -*- ruby -*-
2
+
3
+ require 'autotest/restart'
4
+
5
+ # Autotest.add_hook :initialize do |at|
6
+ # at.extra_files << "../some/external/dependency.rb"
7
+ #
8
+ # at.libs << ":../some/external"
9
+ #
10
+ # at.add_exception 'vendor'
11
+ #
12
+ # at.add_mapping(/dependency.rb/) do |f, _|
13
+ # at.files_matching(/test_.*rb$/)
14
+ # end
15
+ #
16
+ # %w(TestA TestB).each do |klass|
17
+ # at.extra_class_map[klass] = "test/test_misc.rb"
18
+ # end
19
+ # end
20
+
21
+ # Autotest.add_hook :run_command do |at|
22
+ # system "rake build"
23
+ # end
data/History.txt ADDED
@@ -0,0 +1,5 @@
1
+ === 1.0.0 / 2011-04-19
2
+
3
+ * 1 major enhancement
4
+ * Birthday!
5
+
data/Manifest.txt ADDED
@@ -0,0 +1,8 @@
1
+ .autotest
2
+ History.txt
3
+ Manifest.txt
4
+ README.txt
5
+ Rakefile
6
+ lib/isitrubinius.rb
7
+ lib/rubygems/commands/isitrubinius_command.rb
8
+ lib/rubygems_plugin.rb
data/README.txt ADDED
@@ -0,0 +1,54 @@
1
+ = rubygems-isitrubinius
2
+
3
+ * http://isitrubinius.com
4
+ * http://seattlerb.rubyforge.org/rubygems-isitrubinius
5
+
6
+ == DESCRIPTION:
7
+
8
+ Lets you figure out if your gems and gems you install might work on Rubinius. Uses
9
+ http://isitrubinius.com as its datastore. Be sure to update the website with
10
+ your experiences!
11
+
12
+ == FEATURES/PROBLEMS:
13
+
14
+ * gem isitrubinius for checking your installed gems
15
+ * gem install plugin that tells you if your installed gem works on Rubinius
16
+
17
+ == SYNOPSIS:
18
+
19
+ $ gem install ZenTest
20
+
21
+ ZenTest 4.1.4 might work, 100% say 4.1.3 works on Rubinius
22
+ Update http://isitrubinius.com/rubygems/ZenTest with your experiences!
23
+
24
+ Successfully installed ZenTest-4.1.4
25
+ 1 gem installed
26
+
27
+ == INSTALL:
28
+
29
+ * sudo gem install rubygems-isitrubinius
30
+
31
+ == LICENSE:
32
+
33
+ (The MIT License)
34
+
35
+ Copyright (c) 2009-2011 Eric Hodel
36
+
37
+ Permission is hereby granted, free of charge, to any person obtaining
38
+ a copy of this software and associated documentation files (the
39
+ 'Software'), to deal in the Software without restriction, including
40
+ without limitation the rights to use, copy, modify, merge, publish,
41
+ distribute, sublicense, and/or sell copies of the Software, and to
42
+ permit persons to whom the Software is furnished to do so, subject to
43
+ the following conditions:
44
+
45
+ The above copyright notice and this permission notice shall be
46
+ included in all copies or substantial portions of the Software.
47
+
48
+ THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
49
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
50
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
51
+ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
52
+ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
53
+ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
54
+ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/Rakefile ADDED
@@ -0,0 +1,16 @@
1
+ # -*- ruby -*-
2
+
3
+ require 'rubygems'
4
+ require 'hoe'
5
+
6
+ Hoe.plugin :seattlerb
7
+
8
+ Hoe.spec 'rubygems-isitrubinius' do
9
+ developer 'Eric Hodel', 'drbrain@segment7.net'
10
+
11
+ self.rubyforge_name = 'seattlerb'
12
+
13
+ extra_deps << ['json', '~> 1.1']
14
+ end
15
+
16
+ # vim: syntax=Ruby
@@ -0,0 +1,98 @@
1
+ require 'rubygems'
2
+ require 'rubygems/remote_fetcher'
3
+ require 'json'
4
+
5
+ ##
6
+ # Utilities for determining if a Gem::Specification is Rubinius ready. Based
7
+ # on http://isitrubinius.com
8
+
9
+ class IsItRubinius
10
+
11
+ ##
12
+ # This version of rubygems-isitrubinius
13
+
14
+ VERSION = '1.0'
15
+
16
+ ##
17
+ # Comments for this gem
18
+
19
+ attr_reader :comments
20
+
21
+ ##
22
+ # The gemspec
23
+
24
+ attr_reader :spec
25
+
26
+ ##
27
+ # Downloads comments for +spec+ from http://isitrubinius.com
28
+
29
+ def initialize(spec)
30
+ @spec = spec
31
+
32
+ url = URI.parse "http://isitrubinius.com/api/v1/rubygems/#{@spec.name}/comments.json"
33
+
34
+ json = Gem::RemoteFetcher.fetcher.fetch_path url
35
+ comments = JSON.parse json
36
+
37
+ comments.map! do |comment|
38
+ begin
39
+ comment['comment']['version'] =
40
+ Gem::Version.new comment['comment']['version']
41
+ comment['comment']
42
+ rescue ArgumentError # bad data from isitrubinius.com
43
+ next
44
+ end
45
+ end
46
+
47
+ comments.compact!
48
+
49
+ @comments = comments.sort_by do |comment|
50
+ works = comment['working'] ? 1 : 0
51
+ [comment['version'], works, comment['name']]
52
+ end.reverse
53
+ end
54
+
55
+ ##
56
+ # Strict check for this version
57
+
58
+ def rubinius?
59
+ @comments.any? do |comment|
60
+ comment['version'] == @spec.version and comment['working']
61
+ end
62
+ end
63
+
64
+ ##
65
+ # Returns a comment from the latest version that worked with Rubinius
66
+
67
+ def maybe_rubinius?
68
+ @comments.first do |comment|
69
+ comment['working']
70
+ end
71
+ end
72
+
73
+ ##
74
+ # Returns a percentage of people saying +version+ worked for them
75
+
76
+ def percent(version = @spec.version)
77
+ matching = @comments.select do |comment|
78
+ comment['version'] == version
79
+ end
80
+
81
+ works = matching.select do |comment| comment['working'] end.length
82
+
83
+ percent = (works / matching.length.to_f * 100)
84
+ percent = 0 if percent.nan?
85
+ percent = 100 if percent > 100
86
+
87
+ "%2.0f%%" % percent
88
+ end
89
+
90
+ ##
91
+ # URL of this gem on http://isitrubinius.com
92
+
93
+ def url
94
+ "http://isitrubinius.com/rubygems/#{spec.name}"
95
+ end
96
+
97
+ end
98
+
@@ -0,0 +1,74 @@
1
+ require 'rubygems/command'
2
+ require 'rubygems/version_option'
3
+ require 'rubygems/text'
4
+ require 'isitrubinius'
5
+
6
+ ##
7
+ # gem command for querying the Rubinius status of installed gems
8
+
9
+ class Gem::Commands::IsitrubiniusCommand < Gem::Command
10
+
11
+ include Gem::VersionOption
12
+ include Gem::Text
13
+
14
+ def initialize
15
+ super 'isitrubinius', 'Check isitrubinius.com for Rubinius compatibility',
16
+ :version => Gem::Requirement.default
17
+
18
+ add_version_option
19
+ end
20
+
21
+ def arguments # :nodoc:
22
+ 'GEMNAME name of an installed gem to check for Rubinius compatibility'
23
+ end
24
+
25
+ def defaults_str # :nodoc:
26
+ "--version='>= 0'"
27
+ end
28
+
29
+ def usage # :nodoc:
30
+ "#{program_name} GEMNAME [options]"
31
+ end
32
+
33
+ def execute
34
+ name = get_one_gem_name
35
+
36
+ dep = Gem::Dependency.new name, options[:version]
37
+ specs = Gem.source_index.search dep
38
+
39
+ if specs.empty? then
40
+ alert_error "No installed gem #{dep}"
41
+ terminate_interaction 1
42
+ end
43
+
44
+ spec = specs.last
45
+
46
+ isitrubinius = IsItRubinius.new spec
47
+
48
+ comments = isitrubinius.comments
49
+
50
+ say "#{spec.name} #{spec.version}: #{isitrubinius.url}"
51
+
52
+ say ' No reports!' if comments.empty?
53
+
54
+ last_seen_version = nil
55
+
56
+ comments.each_with_index do |comment, i|
57
+ break if i > 0 and comment['version'] != last_seen_version
58
+
59
+ works = comment['working'] ? 'works' : 'fails'
60
+ platform = comment['platform'].values.join ' ' if comment['platform']
61
+
62
+ msg = "#{comment['name']} says #{comment['version']} #{works}"
63
+ msg << " on #{platform}" if platform
64
+
65
+ say " #{msg}"
66
+ say format_text(comment['body'], 68, 8) unless comment['body'].empty?
67
+ say
68
+
69
+ last_seen_version = comment['version']
70
+ end
71
+ end
72
+
73
+ end
74
+
@@ -0,0 +1,40 @@
1
+ require 'rubygems/command_manager'
2
+
3
+ Gem::CommandManager.instance.register_command :isitrubinius
4
+
5
+ Gem.pre_install do |i| # installer
6
+ require 'isitrubinius'
7
+
8
+ next if i.instance_variable_defined? :@isitrubinius_ran
9
+
10
+ i.instance_variable_set :@isitrubinius_ran, true
11
+
12
+ spec = i.spec
13
+ name = "#{spec.name} #{spec.version}"
14
+
15
+ begin
16
+ isitrubinius = IsItRubinius.new i.spec
17
+ rescue Gem::RemoteFetcher::FetchError
18
+ i.say "uh-oh! unable to fetch data for #{name}, maybe it doesn't exist yet?"
19
+ i.say "http://isitrubinius.com/rubygems/#{spec.name}"
20
+ next
21
+ end
22
+
23
+ i.say
24
+
25
+ if isitrubinius.rubinius? then
26
+ i.say "#{name} is #{isitrubinius.percent} verified Rubinius"
27
+ else
28
+ comment = isitrubinius.maybe_rubinius?
29
+
30
+ if comment then
31
+ working = comment['version']
32
+ i.say "#{name} might work, #{isitrubinius.percent working} say #{working} works on Rubinius"
33
+ else
34
+ i.say "Nobody has verified #{name} works with Rubinius"
35
+ end
36
+ end
37
+
38
+ i.say "Update #{isitrubinius.url} with your experiences!"
39
+ i.say
40
+ end
metadata ADDED
@@ -0,0 +1,91 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: rubygems-isitrubinius
3
+ version: !ruby/object:Gem::Version
4
+ prerelease:
5
+ version: "1.0"
6
+ platform: ruby
7
+ authors:
8
+ - Eric Hodel
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+
13
+ date: 2011-04-19 00:00:00 -04:00
14
+ default_executable:
15
+ dependencies:
16
+ - !ruby/object:Gem::Dependency
17
+ name: json
18
+ prerelease: false
19
+ requirement: &id001 !ruby/object:Gem::Requirement
20
+ none: false
21
+ requirements:
22
+ - - ~>
23
+ - !ruby/object:Gem::Version
24
+ version: "1.1"
25
+ type: :runtime
26
+ version_requirements: *id001
27
+ - !ruby/object:Gem::Dependency
28
+ name: hoe
29
+ prerelease: false
30
+ requirement: &id002 !ruby/object:Gem::Requirement
31
+ none: false
32
+ requirements:
33
+ - - ">="
34
+ - !ruby/object:Gem::Version
35
+ version: 2.9.4
36
+ type: :development
37
+ version_requirements: *id002
38
+ description: |-
39
+ Lets you figure out if your gems and gems you install might work on Rubinius. Uses
40
+ http://isitrubinius.com as its datastore. Be sure to update the website with
41
+ your experiences!
42
+ email:
43
+ - drbrain@segment7.net
44
+ executables: []
45
+
46
+ extensions: []
47
+
48
+ extra_rdoc_files:
49
+ - History.txt
50
+ - Manifest.txt
51
+ - README.txt
52
+ files:
53
+ - .autotest
54
+ - History.txt
55
+ - Manifest.txt
56
+ - README.txt
57
+ - Rakefile
58
+ - lib/isitrubinius.rb
59
+ - lib/rubygems/commands/isitrubinius_command.rb
60
+ - lib/rubygems_plugin.rb
61
+ has_rdoc: true
62
+ homepage: http://isitrubinius.com
63
+ licenses: []
64
+
65
+ post_install_message:
66
+ rdoc_options:
67
+ - --main
68
+ - README.txt
69
+ require_paths:
70
+ - lib
71
+ required_ruby_version: !ruby/object:Gem::Requirement
72
+ none: false
73
+ requirements:
74
+ - - ">="
75
+ - !ruby/object:Gem::Version
76
+ version: "0"
77
+ required_rubygems_version: !ruby/object:Gem::Requirement
78
+ none: false
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: "0"
83
+ requirements: []
84
+
85
+ rubyforge_project: seattlerb
86
+ rubygems_version: 1.5.2
87
+ signing_key:
88
+ specification_version: 3
89
+ summary: Lets you figure out if your gems and gems you install might work on Rubinius
90
+ test_files: []
91
+