bun 1.0.2 → 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a78ef77c51beb53e4f9315da260e14e008b985de8d042829f908644a38dbaefb
4
- data.tar.gz: f1aeead00d6e4a8c90938892fefc2315f8789052fce5cbfae0f4cfb1d057fb96
3
+ metadata.gz: 2768a6afdab33b24df8ec9dcb95bb8764bf3c0098dc7008769d3f61b187fba91
4
+ data.tar.gz: b2f875654ae2db8746064d8f5aebbc2618d7cfedef486f0120600cd0fec422c6
5
5
  SHA512:
6
- metadata.gz: d3973bfacf135730a50d3af809f04d68a68dd31f38b1ea4204ffd236aaa1b7df311b4809a48b6179acf0fb2ae27909cc06bf521bdae0a5cd4b8664242bb9742b
7
- data.tar.gz: cbc83eda8586d31eb8f020b6cd823e7fe20f5ecdc81a343dcf15236252f014a77cafd75d113c50f86888537976df8e86a8c1dbf0612845c5311b3b479569e488
6
+ metadata.gz: f2f4c416129ba3d8bd4e4c7166c5d8171fda830eeb5cfa6bcad55b0928eb1c177ea9d05bca8d89dfc854f9ca22b42d365b32221638969f0fc14559937004b71d
7
+ data.tar.gz: e0c913a084c34304c7ed4f1d89413dd8c25e0059bc6b2429328fecc5c97ba0c34927bfb7cf1368dc09bbb58ff6c0cbf0403ac29c1504bf972102fb5a2d791f4e
@@ -0,0 +1,13 @@
1
+ sudo: false
2
+ language: ruby
3
+ rvm:
4
+ - 2.0.0
5
+ - 2.1.10
6
+ - 2.2.9
7
+ - 2.3.6
8
+ - 2.4.3
9
+ - 2.5.0
10
+ install: BUNDLE_GEMFILE=gemfile bundle install
11
+ script: BUNDLE_GEMFILE=gemfile bundle exec rake
12
+ notifications:
13
+ email: false
@@ -12,6 +12,8 @@ Gem::Specification.new do |spec|
12
12
  spec.homepage = "https://github.com/shime/bun"
13
13
  spec.license = "MIT"
14
14
 
15
+ spec.required_ruby_version = '>= 2.0'
16
+
15
17
  spec.files = `git ls-files -z`.split("\x0").reject do |f|
16
18
  f.match(%r{^(test|spec|features)/})
17
19
  end
File without changes
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- bun (1.0.1)
4
+ bun (1.0.2)
5
5
  bundler (~> 1.16)
6
6
  paint (~> 2.0)
7
7
  tty-spinner (~> 0.8)
data/lib/bun.rb CHANGED
@@ -7,4 +7,19 @@ require_relative "bun/gemfile"
7
7
  require_relative "bun/version_fetcher"
8
8
 
9
9
  module Bun
10
+ extend self
11
+
12
+ def add(gems, opts = {})
13
+ runner.add(Array(gems), opts)
14
+ end
15
+
16
+ def remove(gems, opts = {})
17
+ runner.remove(Array(gems), opts)
18
+ end
19
+
20
+ private
21
+
22
+ def runner
23
+ @runner ||= Runner.new
24
+ end
10
25
  end
@@ -9,19 +9,49 @@ module Bun
9
9
 
10
10
  def initialize(*arguments)
11
11
  @arguments = arguments
12
+ @gemfile = Gemfile.new
13
+
14
+ parse_arguments
12
15
  end
13
16
 
14
17
  def call
15
- parse_arguments
16
-
17
18
  command = parsed_arguments.shift
18
19
  gems = parsed_arguments.take_while { |argument| argument !~ /^-|^--/}
19
20
 
20
- self.gemfile = Gemfile.new
21
-
22
21
  run_command(command, gems)
23
22
  end
24
23
 
24
+ def uninstall(gems, opts: {})
25
+ gems.each do |gem|
26
+ gemfile.remove(gem)
27
+ end
28
+
29
+ bundle_install
30
+ end
31
+ alias :remove :uninstall
32
+
33
+ def install(gems = [], opts: {})
34
+ gemfile.init
35
+
36
+ gems.each do |gem|
37
+ name, version = extract_name_and_version_from_gem(gem)
38
+
39
+ if print?
40
+ version ||= VersionFetcher.new(name, arguments).fetch_latest_version
41
+ puts "gem \"#{name}\", \"#{version_string(version)}\""
42
+ else
43
+ gemfile.verify_unique!(name)
44
+ version ||= VersionFetcher.new(name, arguments).fetch_latest_version
45
+ gemfile.add(name,
46
+ version_string(version),
47
+ arguments.group)
48
+ end
49
+ end
50
+
51
+ bundle_install
52
+ end
53
+ alias :add :install
54
+
25
55
  private
