Commit 9ba5654d authored by Eloy Duran's avatar Eloy Duran

Add a `spec create NAME` command which creates a stub file.

parent 11a8a32a
......@@ -89,3 +89,4 @@ module Pod
end
end
end
......@@ -7,22 +7,69 @@ module Pod
$ 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 lint NAME.podspec
Validates `NAME.podspec'. In case `NAME.podspec' is omitted, it defaults
to `*.podspec' in the current working dir.
pod spec push REMOTE
pod spec push NAME 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'.}
end
def initialize(argv)
super unless argv.arguments.size == 2
case argv.arguments.first
when 'create', 'lint'
@action, @name = argv.arguments.first(2)
when 'push'
@action, @name, @remote = argv.arguments.first(3)
else
super
end
end
def run
send @action
end
def create
author = `git config --get user.name`.strip
email = `git config --get user.email`.strip
spec = <<-SPEC.gsub(/^ /, '')
Pod::Spec.new do
name '#{@name}'
version '1.0.0'
summary 'A short description of #{@name}.'
homepage 'http://example.com/#{@name}'
author '#{author}' => '#{email}'
source :git => 'http://example.com/#{@name}.git',
:tag => '1.0.0'
description 'An optional longer description of #{@name}.'
# A list of file patterns. If the pattern is a directory then the path will
# automatically have '*.{h,m,mm,c,cpp' appended.
source_files 'Classes', 'Classes/**/*.{h,m}'
xcconfig 'OTHER_LDFLAGS' => '-framework SomeRequiredFramework'
end
SPEC
(Pathname.pwd + "#{@name}.podspec").open('w') { |f| f << spec }
end
#def lint
#file = @name ? Pathname.new(@name) : config.project_podfile
#spec = Specification.from_podspec(file)
#spec.validate!
#end
#def push
#end
end
end
end
......@@ -45,7 +45,7 @@ module Pod
authors = list.last.is_a?(Hash) ? list.pop : {}
list.each { |name| authors[name] = nil }
end
@authors = authors || list
@authors = authors || list.first
end
alias_method :author, :authors
......
......@@ -38,6 +38,23 @@ describe "Pod::Command" do
(repo3.dir + 'README').read.should.include 'Added!'
end
it "creates a new podspec stub file" do
Dir.chdir(temporary_directory) do
command('spec', 'create', 'Bananas')
end
path = temporary_directory + 'Bananas.podspec'
spec = Pod::Specification.from_podspec(path)
spec.read(:name).should == 'Bananas'
spec.read(:version).should == Pod::Version.new('1.0.0')
spec.read(:summary).should == 'A short description of Bananas.'
spec.read(:homepage).should == 'http://example.com/Bananas'
spec.read(:authors).should == { `git config --get user.name`.strip => `git config --get user.email`.strip }
spec.read(:source).should == { :git => 'http://example.com/Bananas.git', :tag => '1.0.0' }
spec.read(:description).should == 'An optional longer description of Bananas.'
spec.read(:source_files).should == [Pathname.new('Classes'), Pathname.new('Classes/**/*.{h,m}')]
spec.read(:xcconfig).should == { 'OTHER_LDFLAGS' => '-framework SomeRequiredFramework' }
end
before do
config.repos_dir = fixture('spec-repos')
end
......
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