just 0.1.0 → 1.0.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
  SHA1:
3
- metadata.gz: a385f0d81611dde4c311c2d318eb019bb508c98c
4
- data.tar.gz: 135fce4009f7675f5adca668abddeb567df79939
3
+ metadata.gz: e378b6e8c0a58c4a1db0d7bf7515b159b3aecc30
4
+ data.tar.gz: e8acdb1aa86f474a1a32e1cdca314547c20b6ee5
5
5
  SHA512:
6
- metadata.gz: b329c9f1233b3ae9df379cb6599f39bdb57d2e4872e55701a9611d4368d7801ebc1146069c5c48cb212dd277c6bd3f57fedab1460300f3b90d57c418675f7e4a
7
- data.tar.gz: 2e1504a9ebd8f50487b1aee253db1f5261ff8d41380f7e836ec820872fe19ee7b499f5598974de9c8d0b37100fdbcfd675dfd78b0f8a6ac9a17712a9e5fb56ec
6
+ metadata.gz: 369727e8bd6a437d086a1f8c3fb7fb092b6bb0d873b6231cdf0523fd6f7b260e739c965cec626ce119a0eae15b3c345d649f74d0bec301f6c6ca08a999160132
7
+ data.tar.gz: 106921f57a87dfdd7d86a9b27aa9457b624d95a166c799d7cb5ed9e6eae74ff9c1923ef71eca7dd30dfbb4c3bb44bb2843edb011611ed439aa6f58b09fd402f4
data/.gitignore CHANGED
@@ -9,3 +9,5 @@
9
9
 
10
10
  # rspec failure tracking
11
11
  .rspec_status
12
+ spec/.just
13
+ Gemfile.lock
@@ -0,0 +1,3 @@
1
+ [submodule "spec/repos/radar/dot-files"]
2
+ path = spec/repos/radar/dot-files
3
+ url = git@github.com:radar/dot-files
@@ -0,0 +1,7 @@
1
+ Copyright 2017 Ryan Bigg
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
4
+
5
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
6
+
7
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md CHANGED
@@ -1 +1,66 @@
1
1
  # Just (Visiting)
2
+
3
+ For when you want your aliases but you're using someone else's computer.
4
+
5
+ Have you ever paired with someone else, and then gone to type `gco` for `git checkout`, only to be told that the computer has no idea what this `gco` thingo is? Ever wanted to take your aliases with you without forcing you to pollute the terminal environment of whoever you're pairing with?
6
+
7
+ Just is just for you!
8
+
9
+ ## Installation
10
+
11
+ ```
12
+ gem install just
13
+ ```
14
+
15
+ Then you should run `just setup` and follow the instructions there.
16
+
17
+ ## Usage
18
+
19
+ ### Add
20
+
21
+ The first port of call for `just` is the `add` command, which clones down a specified repository. This repository should be fairly light, containing just your aliases.
22
+
23
+ Here's how to run it:
24
+
25
+ ```
26
+ just add radar/dot-files
27
+ ```
28
+
29
+ This will add my `dot-files` repository to `~/.just/radar/dot-files`.
30
+
31
+ ### Use
32
+
33
+ Adding doesn't do anything by default so to make `just` start to use aliases, just use the `use` command:
34
+
35
+ ```
36
+ just use radar/dot-files ryan-aliases
37
+ ```
38
+
39
+ This will tell `just` to use the `ryan-aliases` file from `radar/dot-files`. And only that file.
40
+
41
+ You could also specify multiple files:
42
+
43
+ ```
44
+ just use radar/dot-files gitaliases ryan-aliases
45
+ ```
46
+
47
+ ### Me / Reset
48
+
49
+ When you're done pairing, you can run this command to reset everything back to normal:
50
+
51
+ ```
52
+ just me
53
+ ```
54
+
55
+ Or:
56
+
57
+ ```
58
+ just reset
59
+ ```
60
+
61
+ Any aliases added by `just` will be forgotten.
62
+
63
+
64
+
65
+
66
+
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
3
  require "bundler/setup"
4
- require "just_visiting"
4
+ require "just"
5
5
 
6
6
  # You can add fixtures and/or initialization code here to make experimenting
7
7
  # with your gem easier. You can also use a different console, if you like.
data/exe/just CHANGED
@@ -1,3 +1,5 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
- Just::CLI.run
3
+ require 'just'
4
+ require 'just/cli'
5
+ require 'just/cli/run'
@@ -21,8 +21,18 @@ Gem::Specification.new do |spec|
21
21
  spec.bindir = "exe"
22
22
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
23
23
  spec.require_paths = ["lib"]
