docks 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.1
1
+ 0.0.2
data/bin/docks_build ADDED
@@ -0,0 +1,7 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ load File.expand_path(File.dirname(__FILE__)+"/../lib/docks.rb")
4
+
5
+ dir = ARGV[-1]
6
+ ops_str = ARGV[0..-2].join(" ")
7
+ body = Docks.build "#{dir}/Dockerfile",ops_str
data/bin/docks_parse ADDED
@@ -0,0 +1,6 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ load File.expand_path(File.dirname(__FILE__)+"/../lib/docks.rb")
4
+
5
+ file = ARGV[0]
6
+ print Docks.parsed(file)
data/docks.gemspec CHANGED
@@ -5,13 +5,14 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = "docks"
8
- s.version = "0.0.1"
8
+ s.version = "0.0.2"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Mike Harris"]
12
12
  s.date = "2013-07-10"
13
13
  s.description = "docks"
14
14
  s.email = "mharris717@gmail.com"
15
+ s.executables = ["docks_build", "docks_parse"]
15
16
  s.extra_rdoc_files = [
16
17
  "LICENSE.txt",
17
18
  "README.rdoc"
@@ -25,14 +26,17 @@ Gem::Specification.new do |s|
25
26
  "README.rdoc",
26
27
  "Rakefile",
27
28
  "VERSION",
29
+ "bin/docks_build",
30
+ "bin/docks_parse",
28
31
  "defs/mharris717.yml",
29
32
  "dockerfiles/rubybuild_rails",
30
33
  "docks.gemspec",
31
34
  "lib/docks.rb",
35
+ "lib/docks/build.rb",
32
36
  "lib/docks/line.rb",
33
37
  "lib/docks/list.rb",
34
38
  "lib/docks/parser.rb",
35
- "spec/data/Basic.dock",
39
+ "spec/data/basic/Dockerfile",
36
40
  "spec/docks_spec.rb",
37
41
  "spec/spec_helper.rb"
38
42
  ]
data/lib/docks.rb CHANGED
@@ -1,8 +1,9 @@
1
1
  require 'yaml'
2
2
  require 'mharris_ext'
3
3
  require 'open-uri'
4
+ require 'fileutils'
4
5
 
5
- %w(list parser line).each do |f|
6
+ %w(list parser line build).each do |f|
6
7
  load File.expand_path(File.dirname(__FILE__))+"/docks/#{f}.rb"
7
8
  end
8
9
 
@@ -12,5 +13,8 @@ module Docks
12
13
  parser = Parser.new(:filename => file, :list => List.new)
13
14
  parser.to_s
14
15
  end
16
+ def build(file,ops_str)
17
+ Build.new(:filename => file, :ops_str => ops_str).build!
18
+ end
15
19
  end
16
20
  end
@@ -0,0 +1,19 @@
1
+ module Docks
2
+ class Build
3
+ include FromHash
4
+ attr_accessor :filename, :ops_str
5
+ fattr(:temp_dir) do
6
+ res = "/tmp/docks_#{rand(100000000000000)}"
7
+ FileUtils.mkdir res
8
+ res
9
+ end
10
+ def build!
11
+ parsed = Docks.parsed(filename)
12
+ File.create "#{temp_dir}/Dockerfile",parsed
13
+
14
+ cmd = "docker build #{ops_str} #{temp_dir}"
15
+ puts cmd
16
+ exec cmd unless ops_str.to_s =~ /--mock/
17
+ end
18
+ end
19
+ end
data/lib/docks/list.rb CHANGED
@@ -15,12 +15,17 @@ module Docks
15
15
  handle_yaml_hash(from_yaml)
16
16
  end
17
17
 
18
+ def get_remote_path(path)
19
+ dir = "https://raw.github.com/mharris717/docks/master/dockerfiles"
20
+ "#{dir}/#{path}"
21
+ end
22
+
18
23
  def expand_dock_path(path)
19
24
  if path =~ /http/i
20
25
  path
21
26
  else
22
- dir = File.expand_path(File.dirname(__FILE__)+"/../../dockerfiles")
23
- "#{dir}/#{path}"
27
+
28
+ get_remote_path path
24
29
  end
25
30
  end
26
31
 
File without changes
data/spec/docks_spec.rb CHANGED
@@ -6,7 +6,7 @@ describe "Docks" do
6
6
  end
7
7
 
8
8
  it 'basic' do
9
- file = File.dirname(__FILE__)+"/data/Basic.dock"
9
+ file = File.dirname(__FILE__)+"/data/basic/Dockerfile"
10
10
  Docks.parsed(file).should =~ /gem install bundler/
11
11
  end
12
12
  end
data/spec/spec_helper.rb CHANGED
@@ -10,3 +10,10 @@ Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each {|f| require f}
10
10
  RSpec.configure do |config|
11
11
 
12
12
  end
13
+
14
+ Docks::List.class_eval do
15
+ def get_remote_path(path)
16
+ dir = File.expand_path(File.dirname(__FILE__)+"/../dockerfiles")
17
+ "#{dir}/#{path}"
18
+ end
19
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: docks
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -93,7 +93,9 @@ dependencies:
93
93
  version: 1.8.4
94
94
  description: docks
95
95
  email: mharris717@gmail.com
96
- executables: []
96
+ executables:
97
+ - docks_build
98
+ - docks_parse
97
99
  extensions: []
98
100
  extra_rdoc_files:
99
101
  - LICENSE.txt
@@ -107,14 +109,17 @@ files:
107
109
  - README.rdoc
108
110
  - Rakefile
109
111
  - VERSION
112
+ - bin/docks_build
113
+ - bin/docks_parse
110
114
  - defs/mharris717.yml
111
115
  - dockerfiles/rubybuild_rails
112
116
  - docks.gemspec
113
117
  - lib/docks.rb
118
+ - lib/docks/build.rb
114
119
  - lib/docks/line.rb
115
120
  - lib/docks/list.rb
116
121
  - lib/docks/parser.rb
117
- - spec/data/Basic.dock
122
+ - spec/data/basic/Dockerfile
118
123
  - spec/docks_spec.rb
119
124
  - spec/spec_helper.rb
120
125
  homepage: http://github.com/mharris717/docks
@@ -132,7 +137,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
132
137
  version: '0'
133
138
  segments:
134
139
  - 0
135
- hash: -2932652095204847182
140
+ hash: -63376217560962158
136
141
  required_rubygems_version: !ruby/object:Gem::Requirement
137
142
  none: false
138
143
  requirements: