vintner 1.0

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore ADDED
@@ -0,0 +1,17 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ .DS_Store
7
+ Gemfile.lock
8
+ InstalledFiles
9
+ _yardoc
10
+ coverage
11
+ doc/
12
+ lib/bundler/man
13
+ pkg
14
+ rdoc
15
+ spec/reports
16
+ test
17
+ tmp
data/CHANGELOG.md ADDED
@@ -0,0 +1,2 @@
1
+ ## 1.0
2
+ * First release
data/Gemfile ADDED
@@ -0,0 +1,3 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gemspec
data/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2012 Oame
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,35 @@
1
+ # Vintner
2
+
3
+ Winemaker for Homebrew.
4
+
5
+ ## Installation
6
+
7
+ gem install vintner
8
+
9
+ ## Usage
10
+
11
+ Run following command to create sample of Brewfile!
12
+
13
+ $ vintner init
14
+
15
+ then edit `Brewfile`
16
+
17
+ brew "mecab"
18
+ brew "cabocha, :url => "https://raw.github.com/oame/homebrew/master/Library/Formula/cabocha.rb"
19
+
20
+ run `vintner install` or `vintner` to install all of dependencies!
21
+
22
+ $ vintner install
23
+ Installing mecab ...
24
+ Using cabocha (0.64)
25
+ All of formula in Brewfile is installed!
26
+
27
+ Finish!
28
+
29
+ ## Contributing
30
+
31
+ 1. Fork it
32
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
33
+ 3. Commit your changes (`git commit -am 'Added some feature'`)
34
+ 4. Push to the branch (`git push origin my-new-feature`)
35
+ 5. Create new Pull Request
data/Rakefile ADDED
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env rake
2
+ require "bundler/gem_tasks"
data/bin/vintner ADDED
@@ -0,0 +1,69 @@
1
+ #!/usr/bin/env ruby
2
+ # coding: utf-8
3
+
4
+ require "vintner"
5
+ require "optparse"
6
+ require "pp"
7
+
8
+ class String
9
+ def undent
10
+ gsub /^.{#{slice(/^ +/).length}}/, ''
11
+ end
12
+ end
13
+
14
+ def help
15
+ puts <<-EOD.undent
16
+ Usage: vintner [OPTIONS]
17
+
18
+ options:
19
+ -h, --help\tShow help
20
+ -v, --version\tShow version
21
+
22
+ commands:
23
+ init\tCreate Vintner template file
24
+ install\tInstall formula
25
+ EOD
26
+ end
27
+
28
+ def install(brewfile)
29
+ unless File.exists?(brewfile)
30
+ puts "Brewfile not found"
31
+ exit 1
32
+ end
33
+ parser = Vintner::Parser.new
34
+ parser.parse(brewfile)
35
+ end
36
+
37
+ OptionParser.new do |opts|
38
+ opts.on("-h", "--help") do
39
+ display_help
40
+ exit
41
+ end
42
+ opts.on("-v", "--version") do
43
+ puts "Vintner #{Vintner::VERSION}"
44
+ exit
45
+ end
46
+ opts.parse!(ARGV)
47
+ end
48
+
49
+ command, args = ARGV
50
+ case command
51
+ when "install"
52
+ brewfile = args ? File.expand_path(args) : File.join(Dir.pwd, "Brewfile")
53
+ install(brewfile)
54
+ when "init"
55
+ File.open(File.join(Dir.pwd, "Brewfile"), "w") do |f|
56
+ f.puts <<-EOD.undent
57
+ # Brewfile is created by Vintner(Winemaker)
58
+ # https://github.com/oame/vintner
59
+
60
+ brew "nihonshu"
61
+ brew "sake", :url => "http://example.com"
62
+ EOD
63
+ end
64
+ puts "Finish create Brewfile on current directory!"
65
+ else
66
+ brewfile = File.join(Dir.pwd, "Brewfile")
67
+ install(brewfile)
68
+ end
69
+
@@ -0,0 +1,47 @@
1
+ module Vintner
2
+ class Parser
3
+
4
+ def initialize
5
+
6
+ end
7
+
8
+ protected
9
+ def installed?(name)
10
+ installed = `brew list #{name} -v`.split(/\s/)
11
+ if installed.size > 0
12
+ return installed.last
13
+ end
14
+ end
15
+
16
+ def install(name, args={})
17
+ brewable = `brew info #{name}`
18
+ if brewable =~ /^Error:/
19
+ puts "Error: No available formula for #{name}"
20
+ exit 1
21
+ end
22
+ if args[:url]
23
+ system "brew install #{args[:url]} >& /dev/null"
24
+ else
25
+ system "brew install #{name} >& /dev/null"
26
+ end
27
+ end
28
+
29
+ def brew(formula, args={})
30
+ installed_version = installed?(formula)
31
+ puts "#{installed_version ? "Using" : "Installing"} #{formula} #{installed_version ? "(#{installed_version})" : "..."}"
32
+ install(formula, args) unless installed_version
33
+ end
34
+
35
+ public
36
+ def parse(brewfile)
37
+ begin
38
+ eval(File.open(brewfile).read)
39
+ puts "All of formula in Brewfile is installed!"
40
+ rescue => e
41
+ puts e
42
+ exit 1
43
+ end
44
+ end
45
+
46
+ end
47
+ end
@@ -0,0 +1,3 @@
1
+ module Vintner
2
+ VERSION = "1.0"
3
+ end
data/lib/vintner.rb ADDED
@@ -0,0 +1,9 @@
1
+ # coding: utf-8
2
+
3
+ $LOAD_PATH.unshift(File.expand_path("../", __FILE__))
4
+ require "vintner/version"
5
+ require "vintner/parser"
6
+
7
+ module Vintner
8
+
9
+ end
data/vintner.gemspec ADDED
@@ -0,0 +1,17 @@
1
+ # -*- encoding: utf-8 -*-
2
+ require File.expand_path('../lib/vintner/version', __FILE__)
3
+
4
+ Gem::Specification.new do |gem|
5
+ gem.authors = ["Oame"]
6
+ gem.email = ["oame@oameya.com"]
7
+ gem.description = %q{Winemaker for Homebrew}
8
+ gem.summary = %q{Winemaker for Homebrew}
9
+ gem.homepage = ""
10
+
11
+ gem.files = `git ls-files`.split($\)
12
+ gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
13
+ gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
14
+ gem.name = "vintner"
15
+ gem.require_paths = ["lib"]
16
+ gem.version = Vintner::VERSION
17
+ end
metadata ADDED
@@ -0,0 +1,58 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: vintner
3
+ version: !ruby/object:Gem::Version
4
+ version: '1.0'
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Oame
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2012-07-15 00:00:00.000000000Z
13
+ dependencies: []
14
+ description: Winemaker for Homebrew
15
+ email:
16
+ - oame@oameya.com
17
+ executables:
18
+ - vintner
19
+ extensions: []
20
+ extra_rdoc_files: []
21
+ files:
22
+ - .gitignore
23
+ - CHANGELOG.md
24
+ - Gemfile
25
+ - LICENSE
26
+ - README.md
27
+ - Rakefile
28
+ - bin/vintner
29
+ - lib/vintner.rb
30
+ - lib/vintner/parser.rb
31
+ - lib/vintner/version.rb
32
+ - vintner.gemspec
33
+ homepage: ''
34
+ licenses: []
35
+ post_install_message:
36
+ rdoc_options: []
37
+ require_paths:
38
+ - lib
39
+ required_ruby_version: !ruby/object:Gem::Requirement
40
+ none: false
41
+ requirements:
42
+ - - ! '>='
43
+ - !ruby/object:Gem::Version
44
+ version: '0'
45
+ required_rubygems_version: !ruby/object:Gem::Requirement
46
+ none: false
47
+ requirements:
48
+ - - ! '>='
49
+ - !ruby/object:Gem::Version
50
+ version: '0'
51
+ requirements: []
52
+ rubyforge_project:
53
+ rubygems_version: 1.8.10
54
+ signing_key:
55
+ specification_version: 3
56
+ summary: Winemaker for Homebrew
57
+ test_files: []
58
+ has_rdoc: