Permalink
Browse files

stash hacking

  • Loading branch information...
1 parent 646c3e6 commit f0193f1f8ae341b59634f0a7fda5dafeef246a68 @alloy alloy committed Sep 10, 2011
View
@@ -0,0 +1,6 @@
+[submodule "vendor/bundler"]
+ path = vendor/bundler
+ url = https://github.com/carlhuda/bundler.git
+[submodule "vendor/rubygems"]
+ path = vendor/rubygems
+ url = https://github.com/rubygems/rubygems.git
View
@@ -0,0 +1,8 @@
+#!/usr/bin/env macruby
+
+$:.unshift File.expand_path('../../lib', __FILE__)
+$:.unshift File.expand_path('../../vendor/rubygems/lib', __FILE__)
+
+require 'cocoa_pods'
+
+Pod::Command.parse(*ARGV).run
View
@@ -0,0 +1,13 @@
+# is part of ASIHTTPRequest 1.8 and 1.8.1
+dependency 'Reachability' #, '>= 2.0'
+
+# is part of ASIHTTPRequest
+dependency 'ASIWebPageRequest', '>= 1.8'
+
+# this should fail the ASIHTTPRequest 1.8.1 hard requirement
+#dependency 'ASIWebPageRequest', '1.8.0'
+
+# we have a hard requirement here so:
+# * the Reachability dependency should be taken from this version
+# * the ASIWebPageRequest dependency requirement matches this one so should work
+dependency 'ASIHTTPRequest', '1.8.1'
View
@@ -1,4 +1,9 @@
module Pod
- autoload :Command, 'cocoa_pods/command'
- autoload :Config, 'cocoa_pods/config'
+ autoload :Command, 'cocoa_pods/command'
+ autoload :Config, 'cocoa_pods/config'
+ autoload :Dependency, 'cocoa_pods/dependency'
+ autoload :Source, 'cocoa_pods/source'
+ autoload :Spec, 'cocoa_pods/specification'
+ autoload :Specification, 'cocoa_pods/specification'
+ autoload :Version, 'cocoa_pods/version'
end
View
@@ -2,18 +2,20 @@ module Pod
class Command
include Config::Mixin
- autoload :Help, 'cocoa_pods/command/help'
- autoload :Setup, 'cocoa_pods/command/setup'
- autoload :Spec, 'cocoa_pods/command/spec'
- autoload :Repo, 'cocoa_pods/command/repo'
+ autoload :Help, 'cocoa_pods/command/help'
+ autoload :Install, 'cocoa_pods/command/install'
+ autoload :Repo, 'cocoa_pods/command/repo'
+ autoload :Setup, 'cocoa_pods/command/setup'
+ autoload :Spec, 'cocoa_pods/command/spec'
def self.parse(*argv)
argv = argv.dup
command = case argv.shift
- when 'help' then Help
- when 'setup' then Setup
- when 'spec' then Spec
- when 'repo' then Repo
+ when 'help' then Help
+ when 'install' then Install
+ when 'repo' then Repo
+ when 'setup' then Setup
+ when 'spec' then Spec
end
command.new(*argv)
end
@@ -1,6 +1,55 @@
module Pod
class Command
class Help < Command
+ def run
+ puts %{
+### Setup
+
+ $ pod help setup
+
+ pod setup
+ Creates a directory at `~/.cocoa-pods' which will hold your spec-repos.
+ This is where it will create a clone of the public `master' spec-repo.
+
+### Managing PodSpec files
+
+ $ pod help spec
+
+ pod spec create NAME
+ Creates a directory for your new pod, named `NAME', with a default
+ directory structure and accompanying `NAME.podspec'.
+
+ pod spec init NAME
+ Creates a PodSpec, in the current working dir, called `NAME.podspec'.
+ Use this for existing libraries.
+
+ pod spec lint NAME
+ Validates `NAME.podspec' from a local spec-repo. In case `NAME' is
+ omitted, it defaults to the PodSpec in the current working dir.
+
+ pod spec push REMOTE
+ Validates `NAME.podspec' in the current working dir, copies it to the
+ local clone of the `REMOTE' spec-repo, and pushes it to the `REMOTE'
+ spec-repo. In case `REMOTE' is omitted, it defaults to `master'.
+
+### Managing spec-repos
+
+ $ pod help repo
+
+ pod repo add NAME URL
+ Clones `URL' in the local spec-repos directory at `~/.cocoa-pods'. The
+ remote can later be referred to by `NAME'.
+
+ pod repo update NAME
+ Updates the local clone of the spec-repo `NAME'.
+
+ pod repo change NAME URL
+ Changes the git remote of local spec-repo `NAME' to `URL'.
+
+ pod repo cd NAME
+ Changes the current working dir to the local spec-repo `NAME'.
+}
+ end
end
end
end
@@ -0,0 +1,18 @@
+module Pod
+ class Command
+ class Install < Command
+ def run
+ if spec = Specification.from_podfile(podfile)
+ p spec
+ spec.install!
+ else
+ $stderr.puts "No Podfile found in current working directory."
+ end
+ end
+
+ def podfile
+ File.join(Dir.pwd, 'Podfile')
+ end
+ end
+ end
+end
View
@@ -1,3 +1,5 @@
+require 'pathname'
+
module Pod
class Config
def self.instance
@@ -11,7 +13,7 @@ def self.instance=(instance)
attr_accessor :repos_dir
def initialize
- @repos_dir = File.expand_path("~/.cocoa-pods")
+ @repos_dir = Pathname.new(File.expand_path("~/.cocoa-pods"))
end
module Mixin
@@ -0,0 +1,9 @@
+module Gem
+end
+require 'rubygems/dependency'
+
+module Pod
+ class Dependency < Gem::Dependency
+
+ end
+end
View
@@ -0,0 +1,25 @@
+module Pod
+ class Source
+ def self.all
+ @sources ||= Config.instance.repos_dir.children.map { |repo| new(repo) }
+ end
+
+ def self.search(dependency)
+ all.map { |source| source.search(dependency) }.compact
+ end
+
+ attr_reader :repo
+
+ def initialize(repo)
+ @repo = repo
+ end
+
+ def search(dependency)
+ if dir = @repo.children.find { |c| c.basename.to_s == dependency.name }
+ set = Specification::Set.new(dir)
+ set.add_dependency(dependency)
+ set
+ end
+ end
+ end
+end
@@ -0,0 +1,119 @@
+require 'cocoa_pods/specification/set'
+
+module Pod
+ class Specification
+ def self.from_podfile(path)
+ if File.exist?(path)
+ spec = new
+ spec.instance_eval(File.read(path))
+ spec.defined_in_file = path
+ spec
+ end
+ end
+
+ def self.from_podspec(pathname)
+ spec = eval(File.read(pathname), nil, pathname.to_s)
+ spec.defined_in_file = pathname
+ spec
+ end
+
+ attr_accessor :defined_in_file
+
+ def initialize(&block)
+ @dependencies = []
+ instance_eval(&block) if block_given?
+ end
+
+ # Attributes
+
+ def read(name)
+ instance_variable_get("@#{name}")
+ end
+
+ def name(name)
+ @name = name
+ end
+
+ def version(version)
+ @version = Version.new(version)
+ end
+
+ def authors(*names_and_email_addresses)
+ list = names_and_email_addresses
+ unless list.first.is_a?(Hash)
+ authors = list.last.is_a?(Hash) ? list.pop : {}
+ list.each { |name| authors[name] = nil }
+ end
+ @authors = authors || list
+ end
+ alias_method :author, :authors
+
+ def homepage(url)
+ @homepage = url
+ end
+
+ def summary(summary)
+ @summary = summary
+ @description ||= summary
+ end
+
+ def description(description)
+ @description = description
+ end
+
+ def part_of(name, *version_requirements)
+ @part_of = Dependency.new(name, *version_requirements)
+ end
+
+ def source_files(*patterns)
+ @source_files = patterns
+ end
+
+ def source(remote)
+ @source = remote
+ end
+
+ attr_reader :dependencies
+ def dependency(name, *version_requirements)
+ #version = args || [">= 0"]
+ @dependencies << Dependency.new(name, *version_requirements)
+ end
+
+ # Not attributes
+
+ def from_podfile?
+ @name.nil? && @version.nil?
+ end
+
+ def to_s
+ if from_podfile?
+ "#<#{self.class.name} for podfile at `#{@defined_in_file}'>"
+ else
+ "#<#{self.class.name} for `#{@name}' version `#{@version}'>"
+ end
+ end
+ alias_method :inspect, :to_s
+
+ # TODO move to seperate installer class
+ def install!
+ #p @name, @version, @authors, @dependencies
+ @dependency_sets = @dependencies.map { |dep| Source.search(dep) }.flatten
+ @dependency_sets.each do |set|
+ p set
+ p set.podspec
+ end
+ end
+
+ private
+
+ def attr(name, arg)
+ if arg.nil? || arg.empty?
+ instance_variable_get("@#{name}")
+ else
+ instance_variable_set("@#{name}", block_given? ? yield : arg)
+ end
+ end
+ end
+
+ Spec = Specification
+end
@@ -0,0 +1,46 @@
+module Pod
+ class Specification
+ class Set
+ def initialize(pod_dir)
+ @pod_dir = pod_dir
+ end
+
+ def add_dependency(dependency)
+ @dependency = dependency
+ end
+
+ def name
+ @pod_dir.basename.to_s
+ end
+
+ def spec_pathname
+ @pod_dir + required_version.to_s + "#{name}.podspec"
+ end
+
+ def podspec
+ Specification.from_podspec(spec_pathname)
+ end
+
+ # Return the first version that matches the current dependency.
+ def required_version
+ unless v = versions.find { |v| @dependency.match?(name, v) }
+ raise "Required version (#{@dependency}) not found for `#{name}'."
+ end
+ v
+ end
+
+ def to_s
+ "#<#{self.class.name} for `#{name}' with required version `#{required_version}'>"
+ end
+ alias_method :inspect, :to_s
+
+ private
+
+ # Returns Pod::Version instances, for each version directory, sorted from
+ # lowest version to highest.
+ def versions
+ @pod_dir.children.map { |v| Version.new(v.basename) }.sort
+ end
+ end
+ end
+end
View
@@ -0,0 +1,10 @@
+module Gem
+end
+require 'rubygems/version'
+
+module Pod
+ class Version < Gem::Version
+
+ end
+end
+
Submodule bundler added at b2d6ca
Submodule rubygems added at 62e8c8

0 comments on commit f0193f1

Please sign in to comment.