24
+ spec.license = "MIT"
25
+
26
+ spec.add_dependency "main", "~> 6.2.2"
27
+ spec.add_dependency "rugged", "~> 0.26.0"
28
+ spec.add_dependency "ruby-progressbar", "~> 1.9.0"
29
+ spec.add_dependency "dry-transaction", "~> 0.10.2"
30
+ spec.add_dependency "dry-monads", "~> 0.4.0"
31
+ spec.add_dependency "rainbow", "~> 3.0.0"
24
32
 
25
33
  spec.add_development_dependency "bundler", "~> 1.16"
34
+ spec.add_development_dependency "pry"
26
35
  spec.add_development_dependency "rake", "~> 10.0"
27
36
  spec.add_development_dependency "rspec", "~> 3.0"
37
+ spec.add_development_dependency "climate_control", "~> 0.2.0"
28
38
  end
@@ -1,5 +1,28 @@
1
- require "just_visiting/version"
1
+ require "just/version"
2
+ require "just/cli"
2
3
 
3
4
  module Just
4
- # Your code goes here...
5
+ def self.progress_bar
6
+ ProgressBar::Outputs::Tty
7
+ end
8
+
9
+ def self.directory
10
+ File.expand_path(File.join(ENV['HOME'], ".just"))
11
+ end
12
+
13
+ def self.path(*paths)
14
+ File.expand_path(File.join(directory, *paths))
15
+ end
16
+
17
+ def self.aliases
18
+ path("aliases")
19
+ end
20
+
21
+ def self.git_url
22
+ "https://github.com"
23
+ end
24
+
25
+ def self.git(*paths)
26
+ File.join(git_url, *paths)
27
+ end
5
28
  end
