tvd-tvdinner 0.0.1 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,59 @@
1
+ #!/bin/bash
2
+
3
+ if [[ "${BASH_SOURCE##*/}" != "_sub" ]]; then
4
+ shome="$(cd -P -- "$(dirname -- "$BASH_SOURCE")/.." && pwd -P)"
5
+ source "$shome/libexec/_jason"
6
+ set -- "$BASH_SOURCE" "$@"
7
+ fi
8
+
9
+ if [[ "$(type -t main)" != "function" ]]; then
10
+ function main {
11
+ if [[ "$#" > 0 ]]; then
12
+ logger_fatal "Command $sub_base $1 not implemented"
13
+ else
14
+ logger_fatal "Command $sub_base not implemented"
15
+ fi
16
+ exit 1
17
+ }
18
+ fi
19
+
20
+ function sub {
21
+ local bsource="$1"; shift
22
+ local sub_base="$(basename "$bsource")"
23
+ local bsource_cmd="$shome/libexec/${sub_base}"
24
+
25
+ if [[ "$bsource_cmd" = "$bsource" ]]; then
26
+ FLAGS_SUB="$FLAGS_TRUE"
27
+ parse_command_line "$@" || exit $?
28
+ eval set -- "${FLAGS_ARGV}"
29
+ fi
30
+
31
+ if [[ "$#" > 0 ]]; then
32
+ if [[ ! "$1" =~ ^- ]]; then
33
+ local sub_cmd="$(command -v "${sub_base}-$1" || true)"
34
+ if [[ ! -x "$sub_cmd" ]]; then
35
+ sub_cmd="$shome/libexec/${sub_base}-$1"
36
+ fi
37
+
38
+ if [[ -x "$sub_cmd" ]]; then
39
+ shift
40
+ exec "$sub_cmd" "$@"
41
+ fi
42
+ fi
43
+ fi
44
+
45
+ if [[ -x "$bsource_cmd" && "$bsource_cmd" != "$bsource" ]]; then
46
+ exec "$bsource_cmd" "$@"
47
+ else
48
+ if [[ "$(type -t main)" = "function" ]]; then
49
+ main "$@"
50
+ else
51
+ logger_fatal "Can't run $sub_base, missing main function"
52
+ exit 1
53
+ fi
54
+ fi
55
+ }
56
+
57
+ if [[ "$#" > 0 ]]; then
58
+ sub "$@"
59
+ fi
@@ -0,0 +1,30 @@
1
+ #!/bin/bash
2
+
3
+ #/ NAME
4
+ #/ build-gem -- upload the latest (timestamp) rubygem to rubygems.org
5
+ #/
6
+ #/ SYNOPSIS
7
+ #/ build gem -n gem_name
8
+
9
+ # figure out the project root under which bin, lib live
10
+ shome="$(cd -P -- "$(dirname -- "$BASH_SOURCE")/.." && pwd -P)"
11
+
12
+ # load a jason bourne library
13
+ source "$shome/libexec/_jason"
14
+
15
+ # define command line options:
16
+ DEFINE_string 'name' "$(basename "$shome")" 'name of gem' 'n'
17
+
18
+ # entry point
19
+ function main {
20
+ local pth_gemspec="$shome/$FLAGS_name.gemspec"
21
+ if [[ ! -e "$pth_gemspec" ]]; then
22
+ logger_fatal "could not find gemspec $pth_gemspec"
23
+ exit 1
24
+ fi
25
+
26
+ cd "$shome"
27
+ gem build "$pth_gemspec"
28
+ }
29
+
30
+ require sub "$BASH_SOURCE" "$@"
@@ -0,0 +1,27 @@
1
+ #!/bin/bash
2
+
3
+ #/ NAME
4
+ #/ build-site -- build nanoc site
5
+ #/
6
+ #/ SYNOPSIS
7
+ #/ build site
8
+
9
+ # figure out the project root under which bin, lib live
10
+ shome="$(cd -P -- "$(dirname -- "$BASH_SOURCE")/.." && pwd -P)"
11
+
12
+ # load a jason bourne library
13
+ source "$shome/libexec/_jason"
14
+
15
+ # define command line options:
16
+ DEFINE_boolean 'clean' "$FLAGS_FALSE" 'delete output directory first'
17
+
18
+ # entry point
19
+ function main {
20
+ if [[ "$FLAGS_clean" = "$FLAGS_TRUE" ]]; then
21
+ rm -rf "$shome/output"
22
+ fi
23
+
24
+ bundle exec ghp compile
25
+ }
26
+
27
+ require sub "$BASH_SOURCE" "$@"
@@ -0,0 +1,32 @@
1
+ #!/bin/bash
2
+
3
+ #/ NAME
4
+ #/ bump -- increments a semver in a file or in git tags
5
+ #/
6
+ #/ SYNOPSIS
7
+ #/ bump [major|minor|patch]
8
+ #/ bump 1.2.3
9
+ #/ bump
10
+ #/ without arguments is equivalent to 'bump patch'
11
+
12
+ # figure out the project root under which bin, lib live
13
+ shome="$(cd -P -- "$(dirname -- "$BASH_SOURCE")/.." && pwd -P)"
14
+
15
+ # load a jason bourne library
16
+ source "$shome/libexec/_jason"
17
+
18
+ # parse the command-line
19
+ DEFINE_boolean 'dirty' "$FLAGS_FALSE" 'force bumping in unclean work area' 'f'
20
+
21
+ # entry point
22
+ function main {
23
+ require 'bump'
24
+
25
+ if [[ "$#" = 0 ]]; then
26
+ set -- patch
27
+ fi
28
+
29
+ bump_version "$FLAGS_dirty" "$@"
30
+ }
31
+
32
+ require sub "$BASH_SOURCE" "$@"
@@ -0,0 +1,81 @@
1
+ #!/bin/bash
2
+
3
+ #/ NAME
4
+ #/ edit-gem -- set environment to hint to Gemfile to use a local gemspec
5
+ #/
6
+ #/ SYNOPSIS
7
+ #/ edit gem <name> [location]
8
+ #/ edit gem -r <names>
9
+ #/ edit gem -R
10
+
11
+ # figure out the project root under which bin, lib live
12
+ shome="$(cd -P -- "$(dirname -- "$BASH_SOURCE")/.." && pwd -P)"
13
+
14
+ # load a jason bourne library
15
+ source "$shome/libexec/_jason"
16
+
17
+ # define command line options:
18
+ DEFINE_boolean "update" "$FLAGS_FALSE" "finish editing a local gem and updates project" "u"
19
+ DEFINE_boolean "reset" "$FLAGS_FALSE" "reset gem to remote" "r"
20
+ DEFINE_boolean "resetall" "$FLAGS_FALSE" "reset all gems to remote" "R"
21
+
22
+ # entry point
23
+ function main {
24
+ if [[ "$FLAGS_resetall" = "$FLAGS_TRUE" ]]; then
25
+ set +f
26
+ rm -f $shome/.local/*
27
+ set -f
28
+ bundle --local --quiet && bundle check > /dev/null
29
+ git diff --no-ext-diff Gemfile.lock vendor/cache
30
+ elif [[ "$FLAGS_reset" = "$FLAGS_TRUE" ]]; then
31
+ local nm_gem
32
+ for nm_gem in "$@"; do
33
+ rm -f "$shome/.local/$nm_gem"
34
+ done
35
+
36
+ bundle --local --quiet && bundle check > /dev/null
37
+
38
+ git diff --no-ext-diff Gemfile.lock vendor/cache
39
+ elif [[ "$FLAGS_update" = "$FLAGS_TRUE" ]]; then
40
+ local nm_gem
41
+ for nm_gem in "$@"; do
42
+ echo -n > "$shome/.local/$nm_gem"
43
+ done
44
+
45
+ bundle update "$@"
46
+
47
+ for nm_gem in "$@"; do
48
+ rm -f "$shome/.local/$nm_gem"
49
+ done
50
+ bundle --local --quiet && bundle check > /dev/null
51
+
52
+ git add Gemfile.lock vendor/cache
53
+ git add -u vendor/cache
54
+ git diff --no-ext-diff --cached Gemfile.lock vendor/cache
55
+ else
56
+ local nm_gem="$1"; shift
57
+
58
+ local pth_gem
59
+ if [[ "$#" = 0 ]]; then
60
+ pth_gem="gems/$nm_gem"
61
+ else
62
+ pth_gem="$1"; shift
63
+ fi
64
+
65
+ if [[ ! -d "$pth_gem" ]]; then
66
+ logger_fatal "cannot find local gem directoy at $pth_gem"
67
+ exit 1
68
+ fi
69
+
70
+ pth_gem="$(cd -P -- "$pth_gem" && pwd -P)"
71
+
72
+ echo "enabling local gem development on ${nm_gem} at ${pth_gem}"
73
+ mkdir -p "$shome/.local"
74
+ echo "$pth_gem" > "$shome/.local/$nm_gem"
75
+
76
+ bundle --local --quiet && bundle check > /dev/null
77
+ git diff --no-ext-diff Gemfile.lock vendor/cache
78
+ fi
79
+ }
80
+
81
+ require sub "$BASH_SOURCE" "$@"
@@ -0,0 +1,64 @@
1
+ #!/bin/bash
2
+
3
+ #/ NAME
4
+ #/ publish-gem -- publish a gem to a local, remote rubygems, geminabox repository
5
+ #/
6
+ #/ SYNOPSIS
7
+ #/ publish gem [--public | --private | --local]
8
+
9
+ # figure out the project root under which bin, lib live
10
+ shome="$(cd -P -- "$(dirname -- "$BASH_SOURCE")/.." && pwd -P)"
11
+
12
+ # load a jason bourne library
13
+ source "$shome/libexec/_jason"
14
+
15
+ # define command line options:
16
+ DEFINE_boolean "private" "$FLAGS_TRUE" "push to a local, private geminabox"
17
+ DEFINE_boolean "shared" "$FLAGS_FALSE" "push to a shared, private geminabox"
18
+ DEFINE_boolean "public" "$FLAGS_FALSE" "push to rubygems.org"
19
+ DEFINE_string "server" "http://localhost:9292" "geminabox server"
20
+
21
+ # entry point
22
+ function main {
23
+ if [[ "$FLAGS_public" = "$FLAGS_TRUE" ]]; then
24
+ if [[ ! -f "$shome/.private" ]]; then
25
+ push_gem_public "$@"
26
+ else
27
+ logger_fatal "This project is marked private"
28
+ exit 1
29
+ fi
30
+ elif [[ "$FLAGS_private" = "$FLAGS_TRUE" ]]; then
31
+ push_gem_private
32
+ else
33
+ logger_fatal "must specify --public to confirm a gem push to rubygems.org"
34
+ exit 1
35
+ fi
36
+ }
37
+
38
+ # push a gem locally
39
+ function push_gem_private {
40
+ if [[ "$#" = 0 ]]; then
41
+ set +f
42
+ local latest_gem="$(ls -td *.gem 2>&- | head -1)"
43
+ push_gem_private "$latest_gem"
44
+ set -f
45
+ else
46
+ gem inabox -g "$FLAGS_server" "$@"
47
+ fi
48
+ }
49
+
50
+ # push the latest gem to rubygems.org
51
+ function push_gem_public {
52
+ set +f
53
+ local latest_gem="$(ls -td *.gem 2>&- | head -1)"
54
+ set -f
55
+
56
+ if [[ -z "$latest_gem" ]]; then
57
+ logger_fatal "no gems found"
58
+ exit 1
59
+ fi
60
+
61
+ gem push "$latest_gem"
62
+ }
63
+
64
+ require sub "$BASH_SOURCE" "$@"
@@ -0,0 +1,81 @@
1
+ #!/bin/bash
2
+
3
+ #/ NAME
4
+ #/ publish-site -- commit files from one dir to a repo/branch/dir
5
+ #/
6
+ #/ SYNOPSIS
7
+ #/ publish site src_dir repo branch dst_dir
8
+ #/ publish site # defaults to output . gh-pages .
9
+
10
+ # figure out the project root under which bin, lib live
11
+ shome="$(cd -P -- "$(dirname -- "$BASH_SOURCE")/.." && pwd -P)"
12
+
13
+ # load a jason bourne library
14
+ source "$shome/libexec/_jason"
15
+
16
+ # define command line options:
17
+ DEFINE_boolean "clean" "$FLAGS_FALSE" "delete destination branch contents"
18
+ DEFINE_string "message" "published $(date)" "commit message for published content" "m"
19
+
20
+ # entry point
21
+ function main {
22
+ set -x
23
+
24
+ if [[ "$#" = 0 ]]; then
25
+ local src_dir="output"
26
+ else
27
+ local src_dir="$1"; shift
28
+ fi
29
+
30
+ if [[ "$#" = 0 ]]; then
31
+ local dst_repo="."
32
+ else
33
+ local dst_repo="$1"; shift
34
+ fi
35
+
36
+ if [[ "$#" = 0 ]]; then
37
+ local dst_branch="gh-pages"
38
+ else
39
+ local dst_branch="$1"; shift
40
+ fi
41
+
42
+ if [[ "$#" = 0 ]]; then
43
+ local dst_dir="."
44
+ else
45
+ local dst_dir="$1"; shift
46
+ fi
47
+
48
+ local tmp_dir="$(TMPDIR="$shome/tmp" mktemp -d -t XXXXXXXXX)"
49
+
50
+ git clone "$dst_repo" "$tmp_dir"
51
+
52
+ pushd "$tmp_dir" > /dev/null
53
+ if ! git checkout "$dst_branch"; then
54
+ # basically git disconnect from paul repo
55
+ git checkout --orphan "$dst_branch"
56
+ git rm -rf .
57
+ touch .gitignore
58
+ git add .gitignore
59
+ git commit -m "initializing disconnected branch $dst_branch"
60
+ git clean -fdx
61
+ fi
62
+
63
+ if [[ "$FLAGS_clean" = "$FLAGS_TRUE" ]]; then
64
+ git rm -rf .
65
+ git add -u .
66
+ fi
67
+ popd > /dev/null
68
+
69
+ rsync -q -ia -c -O "$src_dir/." "$tmp_dir/$dst_dir"
70
+
71
+ pushd "$tmp_dir" > /dev/null
72
+ git add .
73
+ git status -s
74
+ git commit -m "$FLAGS_message"
75
+ git push origin "$dst_branch"
76
+ popd > /dev/null
77
+
78
+ rm -rf "$tmp_dir"
79
+ }
80
+
81
+ require sub "$BASH_SOURCE" "$@"
@@ -1,23 +1,23 @@
1
1
  %w(etc etc/chef spec tasks var).each do |d|
2
2
  directory "#{node[:release_dir]}/#{d}" do
3
- mode 0755
3
+ mode 00755
4
4
  end
5
5
  end
6
6
 
7
7
  file "#{node[:release_dir]}/etc/chef/solo.rb" do
8
- mode 0644
8
+ mode 00644
9
9
  end
10
10
 
11
11
  file "#{node[:release_dir]}/spec/.gitignore" do
12
- mode 0644
12
+ mode 00644
13
13
  end
14
14
 
15
15
  file "#{node[:release_dir]}/tasks/.gitignore" do
16
- mode 0644
16
+ mode 00644
17
17
  end
18
18
 
19
19
  template "#{node[:release_dir]}/var/.gitignore" do
20
- mode 0644
20
+ mode 00644
21
21
  source "gitignore.erb"
22
22
  variables({
23
23
  :ignore =>
@@ -26,7 +26,7 @@ template "#{node[:release_dir]}/var/.gitignore" do
26
26
  end
27
27
 
28
28
  template "#{node[:release_dir]}/.gitignore" do
29
- mode 0644
29
+ mode 00644
30
30
  source "gitignore.erb"
31
31
  variables({
32
32
  :ignore =>
@@ -36,33 +36,54 @@ end
36
36
 
37
37
  %w(VERSION NOTICE README.md Gemfile).each do |f|
38
38
  template "#{node[:release_dir]}/#{f}" do
39
- mode 0644
39
+ mode 00644
40
40
  source "#{f}.erb"
41
41
  end
42
42
  end
43
43
 
44
44
  cookbook_file "#{node[:release_dir]}/LICENSE" do
45
- mode 0644
45
+ mode 00644
46
46
  source "LICENSE"
47
47
  end
48
48
 
49
49
  [ "lib", "lib/#{node[:tvd][:name]}" ].each do |d|
50
50
  directory "#{node[:release_dir]}/#{d}" do
51
- mode 0755
51
+ mode 00755
52
52
  end
53
53
  end
54
54
 
55
55
  template "#{node[:release_dir]}/lib/tvd-#{node[:tvd][:name]}.rb" do
56
- mode 0644
56
+ mode 00644
57
57
  source "tvdinner.rb.erb"
58
58
  end
59
59
 
60
60
  template "#{node[:release_dir]}/lib/tvd-#{node[:tvd][:name]}/version.rb" do
61
- mode 0644
61
+ mode 00644
62
62
  source "version.rb.erb"
63
63
  end
64
64
 
65
65
  template "#{node[:release_dir]}/tvd-#{node[:tvd][:name]}.gemspec" do
66
- mode 0644
67
- source "tvd.gemspec.erb"
66
+ mode 00644
67
+ source "gemspec.erb"
68
+ end
69
+
70
+ directory "#{node[:release_dir]}/bin" do
71
+ mode 00755
72
+ end
73
+
74
+ %w(build bump edit publish).each do |f|
75
+ link "#{node[:release_dir]}/bin/#{f}" do
76
+ to "../libexec/_sub"
77
+ end
78
+ end
79
+
80
+ remote_directory "#{node[:release_dir]}/libexec" do
81
+ source "jason"
82
+ mode 00755
83
+ files_mode 00644
84
+ end
85
+
86
+ remote_directory "#{node[:release_dir]}/libexec" do
87
+ source "jasonx"
88
+ files_mode 00755
68
89
  end