WIP
authorCarlhuda <carlhuda@tilde.io>
Sat, 12 Apr 2014 00:39:18 +0000 (17:39 -0700)
committerCarlhuda <carlhuda@tilde.io>
Sat, 12 Apr 2014 00:39:18 +0000 (17:39 -0700)
.vagrant/machines/default/virtualbox/action_provision [new file with mode: 0644]
.vagrant/machines/default/virtualbox/action_set_name [new file with mode: 0644]
.vagrant/machines/default/virtualbox/id [new file with mode: 0644]
DESIGN/MANIFEST.md
Vagrantfile [new file with mode: 0644]
res [new file with mode: 0755]
res.rs [new file with mode: 0644]
src/cargo/core/dependency.rs
src/cargo/core/package.rs
src/cargo/mod.rs
test.rb [new file with mode: 0644]

diff --git a/.vagrant/machines/default/virtualbox/action_provision b/.vagrant/machines/default/virtualbox/action_provision
new file mode 100644 (file)
index 0000000..ba6351d
--- /dev/null
@@ -0,0 +1 @@
+1397249942
\ No newline at end of file
diff --git a/.vagrant/machines/default/virtualbox/action_set_name b/.vagrant/machines/default/virtualbox/action_set_name
new file mode 100644 (file)
index 0000000..9cef1ba
--- /dev/null
@@ -0,0 +1 @@
+1397249941
\ No newline at end of file
diff --git a/.vagrant/machines/default/virtualbox/id b/.vagrant/machines/default/virtualbox/id
new file mode 100644 (file)
index 0000000..d37e2a9
--- /dev/null
@@ -0,0 +1 @@
+08661950-3207-4cee-8cf0-d49d7b01603f
\ No newline at end of file
index 76377fd52d5e3296f18ca4313780d88b5bbcc412..842a664a2ddd4d6107c27ced975f3bdbb8c426fc 100644 (file)
@@ -71,6 +71,15 @@ standalone library limited to the bare minimum requirements.
   an executable, `src/bin/<name>.rs` if the project has both a lib and
   executable, see below)
 
+## The `[dependencies]` Section
+
+```toml
+[dependencies]
+
+rust-http = "~1.2.0"
+hamcrest = [">1.2.0", "<2.0.0"]
+```
+
 ## Projects Containing Both `lib` and `bin`
 
 Most projects will primarily produce either a library or an executable.
