Skip to content

Commit 73be5f2

Browse files
author
Jamz Tang
committed
Initial commit
0 parents  commit 73be5f2

9 files changed

Lines changed: 261 additions & 0 deletions

File tree

.gitignore

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# Xcode
2+
.DS_Store
3+
*/build/*
4+
*.pbxuser
5+
!default.pbxuser
6+
*.mode1v3
7+
!default.mode1v3
8+
*.mode2v3
9+
!default.mode2v3
10+
*.perspectivev3
11+
!default.perspectivev3
12+
xcuserdata
13+
profile
14+
*.moved-aside
15+
DerivedData
16+
.idea/
17+
*.hmap
18+
19+
#CocoaPods
20+
Pods

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# CSStickyHeaderFlowLayout CHANGELOG
2+
3+
## 0.1.0
4+
5+
Initial release.

CSStickyHeaderFlowLayout.podspec

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
#
2+
# Be sure to run `pod spec lint NAME.podspec' to ensure this is a
3+
# valid spec and remove all comments before submitting the spec.
4+
#
5+
# To learn more about the attributes see http://docs.cocoapods.org/specification.html
6+
#
7+
Pod::Spec.new do |s|
8+
s.name = "CSStickyHeaderFlowLayout"
9+
s.version = "0.1.0"
10+
s.summary = "A short description of CSStickyHeaderFlowLayout."
11+
s.description = <<-DESC
12+
An optional longer description of CSStickyHeaderFlowLayout
13+
14+
* Markdown format.
15+
* Don't worry about the indent, we strip it!
16+
DESC
17+
s.homepage = "http://EXAMPLE/NAME"
18+
s.screenshots = "www.example.com/screenshots_1", "www.example.com/screenshots_2"
19+
s.license = 'MIT'
20+
s.author = { "Jamz Tang" => "jamz@jamztang.com" }
21+
s.source = { :git => "http://EXAMPLE/NAME.git", :tag => s.version.to_s }
22+
23+
# s.platform = :ios, '5.0'
24+
# s.ios.deployment_target = '5.0'
25+
# s.osx.deployment_target = '10.7'
26+
s.requires_arc = true
27+
28+
s.source_files = 'Classes'
29+
s.resources = 'Assets'
30+
31+
s.ios.exclude_files = 'Classes/osx'
32+
s.osx.exclude_files = 'Classes/ios'
33+
# s.public_header_files = 'Classes/**/*.h'
34+
# s.frameworks = 'SomeFramework', 'AnotherFramework'
35+
# s.dependency 'JSONKit', '~> 1.4'
36+
end

Classes/ios/.gitkeep

Whitespace-only changes.

Classes/osx/.gitkeep

Whitespace-only changes.

LICENSE

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

Project/Podfile

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
pod "CSStickyHeaderFlowLayout", :path => "../CSStickyHeaderFlowLayout.podspec"
2+
3+
target "Demo" do
4+
end
5+
6+
target "DemoTests" do
7+
end

README.md

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# CSStickyHeaderFlowLayout
2+
3+
[![Version](http://cocoapod-badges.herokuapp.com/v/CSStickyHeaderFlowLayout/badge.png)](http://cocoadocs.org/docsets/CSStickyHeaderFlowLayout)
4+
[![Platform](http://cocoapod-badges.herokuapp.com/p/CSStickyHeaderFlowLayout/badge.png)](http://cocoadocs.org/docsets/CSStickyHeaderFlowLayout)
5+
6+
## Usage
7+
8+
To run the example project; clone the repo, and run `pod install` from the Project directory first.
9+
10+
## Requirements
11+
12+
## Installation
13+
14+
CSStickyHeaderFlowLayout is available through [CocoaPods](http://cocoapods.org), to install
15+
it simply add the following line to your Podfile:
16+
17+
pod "CSStickyHeaderFlowLayout"
18+
19+
## Author
20+
21+
Jamz Tang, jamz@jamztang.com
22+
23+
## License
24+
25+
CSStickyHeaderFlowLayout is available under the MIT license. See the LICENSE file for more info.
26+

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

0 commit comments

Comments
 (0)