jabley-rubygems-isitjruby 1.0

Sign up to get free protection for your applications and to get access to all the features.
data/History.txt ADDED
@@ -0,0 +1,4 @@
1
+ === 0.0.1 2009-08-21
2
+
3
+ * 1 major enhancement:
4
+ * Initial release
data/Manifest.txt ADDED
@@ -0,0 +1,11 @@
1
+ History.txt
2
+ Manifest.txt
3
+ PostInstall.txt
4
+ README.rdoc
5
+ Rakefile
6
+ lib/rubygems-isitjruby.rb
7
+ script/console
8
+ script/destroy
9
+ script/generate
10
+ test/test_helper.rb
11
+ test/test_rubygems-isitjruby.rb
data/README.rdoc ADDED
@@ -0,0 +1,48 @@
1
+ = rubygems-isitjruby
2
+
3
+ * http://github.com/#{github_username}/#{project_name}
4
+
5
+ == DESCRIPTION:
6
+
7
+ FIX (describe your package)
8
+
9
+ == FEATURES/PROBLEMS:
10
+
11
+ * FIX (list of features or problems)
12
+
13
+ == SYNOPSIS:
14
+
15
+ FIX (code sample of usage)
16
+
17
+ == REQUIREMENTS:
18
+
19
+ * FIX (list of requirements)
20
+
21
+ == INSTALL:
22
+
23
+ * FIX (sudo gem install, anything else)
24
+
25
+ == LICENSE:
26
+
27
+ (The MIT License)
28
+
29
+ Copyright (c) 2009 FIXME full name
30
+
31
+ Permission is hereby granted, free of charge, to any person obtaining
32
+ a copy of this software and associated documentation files (the
33
+ 'Software'), to deal in the Software without restriction, including
34
+ without limitation the rights to use, copy, modify, merge, publish,
35
+ distribute, sublicense, and/or sell copies of the Software, and to
36
+ permit persons to whom the Software is furnished to do so, subject to
37
+ the following conditions:
38
+
39
+ The above copyright notice and this permission notice shall be
40
+ included in all copies or substantial portions of the Software.
41
+
42
+ THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
43
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
44
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
45
+ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
46
+ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
47
+ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
48
+ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/Rakefile ADDED
@@ -0,0 +1,26 @@
1
+ require 'rubygems'
2
+ gem 'hoe', '>= 2.1.0'
3
+ require 'hoe'
4
+ require 'fileutils'
5
+ require './lib/rubygems'
6
+
7
+ Hoe.plugin :newgem
8
+ # Hoe.plugin :website
9
+ # Hoe.plugin :cucumberfeatures
10
+
11
+ # Generate all the Rake tasks
12
+ # Run 'rake -T' to see list of generated tasks (from gem root directory)
13
+ $hoe = Hoe.spec 'rubygems-isitjruby' do
14
+ self.developer 'James Abley', 'james.abley@gmail.com'
15
+ self.post_install_message = 'PostInstall.txt' # TODO remove if post-install message not required
16
+ self.rubyforge_name = self.name # TODO this is default value
17
+ self.extra_deps << ['json','-> 1.1']]
18
+
19
+ end
20
+
21
+ require 'newgem/tasks'
22
+ Dir['tasks/**/*.rake'].each { |t| load t }
23
+
24
+ # TODO - want other tests/tasks run by default? Add them to the list
25
+ # remove_task :default
26
+ # task :default => [:spec, :features]
data/lib/isitjruby.rb ADDED
@@ -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 JRuby ready. Based
7
+ # on http://isitjruby.com
8
+
9
+ class IsItJRuby
10
+
11
+ ##
12
+ # This version of rubygems-isitjruby
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://isitjruby.com
28
+
29
+ def initialize(spec)
30
+ @spec = spec
31
+
32
+ url = URI.parse "http://isitjruby.com/#{@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 isitjruby.com
43
+ next
44
+ end
45
+ end
46
+
47
+ comments.compact!
48
+
49
+ @comments = comments.sort_by do |comment|
50
+ works = comment['works_for_me'] ? 1 : 0
51
+ [comment['version'], works, comment['name']]
52
+ end.reverse
53
+ end
54
+
55
+ ##
56
+ # Strict check for this version
57
+
58
+ def jruby?
59
+ @comments.any? do |comment|
60
+ comment['version'] == @spec.version and comment['works_for_me']
61
+ end
62
+ end
63
+
64
+ ##
65
+ # Returns a comment from the latest version that worked with JRuby
66
+
67
+ def maybe_jruby?
68
+ @comments.first do |comment|
69
+ comment['works_for_me']
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['works_for_me'] end.length
82
+
83
+ percent = (matching.length.to_f / works * 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://isitjruby.com
92
+
93
+ def url
94
+ "http://isitjruby.com/#{spec.name}"
95
+ end
96
+
97
+ end
98
+
@@ -0,0 +1,73 @@
1
+ require 'rubygems/command'
2
+ require 'rubygems/version_option'
3
+ require 'rubygems/text'
4
+ require 'isitjruby'
5
+
6
+ ##
7
+ # gem command for querying the jruby status of installed gems
8
+
9
+ class Gem::Commands::IsitJRubyCommand < Gem::Command
10
+
11
+ include Gem::VersionOption
12
+ include Gem::Text
13
+
14
+ def initialize
15
+ super 'isitjruby', 'Check isitjruby.com for JRuby 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 JRuby 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
+ isitjruby = IsItJRuby.new spec
47
+
48
+ comments = isitjruby.comments
49
+
50
+ say "#{spec.name} #{spec.version}: #{isitjruby.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['works_for_me'] ? '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
@@ -0,0 +1,41 @@
1
+ require 'rubygems/command_manager'
2
+
3
+ Gem::CommandManager.instance.register_command :isitjruby
4
+
5
+ Gem.pre_install do |i| # installer
6
+ require 'isitjruby'
7
+
8
+ next if i.instance_variable_defined? :@isitjruby_ran
9
+
10
+ i.instance_variable_set :@isitjruby_ran, true
11
+
12
+ spec = i.spec
13
+ name = "#{spec.name} #{spec.version}"
14
+
15
+ begin
16
+ isitjruby = IsItJRuby.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://isitjruby.com/#{spec.name}"
20
+ next
21
+ end
22
+
23
+ i.say
24
+
25
+ if isitjruby.jruby? then
26
+ i.say "#{name} is #{isitjruby.percent} verified JRuby"
27
+ else
28
+ comment = isitjruby.maybe_jruby?
29
+
30
+ if comment then
31
+ working = comment['version']
32
+ i.say "#{name} might work, #{isitjruby.percent working} say #{working} works on JRuby"
33
+ else
34
+ i.say "Nobody has verified #{name} works with JRuby"
35
+ end
36
+ end
37
+
38
+ i.say "Update #{isitjruby.url} with your experiences!"
39
+ i.say
40
+ end
41
+
metadata ADDED
@@ -0,0 +1,105 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: jabley-rubygems-isitjruby
3
+ version: !ruby/object:Gem::Version
4
+ version: "1.0"
5
+ platform: ruby
6
+ authors:
7
+ - Eric Hodel
8
+ - James Abley
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain:
12
+ - |
13
+ -----BEGIN CERTIFICATE-----
14
+ MIIDNjCCAh6gAwIBAgIBADANBgkqhkiG9w0BAQUFADBBMRAwDgYDVQQDDAdkcmJy
15
+ YWluMRgwFgYKCZImiZPyLGQBGRYIc2VnbWVudDcxEzARBgoJkiaJk/IsZAEZFgNu
16
+ ZXQwHhcNMDcxMjIxMDIwNDE0WhcNMDgxMjIwMDIwNDE0WjBBMRAwDgYDVQQDDAdk
17
+ cmJyYWluMRgwFgYKCZImiZPyLGQBGRYIc2VnbWVudDcxEzARBgoJkiaJk/IsZAEZ
18
+ FgNuZXQwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQCbbgLrGLGIDE76
19
+ LV/cvxdEzCuYuS3oG9PrSZnuDweySUfdp/so0cDq+j8bqy6OzZSw07gdjwFMSd6J
20
+ U5ddZCVywn5nnAQ+Ui7jMW54CYt5/H6f2US6U0hQOjJR6cpfiymgxGdfyTiVcvTm
21
+ Gj/okWrQl0NjYOYBpDi+9PPmaH2RmLJu0dB/NylsDnW5j6yN1BEI8MfJRR+HRKZY
22
+ mUtgzBwF1V4KIZQ8EuL6I/nHVu07i6IkrpAgxpXUfdJQJi0oZAqXurAV3yTxkFwd
23
+ g62YrrW26mDe+pZBzR6bpLE+PmXCzz7UxUq3AE0gPHbiMXie3EFE0oxnsU3lIduh
24
+ sCANiQ8BAgMBAAGjOTA3MAkGA1UdEwQCMAAwCwYDVR0PBAQDAgSwMB0GA1UdDgQW
25
+ BBS5k4Z75VSpdM0AclG2UvzFA/VW5DANBgkqhkiG9w0BAQUFAAOCAQEAHagT4lfX
26
+ kP/hDaiwGct7XPuVGbrOsKRVD59FF5kETBxEc9UQ1clKWngf8JoVuEoKD774dW19
27
+ bU0GOVWO+J6FMmT/Cp7nuFJ79egMf/gy4gfUfQMuvfcr6DvZUPIs9P/TlK59iMYF
28
+ DIOQ3DxdF3rMzztNUCizN4taVscEsjCcgW6WkUJnGdqlu3OHWpQxZBJkBTjPCoc6
29
+ UW6on70SFPmAy/5Cq0OJNGEWBfgD9q7rrs/X8GGwUWqXb85RXnUVi/P8Up75E0ag
30
+ 14jEc90kN+C7oI/AGCBN0j6JnEtYIEJZibjjDJTSMWlUKKkj30kq7hlUC2CepJ4v
31
+ x52qPcexcYZR7w==
32
+ -----END CERTIFICATE-----
33
+
34
+ date: 2009-08-21 00:00:00 -07:00
35
+ default_executable:
36
+ dependencies:
37
+ - !ruby/object:Gem::Dependency
38
+ name: json
39
+ type: :runtime
40
+ version_requirement:
41
+ version_requirements: !ruby/object:Gem::Requirement
42
+ requirements:
43
+ - - ~>
44
+ - !ruby/object:Gem::Version
45
+ version: "1.1"
46
+ version:
47
+ - !ruby/object:Gem::Dependency
48
+ name: hoe
49
+ type: :development
50
+ version_requirement:
51
+ version_requirements: !ruby/object:Gem::Requirement
52
+ requirements:
53
+ - - ">="
54
+ - !ruby/object:Gem::Version
55
+ version: 2.3.3
56
+ version:
57
+ description: Lets you figure out if your gems and gems you install might work on JRuby. Uses http://isitrubyjruby.com as its datastore. Be sure to update the website with your experiences!
58
+ email:
59
+ - james.abley@gmail.com
60
+ executables: []
61
+
62
+ extensions: []
63
+
64
+ extra_rdoc_files:
65
+ - History.txt
66
+ - Manifest.txt
67
+ - README.rdoc
68
+ files:
69
+ - History.txt
70
+ - Manifest.txt
71
+ - README.rdoc
72
+ - Rakefile
73
+ - lib/isitjruby.rb
74
+ - lib/rubygems/commands/isitjruby_command.rb
75
+ - lib/rubygems_plugin.rb
76
+ has_rdoc: true
77
+ homepage: http://isitrubyjruby.com
78
+ licenses:
79
+ post_install_message:
80
+ rdoc_options:
81
+ - --main
82
+ - README.rdoc
83
+ require_paths:
84
+ - lib
85
+ required_ruby_version: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: "0"
90
+ version:
91
+ required_rubygems_version: !ruby/object:Gem::Requirement
92
+ requirements:
93
+ - - ">="
94
+ - !ruby/object:Gem::Version
95
+ version: "0"
96
+ version:
97
+ requirements: []
98
+
99
+ rubyforge_project: rubygems-isitjruby
100
+ rubygems_version: 1.3.5
101
+ signing_key:
102
+ specification_version: 3
103
+ summary: Lets you figure out if your gems and gems you install might work on JRuby
104
+ test_files: []
105
+