26
56
 
27
57
  attr_accessor :arguments
@@ -48,32 +78,6 @@ module Bun
48
78
  exit(1)
49
79
  end
50
80
 
51
- def uninstall(gems)
52
- gems.each do |gem|
53
- gemfile.remove(gem)
54
- end
55
-
56
- bundle_install
57
- end
58
-
59
- def install(gems = [])
60
- gemfile.init
61
-
62
- gems.each do |gem|
63
- if arguments.print?
64
- version = version_string(VersionFetcher.new(gem, arguments).fetch_latest_version)
65
- puts "gem \"#{gem}\", \"#{version}\""
66
- else
67
- gemfile.verify_unique!(gem)
68
- gemfile.add(gem,
69
- version_string(VersionFetcher.new(gem, arguments).fetch_latest_version),
70
- arguments.group)
71
- end
72
- end
73
-
74
- bundle_install
75
- end
76
-
77
81
  def version_string(version)
78
82
  if arguments.optimistic?
79
83
  ">= #{version}"
@@ -85,16 +89,26 @@ module Bun
85
89
  end
86
90
 
87
91
  def bundle_install
88
- return if arguments.skip_install? || arguments.print?
92
+ return if arguments.skip_install? || print?
89
93
 
90
94
  Bundler.with_clean_env do
91
95
  system("bundle install")
92
96
  end
93
97
  end
94
98
 
99
+ def print?
100
+ arguments.print?
101
+ end
102
+
95
103
  def parse_arguments
96
104
  self.arguments = Arguments.new(arguments)
97
105
  self.parsed_arguments = arguments.parse
98
106
  end
107
+
108
+ def extract_name_and_version_from_gem(gem)
109
+ return gem unless gem =~ /:/
110
+
111
+ gem.split(":")
112
+ end
99
113
  end
100
114
  end
@@ -1,3 +1,3 @@
1
1
  module Bun
2
- VERSION = "1.0.2"
2
+ VERSION = "1.1.0"
3
3
  end
@@ -0,0 +1,6 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task :default => :spec
data/readme.md CHANGED
@@ -1,5 +1,7 @@
1
1
  # Bun
2
2
 
3
+ [![Build Status](https://travis-ci.org/shime/bun.svg?branch=master)](https://travis-ci.org/shime/bun)
4
+
3
5
  Bundler's little helper. A missing CLI tool to install and remove gems from Gemfile with ease.
4
6
 
5
7
 
@@ -19,6 +21,12 @@ Install RSpec:
19
21
  $ bun add rspec
20
22
  ```
21
23
 
24
+ Install specific version of RSpec
25
+
26
+ ```
27
+ $ bun add rspec:3.7.0
28
+ ```
29
+
22
30
  Install Pry in development group:
23
31
 
24
32
  ```
@@ -67,6 +75,15 @@ More info:
67
75
  $ bun --help
68
76
  ```
69
77
 
78
+ # API
79
+
80
+ ```ruby
81
+ require "bun"
82
+
83
+ Bun.add("rspec:3.7.0") # adds RSpec to Gemfile and runs bundle install
84
+ Bun.remove("rspec") # removes RSpec from Gemfile
85
+ ```
86
+
70
87
  ## Prior art
71
88
 
72
89
  * [Gemrat](https://github.com/drurly/gemrat)
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bun
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.2
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Hrvoje Šimić
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-03-23 00:00:00.000000000 Z
11
+ date: 2018-03-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: tty-spinner
@@ -103,10 +103,11 @@ extensions: []
103
103
  extra_rdoc_files: []
104
104
  files:
105
105
  - ".gitignore"
106
- - Gemfile
107
- - Gemfile.lock
106
+ - ".travis.yml"
108
107
  - bin/bun
109
108
  - bun.gemspec
109
+ - gemfile
110
+ - gemfile.lock
110
111
  - lib/bun.rb
111
112
  - lib/bun/arguments.rb
112
113
  - lib/bun/errors.rb
@@ -116,6 +117,7 @@ files:
116
117
  - lib/bun/version.rb
117
118
  - lib/bun/version_fetcher.rb
118
119
  - license
120
+ - rakefile
119
121
  - readme.md
120
122
  homepage: https://github.com/shime/bun
121
123
  licenses:
@@ -129,7 +131,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
129
131
  requirements:
130
132
  - - ">="
131
133
  - !ruby/object:Gem::Version
132
- version: '0'
134
+ version: '2.0'
133
135
  required_rubygems_version: !ruby/object:Gem::Requirement
134
136
  requirements:
135
137
  - - ">="