jekyll-theme-open-project-helpers 1.0.0.rc3 → 1.0.0.rc4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 498d821d48e4e9aede7a1fe07626609d0659e8cf
4
- data.tar.gz: cead8af8a560cf3b42e99512f447fc1d722f581d
3
+ metadata.gz: 484676c702c097e92bb095d92c12930ebe1efdb0
4
+ data.tar.gz: e72a6b3ef75ea55af4eff283f6af0fa2ac00f8ee
5
5
  SHA512:
6
- metadata.gz: 710d9a5d4561baa114daf48a3b75bc4b8e176826da9bf71da7602ad359bfe8af46c72ea1252f96aced9545d26291a515d3e7ad8250a8146c80b9002059c8e6de
7
- data.tar.gz: 650f554f122170c80ad5af1d1bba922f8b3302600203e6dd04f5bb7db8852216b398f3b089d06e5aab65326a3201a20fa2ec2b15e974e4b830b26cedba93a9e8
6
+ metadata.gz: 8e2db778262d26d911f5f8b11ee5ec5ac838607984960c975d658c065210ebde47808ed954177c3c7e7aa97af3b9d4dea2ea6d95db0aabca779bb6852f845810
7
+ data.tar.gz: 8e7f7560581e90cd728bbfe04e3657009e3c0207eee4f995b8f832fcc223163042731f7e7f9cf4c9bdc95c79a51576eac21cac55f466070235f82292ec5d8e3d
@@ -2,7 +2,7 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = 'jekyll-theme-open-project-helpers'
5
- s.version = '1.0.0.rc3'
5
+ s.version = '1.0.0.rc4'
6
6
  s.authors = ['Ribose Inc.']
7
7
  s.email = ['open.source@ribose.com']
8
8
 
@@ -69,7 +69,8 @@ class OpenProjectReader < JekyllData::Reader
69
69
  if is_hub(@site)
70
70
  fetch_and_read_projects
71
71
  else
72
- fetch_and_read_docs
72
+ fetch_and_read_docs_for_items('software')
73
+ fetch_and_read_docs_for_items('specs')
73
74
  fetch_hub_logo
74
75
  end
75
76
  end
@@ -93,72 +94,52 @@ class OpenProjectReader < JekyllData::Reader
93
94
  project_indexes.each do |project|
94
95
  project_path = project.path.split('/')[0..-2].join('/')
95
96
 