@@ -0,0 +1,17 @@
1
+ require "rainbow"
2
+
3
+ require "just/cli/add"
4
+ require "just/cli/use"
5
+ require "just/cli/reset"
6
+
7
+ module Just
8
+ module CLI
9
+ def self.success(text)
10
+ puts Rainbow(text).green
11
+ end
12
+
13
+ def self.error(text)
14
+ puts Rainbow(text).red
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,55 @@
1
+ require 'rugged'
2
+ require 'ruby-progressbar'
3
+ require 'dry/transaction'
4
+
5
+ module Just
6
+ module CLI
7
+ class Add
8
+ include Dry::Transaction
9
+
10
+ step :ensure_just_directory_exists
11
+ step :ensure_destination_empty
12
+ step :clone_repository
13
+
14
+ def ensure_just_directory_exists(username_and_repo)
15
+ FileUtils.mkdir_p(Just.directory)
16
+ Success(username_and_repo)
17
+ end
18
+
19
+ def ensure_destination_empty(username_and_repo)
20
+ destination = Just.path(username_and_repo)
21
+ if File.exist?(destination) && !Dir.empty?(destination)
22
+ Failure("Destination already exists")
23
+ else
24
+ Success(username_and_repo)
25
+ end
26
+ end
27
+
28
+
29
+ def clone_repository(username_and_repo)
30
+ progressbar = build_progress_bar(username_and_repo)
31
+
32
+ destination = Just.path(username_and_repo)
33
+ Rugged::Repository.clone_at(Just.git(username_and_repo), destination,
34
+ transfer_progress: lambda { |total_objects, _, received_objects, _, _, _, _|
35
+ progress = (received_objects / total_objects.to_f * 100).ceil
36
+ progressbar.progress = progress
37
+ })
38
+
39
+ Success(username_and_repo)
40
+ end
41
+
42
+
43
+ private
44
+
45
+ def build_progress_bar(username_and_repo)
46
+ ProgressBar.create(
47
+ output: Just.progress_bar,
48
+ title: "Adding #{username_and_repo}",
49
+ throttle_rate: 0.1,
50
+ length: 80
51
+ )
52
+ end
53
+ end
54
+ end
55
+ end
@@ -0,0 +1,19 @@
1
+ require 'dry/transaction'
2
+
3
+ module Just
4
+ module CLI
5
+ class Reset
6
+ include Dry::Transaction
7
+
8
+ step :run
9
+
10
+ def run(_)
11
+ File.open(Just.aliases, "w+") do |f|
12
+ f.truncate(0)
13
+ end
14
+
15
+ Success("Cleared all aliases")
16
+ end
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,103 @@
1
+ require "main"
2
+
3
+ Main {
4
+ mode 'setup' do
5
+ def run()
6
+ doc = <<-DOC
7
+ To setup Just, you just need to add this line to your ~/.bash_profile or ~/.zshrc:
8
+
9
+ . ~/.just/aliases
10
+
11
+ It's just that simple. Just will do the rest!
12
+ DOC
13
+
14
+ Just::CLI.success doc.strip
15
+ end
16
+ end
17
+
18
+ mode 'add' do
19
+ argument('repo') {
20
+ required
21
+ synopsis 'repo'
22
+ description 'Path to dot files repository'
23
+ }
24
+
25
+ def run()
26
+ repo = params['repo'].value
27
+ result = Just::CLI::Add.new.call(repo)
28
+ if result.success?
29
+ Just::CLI.success "Added #{repo} successfully."
30
+ else
31
+ Just::CLI.error result.value
32
+ end
33
+ end
34
+ end
35
+
36
+ mode 'use' do
37
+ argument('repo') {
38
+ synopsis 'repo'
39
+ required
40
+ description 'Repo to use'
41
+ }
42
+
43
+ argument('aliases') {
44
+ synopsis 'aliases'
45
+ arity -1
46
+ description 'Dot files to use'
47
+ }
48
+
49
+ def run()
50
+ repo = params['repo'].value
51
+ aliases = params['aliases'].values
52
+ result = Just::CLI::Use.new.call(
53
+ username_and_repo: repo,
54
+ aliases: aliases
55
+ )
56
+
57
+ if result.failure?
58
+ errors = result.value.map(&:value)
59
+ Just::CLI.error "The following files were not found:"
60
+ errors.each do |file|
61
+ Just::CLI.error " * #{file}"
62
+ end
63
+ return
64
+ end
65
+
66
+ Just::CLI.success "Now using the following aliases from #{repo}:"
67
+ aliases.each do |file|
68
+ Just::CLI.success " * #{file}"
69
+ end
70
+
71
+ reload_shell!
72
+ end
73
+ end
74
+
75
+ mode 'reset' do
76
+ def run()
77
+ reset
78
+ end
79
+ end
80
+
81
+ mode 'me' do
82
+ def run()
83
+ reset
84
+ end
85
+ end
86
+
87
+ def reset
88
+ Just::CLI::Reset.new.call(nil)
89
+ Just::CLI.success "Just you!"
90
+
91
+ reload_shell!
92
+ end
93
+
94
+ def reload_shell!
95
+ puts ""
96
+ Just::CLI.success "Reloading your shell to reset aliases..."
97
+ exec ENV['SHELL']
98
+ end
99
+
100
+ def run
101
+ help!
102
+ end
103
+ }
@@ -0,0 +1,54 @@
1
+ require 'dry/transaction'
2
+
3
+ module Just
4
+ module CLI
5
+ class Use
6
+ include Dry::Transaction
7
+
8
+ step :expand_file_paths
9
+ step :validate_files_are_present
10
+ step :run
11
+
12
+ def run(username_and_repo:, aliases:, files:)
13
+ File.open(Just.aliases, "w+") do |f|
14
+ files.each do |file|
15
+ f.write ". #{file}\n"
16
+ end
17
+ end
18
+
19
+ Success(
20
+ username_and_repo: username_and_repo,
21
+ aliases: aliases
22
+ )
23
+ end
24
+
25
+ def expand_file_paths(username_and_repo:, aliases:)
26
+ Success(
27
+ username_and_repo: username_and_repo,
28
+ aliases: aliases,
29
+ files: aliases.map do |file|
30
+ Just.path(username_and_repo, file)
31
+ end
32
+ )
33
+ end
34
+
35
+ def validate_files_are_present(username_and_repo:, aliases:, files:)
36
+ missing_files = files.map { |f| validate_file_is_present(f) }.select(&:failure?)
37
+
38
+ return Failure(missing_files) if missing_files.any?
39
+
40
+ Success(
41
+ username_and_repo: username_and_repo,
42
+ aliases: aliases,
43
+ files: files
44
+ )
45
+ end
46
+
47
+ private
48
+
49
+ def validate_file_is_present(f)
50
+ File.exist?(f) ? Success(f) : Failure("#{f} is missing")
51
+ end
52
+ end
53
+ end
54
+ end
@@ -1,3 +1,3 @@
1
1
  module Just
2
- VERSION = "0.1.0"
2
+ VERSION = "1.0.0"
3
3
  end
