Skip to content

Commit c5fc3b5

Browse files
committed
Added Podspec
1 parent 827197e commit c5fc3b5

File tree

3 files changed

+185
-0
lines changed

3 files changed

+185
-0
lines changed

LICENSE

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
The MIT License (MIT)
2+
3+
Copyright (c) 2013 SocialObjects-Software
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy of
6+
this software and associated documentation files (the "Software"), to deal in
7+
the Software without restriction, including without limitation the rights to
8+
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
9+
the Software, and to permit persons to whom the Software is furnished to do so,
10+
subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
17+
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
18+
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
19+
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
20+
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Rakefile

Lines changed: 148 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,148 @@
1+
desc "Runs the specs [EMPTY]"
2+
task :spec do
3+
# Provide your own implementation
4+
end
5+
6+
task :version do
7+
git_remotes = `git remote`.strip.split("\n")
8+
9+
if git_remotes.count > 0
10+
puts "-- fetching version number from github"
11+
sh 'git fetch'
12+
13+
remote_version = remote_spec_version
14+
end
15+
16+
if remote_version.nil?
17+
puts "There is no current released version. You're about to release a new Pod."
18+
version = "0.0.1"
19+
else
20+
puts "The current released version of your pod is " + remote_spec_version.to_s()
21+
version = suggested_version_number
22+
end
23+
24+
puts "Enter the version you want to release (" + version + ") "
25+
new_version_number = $stdin.gets.strip
26+
if new_version_number == ""
27+
new_version_number = version
28+
end
29+
30+
replace_version_number(new_version_number)
31+
end
32+
33+
desc "Release a new version of the Pod"
34+
task :release do
35+
36+
puts "* Running version"
37+
sh "rake version"
38+
39+
unless ENV['SKIP_CHECKS']
40+
if `git symbolic-ref HEAD 2>/dev/null`.strip.split('/').last != 'master'
41+
$stderr.puts "[!] You need to be on the `master' branch in order to be able to do a release."
42+
exit 1
43+
end
44+
45+
if `git tag`.strip.split("\n").include?(spec_version)
46+
$stderr.puts "[!] A tag for version `#{spec_version}' already exists. Change the version in the podspec"
47+
exit 1
48+
end
49+
50+
puts "You are about to release `#{spec_version}`, is that correct? [y/n]"
51+
exit if $stdin.gets.strip.downcase != 'y'
52+
end
53+
54+
puts "* Running specs"
55+
sh "rake spec"
56+
57+
puts "* Linting the podspec"
58+
sh "pod lib lint"
59+
60+
# Then release
61+
sh "git commit #{podspec_path} CHANGELOG.md -m 'Release #{spec_version}'"
62+
sh "git tag -a #{spec_version} -m 'Release #{spec_version}'"
63+
sh "git push origin master"
64+
sh "git push origin --tags"
65+
sh "pod push master #{podspec_path}"
66+
end
67+
68+
# @return [Pod::Version] The version as reported by the Podspec.
69+
#
70+
def spec_version
71+
require 'cocoapods'
72+
spec = Pod::Specification.from_file(podspec_path)
73+
spec.version
74+
end
75+
76+
# @return [Pod::Version] The version as reported by the Podspec from remote.
77+
#
78+
def remote_spec_version
79+
require 'cocoapods-core'
80+
81+
if spec_file_exist_on_remote?
82+
remote_spec = eval(`git show origin/master:#{podspec_path}`)
83+
remote_spec.version
84+
else
85+
nil
86+
end
87+
end
88+
89+
# @return [Bool] If the remote repository has a copy of the podpesc file or not.
90+
#
91+
def spec_file_exist_on_remote?
92+
test_condition = `if git rev-parse --verify --quiet origin/master:#{podspec_path} >/dev/null;
93+
then
94+
echo 'true'
95+
else
96+
echo 'false'
97+
fi`
98+
99+
'true' == test_condition.strip
100+
end
101+
102+
# @return [String] The relative path of the Podspec.
103+
#
104+
def podspec_path
105+
podspecs = Dir.glob('*.podspec')
106+
if podspecs.count == 1
107+
podspecs.first
108+
else
109+
raise "Could not select a podspec"
110+
end
111+
end
112+
113+
# @return [String] The suggested version number based on the local and remote version numbers.
114+
#
115+
def suggested_version_number
116+
if spec_version != remote_spec_version
117+
spec_version.to_s()
118+
else
119+
next_version(spec_version).to_s()
120+
end
121+
end
122+
123+
# @param [Pod::Version] version
124+
# the version for which you need the next version
125+
#
126+
# @note It is computed by bumping the last component of the versino string by 1.
127+
#
128+
# @return [Pod::Version] The version that comes next after the version supplied.
129+
#
130+
def next_version(version)
131+
version_components = version.to_s().split(".");
132+
last = (version_components.last.to_i() + 1).to_s
133+
version_components[-1] = last
134+
Pod::Version.new(version_components.join("."))
135+
end
136+
137+
# @param [String] new_version_number
138+
# the new version number
139+
#
140+
# @note This methods replaces the version number in the podspec file with a new version number.
141+
#
142+
# @return void
143+
#
144+
def replace_version_number(new_version_number)
145+
text = File.read(podspec_path)
146+
text.gsub!(/(s.version( )*= ")#{spec_version}(")/, "\\1#{new_version_number}\\3")
147+
File.open(podspec_path, "w") { |file| file.puts text }
148+
end

SOMessaging.podspec

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
Pod::Spec.new do |s|
2+
s.name = "SOMessaging"
3+
s.version = "1.0.0"
4+
s.summary = "Messaging library for iOS 7.x "
5+
s.platform = :ios, '7.0'
6+
s.source = { :git => "https://github.com/SocialObjects-Software/SOMessaging.git", :tag => "1.0.0" }
7+
s.description = <<-DESC
8+
This is a simple library to easily create a messaging app with smooth animations.
9+
10+
DESC
11+
12+
s.homepage = 'https://github.com/SocialObjects-Software/SOMessaging'
13+
s.license = 'MIT'
14+
s.author = { "Artur Mkrtchyan" => "mkrtarturdev@gmail.com" }
15+
s.source_files = 'SOMessaging/*'
16+
s.requires_arc = true
17+
end

0 commit comments

Comments
 (0)