futon 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: ee8b676e504965628715f32448275b47a4944646
4
+ data.tar.gz: 7006828766f6c919195f556e011c27c9ac02c2a9
5
+ SHA512:
6
+ metadata.gz: a7bbec206f5c280159086bb76cb6da58e025172c4d7bb4cbf8d0add01817e9f53c04599ae592f1c63f193e6d11faf4dec5d8dc6d14a500153b35da962f80c986
7
+ data.tar.gz: f13828c4d78ce649c04e3cc014b7e96058181a8cacd8a6cb53ed1dee3decb4aa633208083b429fd2973022f74c9eb53e61a313ea67f6b9894f930e9fc14e79c1
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2016 Cezary Baginski
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.
@@ -0,0 +1,72 @@
1
+ # Futon
2
+
3
+ Restore/wrap up your repositories and workspaces like a futon.
4
+
5
+ Restore only repositories/workspaces you need to work on. Safely delete or wrap up anything else.
6
+
7
+ ## Why a new project?
8
+
9
+ - [Puppet](puppetlabs.com) is for servers, not developers (it clobbers repositories or needs complex custom modules)
10
+ - [Repo] (https://source.android.com/source/using-repo.html) is for related repositories and extending it is troublesome
11
+ - [myrepos](http://myrepos.branchable.com/) is close (!), except it emphasises push/pull on multiple repositories, while futon is more about backup/restore/"safely-implode"
12
+ - [git-sweep](https://github.com/arc90/git-sweep) only cleans up a repo, no backup, no restore, no switching between sets of projects
13
+ - dotfiles managers - mostly only for retrieving and updating, not many storage options
14
+ - custom shell scripts - we all know what happens with them...
15
+
16
+ ## Installation
17
+
18
+ $ gem install futon
19
+
20
+ ## Usage
21
+
22
+ Create a `~/.futon/default.yml` with a configuration like this:
23
+
24
+ ```
25
+ ---
26
+ :workspaces:
27
+ myproject1:
28
+ :directory: '/home/user/workspace/myproject1'
29
+ :source:
30
+ type: :git
31
+ :url: "https://example.org/myproject.git"
32
+ ```
33
+
34
+ And run `futon` to restore those defined projects.
35
+
36
+
37
+ ## Features
38
+
39
+ - [x] Restore git workspace from global ~/.futon/default.yml
40
+ - [x] Project ready for heavy development (RSpec tests, Guard, RuboCop, Docker acceptance test)
41
+ - [x] Initial gem release
42
+ - [ ] Per-project settings
43
+ - [ ] Alternative config file on command line
44
+ - [ ] "Unrestore" repo (safely remove if full backup is available)
45
+ - [ ] Tagging and switching whole sets on/off
46
+ - [ ] smart "out of sight" git repo cache for fast checkouts/updates
47
+ - [ ] Support S3 providers (with IAM auth)
48
+ - [ ] Support for tarball/gpg/ssh/rsync providers
49
+ - [ ] "Fetch" command on specified sets of repos
50
+ - [ ] Support mixed backup when files are modified, stashed or in local branches
51
+
52
+ These will likely be added soon, though PRs and issues reports are welcome if you can't wait!
53
+
54
+ ## Development
55
+
56
+ After checking out the repo, run `bin/setup` to install dependencies.
57
+ Then, run `rake spec` to run the tests.
58
+ For TDD/BDD workflow, run `bin/guard`.
59
+ You can also run `bin/console` for an interactive prompt that will allow you to experiment.
60
+
61
+ To install this gem onto your local machine, run `bundle exec rake install`.
62
+ To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
63
+
64
+ ## Contributing
65
+
66
+ Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/futon.
67
+
68
+
69
+ ## License
70
+
71
+ The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
72
+
@@ -0,0 +1,5 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'futon/cli'
4
+
5
+ Futon::Cli.new(ARGV).execute!
@@ -0,0 +1,3 @@
1
+ require 'futon/version'
2
+ module Futon
3
+ end
@@ -0,0 +1,14 @@
1
+ require 'futon/configuration'
2
+ require 'futon/workspace'
3
+
4
+ module Futon
5
+ class Cli
6
+ def initialize(_argv)
7
+ @config = Configuration.new
8
+ end
9
+
10
+ def execute!
11
+ @config.workspaces.map(&:setup)
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,42 @@
1
+ require 'futon/workspace'
2
+ require 'yaml'
3
+
4
+ module Futon
5
+ class Configuration
6
+ class Error < RuntimeError
7
+ class NoWorkspaces < Error
8
+ end
9
+ end
10
+
11
+ def initialize
12
+ options = load_from(default_config_file)
13
+
14
+ @workspaces = setup_workspaces(options)
15
+ end
16
+
17
+ attr_reader :workspaces
18
+
19
+ private
20
+
21
+ def load_from(filename)
22
+ YAML.load_file(filename)
23
+ end
24
+
25
+ def default_config_file
26
+ File.expand_path('~/.futon/default.yml')
27
+ end
28
+
29
+ def setup_workspaces(options)
30
+ msg = 'expected valid config, got %s'
31
+ raise Error::NoWorkspaces, format(msg, options.inspect) unless options
32
+
33
+ workspaces = options.fetch(:workspaces)
34
+ workspaces.map do |name, workspace_options|
35
+ Workspace.new(workspace_options.merge(name: name))
36
+ end
37
+
38
+ rescue KeyError => e
39
+ raise Error::NoWorkspaces, e.message
40
+ end
41
+ end
42
+ end
@@ -0,0 +1,7 @@
1
+ module Futon
2
+ class Os
3
+ def self.system(*args)
4
+ Kernel.system(*args)
5
+ end
6
+ end
7
+ end
@@ -0,0 +1,26 @@
1
+ require 'futon/workspace/provider/git'
2
+
3
+ module Futon
4
+ class Workspace
5
+ class Error < RuntimeError
6
+ class MissingSource < Error
7
+ end
8
+ end
9
+
10
+ def initialize(options)
11
+ source = options.fetch(:source) { raise Error::MissingSource }
12
+ @provider = Provider::Git.new(source)
13
+ @directory = File.expand_path(options.fetch(:directory))
14
+ end
15
+
16
+ def setup
17
+ provider.provide(directory)
18
+ end
19
+
20
+ private
21
+
22
+ attr_reader :directory
23
+
24
+ attr_reader :provider
25
+ end
26
+ end
@@ -0,0 +1,8 @@
1
+ module Futon
2
+ class Workspace
3
+ class Provider
4
+ class Error < RuntimeError
5
+ end
6
+ end
7
+ end
8
+ end
@@ -0,0 +1,33 @@
1
+ require 'futon/os'
2
+ require 'futon/workspace/provider'
3
+
4
+ module Futon
5
+ class Workspace
6
+ class Provider
7
+ class Git < Provider
8
+ class Error < Provider::Error
9
+ class CloneFailed < Error
10
+ end
11
+ end
12
+
13
+ def initialize(options)
14
+ @url = options.fetch(:url)
15
+ end
16
+
17
+ def provide(directory)
18
+ args = %W(git clone #{url} #{directory})
19
+ result = Os.system(*args)
20
+ return if result == true
21
+
22
+ info = result.nil? ? '(exec failed)' : $CHILD_STATUS.to_s
23
+ msg = "command failed [%s]: '%s'"
24
+ raise Error::CloneFailed, format(msg, info, args.join(' '))
25
+ end
26
+
27
+ private
28
+
29
+ attr_reader :url
30
+ end
31
+ end
32
+ end
33
+ end
metadata ADDED
@@ -0,0 +1,98 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: futon
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Cezary Baginski
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2016-05-30 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: nenv
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '0.3'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '0.3'
27
+ - !ruby/object:Gem::Dependency
28
+ name: bundler
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '1.11'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '1.11'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rake
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '11.1'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '11.1'
55
+ description: Restores/backups your repositories/workspaces based on what you need
56
+ right now
57
+ email:
58
+ - cezary@chronomantic.net
59
+ executables:
60
+ - futon
61
+ extensions: []
62
+ extra_rdoc_files: []
63
+ files:
64
+ - LICENSE.txt
65
+ - README.md
66
+ - exe/futon
67
+ - lib/futon.rb
68
+ - lib/futon/cli.rb
69
+ - lib/futon/configuration.rb
70
+ - lib/futon/os.rb
71
+ - lib/futon/workspace.rb
72
+ - lib/futon/workspace/provider.rb
73
+ - lib/futon/workspace/provider/git.rb
74
+ homepage: http://github.com/e2/futon
75
+ licenses:
76
+ - MIT
77
+ metadata: {}
78
+ post_install_message:
79
+ rdoc_options: []
80
+ require_paths:
81
+ - lib
82
+ required_ruby_version: !ruby/object:Gem::Requirement
83
+ requirements:
84
+ - - ">="
85
+ - !ruby/object:Gem::Version
86
+ version: '0'
87
+ required_rubygems_version: !ruby/object:Gem::Requirement
88
+ requirements:
89
+ - - ">="
90
+ - !ruby/object:Gem::Version
91
+ version: '0'
92
+ requirements: []
93
+ rubyforge_project:
94
+ rubygems_version: 2.6.4
95
+ signing_key:
96
+ specification_version: 4
97
+ summary: Makes your workspaces like a futon
98
+ test_files: []