lense 0.1.39 → 0.1.40
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/bin/lense +3 -2
- data/lib/lense.rb +66 -7
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f8046ab388fd8787dd774068dbbd8cdd22cd24ca
|
4
|
+
data.tar.gz: 9c5db94e5ca701d53dc14948c6e3b184140beb44
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 93caf439b7d324d6edda091945a0402dee0977cddd7c903bff1497e7884dca3c2d5da36553629c0a9ea69720afee14abc61832dab304453ca8aaedaf2799829b
|
7
|
+
data.tar.gz: 4b50ba8a0f1f43aca9223414530a3870a92c60a0f99b82a742495573809750561a509465e44438b3298f490520be9c6b37e4b085dc0e68de7c0e70d13172d453
|
data/bin/lense
CHANGED
data/lib/lense.rb
CHANGED
@@ -6,7 +6,7 @@ require 'sqlite3'
|
|
6
6
|
class LENSE
|
7
7
|
attr_reader :config, :current_course, :lense_file_hash
|
8
8
|
|
9
|
-
VERSION = '0.1.
|
9
|
+
VERSION = '0.1.40'
|
10
10
|
LENSE_DIR = File.join(ENV['HOME'],'.lense')
|
11
11
|
COURSES_DIR = File.join(LENSE_DIR,'courses')
|
12
12
|
CURRENT_COURSE_FILE = File.join(LENSE_DIR,'current_course')
|
@@ -150,7 +150,9 @@ class LENSE
|
|
150
150
|
# - - output any ones that have changed
|
151
151
|
end
|
152
152
|
|
153
|
-
def commit()
|
153
|
+
def commit(msg)
|
154
|
+
# check that we have items in staging
|
155
|
+
rows = @DB.execute 'select path from staging;'
|
154
156
|
# add new files to dependancies
|
155
157
|
# create a hash for the commit and add to commits
|
156
158
|
# for all dependancies add current hashes to revisions
|
@@ -158,10 +160,28 @@ class LENSE
|
|
158
160
|
end
|
159
161
|
|
160
162
|
def stage(file)
|
161
|
-
if File.file?(file)
|
162
|
-
|
163
|
-
|
164
|
-
|
163
|
+
if File.file?(file)
|
164
|
+
dependency = get_dependency(file)
|
165
|
+
if depenency.nil?
|
166
|
+
should_stage = true
|
167
|
+
else
|
168
|
+
current_hash = Digest::SHA256.hexdigest(File.read(file))
|
169
|
+
rows = @DB.execute "select "
|
170
|
+
# is it modified?
|
171
|
+
if rows.length == 0
|
172
|
+
say "Staging because we haven't seen this revision"
|
173
|
+
should_stage = true
|
174
|
+
else
|
175
|
+
say "Not Staging because we've seen this file"
|
176
|
+
should_stage = false
|
177
|
+
end
|
178
|
+
end
|
179
|
+
|
180
|
+
if should_stage
|
181
|
+
@DB.transaction
|
182
|
+
@DB.execute "insert into staging (path) values (?);", file
|
183
|
+
@DB.commit
|
184
|
+
end
|
165
185
|
end
|
166
186
|
end
|
167
187
|
|
@@ -177,27 +197,61 @@ class LENSE
|
|
177
197
|
end
|
178
198
|
|
179
199
|
private
|
200
|
+
def get_dependency(file)
|
201
|
+
rows = @DB.execute("
|
202
|
+
select d.id, d.path, d.added_at, r.hash, r.created_at, c.hash
|
203
|
+
from dependencies d
|
204
|
+
join revisions r on r.dependency_id = d.id
|
205
|
+
join commits c on c.id = r.commit_id
|
206
|
+
where
|
207
|
+
d.path = ?
|
208
|
+
and d.deleted = 0
|
209
|
+
order by r.created_at desc
|
210
|
+
limit 1;
|
211
|
+
", file)
|
212
|
+
if rows.length > 0
|
213
|
+
id, path, added_at, file_hash, saved_at, commit_hash = row[0]
|
214
|
+
|
215
|
+
{
|
216
|
+
id: id,
|
217
|
+
path: path,
|
218
|
+
added_at: added_at,
|
219
|
+
file_hash: file_hash,
|
220
|
+
saved_at: saved_at,
|
221
|
+
commit_hash: commit_hash
|
222
|
+
}
|
223
|
+
else
|
224
|
+
nil
|
225
|
+
end
|
226
|
+
end
|
227
|
+
|
180
228
|
def setup_db()
|
181
229
|
@DB.execute <<-SQL
|
182
230
|
CREATE TABLE IF NOT EXISTS dependencies (
|
183
231
|
id integer primary key autoincrement,
|
184
232
|
path text not null,
|
185
|
-
added_at datetime not null
|
233
|
+
added_at datetime not null,
|
234
|
+
deleted bool default false
|
186
235
|
);
|
187
236
|
SQL
|
237
|
+
|
188
238
|
@DB.execute <<-SQL
|
189
239
|
CREATE UNIQUE INDEX IF NOT EXISTS dependency_path_idx ON dependencies (path);
|
190
240
|
SQL
|
241
|
+
|
191
242
|
@DB.execute <<-SQL
|
192
243
|
CREATE TABLE IF NOT EXISTS commits (
|
193
244
|
id integer primary key autoincrement,
|
194
245
|
hash text not null,
|
246
|
+
message text not null,
|
195
247
|
created_at datetime not null
|
196
248
|
);
|
197
249
|
SQL
|
250
|
+
|
198
251
|
@DB.execute <<-SQL
|
199
252
|
CREATE INDEX IF NOT EXISTS commits_hash_idx ON commits (hash);
|
200
253
|
SQL
|
254
|
+
|
201
255
|
@DB.execute <<-SQL
|
202
256
|
CREATE TABLE IF NOT EXISTS revisions (
|
203
257
|
id integer primary key autoincrement,
|
@@ -207,21 +261,26 @@ class LENSE
|
|
207
261
|
created_at datetime not null
|
208
262
|
);
|
209
263
|
SQL
|
264
|
+
|
210
265
|
@DB.execute <<-SQL
|
211
266
|
CREATE INDEX IF NOT EXISTS revisions_hash_idx ON revisions (hash);
|
212
267
|
SQL
|
268
|
+
|
213
269
|
@DB.execute <<-SQL
|
214
270
|
CREATE INDEX IF NOT EXISTS revisions_dependency_id_idx ON revisions (dependency_id);
|
215
271
|
SQL
|
272
|
+
|
216
273
|
@DB.execute <<-SQL
|
217
274
|
CREATE INDEX IF NOT EXISTS revisions_commit_id_idx ON revisions (commit_id);
|
218
275
|
SQL
|
276
|
+
|
219
277
|
@DB.execute <<-SQL
|
220
278
|
CREATE TABLE IF NOT EXISTS staging (
|
221
279
|
id integer primary key autoincrement,
|
222
280
|
path text not null
|
223
281
|
);
|
224
282
|
SQL
|
283
|
+
|
225
284
|
@DB.execute <<-SQL
|
226
285
|
CREATE UNIQUE INDEX IF NOT EXISTS staging_path_idx ON staging (path);
|
227
286
|
SQL
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: lense
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.40
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Manuel Zubieta
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2015-04-
|
12
|
+
date: 2015-04-25 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rake
|