bundle-try 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: dba4b956bcde2c5e8c37622f70fc74c7c1b75bfb
4
+ data.tar.gz: 1ee56921567378bcedcf1dc0e22f71faa735e445
5
+ SHA512:
6
+ metadata.gz: 50136e64f8c0849c1bbce7ec10553de66958c4958f0938e2ca47f37a1ee190f320c69472d7a9acc8c27e79982d7a7d2104b303a1b476808869daecb3ea691381
7
+ data.tar.gz: 238bd55057b4b492a17c7a3f2282a2026568448ccfa39809020adc58058497b957c47a0a3c81531617ed5d4a776d0d1aadad01f6cacbc7082fa299cb56b56533
data/.gitignore ADDED
@@ -0,0 +1,9 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --format documentation
2
+ --color
data/.travis.yml ADDED
@@ -0,0 +1,3 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.1.5
@@ -0,0 +1,13 @@
1
+ # Contributor Code of Conduct
2
+
3
+ As contributors and maintainers of this project, we pledge to respect all people who contribute through reporting issues, posting feature requests, updating documentation, submitting pull requests or patches, and other activities.
4
+
5
+ We are committed to making participation in this project a harassment-free experience for everyone, regardless of level of experience, gender, gender identity and expression, sexual orientation, disability, personal appearance, body size, race, age, or religion.
6
+
7
+ Examples of unacceptable behavior by participants include the use of sexual language or imagery, derogatory comments or personal attacks, trolling, public or private harassment, insults, or other unprofessional conduct.
8
+
9
+ Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct. Project maintainers who do not follow the Code of Conduct may be removed from the project team.
10
+
11
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by opening an issue or contacting one or more of the project maintainers.
12
+
13
+ This Code of Conduct is adapted from the [Contributor Covenant](http:contributor-covenant.org), version 1.0.0, available at [http://contributor-covenant.org/version/1/0/0/](http://contributor-covenant.org/version/1/0/0/)
data/Gemfile ADDED
@@ -0,0 +1,6 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in bundle-try.gemspec
4
+ gemspec
5
+
6
+ gem 'pry'
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2015 Gert Goet
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,71 @@
1
+ # Bundle Try
2
+
3
+ Open a REPL with the gems you want to try.
4
+ Quick weekend-hack inspired by [lein-try](https://github.com/rkneufeld/lein-try).
5
+
6
+ ## Usage
7
+
8
+ Pick a gem, any gem:
9
+
10
+ ```
11
+ $ bundle try redis
12
+ ... some bundling ...
13
+ irb(main):001:0> Redis
14
+ => Redis
15
+ ```
16
+
17
+ Multiple gems:
18
+
19
+ ```
20
+ $ bundle try redis rake
21
+ ```
22
+
23
+ Specific version:
24
+
25
+ ```
26
+ $ bundle try redis '3.1.0'
27
+ ```
28
+
29
+ ...or any requirement that would be understood by bundler:
30
+
31
+ ```
32
+ $ bundle try redis '~> 3.1.0'
33
+ ```
34
+
35
+ Mix and match with gems you don't care about the version:
36
+
37
+ ```
38
+ $ bundle try redis '~> 3.1.0' rake gem3 '1.0'
39
+ ```
40
+
41
+ Github repository:
42
+
43
+ ```
44
+ $ bundle try https://github.com/jeremyevans/sequel # or the clone-url with .git
45
+ ```
46
+
47
+ Specific github version:
48
+
49
+ ```
50
+ $ bundle try https://github.com/jeremyevans/sequel 4.21.0
51
+ ```
52
+
53
+ Prepend the gem-name when it can't be derived from the url:
54
+
55
+ ```
56
+ $ bundle try redis@https://github.com/redis/redis-rb
57
+ ```
58
+
59
+ No Gemfile will be saved, so it's save to run from an existing project-folder.
60
+ But if you need it:
61
+
62
+ ```
63
+ $ bundle try rake > Gemfile
64
+ ```
65
+
66
+ ## Installation
67
+
68
+ ```
69
+ gem install bundle-try
70
+ ```
71
+
data/Rakefile ADDED
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "bundle-try"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start
data/bin/setup ADDED
@@ -0,0 +1,7 @@
1
+ #!/bin/bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+
5
+ bundle install
6
+
7
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,31 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+
5
+ Gem::Specification.new do |spec|
6
+ spec.name = "bundle-try"
7
+ spec.version = '1.0.0'
8
+ spec.authors = ["Gert Goet"]
9
+ spec.email = ["gert@thinkcreate.nl"]
10
+
11
+ spec.summary = %q{Start a REPL with the gems you want to try}
12
+ spec.description = %q{Start a REPL with the gems you want to try}
13
+ spec.homepage = "https://github.com/eval/bundle-try"
14
+ spec.license = "MIT"
15
+
16
+ # Prevent pushing this gem to RubyGems.org by setting 'allowed_push_host', or
17
+ # delete this section to allow pushing this gem to any host.
18
+ if spec.respond_to?(:metadata)
19
+ spec.metadata['allowed_push_host'] = "https://rubygems.org"
20
+ else
21
+ raise "RubyGems 2.0 or newer is required to protect against public gem pushes."
22
+ end
23
+
24
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
25
+ spec.bindir = "exe"
26
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
27
+ spec.require_paths = ["lib"]
28
+
29
+ spec.add_dependency "bundler", "~> 1.9"
30
+ spec.add_development_dependency "rake", "~> 10.0"
31
+ end
data/exe/bundler-try ADDED
@@ -0,0 +1,57 @@
1
+ #!/usr/bin/env ruby
2
+ require 'bundle-try'
3
+ require 'tempfile'
4
+ gemfile = Tempfile.new('bundle-try')
5
+ gemfile_content = BundleTry::GemfileGenerator.new(ARGV.dup).generate
6
+ File.write(gemfile.path, gemfile_content)
7
+
8
+ if %w(-h --help help try).include?(ARGV.first)
9
+ puts(<<-EOH)
10
+ Examples:
11
+
12
+ Pick a gem, any gem:
13
+
14
+ $ bundle try redis
15
+ ... some bundling ...
16
+ irb(main):001:0> Redis
17
+ => Redis
18
+
19
+
20
+ Multiple gems:
21
+ $ bundle try redis rake
22
+
23
+ Specific version:
24
+ $ bundle try redis '3.1.0'
25
+
26
+ ...or any requirement that would be understood by bundler:
27
+ $ bundle try redis '~> 3.1.0'
28
+
29
+ Mix and match with gems you don't care about the version:
30
+ $ bundle try redis '~> 3.1.0' rake gem3 '1.0'
31
+
32
+ Github repository:
33
+ $ bundle try https://github.com/jeremyevans/sequel # or the clone-url with .git
34
+
35
+ Specific github version:
36
+ $ bundle try https://github.com/jeremyevans/sequel 4.21.0
37
+
38
+ Prepend the gem-name when it can't be derived from the url:
39
+ $ bundle try redis@https://github.com/redis/redis-rb
40
+
41
+ No Gemfile will be saved, so it's save to run from an existing project-folder.
42
+ But if you need it:
43
+ $ bundle try rake > Gemfile
44
+
45
+ EOH
46
+ exit
47
+ end
48
+
49
+ ENV['BUNDLE_GEMFILE'] = gemfile.path
50
+ if STDOUT.tty?
51
+ puts "Need to see/re-use the generated Gemfile? Just pipe to a file (e.g. `bundle try rake > Gemfile`)"
52
+ require 'bundler/cli'
53
+ Bundler::CLI.start(%W(install), :debug => true)
54
+ Bundler::CLI.start(%W(console), :debug => true)
55
+ else
56
+ puts gemfile_content
57
+ end
data/lib/bundle-try.rb ADDED
@@ -0,0 +1,17 @@
1
+ require 'bundle_try/gemfile_generator'
2
+ require 'thor'
3
+
4
+ module BundleTry
5
+ class Cli < Thor
6
+ include Thor::Actions
7
+
8
+ desc "try [OPTIONS]", "Try a gem"
9
+ long_desc <<-D
10
+ Some reallt long description
11
+ D
12
+ #method_option "gemspec", :type => :string, :banner => "Use the specified .gemspec to create the Gemfile"
13
+ def help
14
+ puts "A helping hand"
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,65 @@
1
+ module BundleTry
2
+ class GemfileGenerator
3
+ def initialize(args)
4
+ @args = args
5
+ end
6
+
7
+ def grouped_args
8
+ @args.each_with_object([]) do |arg, obj|
9
+ if arg_is_version?(arg)
10
+ obj[-1] << arg
11
+ else
12
+ obj << [arg]
13
+ end
14
+ end
15
+ end
16
+
17
+ def arg_is_version?(arg)
18
+ arg[/v?\d+\.\d+/] ||
19
+ arg[/^\h+$/] ||
20
+ arg[Gem::Requirement::PATTERN]
21
+ end
22
+
23
+ def group2gemline(group)
24
+ result = begin
25
+ case group.first
26
+ when /\/\/github\.com/
27
+ github = group.first[/github\.com\/(.+)(?:\.git)?$/, 1]
28
+ name = if group.first.include?('@')
29
+ group.first.split('@').first
30
+ else
31
+ github.split('/').last
32
+ end
33
+ { name: name, github: github, ref: group[1] }
34
+ else
35
+ { name: group[0], requirement: group[1] }
36
+ end
37
+ end
38
+ result.delete_if {|_,v| v.nil? }
39
+ end
40
+
41
+ def gemlines
42
+ gemlines = grouped_args.map {|g| group2gemline(g) }
43
+ gemlines.map do |line|
44
+ case
45
+ when line[:github]
46
+ s = "gem '#{line[:name]}', github: '#{line[:github]}'"
47
+ s += ", ref: '#{line[:ref]}'" if line[:ref]
48
+ s
49
+ else
50
+ s = "gem '#{line[:name]}'"
51
+ s += ", '#{line[:requirement]}'" if line[:requirement]
52
+ s
53
+ end
54
+ end
55
+ end
56
+
57
+ def generate
58
+ return <<-EOF
59
+ source "https://rubygems.org"
60
+
61
+ #{gemlines.join("\n")}
62
+ EOF
63
+ end
64
+ end
65
+ end
metadata ADDED
@@ -0,0 +1,88 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: bundle-try
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ platform: ruby
6
+ authors:
7
+ - Gert Goet
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2015-05-17 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.9'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.9'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '10.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '10.0'
41
+ description: Start a REPL with the gems you want to try
42
+ email:
43
+ - gert@thinkcreate.nl
44
+ executables:
45
+ - bundler-try
46
+ extensions: []
47
+ extra_rdoc_files: []
48
+ files:
49
+ - ".gitignore"
50
+ - ".rspec"
51
+ - ".travis.yml"
52
+ - CODE_OF_CONDUCT.md
53
+ - Gemfile
54
+ - LICENSE.txt
55
+ - README.md
56
+ - Rakefile
57
+ - bin/console
58
+ - bin/setup
59
+ - bundle-try.gemspec
60
+ - exe/bundler-try
61
+ - lib/bundle-try.rb
62
+ - lib/bundle_try/gemfile_generator.rb
63
+ homepage: https://github.com/eval/bundle-try
64
+ licenses:
65
+ - MIT
66
+ metadata:
67
+ allowed_push_host: https://rubygems.org
68
+ post_install_message:
69
+ rdoc_options: []
70
+ require_paths:
71
+ - lib
72
+ required_ruby_version: !ruby/object:Gem::Requirement
73
+ requirements:
74
+ - - ">="
75
+ - !ruby/object:Gem::Version
76
+ version: '0'
77
+ required_rubygems_version: !ruby/object:Gem::Requirement
78
+ requirements:
79
+ - - ">="
80
+ - !ruby/object:Gem::Version
81
+ version: '0'
82
+ requirements: []
83
+ rubyforge_project:
84
+ rubygems_version: 2.2.2
85
+ signing_key:
86
+ specification_version: 4
87
+ summary: Start a REPL with the gems you want to try
88
+ test_files: []