]> gitweb.factorcode.org Git - factor.git/commitdiff
env vocab for accessing the environment as an assoc
authorJoe Groff <arcata@gmail.com>
Thu, 23 Apr 2009 17:08:30 +0000 (12:08 -0500)
committerJoe Groff <arcata@gmail.com>
Thu, 23 Apr 2009 17:08:30 +0000 (12:08 -0500)
extra/env/authors.txt [new file with mode: 0644]
extra/env/env-docs.factor [new file with mode: 0644]
extra/env/env.factor [new file with mode: 0644]
extra/env/summary.txt [new file with mode: 0644]

diff --git a/extra/env/authors.txt b/extra/env/authors.txt
new file mode 100644 (file)
index 0000000..f13c9c1
--- /dev/null
@@ -0,0 +1 @@
+Joe Groff
diff --git a/extra/env/env-docs.factor b/extra/env/env-docs.factor
new file mode 100644 (file)
index 0000000..918b30a
--- /dev/null
@@ -0,0 +1,13 @@
+! (c)2009 Joe Groff, see bsd license
+USING: help.markup help.syntax ;
+IN: env
+
+HELP: env
+{ $class-description "A singleton that implements the " { $link "assocs-protocol" } " over " { $link "environment" } "." } ;
+
+ARTICLE: "env" "Accessing the environment via the assoc protocol"
+"The " { $vocab-link "env" } " vocabulary defines a " { $link env } " word which implements the " { $link "assocs-protocol" } " over " { $link "environment" } "."
+{ $subsection env }
+;
+
+ABOUT: "env"
diff --git a/extra/env/env.factor b/extra/env/env.factor
new file mode 100644 (file)
index 0000000..f7f4c5d
--- /dev/null
@@ -0,0 +1,26 @@
+! (c)2009 Joe Groff, see bsd license
+USING: assocs environment kernel sequences ;
+IN: env
+
+SINGLETON: env
+
+INSTANCE: env assoc
+
+M: env at*
+    drop os-env dup >boolean ;
+
+M: env assoc-size
+    drop (os-envs) length ;
+
+M: env >alist
+    drop os-envs >alist ;
+
+M: env set-at
+    drop set-os-env ;
+
+M: env delete-at
+    drop unset-os-env ;
+
+M: env clear-assoc
+    drop os-envs keys [ unset-os-env ] each ;
+
diff --git a/extra/env/summary.txt b/extra/env/summary.txt
new file mode 100644 (file)
index 0000000..bd15472
--- /dev/null
@@ -0,0 +1 @@
+Access environment variables via the assoc protocol