Commit f0193f1f authored by Eloy Duran's avatar Eloy Duran

stash hacking

parent 646c3e63
[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
#!/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
# 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'
module Pod
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
......@@ -3,17 +3,19 @@ module Pod
include Config::Mixin
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'
autoload :Repo, 'cocoa_pods/command/repo'
def self.parse(*argv)
argv = argv.dup
command = case argv.shift
when 'help' then Help
when 'install' then Install
when 'repo' then Repo
when 'setup' then Setup
when 'spec' then Spec
when 'repo' then Repo
end
command.new(*argv)
end
......
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
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
require 'pathname'
module Pod
class Config
def self.instance
......@@ -11,7 +13,7 @@ module Pod
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
......
module Gem
end
require 'rubygems/dependency'
module Pod
class Dependency < Gem::Dependency
end
end
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
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
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
module Gem
end
require 'rubygems/version'
module Pod
class Version < Gem::Version
end
end
Subproject commit b2d6caf2ccc79a4996db9aedd617ae42be6b3632
Subproject commit 62e8c85dc3012608d3142a1d6adf50070d2cd4c4
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment