fig 0.1.1 → 0.1.2
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.
- data/README.md +78 -1
- data/bin/fig +7 -3
- data/lib/fig/os.rb +0 -1
- data/spec/fig_spec.rb +7 -4
- metadata +2 -2
data/README.md
CHANGED
@@ -22,7 +22,7 @@ Then you can install fig:
|
|
22
22
|
Usage
|
23
23
|
=====
|
24
24
|
|
25
|
-
Fig recognizes the following options:
|
25
|
+
Fig recognizes the following options (not all are implemented yet):
|
26
26
|
|
27
27
|
### Flags ###
|
28
28
|
|
@@ -60,6 +60,83 @@ Fig also supports the following options, which don't require a fig environment.
|
|
60
60
|
--publish-local Install package in local repository only
|
61
61
|
--list List the packages installed in local repository
|
62
62
|
|
63
|
+
Examples
|
64
|
+
========
|
65
|
+
|
66
|
+
Fig lets you modify environment variables three ways:
|
67
|
+
|
68
|
+
* From the command line
|
69
|
+
* From a ".fig" file in the current directory
|
70
|
+
* From packages loaded via one of the previous two methods
|
71
|
+
|
72
|
+
### Command Line ###
|
73
|
+
|
74
|
+
So to get started, let's trying defining an environment variable via the command line and executing a command in the newly created environment. We'll set the "PLANET" variable to "NEPTUNE", then run "echo $PLANET" to ensure that the variable was updated:
|
75
|
+
|
76
|
+
$ fig -s GREETING=Hello -- echo "\$GREETING, World"
|
77
|
+
Hello, World
|
78
|
+
|
79
|
+
(Note that you need to put a slash before the dollar sign, otherwise the shell will evaluate the environment variable before it ever gets to fig.)
|
80
|
+
|
81
|
+
Also note that when running fig, the original environment is never affected:
|
82
|
+
|
83
|
+
$ echo $GREETING
|
84
|
+
<nothing>
|
85
|
+
|
86
|
+
Fig also lets you append environment variables, using the system-specified path separator (e.g. colon on unix, semicolon on windows). This is useful for adding directories to the PATH, LD_LIBRARY_PATH, etc. For example, let's create a "bin" directory, add a shell script to it, then include it in the PATH:
|
87
|
+
|
88
|
+
$ mkdir bin
|
89
|
+
$ echo "echo \$GREETING, World" > bin/hello
|
90
|
+
$ chmod +x bin/hello
|
91
|
+
$ fig -s GREETING=Hello -p bin -- hello
|
92
|
+
Hello, World
|
93
|
+
|
94
|
+
### Fig Files ###
|
95
|
+
|
96
|
+
You can also specify environment modifiers in files. Fig looks for a file called ".fig" in the current directory, and automatically processes it. So we can implement the previous example by creating a ".fig" file that looks like:
|
97
|
+
|
98
|
+
config default
|
99
|
+
set GREETING=Hello
|
100
|
+
append PATH=bin
|
101
|
+
end
|
102
|
+
|
103
|
+
Then we can just run:
|
104
|
+
|
105
|
+
$ fig -- hello
|
106
|
+
Hello, World
|
107
|
+
|
108
|
+
A single fig file can have multiple configurations:
|
109
|
+
|
110
|
+
config default
|
111
|
+
set GREETING=Hello
|
112
|
+
append PATH=bin
|
113
|
+
end
|
114
|
+
|
115
|
+
config french
|
116
|
+
set GREETING=Bonjour
|
117
|
+
append PATH=bin
|
118
|
+
end
|
119
|
+
|
120
|
+
Configurations other than "default" can be specified using the "-c" option:
|
121
|
+
|
122
|
+
$ fig -c french -- hello
|
123
|
+
Bonjour, World
|
124
|
+
|
125
|
+
### Packages ###
|
126
|
+
|
127
|
+
Now let's say we want to share our little script with the rest of the team by bundling it into a package. The first thing you'll need to do is specify the location of your remote repository by defining the FIG_REMOTE_URL environment variable. If you just want to play around with fig, you can have it point to localhost:
|
128
|
+
|
129
|
+
$ export FIG_REMOTE_URL=ssh://localhost/<path to home dir>/figremote
|
130
|
+
|
131
|
+
...TODO...
|
132
|
+
|
133
|
+
Community
|
134
|
+
=========
|
135
|
+
|
136
|
+
\#fig on irc.freenode.net
|
137
|
+
|
138
|
+
[Fig Mailing List](http://groups.google.com/group/fig-user)
|
139
|
+
|
63
140
|
Copyright
|
64
141
|
=========
|
65
142
|
|
data/bin/fig
CHANGED
@@ -107,6 +107,10 @@ if options[:list]
|
|
107
107
|
end
|
108
108
|
end
|
109
109
|
|
110
|
+
def shell_exec(cmd)
|
111
|
+
exec(ENV['SHELL'], '-c', cmd.join(' '))
|
112
|
+
end
|
113
|
+
|
110
114
|
if options[:publish]
|
111
115
|
raise "Unexpected arguments: #{argv.join(' ')}" if !argv.empty?
|
112
116
|
package_name, config_name, version_name = parse_descriptor(options[:publish])
|
@@ -119,11 +123,11 @@ elsif options[:echo]
|
|
119
123
|
puts env[options[:echo]]
|
120
124
|
elsif argv[0] == "-"
|
121
125
|
argv.shift
|
122
|
-
env.execute_shell(argv) { |cmd|
|
126
|
+
env.execute_shell(argv) { |cmd| shell_exec cmd }
|
123
127
|
elsif argv[0]
|
124
128
|
package_name, config_name, version_name = parse_descriptor(argv.shift)
|
125
129
|
env.include_config(package, package_name, config_name, version_name)
|
126
|
-
env.execute_config(package, package_name, config_name, nil) { |cmd|
|
130
|
+
env.execute_config(package, package_name, config_name, nil) { |cmd| shell_exec cmd }
|
127
131
|
else
|
128
|
-
env.execute_config(package, nil, options[:config], nil) { |cmd|
|
132
|
+
env.execute_config(package, nil, options[:config], nil) { |cmd| shell_exec cmd }
|
129
133
|
end
|
data/lib/fig/os.rb
CHANGED
@@ -85,7 +85,6 @@ module Fig
|
|
85
85
|
if uri.scheme == "ssh"
|
86
86
|
dir = uri.path[0, uri.path.rindex('/')]
|
87
87
|
cmd = "mkdir -p #{dir} && cat > #{uri.path}"
|
88
|
-
puts local_file
|
89
88
|
fail unless system "cat #{local_file} | ssh #{uri.user + '@' if uri.user}#{uri.host} '#{cmd}'"
|
90
89
|
else
|
91
90
|
fail unless system "curl -p -T #{local_file} --create-dirs --ftp-create-dirs #{remote_file}"
|
data/spec/fig_spec.rb
CHANGED
@@ -12,8 +12,11 @@ FileUtils.mkdir_p(FIG_REMOTE_DIR)
|
|
12
12
|
ENV['FIG_REMOTE_URL'] = "ssh://localhost#{FIG_REMOTE_DIR}"
|
13
13
|
puts ENV['FIG_REMOTE_URL']
|
14
14
|
|
15
|
+
FIG_EXE = File.expand_path(File.dirname(__FILE__) + '/../bin/fig')
|
16
|
+
|
15
17
|
def fig(args, input=nil)
|
16
|
-
|
18
|
+
args = "--input - #{args}" if input
|
19
|
+
stdin, stdout, stderr = Open3.popen3("#{FIG_EXE} #{args}")
|
17
20
|
if input
|
18
21
|
stdin.puts input
|
19
22
|
stdin.close
|
@@ -33,7 +36,7 @@ describe "Fig" do
|
|
33
36
|
set FOO=BAR
|
34
37
|
end
|
35
38
|
END
|
36
|
-
fig('
|
39
|
+
fig('-g FOO', input)[0].should == 'BAR'
|
37
40
|
end
|
38
41
|
|
39
42
|
it "append environment variable from command line" do
|
@@ -46,7 +49,7 @@ describe "Fig" do
|
|
46
49
|
append PATH=foo
|
47
50
|
end
|
48
51
|
END
|
49
|
-
fig('
|
52
|
+
fig('-g PATH', input).should == ["#{ENV['PATH']}#{File::PATH_SEPARATOR}foo",""]
|
50
53
|
end
|
51
54
|
|
52
55
|
it "append empty environment variable" do
|
@@ -61,7 +64,7 @@ describe "Fig" do
|
|
61
64
|
end
|
62
65
|
end
|
63
66
|
END
|
64
|
-
puts fig('--
|
67
|
+
puts fig('--publish foo/1.2.3', input)
|
65
68
|
fig('-i foo/1.2.3 -g FOO').should == ['BAR','']
|
66
69
|
end
|
67
70
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fig
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Matthew Foemmel
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-12-
|
12
|
+
date: 2009-12-30 00:00:00 -06:00
|
13
13
|
default_executable: fig
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|