zenkeeper 0.0.1 → 0.0.2
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/lib/commands.rb +2 -0
- data/lib/commands/history.rb +29 -0
- data/lib/commands/push.rb +12 -0
- data/lib/helpers/uploader.rb +46 -0
- data/lib/zenkeeper.rb +1 -1
- metadata +5 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 662c50323ebdae3eb1b1ee27d7f1fc574ce765bb
|
4
|
+
data.tar.gz: cf68e4e2f5235000b74d3a34404bc7d525886b19
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4bf3536a4bd47f813b67214c2cae29ba64db49f90f004ae5c17f04e513f5264f70d6402ef2bfde25b7da69f12a327dd75a9910a9b177b923e651876c84aad650
|
7
|
+
data.tar.gz: 14177796371975d18e21355c85188ab88716df2ec4d2a448a68b0a23f01c58a9525f4c9e95ca283baa51c88866cd4c1b2aaec56c806f3714d02c63b599240734
|
data/lib/commands.rb
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
require "time"
|
2
|
+
|
3
|
+
class Commands::History < Clamp::Command
|
4
|
+
|
5
|
+
parameter "project_token", "Your project API token"
|
6
|
+
|
7
|
+
def execute
|
8
|
+
puts "Retracing History..."
|
9
|
+
r = `git log --pretty=format:"%h %cd" --first-parent -- Gemfile.lock`
|
10
|
+
logs = r.split("\n")
|
11
|
+
logs.reverse.each do |log|
|
12
|
+
puts "\n\n----------> #{log}"
|
13
|
+
sha = log.split(" ").first
|
14
|
+
date = log.split(" ")[1..log.split(" ").size].join(" ")
|
15
|
+
formated_date = Time.parse(date)
|
16
|
+
puts "Checking out #{sha} at #{formated_date} (#{formated_date.to_i})"
|
17
|
+
`git checkout #{sha}`
|
18
|
+
|
19
|
+
Uploader.upload(
|
20
|
+
project_token: project_token,
|
21
|
+
forced_date: formated_date.to_i,
|
22
|
+
sha: sha,
|
23
|
+
comment: "From history"
|
24
|
+
)
|
25
|
+
sleep 10
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
@@ -0,0 +1,46 @@
|
|
1
|
+
module Uploader
|
2
|
+
REMOTE_URL = "http://zenkeeper.io/api/v1/dependency_files"
|
3
|
+
ERROR_CODES = {
|
4
|
+
"404" => "Project not found. Please make sure your credentials are valid."
|
5
|
+
}
|
6
|
+
|
7
|
+
def self.upload(project_token:, forced_date: nil, sha: nil, comment: nil)
|
8
|
+
upload_tag = ::SecureRandom.hex(32)
|
9
|
+
%w(Gemfile Gemfile.lock).map do |file_name|
|
10
|
+
puts file_name
|
11
|
+
|
12
|
+
puts "\tReading..."
|
13
|
+
begin
|
14
|
+
file = File.open(file_name, "rb")
|
15
|
+
rescue Errno::ENOENT
|
16
|
+
puts "\t\tNo file!"
|
17
|
+
next
|
18
|
+
end
|
19
|
+
contents = file.read
|
20
|
+
|
21
|
+
puts "\tUploading..."
|
22
|
+
res = Net::HTTP.post_form(
|
23
|
+
URI(REMOTE_URL),
|
24
|
+
content: contents,
|
25
|
+
file_type: file_name.downcase.gsub("\.", "_"),
|
26
|
+
project_token: project_token,
|
27
|
+
upload_tag: upload_tag,
|
28
|
+
forced_date: forced_date,
|
29
|
+
sha: sha,
|
30
|
+
comment: comment,
|
31
|
+
client_version: Zenkeeper::VERSION
|
32
|
+
)
|
33
|
+
|
34
|
+
if res.code == "200"
|
35
|
+
puts "\t" + JSON.parse(res.body)["info"]
|
36
|
+
else
|
37
|
+
error_message = ERROR_CODES[res.code]
|
38
|
+
if error_message
|
39
|
+
puts "\tFailure: #{error_message}"
|
40
|
+
else
|
41
|
+
puts "\tUnknown error, please contact support."
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
data/lib/zenkeeper.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: zenkeeper
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Michael Bensoussan
|
@@ -33,6 +33,10 @@ extensions: []
|
|
33
33
|
extra_rdoc_files: []
|
34
34
|
files:
|
35
35
|
- bin/zenkeeper
|
36
|
+
- lib/commands.rb
|
37
|
+
- lib/commands/history.rb
|
38
|
+
- lib/commands/push.rb
|
39
|
+
- lib/helpers/uploader.rb
|
36
40
|
- lib/zenkeeper.rb
|
37
41
|
homepage: https://zenkeeper.io
|
38
42
|
licenses:
|