figs 1.2.3 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +15 -0
- data/lib/figs/application.rb +8 -8
- data/lib/figs/directory_flattener.rb +41 -9
- data/lib/figs/{figfile.rb → figsfile.rb} +1 -1
- data/lib/figs/tasks/install.rake +19 -7
- data/lib/figs/version.rb +1 -1
- data/lib/figs.rb +4 -4
- metadata +6 -18
checksums.yaml
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
---
|
2
|
+
!binary "U0hBMQ==":
|
3
|
+
metadata.gz: !binary |-
|
4
|
+
MDQzNTVmYWVlMWNkMzNkZDc2ZWIzZmM5ZjAwNTM5NDFlMjg5NTRhZA==
|
5
|
+
data.tar.gz: !binary |-
|
6
|
+
NWQwMzI5YzNlZGEwNDMwZDZlZjVhZWRlMmMwNmJmMTdlOGY4YjMxNA==
|
7
|
+
SHA512:
|
8
|
+
metadata.gz: !binary |-
|
9
|
+
MjAwY2UxMWZkY2UyMGU3YzYyNGE2MzZmNjcxMzZhNGU2ZjRhNWU5M2VjNDll
|
10
|
+
Y2Y2NTUzM2JmZTk4YjgzYTQ4ZTk2MDc1N2FmNDY1NTdjNTk0ODRlODcyZWU1
|
11
|
+
NDhmNGJhMmUzMjllYzkzM2RjMzgyNDY2ZDc4MWMyMGJkNzk3N2I=
|
12
|
+
data.tar.gz: !binary |-
|
13
|
+
M2UxM2I1YTM5YWRjMjM5NGQ0YzY1YWI3NzRjY2NhM2Y4MzllM2Y4NjUyZjFk
|
14
|
+
MzJiODUzMjA1YWU1NDI0ZmU5YTJmNzU0ODA2NmU3ZGMyNTQ3ODQyNGM1M2U2
|
15
|
+
MzhlZTRkOTFlYzRkMDBkNzA5M2Y3M2Y5MTIwNTBjMmYyZjM1MzE=
|
data/lib/figs/application.rb
CHANGED
@@ -15,13 +15,13 @@ module Figs
|
|
15
15
|
attr_writer :stage, :path
|
16
16
|
|
17
17
|
def initialize(options = {})
|
18
|
-
@
|
18
|
+
@figsfile = options[:file]
|
19
19
|
@stage = options[:stage]
|
20
20
|
load_path
|
21
21
|
end
|
22
22
|
|
23
23
|
def locations
|
24
|
-
|
24
|
+
figsfile["locations"]
|
25
25
|
end
|
26
26
|
|
27
27
|
def flattened_filenames(filenames)
|
@@ -29,10 +29,10 @@ module Figs
|
|
29
29
|
end
|
30
30
|
|
31
31
|
def load_path
|
32
|
-
if
|
33
|
-
@path = path_from_git(
|
32
|
+
if figsfile["method"].eql? "git"
|
33
|
+
@path = path_from_git(figsfile["repo"], flattened_filenames(figsfile["locations"]))
|
34
34
|
else
|
35
|
-
@path = flattened_filenames(
|
35
|
+
@path = flattened_filenames(figsfile["locations"])
|
36
36
|
end
|
37
37
|
end
|
38
38
|
|
@@ -44,8 +44,8 @@ module Figs
|
|
44
44
|
end
|
45
45
|
end
|
46
46
|
|
47
|
-
def
|
48
|
-
(@
|
47
|
+
def figsfile
|
48
|
+
(@figsfile || default_figsfile)
|
49
49
|
end
|
50
50
|
|
51
51
|
def path
|
@@ -86,7 +86,7 @@ module Figs
|
|
86
86
|
"test"
|
87
87
|
end
|
88
88
|
|
89
|
-
def
|
89
|
+
def default_figsfile
|
90
90
|
raise NotImplementedError
|
91
91
|
end
|
92
92
|
|
@@ -1,19 +1,51 @@
|
|
1
|
+
##
|
2
|
+
# Module for anything Figs related.
|
1
3
|
module Figs
|
4
|
+
##
|
5
|
+
# A tool to get filenames from a directory.
|
2
6
|
module DirectoryFlattener
|
7
|
+
##
|
8
|
+
# Extending self to allow methods to be available as class methods.
|
3
9
|
extend self
|
4
|
-
|
10
|
+
##
|
11
|
+
# Creates an array consisting of only files contained in a directory and its subdirectories.
|
12
|
+
#
|
13
|
+
# Expects an array of filenames or dirnames or a combination of both.
|
14
|
+
def flattened_filenames(filenames)
|
15
|
+
# Expect an array of filenames return otherwise
|
5
16
|
return filenames if !filenames.is_a?(Array)
|
6
|
-
|
7
|
-
filenames.
|
8
|
-
|
17
|
+
# Iterate through array
|
18
|
+
filenames.map! do |filename|
|
19
|
+
# Flatten if its a file, flatten if a dir.
|
20
|
+
Dir.exists?(filename) ? directory_to_filenames(filename) : filename
|
9
21
|
end
|
10
|
-
|
22
|
+
# Flattern the array and remove all nils
|
23
|
+
filenames.flatten.compact
|
11
24
|
end
|
25
|
+
|
12
26
|
private
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
27
|
+
|
28
|
+
##
|
29
|
+
# Expects a directory, returns its files and subdirectories files as an array of filenames/paths.
|
30
|
+
# be concave.
|
31
|
+
def directory_to_filenames(file_or_directory)
|
32
|
+
directory = Dir.new(file_or_directory)
|
33
|
+
# Returns an array of files that have been flattened.
|
34
|
+
directory.map { |file| flatten_files(directory.path,file) }
|
35
|
+
end
|
36
|
+
|
37
|
+
##
|
38
|
+
# Expects the directory path and filename, checks to see if its another directory or filename,
|
39
|
+
# if directory, calls directory_to_filenames.
|
40
|
+
def flatten_files(directoryname,filename)
|
41
|
+
# If the filename turns out to be a directory...
|
42
|
+
if Dir.exist?("#{directoryname}/#{filename}")
|
43
|
+
# do a recursive call to the parent method, unless the directory is . or ..
|
44
|
+
directory_to_filenames("#{directoryname}/#{filename}") unless ['.','..'].include?(filename)
|
45
|
+
else
|
46
|
+
# Otherwise check if its actually a file and return its filepath.
|
47
|
+
"#{directoryname}/#{filename}" if File.exists?("#{directoryname}/#{filename}")
|
48
|
+
end
|
17
49
|
end
|
18
50
|
end
|
19
51
|
end
|
data/lib/figs/tasks/install.rake
CHANGED
@@ -1,23 +1,23 @@
|
|
1
1
|
require 'erb'
|
2
2
|
require 'pathname'
|
3
|
-
require 'figs/
|
3
|
+
require 'figs/figsfile'
|
4
4
|
desc 'Install Fig'
|
5
5
|
task :install do |task, args|
|
6
6
|
base_dir = Pathname.new('.')
|
7
7
|
locations = args.extras.empty? ? "application.yml" : args.extras
|
8
|
-
|
8
|
+
figsfile = Figs::Figsfile.new(*locations)
|
9
9
|
|
10
|
-
|
11
|
-
create_non_existent_yaml(
|
10
|
+
create_figsfile base_dir, figsfile
|
11
|
+
create_non_existent_yaml(figsfile.locations) if figsfile.method.eql?("path")
|
12
12
|
|
13
13
|
puts "[Done] Enjoy your figs sir!"
|
14
14
|
end
|
15
15
|
|
16
|
-
def
|
16
|
+
def create_figsfile(base_dir, figsfile)
|
17
17
|
puts "Figsifying #{base_dir}/ ..."
|
18
|
-
file = base_dir.join('
|
18
|
+
file = base_dir.join('Figsfile')
|
19
19
|
File.open(file, 'w+') do |f|
|
20
|
-
f.write(
|
20
|
+
f.write(figsfile.to_yaml)
|
21
21
|
end
|
22
22
|
end
|
23
23
|
|
@@ -28,7 +28,19 @@ def create_non_existent_yaml(locations)
|
|
28
28
|
application_yml = File.expand_path("../../templates/application.yml", __FILE__)
|
29
29
|
File.open(file, 'w+') do |f|
|
30
30
|
f.write(ERB.new(File.read(application_yml)).result(binding))
|
31
|
+
ignore_configuration(f.path)
|
31
32
|
end
|
32
33
|
end
|
33
34
|
end
|
35
|
+
end
|
36
|
+
|
37
|
+
def ignore_configuration(application_yml)
|
38
|
+
if File.exists?(".gitignore")
|
39
|
+
File.open('.gitignore', 'a') do |file|
|
40
|
+
file.write(<<-EOF)
|
41
|
+
# Ignore application configuration
|
42
|
+
#{application_yml}
|
43
|
+
EOF
|
44
|
+
end
|
45
|
+
end
|
34
46
|
end
|
data/lib/figs/version.rb
CHANGED
data/lib/figs.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
require "figs/application"
|
2
2
|
require "figs/env"
|
3
|
-
require "figs/
|
3
|
+
require "figs/figsfile"
|
4
4
|
require "figs/directory_flattener"
|
5
5
|
|
6
6
|
module Figs
|
@@ -17,7 +17,7 @@ module Figs
|
|
17
17
|
end
|
18
18
|
|
19
19
|
def application(options = {})
|
20
|
-
@application ||= backend.new({:file =>
|
20
|
+
@application ||= backend.new({:file => figsfile, :stage => options[:stage]})
|
21
21
|
end
|
22
22
|
|
23
23
|
def load(options = {})
|
@@ -26,7 +26,7 @@ module Figs
|
|
26
26
|
|
27
27
|
private
|
28
28
|
|
29
|
-
def
|
30
|
-
@
|
29
|
+
def figsfile
|
30
|
+
@figsfile ||=YAML.load(ERB.new(File.read('Figsfile')).result)
|
31
31
|
end
|
32
32
|
end
|
metadata
CHANGED
@@ -1,20 +1,18 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: figs
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
5
|
-
prerelease:
|
4
|
+
version: 2.0.0
|
6
5
|
platform: ruby
|
7
6
|
authors:
|
8
7
|
- hab278
|
9
8
|
autorequire:
|
10
9
|
bindir: bin
|
11
10
|
cert_chain: []
|
12
|
-
date: 2014-03-
|
11
|
+
date: 2014-03-10 00:00:00.000000000 Z
|
13
12
|
dependencies:
|
14
13
|
- !ruby/object:Gem::Dependency
|
15
14
|
name: rake
|
16
15
|
requirement: !ruby/object:Gem::Requirement
|
17
|
-
none: false
|
18
16
|
requirements:
|
19
17
|
- - ~>
|
20
18
|
- !ruby/object:Gem::Version
|
@@ -22,7 +20,6 @@ dependencies:
|
|
22
20
|
type: :development
|
23
21
|
prerelease: false
|
24
22
|
version_requirements: !ruby/object:Gem::Requirement
|
25
|
-
none: false
|
26
23
|
requirements:
|
27
24
|
- - ~>
|
28
25
|
- !ruby/object:Gem::Version
|
@@ -30,7 +27,6 @@ dependencies:
|
|
30
27
|
- !ruby/object:Gem::Dependency
|
31
28
|
name: git
|
32
29
|
requirement: !ruby/object:Gem::Requirement
|
33
|
-
none: false
|
34
30
|
requirements:
|
35
31
|
- - ~>
|
36
32
|
- !ruby/object:Gem::Version
|
@@ -38,7 +34,6 @@ dependencies:
|
|
38
34
|
type: :runtime
|
39
35
|
prerelease: false
|
40
36
|
version_requirements: !ruby/object:Gem::Requirement
|
41
|
-
none: false
|
42
37
|
requirements:
|
43
38
|
- - ~>
|
44
39
|
- !ruby/object:Gem::Version
|
@@ -54,7 +49,7 @@ files:
|
|
54
49
|
- lib/figs/directory_flattener.rb
|
55
50
|
- lib/figs/env.rb
|
56
51
|
- lib/figs/error.rb
|
57
|
-
- lib/figs/
|
52
|
+
- lib/figs/figsfile.rb
|
58
53
|
- lib/figs/git_handler.rb
|
59
54
|
- lib/figs/install.rb
|
60
55
|
- lib/figs/tasks/install.rake
|
@@ -68,32 +63,25 @@ files:
|
|
68
63
|
homepage: https://github.com/NYULibraries/figs
|
69
64
|
licenses:
|
70
65
|
- MIT
|
66
|
+
metadata: {}
|
71
67
|
post_install_message:
|
72
68
|
rdoc_options: []
|
73
69
|
require_paths:
|
74
70
|
- lib
|
75
71
|
required_ruby_version: !ruby/object:Gem::Requirement
|
76
|
-
none: false
|
77
72
|
requirements:
|
78
73
|
- - ! '>='
|
79
74
|
- !ruby/object:Gem::Version
|
80
75
|
version: '0'
|
81
|
-
segments:
|
82
|
-
- 0
|
83
|
-
hash: 4152814583514099244
|
84
76
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
85
|
-
none: false
|
86
77
|
requirements:
|
87
78
|
- - ! '>='
|
88
79
|
- !ruby/object:Gem::Version
|
89
80
|
version: '0'
|
90
|
-
segments:
|
91
|
-
- 0
|
92
|
-
hash: 4152814583514099244
|
93
81
|
requirements: []
|
94
82
|
rubyforge_project:
|
95
|
-
rubygems_version: 1.
|
83
|
+
rubygems_version: 2.1.11
|
96
84
|
signing_key:
|
97
|
-
specification_version:
|
85
|
+
specification_version: 4
|
98
86
|
summary: Simple app configuration
|
99
87
|
test_files: []
|