diff --git a/Vagrantfile b/Vagrantfile
new file mode 100644 (file)
index 0000000..5439c60
--- /dev/null
@@ -0,0 +1,118 @@
+# -*- mode: ruby -*-
+# vi: set ft=ruby :
+
+# Vagrantfile API/syntax version. Don't touch unless you know what you're doing!
+VAGRANTFILE_API_VERSION = "2"
+
+Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
+  # All Vagrant configuration is done here. The most common configuration
+  # options are documented and commented below. For a complete reference,
+  # please see the online documentation at vagrantup.com.
+
+  # Every Vagrant virtual environment requires a box to build off of.
+  config.vm.box = "saucy"
+
+  # The url from where the 'config.vm.box' box will be fetched if it
+  # doesn't already exist on the user's system.
+  # config.vm.box_url = "http://domain.com/path/to/above.box"
+
+  # Create a forwarded port mapping which allows access to a specific port
+  # within the machine from a port on the host machine. In the example below,
+  # accessing "localhost:8080" will access port 80 on the guest machine.
+  # config.vm.network :forwarded_port, guest: 80, host: 8080
+
+  # Create a private network, which allows host-only access to the machine
+  # using a specific IP.
+  # config.vm.network :private_network, ip: "192.168.33.10"
+
+  # Create a public network, which generally matched to bridged network.
+  # Bridged networks make the machine appear as another physical device on
+  # your network.
+  # config.vm.network :public_network
+
+  # If true, then any SSH connections made will enable agent forwarding.
+  # Default value: false
+  # config.ssh.forward_agent = true
+
+  # Share an additional folder to the guest VM. The first argument is
+  # the path on the host to the actual folder. The second argument is
+  # the path on the guest to mount the folder. And the optional third
+  # argument is a set of non-required options.
+  # config.vm.synced_folder "../data", "/vagrant_data"
+
+  # Provider-specific configuration so you can fine-tune various
+  # backing providers for Vagrant. These expose provider-specific options.
+  # Example for VirtualBox:
+  #
+  # config.vm.provider :virtualbox do |vb|
+  #   # Don't boot with headless mode
+  #   vb.gui = true
+  #
+  #   # Use VBoxManage to customize the VM. For example to change memory:
+  #   vb.customize ["modifyvm", :id, "--memory", "1024"]
+  # end
+  #
+  # View the documentation for the provider you're using for more
+  # information on available options.
+
+  # Enable provisioning with Puppet stand alone.  Puppet manifests
+  # are contained in a directory path relative to this Vagrantfile.
+  # You will need to create the manifests directory and a manifest in
+  # the file saucy.pp in the manifests_path directory.
+  #
+  # An example Puppet manifest to provision the message of the day:
+  #
+  # # group { "puppet":
+  # #   ensure => "present",
+  # # }
+  # #
+  # # File { owner => 0, group => 0, mode => 0644 }
+  # #
+  # # file { '/etc/motd':
+  # #   content => "Welcome to your Vagrant-built virtual machine!
+  # #               Managed by Puppet.\n"
+  # # }
+  #
+  # config.vm.provision :puppet do |puppet|
+  #   puppet.manifests_path = "manifests"
+  #   puppet.manifest_file  = "site.pp"
+  # end
+
+  # Enable provisioning with chef solo, specifying a cookbooks path, roles
+  # path, and data_bags path (all relative to this Vagrantfile), and adding
+  # some recipes and/or roles.
+  #
+  # config.vm.provision :chef_solo do |chef|
+  #   chef.cookbooks_path = "../my-recipes/cookbooks"
+  #   chef.roles_path = "../my-recipes/roles"
+  #   chef.data_bags_path = "../my-recipes/data_bags"
+  #   chef.add_recipe "mysql"
+  #   chef.add_role "web"
+  #
+  #   # You may also specify custom JSON attributes:
+  #   chef.json = { :mysql_password => "foo" }
+  # end
+
+  # Enable provisioning with chef server, specifying the chef server URL,
+  # and the path to the validation key (relative to this Vagrantfile).
+  #
+  # The Opscode Platform uses HTTPS. Substitute your organization for
+  # ORGNAME in the URL and validation key.
+  #
+  # If you have your own Chef Server, use the appropriate URL, which may be
+  # HTTP instead of HTTPS depending on your configuration. Also change the
+  # validation key to validation.pem.
+  #
+  # config.vm.provision :chef_client do |chef|
+  #   chef.chef_server_url = "https://api.opscode.com/organizations/ORGNAME"
+  #   chef.validation_key_path = "ORGNAME-validator.pem"
+  # end
+  #
+  # If you're using the Opscode platform, your validator client is
+  # ORGNAME-validator, replacing ORGNAME with your organization name.
+  #
+  # If you have your own Chef Server, the default validation client name is
+  # chef-validator, unless you changed the configuration.
+  #
+  #   chef.validation_client_name = "ORGNAME-validator"
+end
diff --git a/res b/res
new file mode 100755 (executable)
index 0000000..733e4a3
Binary files /dev/null and b/res differ
diff --git a/res.rs b/res.rs
new file mode 100644 (file)
index 0000000..c1c08ba
--- /dev/null
+++ b/res.rs
@@ -0,0 +1,23 @@
+enum MyResult {
+    Ok(()),
+    Err(())
+}
+
+impl MyResult {
+    fn wat(self) -> MyResult {
+        println!("wat");
+        self
+    }
+}
+
+fn hi2u() -> MyResult {
+    Ok(())
+}
+
+fn zomg() -> MyResult {
+    Ok(try!(hi2u().wat()))
+}
+
+fn main() {
+    println!("{:?}", zomg());
+}
index 4425af0cf8c77d063d3d7f3c77cf96a3fb794aa7..122a3364c0e1f4de3027fdaf2e5cf07eb68d1f8b 100644 (file)
+use semver::Version;
 
