joonty / pessimize Goto Github PK
View Code? Open in Web Editor NEWAdd version numbers with the pessimistic constraint operator to all gems in your Gemfile
License: MIT License
Add version numbers with the pessimistic constraint operator to all gems in your Gemfile
License: MIT License
Hello
I'm unable to use the gem suddenly. Please let me know if I am missing something, or what I should inspect? Thanks!
[DEPRECATION] The trollop gem has been renamed to optimist and will no longer be supported. Please switch to optimist as soon as possible.
Backing up Gemfile and Gemfile.lock
+ cp Gemfile Gemfile.backup
+ cp Gemfile.lock Gemfile.lock.backup
Traceback (most recent call last):
13: from /Users/joemsak/.asdf/installs/ruby/2.6.5/bin/pessimize:23:in `<main>'
12: from /Users/joemsak/.asdf/installs/ruby/2.6.5/bin/pessimize:23:in `load'
11: from /Users/joemsak/.asdf/installs/ruby/2.6.5/lib/ruby/gems/2.6.0/gems/pessimize-0.4.0/bin/pessimize:5:in `<top (required)>'
10: from /Users/joemsak/.asdf/installs/ruby/2.6.5/lib/ruby/gems/2.6.0/gems/pessimize-0.4.0/lib/pessimize/shell.rb:15:in `run'
9: from /Users/joemsak/.asdf/installs/ruby/2.6.5/lib/ruby/gems/2.6.0/gems/pessimize-0.4.0/lib/pessimize/pessimizer.rb:14:in `run'
8: from /Users/joemsak/.asdf/installs/ruby/2.6.5/lib/ruby/gems/2.6.0/gems/pessimize-0.4.0/lib/pessimize/pessimizer.rb:28:in `collect_gems_and_versions'
7: from /Users/joemsak/.asdf/installs/ruby/2.6.5/lib/ruby/gems/2.6.0/gems/pessimize-0.4.0/lib/pessimize/pessimizer.rb:28:in `new'
6: from /Users/joemsak/.asdf/installs/ruby/2.6.5/lib/ruby/gems/2.6.0/gems/pessimize-0.4.0/lib/pessimize/gemfile.rb:13:in `initialize'
5: from /Users/joemsak/.asdf/installs/ruby/2.6.5/lib/ruby/gems/2.6.0/gems/pessimize-0.4.0/lib/pessimize/gemfile.rb:27:in `parse_gems_from_tokens!'
4: from /Users/joemsak/.asdf/installs/ruby/2.6.5/lib/ruby/gems/2.6.0/gems/pessimize-0.4.0/lib/pessimize/gemfile.rb:27:in `loop'
3: from /Users/joemsak/.asdf/installs/ruby/2.6.5/lib/ruby/gems/2.6.0/gems/pessimize-0.4.0/lib/pessimize/gemfile.rb:37:in `block in parse_gems_from_tokens!'
2: from /Users/joemsak/.asdf/installs/ruby/2.6.5/lib/ruby/gems/2.6.0/gems/pessimize-0.4.0/lib/pessimize/gemfile.rb:37:in `new'
1: from /Users/joemsak/.asdf/installs/ruby/2.6.5/lib/ruby/gems/2.6.0/gems/pessimize-0.4.0/lib/pessimize/gem.rb:9:in `initialize'
/Users/joemsak/.asdf/installs/ruby/2.6.5/lib/ruby/gems/2.6.0/gems/pessimize-0.4.0/lib/pessimize/gem.rb:52:in `parse_version': undefined method `[]' for nil:NilClass (NoMethodError)
kadenzeweb develop % ruby -v
ruby 2.6.5p114 (2019-10-01 revision 67812) [x86_64-darwin19]```
Before pessimize...
ruby "1.9.3"
if RUBY_VERSION =~ /1.9/
Encoding.default_external = Encoding::UTF_8
Encoding.default_internal = Encoding::UTF_8
end
source 'http://rubygems.org'
source 'http://gems.github.com'
gem 'rails', '3.0.20'
...after...
ruby "1.9.3"source "http://rubygems.org"source "http://gems.github.com"
gem "rails", "~> 3.0.20"
Upon installing the gem I get the following:
$ gem install pessimize
Fetching: trollop-2.9.9.gem (100%)
! The 'trollop' gem has been deprecated and has been replaced by 'optimist'.
! See: https://rubygems.org/gems/optimist
! And: https://github.com/ManageIQ/optimist
Successfully installed trollop-2.9.9
Fetching: pessimize-0.4.0.gem (100%)
Successfully installed pessimize-0.4.0
Parsing documentation for trollop-2.9.9
Installing ri documentation for trollop-2.9.9
Parsing documentation for pessimize-0.4.0
Installing ri documentation for pessimize-0.4.0
Done installing documentation for trollop, pessimize after 0 seconds
2 gems installed
And when I run the command, I get:
$ pessimize --no-backup
[DEPRECATION] This gem has been renamed to optimist and will no longer be supported. Please switch to optimist as soon as possible.
~> written 94 gems to Gemfile, constrained to minor version updates
I figured you might want to know :)
Feature idea: Support an option to take the more pessimistic version:
Given a gem pinned to a patch version
When I run pessimize -c minor
The more pessimistic patch version is kept in the Gemfile
The README currently contains a link to "rubygems explanation", but that link no longer works.
Is anyone aware of an alternative resource? If not, the link could point towards the last Internet Archive snapshot of the page.
You can write your own bundler plugins instead of invoking gem.
did you consider that ?
more info:
https://bundler.io/guides/bundler_plugins.html
I also think about those bundle update switches:
--minor
Prefer updating only to next minor version.
--major
Prefer updating to next major version (default).
--strict
Do not allow any gem to be updated past latest --patch | --minor | --major.
--conservative
Use bundle install conservative update behavior and do not allow indirect dependencies to be updated.
https://github.com/bbatsov/ruby-style-guide#consistent-string-literals
Options:
-q, --quote=<s> Quote style ('single' or 'double') (default: double)
Feature Request: How about adding an option to unpessimize i.e. remove version specification from Gemfile?
This is useful in case when you want to update old Gemfile and running bundle update instead of removing the version restrictions manully.
Some companies will only use gems with a certain license.
The canonical and easy way to check is via the gemspec,
via e.g.
spec.license = 'MIT'
# or
spec.licenses = ['MIT', 'GPL-2']
Even for projects that already specify a license, including a license in your gemspec is a good practice, since it is easily
discoverable there without having to check the readme or for a license file. For example, it is the field that rubygems.org uses to display a gem's license.
For example, there is a License Finder gem to help companies ensure all gems they use
meet their licensing needs. This tool depends on license information being available in the gemspec. This is an important enough
issue that even Bundler now generates gems with a default 'MIT' license.
If you need help choosing a license (sorry, I haven't checked your readme or looked for a license file), github has created a license picker tool.
In case you're wondering how I found you and why I made this issue, it's because I'm collecting stats on gems (I was originally looking for download data) and decided to collect license metadata,too, and make issues for gemspecs not specifying a license as a public service :).
I hope you'll consider specifying a license in your gemspec. If not, please just close the issue and let me know. In either case, I'll follow up. Thanks!
p.s. I've written a blog post about this project
Hope this helps some what! Just a though and what I expected from the result.
When I have:
group :production, :staging, :live_dev do
gem 'newrelic_rpm'
gem 'rails_12factor'
gem 'heroku-deflater'
end
What I get after running pessimize
group :production do
gem 'newrelic_rpm', '~> 3.12'
gem 'rails_12factor', '~> 0.0'
gem 'heroku-deflater', '~> 0.5'
end
group :staging do
gem 'newrelic_rpm', '~> 3.12'
gem 'rails_12factor', '~> 0.0'
gem 'heroku-deflater', '~> 0.5'
end
group :live_dev do
gem 'newrelic_rpm', '~> 3.12'
gem 'rails_12factor', '~> 0.0'
gem 'heroku-deflater', '~> 0.5'
end
This will cause the following errors to appear on any bundle
command and will repeat for each group stage.
Your Gemfile lists the gem newrelic_rpm (~> 3.12) more than once.
You should probably keep only one of them.
While it's not a problem now, it could cause errors if you change the version of just one of them later.
Your Gemfile lists the gem rails_12factor (~> 0.0) more than once.
You should probably keep only one of them.
While it's not a problem now, it could cause errors if you change the version of just one of them later.
Your Gemfile lists the gem heroku-deflater (~> 0.5) more than once.
You should probably keep only one of them.
What I expect
group :production, :staging, :live_dev do
gem 'newrelic_rpm', '~> 3.12'
gem 'rails_12factor', '~> 0.0'
gem 'heroku-deflater', '~> 0.5'
end
If a gem version is in beta or pre (the final part of the version can be any string, I think), pessimize doesn't currently work correctly. For example, the debugger2 gem has version "1.0.0.beta2", but using the constraint "~> 1.0" doesn't seem to include beta gems.
There are two ways round this:
gem "debugger2"
gem "debugger2", "1.0.0.beta2"
I'm leaning towards 1, as it's not ideal to lock down a gem version to always be in beta.
I'm a bit disappointed by the results from executing this gem (trying all possible settings)
So it takes rspec 3 and turns it into rspec 0.1. Umm...
Dunno if it's a parsing issue or an algorithm issue.
The algo should be dead-simple and it should absolutely not try to be smart:
What do you think it happened?
Cheers - Victor
Currently, only methods and their arguments are retained in a Gemfile, as it is evaluated using instance_eval
. If there are any extra statements (such as conditionals), they will not be kept.
This could be fixed by actually parsing the file with Ripper, or something similar.
When there are two sources:
source "https://rubygems.org"
source "http://myothersource.com"
Pessimizing the project results in those both being re-output to the same line.
source "http://myothersource.com"source "https://rubygems.org"
This will result in a Gemfile syntax error.
They need to be each on their own line, as in the first example.
No pessimistic constraint operators are added for lines of the Gemfile
which have an inline comment e.g.
gem 'spring' # Rails application preloader
Problems:
Before:
gem "seedbank", "~> 0.3.0.pre"
gem "high_voltage"
After:
gem "seedbank", '0.2'
gem "high_voltage" # Still no version
/Users/mikepence/.rvm/gems/ruby-1.9.3-p448@sg/gems/pessimize-0.0.2/lib/pessimize/dsl.rb:9:in
'instance_eval': wrong number of arguments (2 for 1) (ArgumentError) from (eval):62:in
parse'
from /Users/mikepence/.rvm/gems/ruby-1.9.3-p448@sg/gems/pessimize-0.0.2/lib/pessimize/dsl.rb:9:ininstance_eval' from /Users/mikepence/.rvm/gems/ruby-1.9.3-p448@sg/gems/pessimize-0.0.2/lib/pessimize/dsl.rb:9:in
parse'
from /Users/mikepence/.rvm/gems/ruby-1.9.3-p448@sg/gems/pessimize-0.0.2/lib/pessimize/pessimizer.rb:28:incollect_gems_and_versions' from /Users/mikepence/.rvm/gems/ruby-1.9.3-p448@sg/gems/pessimize-0.0.2/lib/pessimize/pessimizer.rb:15:in
run'
from /Users/mikepence/.rvm/gems/ruby-1.9.3-p448@sg/gems/pessimize-0.0.2/lib/pessimize/shell.rb:12:inrun' from /Users/mikepence/.rvm/gems/ruby-1.9.3-p448@sg/gems/pessimize-0.0.2/bin/pessimize:5:in
<top (required)>'
from /Users/mikepence/.rvm/gems/ruby-1.9.3-p448@sg/bin/pessimize:19:inload' from /Users/mikepence/.rvm/gems/ruby-1.9.3-p448@sg/bin/pessimize:19:in
from /Users/mikepence/.rvm/gems/ruby-1.9.3-p448@sg/bin/ruby_noexec_wrapper:14:ineval' from /Users/mikepence/.rvm/gems/ruby-1.9.3-p448@sg/bin/ruby_noexec_wrapper:14:in
'
Correct specification for semantic versioning is described in the RubyGems guides patterns for declaring dependencies. You lock users to a bug fix series and don't allow backward-compatible releases with new features.
For >= 1.2.3
the semantic-versioning-safe requirement is ~> 1.2, >= 1.2.3
.
We use comments to label gems in our Gemfile (sometimes the use of a gem doesn't come easily from the name ๐) and this seems to stop the Pessimize parser from labeling subsequent gem lines. I've attached a sample Gemfile (and the Gemfile.backup) that triggers the issue. If I remove the ruby comment everything seems to work great.
Gemfile (after running pessimize
):
# A sample Gemfile
source "https://rubygems.org"
gem "rails", "~> 4.2"
gem "pessimize", "~> 0.3" # Breaks here
gem "devise"
Gemfile.backup:
# A sample Gemfile
source "https://rubygems.org"
gem "rails"
gem "pessimize" # Breaks here
gem "devise"
Instead of using a custom parser, use the lock file parser that comes with bundler.
Cloning this project, bundling, and running rake
fails:
WARN -- : This usage of the Code Climate Test Reporter is now deprecated. Since version
1.0, we now require you to run `SimpleCov` in your test/spec helper, and then
run the provided `codeclimate-test-reporter` binary separately to report your
results to Code Climate.
More information here: https://github.com/codeclimate/ruby-test-reporter/blob/master/README.md
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.