96
- did_check_out = git_sparse_checkout(
97
+ result = git_sparse_checkout(
97
98
  project_path,
98
99
  project['site']['git_repo_url'],
99
100
  ['assets/', '_posts/', '_software/', '_specs/'])
100
101
 
101
- if did_check_out
102
+ if result[:newly_initialized]
102
103
  CollectionDocReader.new(site).read(
103
104
  project_path,
104
105
  @site.collections['projects'])
105
106
  end
107
+
108
+ fetch_and_read_docs_for_items('projects', 'software')
109
+ fetch_and_read_docs_for_items('projects', 'specs')
106
110
  end
107
111
  end
108
112
 
109
- def fetch_and_read_docs
110
-
111
- # Software
112
- software_entry_points = @site.collections['software'].docs.select do |doc|
113
- pieces = doc.id.split('/')
114
- product_name = pieces[2]
115
- last_piece = pieces[-1]
113
+ def fetch_docs_for_item(item_doc)
114
+ item_name = item_doc.id.split('/')[-1]
115
+ docs_path = "#{item_doc.path.split('/')[0..-2].join('/')}/#{item_name}"
116
116
 
117
- doc.data.key?('docs') and
118
- doc.data['docs']['git_repo_url'] and
119
- pieces[1] == 'software' and
120
- last_piece == product_name
121
- end
122
- software_entry_points.each do |index_doc|
123
- item_name = index_doc.id.split('/')[-1]
124
- docs_path = "#{index_doc.path.split('/')[0..-2].join('/')}/#{item_name}"
125
-
126
- did_check_out = git_sparse_checkout(
117
+ return {
118
+ :checkout_result => git_sparse_checkout(
127
119
  docs_path,
128
- index_doc['docs']['git_repo_url'],
129
- [index_doc['docs']['git_repo_subtree']])
120
+ item_doc['docs']['git_repo_url'],
121
+ [item_doc['docs']['git_repo_subtree']]),
122
+ :docs_path => docs_path,
123
+ }
124
+ end
130
125
 
131
- if did_check_out
132
- CollectionDocReader.new(site).read(
133
- docs_path,
134
- @site.collections['software'])
135
- end
136
- end
126
+ def fetch_and_read_docs_for_items(collection_name, index_collection_name=nil)
127
+ # collection_name would be either software, specs, or (for hub site) projects
128
+ # index_collection_name would be either software or specs
137
129
 
138
- # Specs
139
- spec_entry_points = @site.collections['specs'].docs.select do |doc|
140
- pieces = doc.id.split('/')
141
- product_name = pieces[2]
142
- last_piece = pieces[-1]
130
+ index_collection_name = index_collection_name or collection_name
143
131
 
132
+ entry_points = @site.collections[collection_name].docs.select do |doc|
144
133
  doc.data.key?('docs') and
145
- doc.data['docs']['git_repo_url'] and
146
- pieces[1] == 'specs' and
147
- last_piece == product_name
134
+ doc.data['docs']['git_repo_url']
148
135
  end
149
- spec_entry_points.each do |index_doc|
150
- item_name = index_doc.id.split('/')[-1]
151
- docs_path = "#{index_doc.path.split('/')[0..-2].join('/')}/#{item_name}"
152
-
153
- did_check_out = git_sparse_checkout(
154
- docs_path,
155
- index_doc['docs']['git_repo_url'],
156
- [index_doc['docs']['git_repo_subtree']])
157
-
158
- if did_check_out
136
+ entry_points.each do |index_doc|
137
+ result = fetch_docs_for_item(index_doc)
138
+ index_doc.merge_data!({ 'last_update' => result[:checkout_result][:modified_at] })
139
+ if result[:checkout_result][:newly_initialized]
159
140
  CollectionDocReader.new(site).read(
160
- docs_path,
161
- @site.collections['software'])
141
+ result[:docs_path],
142
+ @site.collections[collection_name])
162
143
  end
163
144
  end
164
145
  end
@@ -166,33 +147,43 @@ class OpenProjectReader < JekyllData::Reader
166
147
  def git_sparse_checkout(repo_path, remote_url, subtrees)
167
148
  # Returns boolean indicating whether the checkout happened
168
149
 
150
+ newly_initialized = false
151
+ repo = nil
152
+
169
153
  git_dir = File.join(repo_path, '.git')
170
154
  unless File.exists? git_dir
155
+ newly_initialized = true
156
+
171
157
  repo = Git.init(repo_path)
172
158
 
159
+ repo.config(
160
+ 'core.sshCommand',
161
+ 'ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no')
162
+
173
163
  repo.add_remote('origin', remote_url)
174
164
 
175
165
  repo.config('core.sparseCheckout', true)
176
166
  open(File.join(git_dir, 'info', 'sparse-checkout'), 'a') { |f|
177
- subtrees.each { |path|
178
- f << "#{path}\n"
179
- }
167
+ subtrees.each { |path| f << "#{path}\n" }
180
168
  }
181
169
 
182
- repo.config(
183
- 'core.sshCommand',
184
- 'ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no')
170
+ else
171
+ repo = Git.open(repo_path)
185
172
 
186
- repo.fetch
187
- repo.reset_hard
188
- repo.checkout('origin/master', { :f => true })
173
+ end
189
174
 
190
- return true
175
+ repo.fetch
176
+ repo.reset_hard
177
+ repo.checkout('origin/master', { :f => true })
191
178
 
192
- else
193
- return false
179
+ latest_commit = repo.gcommit('HEAD')
194
180
 
195
- end
181
+ latest_commit.date
182
+
183
+ return {
184
+ :newly_initialized => newly_initialized,
185
+ :modified_at => latest_commit.date,
186
+ }
196
187
  end
197
188
  end
198
189
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jekyll-theme-open-project-helpers
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0.rc3
4
+ version: 1.0.0.rc4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ribose Inc.