How to check the compatible Ruby versions for a gem

后端 未结 3 1414
生来不讨喜
生来不讨喜 2021-01-25 08:58

How do I find out if a particular gem is compatible with a certain Ruby version or not?

I want to upgrade the Ruby version of an application I am working on, But I did n

3条回答
  •  故里飘歌
    2021-01-25 09:36

    I found something more interesting on Rubygems.org, that serves as an API that renders a JSON/XML response about the gem.

    Often it is mentioned in Rubygems.org but not in the gemspec file about the Ruby version compatibility.

    This is a one-off way to fetch it:

    curl https://rubygems.org/api/v2/rubygems/activerecord/versions/4.2.7.1.json
    
    {
      "name": "activerecord",
      "downloads": 163190934,
      "version": "4.2.7.1",
      "version_downloads": 6061660,
      "platform": "ruby",
      "authors": "David Heinemeier Hansson",
      "info": "Databases on Rails. Build a persistent domain model by mapping database tables to Ruby classes. Strong conventions for associations, validations, aggregations, migrations, and testing come baked-in.",
      "licenses": [
        "MIT"
      ],
      "metadata": {},
      "sha": "923a64e2ebb9c4529761bf65ed37601a7000af2f3b18f12ea00e9f9ba2a168d2",
      "project_uri": "https://rubygems.org/gems/activerecord",
      "gem_uri": "https://rubygems.org/gems/activerecord-4.2.7.1.gem",
      "homepage_uri": "http://rubyonrails.org",
      "wiki_uri": null,
      "documentation_uri": "http://www.rubydoc.info/gems/activerecord/4.2.7.1",
      "mailing_list_uri": null,
      "source_code_uri": null,
      "bug_tracker_uri": null,
      "changelog_uri": null,
      "dependencies": {
        "development": [],
        "runtime": [
          {
            "name": "activemodel",
            "requirements": "= 4.2.7.1"
          },
          {
            "name": "activesupport",
            "requirements": "= 4.2.7.1"
          },
          {
            "name": "arel",
            "requirements": "~> 6.0"
          }
        ]
      },
      "built_at": "2016-08-10T00:00:00.000Z",
      "created_at": "2016-08-11T17:33:45.486Z",
      "description": "Databases on Rails. Build a persistent domain model by mapping database tables to Ruby classes. Strong conventions for associations, validations, aggregations, migrations, and testing come baked-in.",
      "downloads_count": 6061660,
      "number": "4.2.7.1",
      "summary": "Object-relational mapper framework (part of Rails).",
      "rubygems_version": ">= 0",
      "ruby_version": ">= 1.9.3",
      "prerelease": false,
      "requirements": []
    }
    

    And extract ruby_version.

    See API documentation for more information.

提交回复
热议问题