-// TODO: add version restrictions
 #[deriving(Clone,Eq,Show)]
 pub struct Dependency {
-  name: ~str,
+    name: ~str,
+    version: Vec<VersionReq>
+}
+
+#[deriving(Clone,Eq,Show)]
+pub struct VersionReq {
+    parts: Vec<VersionOrd>
+}
+
+type VersionOrd = (Version, Vec<Ordering>);
+
+impl VersionReq {
+    pub fn parse(req: &str) -> VersionReq {
+    }
+
+    /*
+    pub fn new(version: Version, comparison: Vec<Ordering>) -> VersionReq {
+        VersionReq { comparison: comparison, version: version }
+    }
+    */
+
+    pub fn matches(&self, version: &Version) -> bool {
+        /*
+        let ordering = compare_versions(&self.version, version);
+        self.comparison.iter().any(|ord| ordering == *ord)
+        */
+        false
+    }
+}
+
+fn compare_versions(a: &Version, b: &Version) -> Ordering {
+    if a == b {
+        Equal
+    } else if a.lt(b) {
+        Less
+    } else {
+        Greater
+    }
 }
 
 impl Dependency {
-  pub fn new(name: &str) -> Dependency {
-    Dependency { name: name.to_owned() }
-  }
+    pub fn new(name: &str) -> Dependency {
+        Dependency { name: name.to_owned(), version: Vec::new() }
+    }
+
+    pub fn get_name<'a>(&'a self) -> &'a str {
+        self.name.as_slice()
+    }
+}
+
+#[cfg(test)]
+mod tests {
+    use super::VersionReq;
+    use semver;
+    use semver::Version;
+    use hamcrest::{
+        assert_that,
+        Matcher,
+        MatchResult,
+        SelfDescribing
+    };
+
+    trait VersionReqExt {
+        pub fn greater_than(version: Version) -> VersionReq {
+            VersionReq::new(version, vec!(Greater))
+        }
+
+        pub fn equal_to(version: Version) -> VersionReq {
+            VersionReq::new(version, vec!(Equal))
+        }
+    }
+
+    impl VersionReqExt for VersionReq {}
+
+    #[test]
+    fn test_req_matches() {
+        let req = VersionReq::new(semver::parse("2.0.0").unwrap(), vec!(Equal));
+        //let req = greater_than(semver::parse("2.0.0").unwrap());
+
+        assert_that(req, version_match("2.0.0"));
+    }
+
+    struct VersionMatch {
+        version: ~str,
+    }
+
+    impl SelfDescribing for VersionMatch {
+        fn describe(&self) -> ~str {
+            format!("Requirement to match {}", self.version)
+        }
+    }
+
+    impl Matcher<VersionReq> for VersionMatch {
+        fn matches(&self, actual: VersionReq) -> MatchResult {
+            match semver::parse(self.version) {
+                None => Err(~"was not a valid semver version"),
+                Some(ref version) => {
+                    if actual.matches(version) {
+                        Ok(())
+                    } else {
+                        Err(format!("{} did not match {}", version, actual))
+                    }
+                }
+            }
+        }
+    }
+
+    fn version_match(str: &str) -> ~VersionMatch {
+        ~VersionMatch { version: str.to_owned() }
+    }
 
-  pub fn get_name<'a>(&'a self) -> &'a str {
-    self.name.as_slice()
-  }
 }
index 535e65c8983604e59056712299bf807eafd56950..0b9e97fa8cc7fc0b9137faa88875b1bf9dd7ce83 100644 (file)
@@ -10,20 +10,20 @@ use core;
  */
 #[deriving(Clone,Eq,Show)]
 pub struct Package {
-  name: ~str,
-  deps: Vec<core::Dependency>
+    name: ~str,
+    deps: Vec<core::Dependency>
 }
 
 impl Package {
-  pub fn new(name: &str, deps: &Vec<core::Dependency>) -> Package {
-    Package { name: name.to_owned(), deps: deps.clone() }
-  }
+    pub fn new(name: &str, deps: &Vec<core::Dependency>) -> Package {
+        Package { name: name.to_owned(), deps: deps.clone() }
+    }
 
-  pub fn get_name<'a>(&'a self) -> &'a str {
-    self.name.as_slice()
-  }
+    pub fn get_name<'a>(&'a self) -> &'a str {
+        self.name.as_slice()
+    }
 
-  pub fn get_dependencies<'a>(&'a self) -> &'a Vec<core::Dependency> {
-      &self.deps
-  }
+    pub fn get_dependencies<'a>(&'a self) -> &'a Vec<core::Dependency> {
+            &self.deps
+    }
 }
index 58e6f72baeeaa90225f1bcfbca08d1c50302a0f8..57947b706e87cde0829403980b3afce4d79e949c 100644 (file)
@@ -7,6 +7,7 @@
 extern crate collections;
 extern crate hammer;
 extern crate serialize;
+extern crate semver;
 
 #[cfg(test)]
 extern crate hamcrest;
diff --git a/test.rb b/test.rb
new file mode 100644 (file)
index 0000000..f0a23d0
--- /dev/null
+++ b/test.rb
@@ -0,0 +1,3 @@
+io = IO.popen("rustc libs/hammer.rs/src/hammer.rs --out-dir libs/hammer.rs/target --crate-type lib")
+
+Process.wait2(io.pid)