figs 1.2.2 → 1.2.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -4,6 +4,7 @@ require "yaml"
4
4
  require "figs/error"
5
5
  require "figs/env"
6
6
  require "figs/git_handler"
7
+ require "figs/directory_flattener"
7
8
 
8
9
  module Figs
9
10
  class Application
@@ -23,11 +24,15 @@ module Figs
23
24
  figfile["locations"]
24
25
  end
25
26
 
27
+ def flattened_filenames(filenames)
28
+ Figs::DirectoryFlattener.flattened_filenames(filenames)
29
+ end
30
+
26
31
  def load_path
27
32
  if figfile["method"].eql? "git"
28
- @path = path_from_git(figfile["repo"], figfile["locations"])
33
+ @path = path_from_git(figfile["repo"], flattened_filenames(figfile["locations"]))
29
34
  else
30
- @path = figfile["locations"]
35
+ @path = flattened_filenames(figfile["locations"])
31
36
  end
32
37
  end
33
38
 
@@ -0,0 +1,19 @@
1
+ module Figs
2
+ module DirectoryFlattener
3
+ extend self
4
+ def flattened_filenames filenames
5
+ return filenames if !filenames.is_a?(Array)
6
+ names = []
7
+ filenames.each do |filename|
8
+ Dir.exists?(filename) ? names << directory_to_filenames(filename) : names << filename
9
+ end
10
+ names.flatten
11
+ end
12
+ private
13
+ def directory_to_filenames file
14
+ arr = []
15
+ Dir.exists?(file) ? Dir.foreach(file) {|s| arr << directory_to_filenames("#{file}/#{s}") unless (s =='.' || s == '..')} : arr << file if File.exists?(file)
16
+ arr
17
+ end
18
+ end
19
+ end
data/lib/figs/env.rb CHANGED
@@ -1,4 +1,3 @@
1
- require 'hashie'
2
1
  module Figs
3
2
  module ENV
4
3
  extend self
@@ -1,5 +1,6 @@
1
1
  require "git"
2
2
 
3
+ require "figs/directory_flattener"
3
4
  module Figs
4
5
  module GitHandler
5
6
  extend self
@@ -8,7 +9,7 @@ module Figs
8
9
  def location(gitpath, filenames)
9
10
  @temp_files = []
10
11
  git_clone gitpath
11
- temp_filenames(([]<< filenames).flatten)
12
+ temp_filenames(([]<< Figs::DirectoryFlattener.flattened_filenames(filenames.collect {|filename| "#{TMP_GIT_DIR}#{filename}"})).flatten)
12
13
  rescue Exception => e
13
14
  p e
14
15
  clear_tmp_dir
@@ -32,7 +33,7 @@ module Figs
32
33
  def copy_to_temp_files(filename)
33
34
  temp_file = Tempfile.new("#{filename.gsub('/','-')}")
34
35
  temp_file.open
35
- temp_file.write(File.open("#{TMP_GIT_DIR}#{filename}").read)
36
+ temp_file.write(File.open("#{filename}").read)
36
37
  temp_file.flush
37
38
  @temp_files << temp_file
38
39
  temp_file.path
@@ -23,7 +23,7 @@ end
23
23
 
24
24
  def create_non_existent_yaml(locations)
25
25
  locations.each do |file|
26
- if !File.exists?(file)
26
+ if !File.exists?(file) && !Dir.exists?(file)
27
27
  puts "[Add] #{file} does not exist, creating."
28
28
  application_yml = File.expand_path("../../templates/application.yml", __FILE__)
29
29
  File.open(file, 'w+') do |f|
data/lib/figs/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Figs
2
- VERSION = "1.2.2"
2
+ VERSION = "1.2.3"
3
3
  end
data/lib/figs.rb CHANGED
@@ -1,6 +1,7 @@
1
1
  require "figs/application"
2
2
  require "figs/env"
3
3
  require "figs/figfile"
4
+ require "figs/directory_flattener"
4
5
 
5
6
  module Figs
6
7
  extend self
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: figs
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.2
4
+ version: 1.2.3
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -27,22 +27,6 @@ dependencies:
27
27
  - - ~>
28
28
  - !ruby/object:Gem::Version
29
29
  version: '10.1'
30
- - !ruby/object:Gem::Dependency
31
- name: hashie
32
- requirement: !ruby/object:Gem::Requirement
33
- none: false
34
- requirements:
35
- - - ~>
36
- - !ruby/object:Gem::Version
37
- version: 2.0.5
38
- type: :runtime
39
- prerelease: false
40
- version_requirements: !ruby/object:Gem::Requirement
41
- none: false
42
- requirements:
43
- - - ~>
44
- - !ruby/object:Gem::Version
45
- version: 2.0.5
46
30
  - !ruby/object:Gem::Dependency
47
31
  name: git
48
32
  requirement: !ruby/object:Gem::Requirement
@@ -67,6 +51,7 @@ extensions: []
67
51
  extra_rdoc_files: []
68
52
  files:
69
53
  - lib/figs/application.rb
54
+ - lib/figs/directory_flattener.rb
70
55
  - lib/figs/env.rb
71
56
  - lib/figs/error.rb
72
57
  - lib/figs/figfile.rb
@@ -95,7 +80,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
95
80
  version: '0'
96
81
  segments:
97
82
  - 0
98
- hash: -228231686379995656
83
+ hash: 4152814583514099244
99
84
  required_rubygems_version: !ruby/object:Gem::Requirement
100
85
  none: false
101
86
  requirements:
@@ -104,7 +89,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
104
89
  version: '0'
105
90
  segments:
106
91
  - 0
107
- hash: -228231686379995656
92
+ hash: 4152814583514099244
108
93
  requirements: []
109
94
  rubyforge_project:
110
95
  rubygems_version: 1.8.23