lense 0.1.31 → 0.1.32
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/bin/lense +3 -3
- data/lib/lense.rb +67 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ecf97e0a23acb96f3d84a029e60a585241041ff0
|
4
|
+
data.tar.gz: b8bd992c51ffa86246dfed2c4104655658e425af
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e3e3f1fbb7ce8c3afa1817a5c3414fc217d8e3cfac4e7ed5f49b836bd584bf99eb5d24ef0fa2f3c09001a671482bc4d642351de31bd48771e39f81eff09b0871
|
7
|
+
data.tar.gz: 5542bd124a099f7292723fa27989f15fc0d1e41a65500c56f78a7f060b60f45fe2d0c3eb48bc2092cb9f28ecfd292bfa0b1ccf6bc45a366298081394ce039c73
|
data/bin/lense
CHANGED
@@ -18,7 +18,7 @@ pre do |global_options,command,options,args|
|
|
18
18
|
found_docker_compose = system_check('which docker-compose')
|
19
19
|
docker_running = found_docker && system_check('docker version')
|
20
20
|
found_vagrant = system_check('which vagrant')
|
21
|
-
|
21
|
+
found_sqlite3 = system_check('which sqlite3')
|
22
22
|
|
23
23
|
be_quiet = global_options[:quiet] || LENSE_APP.config["quiet"]
|
24
24
|
puts "WARNING: Docker not found. Unable to run courses that use Docker!" unless found_docker || be_quiet
|
@@ -27,7 +27,7 @@ pre do |global_options,command,options,args|
|
|
27
27
|
puts "WARNING: Vagrant not found. Unable to run courses that use Vagrant!" unless found_vagrant || be_quiet
|
28
28
|
|
29
29
|
minimal_needed = found_docker || found_vagrant
|
30
|
-
exit_now!("Must have
|
30
|
+
exit_now!("Must have sqlite3 installed!") unless found_sqlite3
|
31
31
|
exit_now!("Must have either Docker or Vagrant!") unless minimal_needed
|
32
32
|
|
33
33
|
minimal_needed
|
@@ -91,7 +91,7 @@ end
|
|
91
91
|
|
92
92
|
command :commit do |c|
|
93
93
|
c.action do
|
94
|
-
|
94
|
+
LENSE_APP.commit
|
95
95
|
end
|
96
96
|
end
|
97
97
|
|
data/lib/lense.rb
CHANGED
@@ -1,11 +1,12 @@
|
|
1
1
|
require 'rest-client'
|
2
2
|
require 'highline/import'
|
3
3
|
require 'digest'
|
4
|
+
require 'sqlite3'
|
4
5
|
|
5
6
|
class LENSE
|
6
7
|
attr_reader :config, :current_course, :lense_file_hash
|
7
8
|
|
8
|
-
VERSION = '0.1.
|
9
|
+
VERSION = '0.1.32'
|
9
10
|
LENSE_DIR = File.join(ENV['HOME'],'.lense')
|
10
11
|
COURSES_DIR = File.join(LENSE_DIR,'courses')
|
11
12
|
CURRENT_COURSE_FILE = File.join(LENSE_DIR,'current_course')
|
@@ -28,6 +29,8 @@ class LENSE
|
|
28
29
|
@current_course = File.read(CURRENT_COURSE_FILE).strip()
|
29
30
|
@current_course = '> NOT SET <' if @current_course.empty?
|
30
31
|
@lense_file_hash = Digest::SHA256.hexdigest(File.read(LENSE_FILE)) if File.file?(LENSE_FILE)
|
32
|
+
@DB = SQLite3::Database.new File.join(LOCAL_LENSE_DIR,'db')
|
33
|
+
setup_db()
|
31
34
|
end
|
32
35
|
|
33
36
|
def select_course(course)
|
@@ -134,5 +137,68 @@ class LENSE
|
|
134
137
|
def status()
|
135
138
|
say "Hash : #{@lense_file_hash}"
|
136
139
|
exit_now!("Not a LENSE project: .lense") unless File.directory?(LOCAL_LENSE_DIR)
|
140
|
+
# check changes in depenancy files
|
141
|
+
# - for each depenceny
|
142
|
+
# - - get the current file hash
|
143
|
+
# - - check against .lense/deps/#{rel_path_to_dep}
|
144
|
+
# - - output any ones that have changed
|
145
|
+
end
|
146
|
+
|
147
|
+
def commit()
|
148
|
+
# copy LENSEfile to .lense/refs/#{hash}
|
149
|
+
# write the new hash to the CURRENT_REF_FILE
|
150
|
+
# loop through staged dependancies
|
151
|
+
# - update expected hashes for dependancies
|
152
|
+
end
|
153
|
+
|
154
|
+
def stage(file)
|
155
|
+
end
|
156
|
+
|
157
|
+
def unstage(file)
|
158
|
+
end
|
159
|
+
|
160
|
+
def remove(file)
|
161
|
+
end
|
162
|
+
|
163
|
+
private
|
164
|
+
def setup_db()
|
165
|
+
@db.execute <<-SQL
|
166
|
+
CREATE TABLE IF NOT EXISTS dependencies (
|
167
|
+
id integer primary key autoincrement,
|
168
|
+
path text not null,
|
169
|
+
added_at datetime not null
|
170
|
+
);
|
171
|
+
SQL
|
172
|
+
@db.execute <<-SQL
|
173
|
+
CREATE UNIQUE INDEX IF NOT EXISTS dependency_path_idx ON dependencies (path);
|
174
|
+
SQL
|
175
|
+
@db.execute <<-SQL
|
176
|
+
CREATE TABLE IF NOT EXISTS commits (
|
177
|
+
id integer primary key autoincrement,
|
178
|
+
hash text not null,
|
179
|
+
created_at datetime not null
|
180
|
+
);
|
181
|
+
SQL
|
182
|
+
@db.execute <<-SQL
|
183
|
+
CREATE INDEX IF NOT EXISTS commits_hash_idx ON commits (hash);
|
184
|
+
SQL
|
185
|
+
@db.execute <<-SQL
|
186
|
+
CREATE TABLE IF NOT EXISTS revisions (
|
187
|
+
id integer primary key autoincrement,
|
188
|
+
dependency_id integer not null,
|
189
|
+
commit_id integer not null,
|
190
|
+
hash text not null,
|
191
|
+
created_at datetime not null
|
192
|
+
);
|
193
|
+
SQL
|
194
|
+
@db.execute <<-SQL
|
195
|
+
CREATE INDEX IF NOT EXISTS revisions_hash_idx ON revisions (hash);
|
196
|
+
SQL
|
197
|
+
@db.execute <<-SQL
|
198
|
+
CREATE INDEX IF NOT EXISTS revisions_dependency_id_idx ON revisions (dependency_id);
|
199
|
+
SQL
|
200
|
+
@db.execute <<-SQL
|
201
|
+
CREATE INDEX IF NOT EXISTS revisions_commit_id_idx ON revisions (commit_id);
|
202
|
+
SQL
|
137
203
|
end
|
138
204
|
end
|