filander 0.2.0 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
data/lib/filander.rb CHANGED
@@ -7,6 +7,7 @@ require 'filander/actions/create_file'
7
7
  require 'filander/actions/empty_directory'
8
8
  require 'filander/actions/inject_into_file'
9
9
  require 'filander/actions/inside'
10
+ require 'filander/actions/install_gem'
10
11
  require 'filander/actions/template'
11
12
 
12
13
  module Filander
@@ -73,5 +74,6 @@ module Filander
73
74
  include EmptyDirectory
74
75
  include InjectIntoFile
75
76
  include Inside
77
+ include InstallGem
76
78
  include Template
77
79
  end
@@ -77,7 +77,6 @@ module Filander
77
77
  name = filename
78
78
  end
79
79
 
80
- # left: cyan
81
80
  color = case verb
82
81
  when :create
83
82
  :green
@@ -87,6 +86,8 @@ module Filander
87
86
  :red
88
87
  when :execute
89
88
  :magenta
89
+ when :install
90
+ :cyan
90
91
  else
91
92
  :blue
92
93
  end
@@ -0,0 +1,25 @@
1
+ module Filander
2
+ module InstallGem
3
+ include Base
4
+
5
+ def install_gem(name, version = nil)
6
+ if version
7
+ gem_args = [name, version]
8
+ gem_install_args = "-v=#{version} #{name}"
9
+ report_name = "#{name} #{version}"
10
+ else
11
+ gem_args = [name]
12
+ gem_install_args = name
13
+ report_name = name
14
+ end
15
+ report :install, report_name
16
+ unless Filander.behavior == :pretend
17
+ begin
18
+ gem *gem_args
19
+ rescue => Gem::LoadError
20
+ cmd "gem install #{gem_install_args}"
21
+ end
22
+ end
23
+ end
24
+ end
25
+ end
metadata CHANGED
@@ -4,9 +4,9 @@ version: !ruby/object:Gem::Version
4
4
  prerelease: false
5
5
  segments:
6
6
  - 0
7
- - 2
7
+ - 3
8
8
  - 0
9
- version: 0.2.0
9
+ version: 0.3.0
10
10
  platform: ruby
11
11
  authors:
12
12
  - Johannes J. Schmidt
@@ -50,6 +50,7 @@ files:
50
50
  - lib/filander/actions/empty_directory.rb
51
51
  - lib/filander/actions/inject_into_file.rb
52
52
  - lib/filander/actions/inside.rb
53
+ - lib/filander/actions/install_gem.rb
53
54
  - lib/filander/actions/template.rb
54
55
  - LICENSE
55
56
  - README.rdoc