statusz 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore ADDED
@@ -0,0 +1 @@
1
+ *.gem
data/README.md CHANGED
@@ -1,13 +1,13 @@
1
1
  statusz
2
2
  =======
3
3
 
4
- statusz is a Ruby tool to write out git information when you deploy. It is useful if your project
5
- meets the following criteria:
4
+ statusz is a Ruby tool to write out git information when you deploy. It is useful if your project meets the
5
+ following criteria:
6
6
 
7
- * It lives in git (required)
8
- * It uses some kind of ruby-based deployment system (not strictly necessary, because you can call statusz via
9
- the command-line if you want, but this still requires Ruby to run).
10
- * It is a web server that can serve up web pages (also not necessary; if this isn't the case, statusz can
7
+ * It lives in git.
8
+ * It's deployed using some kind of unix-y OS.
9
+ * It uses some kind of ruby-based deployment system.
10
+ * It is a web server that can serve up web pages (not strictly necessary; if this isn't the case, statusz can
11
11
  write out a plain text file for you instead).
12
12
 
13
13
  statusz helps you quickly tell what version of the code is actually running on your server, and who most
@@ -23,3 +23,53 @@ versions as well.
23
23
 
24
24
  Usage
25
25
  -----
26
+
27
+ ``` ruby
28
+ # Somewhere in your deploy scripts, probably where you stage the files before you rsync them:
29
+ require "statusz"
30
+ Statusz.write_git_metadata("#{your_staging_root}/statusz.html")
31
+ ```
32
+
33
+ Now you can serve up the file from your webserver however you like. If you have a public folder, you can drop
34
+ the file in there. Here's how we serve it from one of our sinatra servers:
35
+
36
+ ``` ruby
37
+ get "/statusz" do
38
+ statusz_file = File.join(settings.root, "statusz.html")
39
+ File.file?(statusz_file) ? send_file(statusz_file) : "No deploy data."
40
+ end
41
+ ```
42
+
43
+ If you want statusz to write a plain text file instead of an html file, you can do that:
44
+
45
+ ``` ruby
46
+ Statusz.write_git_metadata("statusz.txt", :format => :text)
47
+ ```
48
+
49
+ If you want statusz to only write some of the fields (skip `commit_search` to save space -- this field
50
+ contains every sha in your repo, so it can be kind of large):
51
+
52
+ ``` ruby
53
+ Statusz.write_git_metadata("statusz.html", :fields => ["latest_sha", "date", "username"])
54
+ ```
55
+
56
+ Here are the possible fields -- by default, statusz will write them all:
57
+
58
+ * `git_directory` -- The name of the directory at the git root
59
+ * `latest_sha` -- The sha of the latest commit
60
+ * `current_branch` -- The name of the branch, if any, from which the deploy is being run
61
+ * `date` -- Timestamp
62
+ * `username` -- The output of `whoami`
63
+ * `git_user_info` -- The user name and email in git
64
+ * `commit_search` -- A list of all commits. In the html version, it's a search box.
65
+
66
+ Screenshot
67
+ ----------
68
+
69
+ ![screenshot](http://i.imgur.com/hjNvH.png)
70
+
71
+ TODO
72
+ ----
73
+
74
+ * Call via command-line script? Useful if doing a non-ruby deploy.
75
+ * Other formats? (JSON?)
@@ -1,3 +1,3 @@
1
1
  module Statusz
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
data/lib/statusz.rb CHANGED
@@ -1,3 +1,4 @@
1
+ require "cgi"
1
2
  require "erb"
2
3
  require "time"
3
4
 
@@ -50,7 +51,7 @@ module Statusz
50
51
  if field == "commit_search"
51
52
  pair = { FIELD_TO_HEADER_NAME[field] => FIELD_TO_SCRAPING_PROC[field].call.split("\n") }
52
53
  else
53
- pair = { FIELD_TO_HEADER_NAME[field] => FIELD_TO_SCRAPING_PROC[field].call }
54
+ pair = { FIELD_TO_HEADER_NAME[field] => CGI.escapeHTML(FIELD_TO_SCRAPING_PROC[field].call) }
54
55
  end
55
56
  hash.merge pair
56
57
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: statusz
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -18,6 +18,7 @@ executables: []
18
18
  extensions: []
19
19
  extra_rdoc_files: []
20
20
  files:
21
+ - .gitignore
21
22
  - Gemfile
22
23
  - LICENSE
23
24
  - README.md