boxy 0.1.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: ce72258b164430e416cd87f325064ca8af6956e2
4
+ data.tar.gz: cc283f2206924597fe0852ebfb75a6f8657045dd
5
+ SHA512:
6
+ metadata.gz: 5094b144675398051ffe6d15fed47a7afef1981c78134f87457b362563c6df32c627ee75c57c78c63feccb66ccfc769b0641d6018d4ac76d10766b7f13b51df6
7
+ data.tar.gz: 64d42f51bc09d4f863f1ab202b1866566ab46ba58611d8fb6bad557abdf0b2bc0163b20f28e6cfbf00be9452fcef6227530e0843a7bfc5a677d40bd825b70911
data/.gitignore ADDED
@@ -0,0 +1,15 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
10
+ *.bundle
11
+ *.so
12
+ *.o
13
+ *.a
14
+ mkmf.log
15
+ vendor
@@ -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, ethnicity, 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,8 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in boxy.gemspec
4
+ gemspec
5
+
6
+ gem 'pry'
7
+ gem 'defaulty', github: 'fooheads/defaulty', branch: 'master'
8
+
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2015 Jon-Erling Dahl
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,51 @@
1
+ # Boxy
2
+
3
+ Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/boxy`. To experiment with that code, run `bin/console` for an interactive prompt.
4
+
5
+ TODO: Delete this and the text above, and describe your gem
6
+
7
+ ## Installation
8
+
9
+
10
+ ### First, install some dependencies
11
+
12
+ ```
13
+ xcode-select --install
14
+ ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
15
+
16
+
17
+
18
+
19
+ Add this line to your application's Gemfile:
20
+
21
+ ```ruby
22
+ gem 'boxy'
23
+ ```
24
+
25
+ And then execute:
26
+
27
+ $ bundle
28
+
29
+ Or install it yourself as:
30
+
31
+ $ gem install boxy
32
+
33
+ ## Usage
34
+
35
+ TODO: Write usage instructions here
36
+
37
+ ## Development
38
+
39
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment. Run `bundle exec boxy` to use the gem in this directory, ignoring other installed copies of this gem.
40
+
41
+ To install this gem onto your local machine, run `bundle exec rake install`. 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).
42
+
43
+ ## Contributing
44
+
45
+ Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/boxy. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](contributor-covenant.org) code of conduct.
46
+
47
+
48
+ ## License
49
+
50
+ The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
51
+
data/Rakefile ADDED
@@ -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/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "boxy"
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
data/boxy.gemspec ADDED
@@ -0,0 +1,37 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'boxy/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "boxy"
8
+ spec.version = Boxy::VERSION
9
+ spec.authors = ["Jon-Erling Dahl", "Niclas Nilsson"]
10
+ spec.email = ["jon-erling@fooheads.com", "niclas@fooheads.com"]
11
+
12
+ spec.summary = %q{Automates installation of mac computers}
13
+ spec.homepage = "https://github.com/fooheads/boxy"
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'] = "TODO: Set to 'http://mygemserver.com'"
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 "table_print"
30
+ spec.add_dependency "defaulty"
31
+
32
+ spec.add_development_dependency "bundler", "~> 1.10"
33
+ spec.add_development_dependency "rake", "~> 10.0"
34
+ spec.add_development_dependency "rspec"
35
+
36
+ spec.required_ruby_version = '~> 2.0'
37
+ end
data/exe/boxy ADDED
@@ -0,0 +1,15 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'boxy'
4
+ require 'table_print'
5
+
6
+ unless ARGV.size == 2
7
+ puts "usage: boxy <command> <url>"
8
+ exit -1
9
+ end
10
+
11
+ command, url = ARGV
12
+ case command
13
+ when 'validate' then tp Boxy.validate(Boxy.load_commands(url))
14
+ when 'install' then Boxy.install(Boxy.load_commands(url))
15
+ end
data/lib/boxy.rb ADDED
@@ -0,0 +1,38 @@
1
+ require 'boxy/version'
2
+ require 'boxy/dsl'
3
+ require 'bundler'
4
+
5
+ module Boxy
6
+ def self.load_commands(url)
7
+ Boxy::Dsl.interpret(url).uniq
8
+ end
9
+
10
+ def self.validate(commands)
11
+ commands.map do |command|
12
+ command.valid = !!@@handlers[command.type]
13
+ command
14
+ end
15
+ end
16
+
17
+
18
+ def self.install(commands)
19
+ commands.each do |command|
20
+ handler = @@handlers[command.type]
21
+ Bundler.with_clean_env do
22
+ handler.install(command.name, command.options)
23
+ end
24
+ end
25
+ end
26
+
27
+ def self.register(type, handler)
28
+ @@handlers ||= {}
29
+ @@handlers[type] = handler
30
+ end
31
+ end
32
+
33
+ require 'boxy/brew'
34
+ require 'boxy/brew_cask'
35
+ require 'boxy/defaulty'
36
+ require 'boxy/homesick'
37
+ require 'boxy/luarock'
38
+
data/lib/boxy/brew.rb ADDED
@@ -0,0 +1,20 @@
1
+ module Boxy
2
+ class BrewPackageHandler
3
+ def install(name, options)
4
+ unless formula_installed?(name)
5
+ system "brew install #{name}"
6
+ else
7
+ puts "skipping #{name}, already installed"
8
+ end
9
+ end
10
+
11
+ private
12
+
13
+ def formula_installed?(name)
14
+ `brew list #{name} > /dev/null 2>&1`
15
+ $? == 0
16
+ end
17
+ end
18
+
19
+ Boxy.register(:brew, BrewPackageHandler.new)
20
+ end
@@ -0,0 +1,21 @@
1
+ module Boxy
2
+ class BrewCaskHandler
3
+ def install(name, options)
4
+ unless formula_installed?(name)
5
+ system "brew cask install #{name}"
6
+ else
7
+ puts "skipping #{name}, already installed"
8
+ end
9
+ end
10
+
11
+ private
12
+
13
+ def formula_installed?(name)
14
+ `brew cask list #{name} > /dev/null 2>&1`
15
+ $? == 0
16
+ end
17
+ end
18
+
19
+ Boxy.register(:cask, BrewCaskHandler.new)
20
+ end
21
+
@@ -0,0 +1,4 @@
1
+ module Boxy
2
+ Command = Struct.new(:type, :name, :options, :valid)
3
+ end
4
+
@@ -0,0 +1,16 @@
1
+ require 'defaulty'
2
+
3
+ module Boxy
4
+ class DefaultyHandler
5
+ def install(domain, options)
6
+ defaulty_url = ENV['DEFAULTY_URL'] || 'https://api.github.com/repos/fooheads/osxdefaults/contents/'
7
+ @defaulty ||= Defaulty.load(defaulty_url)
8
+ @defaulty.write(domain, options)
9
+ end
10
+ end
11
+
12
+ Boxy.register(:osx, DefaultyHandler.new)
13
+ end
14
+
15
+
16
+
data/lib/boxy/dsl.rb ADDED
@@ -0,0 +1,56 @@
1
+ require 'open-uri'
2
+ require 'uri'
3
+ require_relative 'command'
4
+
5
+ module Boxy
6
+ class Dsl
7
+ def self.interpret(url)
8
+ Dsl.new(url).send(:interpret)
9
+ end
10
+
11
+ private
12
+
13
+ def initialize(url)
14
+ @url = URI.parse(url.to_s)
15
+ @commands = []
16
+ end
17
+
18
+ def interpret
19
+ instance_eval(open(@url.to_s).read)
20
+ @commands
21
+ end
22
+
23
+ def method_missing(sym, *args)
24
+ add_command(sym, args.shift, args.shift.to_h)
25
+ end
26
+
27
+ def include(path_or_url)
28
+ url = include_url(path_or_url)
29
+ @commands += Dsl.interpret(url)
30
+ end
31
+
32
+ def include_url(url)
33
+ url = URI.parse(url)
34
+ if url.absolute?
35
+ url
36
+ else
37
+ dirname = File.dirname(@url.path)
38
+ path = "#{dirname}/#{url.to_s}"
39
+ include_url = @url.clone
40
+ include_url.path = path
41
+ include_url
42
+ end
43
+ end
44
+
45
+ # This is required to override Kernel.gem
46
+ def gem(name, args = {})
47
+ add_command(:gem, name, args)
48
+ end
49
+
50
+ def add_command(type, name, options)
51
+ @commands << Command.new(type, name, options)
52
+ end
53
+
54
+ end
55
+ end
56
+
@@ -0,0 +1,25 @@
1
+ module Boxy
2
+ class HomesickHandler
3
+ def install(url, options)
4
+ url = URI.parse(url)
5
+ name = File.basename(url.path)
6
+ unless castle_cloned?(name)
7
+ system "homesick clone #{url.to_s}"
8
+ system "homesick symlink #{name}"
9
+ else
10
+ puts "skipping #{name}, already installed"
11
+ end
12
+ end
13
+
14
+ private
15
+
16
+ def castle_cloned?(name)
17
+ `homesick status #{name} > /dev/null 2>&1`
18
+ $? == 0
19
+ end
20
+ end
21
+
22
+ Boxy.register(:homesick, HomesickHandler.new)
23
+ end
24
+
25
+
@@ -0,0 +1,23 @@
1
+ module Boxy
2
+ class LuarockHandler
3
+ def install(name, options)
4
+ unless luarock_installed?(name)
5
+ system "luarocks install #{name}"
6
+ else
7
+ puts "skipping #{name}, already installed"
8
+ end
9
+ end
10
+
11
+ private
12
+
13
+ def luarock_installed?(name)
14
+ `luarocks show #{name} > /dev/null 2>&1`
15
+ $? == 0
16
+ end
17
+ end
18
+
19
+ Boxy.register(:luarock, LuarockHandler.new)
20
+ end
21
+
22
+
23
+
@@ -0,0 +1,3 @@
1
+ module Boxy
2
+ VERSION = "0.1.0"
3
+ end
metadata ADDED
@@ -0,0 +1,137 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: boxy
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Jon-Erling Dahl
8
+ - Niclas Nilsson
9
+ autorequire:
10
+ bindir: exe
11
+ cert_chain: []
12
+ date: 2016-02-11 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: table_print
16
+ requirement: !ruby/object:Gem::Requirement
17
+ requirements:
18
+ - - '>='
19
+ - !ruby/object:Gem::Version
20
+ version: '0'
21
+ type: :runtime
22
+ prerelease: false
23
+ version_requirements: !ruby/object:Gem::Requirement
24
+ requirements:
25
+ - - '>='
26
+ - !ruby/object:Gem::Version
27
+ version: '0'
28
+ - !ruby/object:Gem::Dependency
29
+ name: defaulty
30
+ requirement: !ruby/object:Gem::Requirement
31
+ requirements:
32
+ - - '>='
33
+ - !ruby/object:Gem::Version
34
+ version: '0'
35
+ type: :runtime
36
+ prerelease: false
37
+ version_requirements: !ruby/object:Gem::Requirement
38
+ requirements:
39
+ - - '>='
40
+ - !ruby/object:Gem::Version
41
+ version: '0'
42
+ - !ruby/object:Gem::Dependency
43
+ name: bundler
44
+ requirement: !ruby/object:Gem::Requirement
45
+ requirements:
46
+ - - ~>
47
+ - !ruby/object:Gem::Version
48
+ version: '1.10'
49
+ type: :development
50
+ prerelease: false
51
+ version_requirements: !ruby/object:Gem::Requirement
52
+ requirements:
53
+ - - ~>
54
+ - !ruby/object:Gem::Version
55
+ version: '1.10'
56
+ - !ruby/object:Gem::Dependency
57
+ name: rake
58
+ requirement: !ruby/object:Gem::Requirement
59
+ requirements:
60
+ - - ~>
61
+ - !ruby/object:Gem::Version
62
+ version: '10.0'
63
+ type: :development
64
+ prerelease: false
65
+ version_requirements: !ruby/object:Gem::Requirement
66
+ requirements:
67
+ - - ~>
68
+ - !ruby/object:Gem::Version
69
+ version: '10.0'
70
+ - !ruby/object:Gem::Dependency
71
+ name: rspec
72
+ requirement: !ruby/object:Gem::Requirement
73
+ requirements:
74
+ - - '>='
75
+ - !ruby/object:Gem::Version
76
+ version: '0'
77
+ type: :development
78
+ prerelease: false
79
+ version_requirements: !ruby/object:Gem::Requirement
80
+ requirements:
81
+ - - '>='
82
+ - !ruby/object:Gem::Version
83
+ version: '0'
84
+ description:
85
+ email:
86
+ - jon-erling@fooheads.com
87
+ - niclas@fooheads.com
88
+ executables:
89
+ - boxy
90
+ extensions: []
91
+ extra_rdoc_files: []
92
+ files:
93
+ - .gitignore
94
+ - CODE_OF_CONDUCT.md
95
+ - Gemfile
96
+ - LICENSE.txt
97
+ - README.md
98
+ - Rakefile
99
+ - bin/console
100
+ - bin/setup
101
+ - boxy.gemspec
102
+ - exe/boxy
103
+ - lib/boxy.rb
104
+ - lib/boxy/brew.rb
105
+ - lib/boxy/brew_cask.rb
106
+ - lib/boxy/command.rb
107
+ - lib/boxy/defaulty.rb
108
+ - lib/boxy/dsl.rb
109
+ - lib/boxy/homesick.rb
110
+ - lib/boxy/luarock.rb
111
+ - lib/boxy/version.rb
112
+ homepage: https://github.com/fooheads/boxy
113
+ licenses:
114
+ - MIT
115
+ metadata:
116
+ allowed_push_host: 'TODO: Set to ''http://mygemserver.com'''
117
+ post_install_message:
118
+ rdoc_options: []
119
+ require_paths:
120
+ - lib
121
+ required_ruby_version: !ruby/object:Gem::Requirement
122
+ requirements:
123
+ - - ~>
124
+ - !ruby/object:Gem::Version
125
+ version: '2.0'
126
+ required_rubygems_version: !ruby/object:Gem::Requirement
127
+ requirements:
128
+ - - '>='
129
+ - !ruby/object:Gem::Version
130
+ version: '0'
131
+ requirements: []
132
+ rubyforge_project:
133
+ rubygems_version: 2.0.14
134
+ signing_key:
135
+ specification_version: 4
136
+ summary: Automates installation of mac computers
137
+ test_files: []