metadata CHANGED
@@ -1,15 +1,99 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: just
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 1.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ryan Bigg
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-12-21 00:00:00.000000000 Z
11
+ date: 2017-12-22 00:00:00.000000000 Z
12
12
  dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: main
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: 6.2.2
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: 6.2.2
27
+ - !ruby/object:Gem::Dependency
28
+ name: rugged
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: 0.26.0
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: 0.26.0
41
+ - !ruby/object:Gem::Dependency
42
+ name: ruby-progressbar
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: 1.9.0
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: 1.9.0
55
+ - !ruby/object:Gem::Dependency
56
+ name: dry-transaction
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: 0.10.2
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: 0.10.2
69
+ - !ruby/object:Gem::Dependency
70
+ name: dry-monads
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: 0.4.0
76
+ type: :runtime
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: 0.4.0
83
+ - !ruby/object:Gem::Dependency
84
+ name: rainbow
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: 3.0.0
90
+ type: :runtime
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - "~>"
95
+ - !ruby/object:Gem::Version
96
+ version: 3.0.0
13
97
  - !ruby/object:Gem::Dependency
14
98
  name: bundler
15
99
  requirement: !ruby/object:Gem::Requirement
@@ -24,6 +108,20 @@ dependencies:
24
108
  - - "~>"
25
109
  - !ruby/object:Gem::Version
26
110
  version: '1.16'
111
+ - !ruby/object:Gem::Dependency
112
+ name: pry
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - ">="
116
+ - !ruby/object:Gem::Version
117
+ version: '0'
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - ">="
123
+ - !ruby/object:Gem::Version
124
+ version: '0'
27
125
  - !ruby/object:Gem::Dependency
28
126
  name: rake
29
127
  requirement: !ruby/object:Gem::Requirement
@@ -52,6 +150,20 @@ dependencies:
52
150
  - - "~>"
53
151
  - !ruby/object:Gem::Version
54
152
  version: '3.0'
153
+ - !ruby/object:Gem::Dependency
154
+ name: climate_control
155
+ requirement: !ruby/object:Gem::Requirement
156
+ requirements:
157
+ - - "~>"
158
+ - !ruby/object:Gem::Version
159
+ version: 0.2.0
160
+ type: :development
161
+ prerelease: false
162
+ version_requirements: !ruby/object:Gem::Requirement
163
+ requirements:
164
+ - - "~>"
165
+ - !ruby/object:Gem::Version
166
+ version: 0.2.0
55
167
  description: I'm just visiting thanks
56
168
  email:
57
169
  - git@ryanbigg.com
@@ -61,20 +173,27 @@ extensions: []
61
173
  extra_rdoc_files: []
62
174
  files:
63
175
  - ".gitignore"
176
+ - ".gitmodules"
64
177
  - ".rspec"
65
178
  - ".travis.yml"
66
179
  - Gemfile
67
- - Gemfile.lock
180
+ - LICENSE.md
68
181
  - README.md
69
182
  - Rakefile
70
183
  - bin/console
71
184
  - bin/setup
72
185
  - exe/just
73
- - just_visiting.gemspec
186
+ - just.gemspec
74
187
  - lib/just.rb
188
+ - lib/just/cli.rb
189
+ - lib/just/cli/add.rb
190
+ - lib/just/cli/reset.rb
191
+ - lib/just/cli/run.rb
192
+ - lib/just/cli/use.rb
75
193
  - lib/just/version.rb
76
194
  homepage: https://github.com/radar/just
77
- licenses: []
195
+ licenses:
196
+ - MIT
78
197
  metadata:
79
198
  allowed_push_host: https://rubygems.org
80
199
  post_install_message:
@@ -1,35 +0,0 @@
1
- PATH
2
- remote: .
3
- specs:
4
- just (0.1.0)
5
-
6
- GEM
7
- remote: https://rubygems.org/
8
- specs:
9
- diff-lcs (1.3)
10
- rake (10.5.0)
11
- rspec (3.7.0)
12
- rspec-core (~> 3.7.0)
13
- rspec-expectations (~> 3.7.0)
14
- rspec-mocks (~> 3.7.0)
15
- rspec-core (3.7.0)
16
- rspec-support (~> 3.7.0)
17
- rspec-expectations (3.7.0)
18
- diff-lcs (>= 1.2.0, < 2.0)
19
- rspec-support (~> 3.7.0)
20
- rspec-mocks (3.7.0)
21
- diff-lcs (>= 1.2.0, < 2.0)
22
- rspec-support (~> 3.7.0)
23
- rspec-support (3.7.0)
24
-
25
- PLATFORMS
26
- ruby
27
-
28
- DEPENDENCIES
29
- bundler (~> 1.16)
30
- just!
31
- rake (~> 10.0)
32
- rspec (~> 3.0)
33
-
34
- BUNDLED WITH
35
- 1.16.0