bard 1.0.1 → 1.0.3

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.
@@ -0,0 +1,83 @@
1
+ require "bard/config"
2
+
3
+ describe Bard::Config do
4
+ context "empty" do
5
+ subject { described_class.new("tracker") }
6
+
7
+ describe "#project_name" do
8
+ it "returns the project_name setting" do
9
+ expect(subject.project_name).to eq "tracker"
10
+ end
11
+ end
12
+
13
+ describe "#servers" do
14
+ it "is prefilled with many servers" do
15
+ expect(subject.servers.keys).to eq %i[local gubs ci staging]
16
+ end
17
+ end
18
+
19
+ describe "#[]" do
20
+ it "promotes staging to production when production doesn't exist" do
21
+ expect(subject[:production]).to eq subject[:staging]
22
+ end
23
+ end
24
+
25
+ describe "#data" do
26
+ it "return an empty array" do
27
+ expect(subject.data).to eq []
28
+ end
29
+ end
30
+
31
+ describe "#backup" do
32
+ it "returns true" do
33
+ expect(subject.backup).to eq true
34
+ end
35
+ end
36
+ end
37
+
38
+ context "with production definition" do
39
+ subject { described_class.new("tracker", source: <<~SOURCE) }
40
+ server :production do
41
+ ssh "www@ssh.botandrose.com:22022"
42
+ ping "tracker.botandrose.com"
43
+ end
44
+
45
+ data "public/system", "public/ckeditor"
46
+ backup false
47
+ SOURCE
48
+
49
+ describe "#project_name" do
50
+ it "returns the project_name setting" do
51
+ expect(subject.project_name).to eq "tracker"
52
+ end
53
+ end
54
+
55
+ describe "#servers" do
56
+ it "contains the defined server" do
57
+ expect(subject.servers.keys).to eq %i[local gubs ci staging production]
58
+ end
59
+ end
60
+
61
+ describe "#server" do
62
+ it "can overwrite existing definition" do
63
+ subject.server :staging do
64
+ ssh "www@tracker-staging.botandrose.com:22022"
65
+ end
66
+ expect(subject[:staging].ssh).to eq "www@tracker-staging.botandrose.com:22022"
67
+ end
68
+ end
69
+
70
+ describe "#data" do
71
+ it "returns the data setting" do
72
+ expect(subject.data).to eq ["public/system", "public/ckeditor"]
73
+ end
74
+ end
75
+
76
+ describe "#backup" do
77
+ it "returns the backup setting" do
78
+ expect(subject.backup).to eq false
79
+ end
80
+ end
81
+ end
82
+ end
83
+
@@ -0,0 +1,127 @@
1
+ require "bard/server"
2
+
3
+ describe Bard::Server do
4
+ subject do
5
+ described_class.define("tracker", :production) do
6
+ ssh "www@tracker.botandrose.com:22022"
7
+ path "work/tracker"
8
+ ping "tracker.botandrose.com", "www.tracker.botandrose.com"
9
+ gateway "www@staging.botandrose.com:22022"
10
+ ssh_key "~/.ssh/id_rsa.pub"
11
+ env "RAILS_ENV=production"
12
+ end
13
+ end
14
+
15
+ describe "#ssh" do
16
+ it "returns the ssh setting" do
17
+ expect(subject.ssh).to eq "www@tracker.botandrose.com:22022"
18
+ end
19
+ end
20
+
21
+ describe "#ssh_uri" do
22
+ it "exposes the host" do
23
+ expect(subject.ssh_uri.host).to eq "tracker.botandrose.com"
24
+ end
25
+
26
+ it "exposes the user" do
27
+ expect(subject.ssh_uri.user).to eq "www"
28
+ end
29
+
30
+ it "exposes the port" do
31
+ expect(subject.ssh_uri.port).to eq 22022
32
+ end
33
+
34
+ it "has no path" do
35
+ expect(subject.ssh_uri.path).to be_empty
36
+ end
37
+
38
+ it "can specify another field to read from" do
39
+ expect(subject.ssh_uri(:gateway).host).to eq "staging.botandrose.com"
40
+ end
41
+
42
+ it "has no path" do
43
+ expect(subject.ssh_uri.path).to be_empty
44
+ end
45
+ end
46
+
47
+ describe "#scp_uri" do
48
+ it "exposes the host" do
49
+ expect(subject.scp_uri.host).to eq "tracker.botandrose.com"
50
+ end
51
+
52
+ it "exposes the user" do
53
+ expect(subject.scp_uri.user).to eq "www"
54
+ end
55
+
56
+ it "exposes the port" do
57
+ expect(subject.scp_uri.port).to eq 22022
58
+ end
59
+
60
+ it "includes the path to the project" do
61
+ expect(subject.scp_uri.path).to eq "/work/tracker"
62
+ end
63
+
64
+ it "compiles to an scp:// string" do
65
+ expect(subject.scp_uri.to_s).to eq "scp://www@tracker.botandrose.com:22022/work/tracker"
66
+ end
67
+ end
68
+
69
+ describe "#rsync_uri" do
70
+ it "works" do
71
+ expect(subject.rsync_uri("public/assets")).to eq "www@tracker.botandrose.com:work/tracker/public/assets"
72
+ end
73
+ end
74
+
75
+ describe "#path" do
76
+ it "returns the path setting" do
77
+ expect(subject.path).to eq "work/tracker"
78
+ end
79
+
80
+ it "defaults to the project name" do
81
+ subject.path nil
82
+ expect(subject.path).to eq "tracker"
83
+ end
84
+ end
85
+
86
+ describe "#ping" do
87
+ it "returns the ping urls, normalized" do
88
+ expect(subject.ping).to eq [
89
+ "https://tracker.botandrose.com",
90
+ "https://www.tracker.botandrose.com",
91
+ ]
92
+ end
93
+
94
+ it "accepts paths" do
95
+ subject.ping "/ping"
96
+ expect(subject.ping).to eq ["https://tracker.botandrose.com/ping"]
97
+ end
98
+
99
+ it "defaults to the ssh value" do
100
+ subject.ping nil
101
+ expect(subject.ping).to eq ["https://tracker.botandrose.com"]
102
+ end
103
+
104
+ it "accepts false to disable pings" do
105
+ subject.ping false
106
+ expect(subject.ping).to eq []
107
+ end
108
+ end
109
+
110
+ describe "#gateway" do
111
+ it "returns the gateway setting" do
112
+ expect(subject.gateway).to eq "www@staging.botandrose.com:22022"
113
+ end
114
+ end
115
+
116
+ describe "#ssh_key" do
117
+ it "returns the ssh_key setting" do
118
+ expect(subject.ssh_key).to eq "~/.ssh/id_rsa.pub"
119
+ end
120
+ end
121
+
122
+ describe "#env" do
123
+ it "returns the env setting" do
124
+ expect(subject.env).to eq "RAILS_ENV=production"
125
+ end
126
+ end
127
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bard
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.1
4
+ version: 1.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Micah Geisel
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-08-22 00:00:00.000000000 Z
11
+ date: 2024-08-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: thor
@@ -138,6 +138,20 @@ files:
138
138
  - lib/bard/ci/jenkins.rb
139
139
  - lib/bard/ci/local.rb
140
140
  - lib/bard/cli.rb
141
+ - lib/bard/cli/ci.rb
142
+ - lib/bard/cli/data.rb
143
+ - lib/bard/cli/deploy.rb
144
+ - lib/bard/cli/hurt.rb
145
+ - lib/bard/cli/install.rb
146
+ - lib/bard/cli/master_key.rb
147
+ - lib/bard/cli/open.rb
148
+ - lib/bard/cli/ping.rb
149
+ - lib/bard/cli/provision.rb
150
+ - lib/bard/cli/run.rb
151
+ - lib/bard/cli/setup.rb
152
+ - lib/bard/cli/ssh.rb
153
+ - lib/bard/cli/stage.rb
154
+ - lib/bard/cli/vim.rb
141
155
  - lib/bard/command.rb
142
156
  - lib/bard/config.rb
143
157
  - lib/bard/copy.rb
@@ -149,7 +163,7 @@ files:
149
163
  - lib/bard/provision/apt.rb
150
164
  - lib/bard/provision/data.rb
151
165
  - lib/bard/provision/http.rb
152
- - lib/bard/provision/master_key.rb
166
+ - lib/bard/provision/masterkey.rb
153
167
  - lib/bard/provision/mysql.rb
154
168
  - lib/bard/provision/passenger.rb
155
169
  - lib/bard/provision/repo.rb
@@ -159,6 +173,9 @@ files:
159
173
  - lib/bard/server.rb
160
174
  - lib/bard/version.rb
161
175
  - spec/bard/ci/github_actions_spec.rb
176
+ - spec/bard/ci_spec.rb
177
+ - spec/bard/config_spec.rb
178
+ - spec/bard/server_spec.rb
162
179
  - spec/bard_spec.rb
163
180
  - spec/spec_helper.rb
164
181
  - spec/support/fixtures/job.json
@@ -200,6 +217,9 @@ test_files:
200
217
  - features/support/grit_ext.rb
201
218
  - features/support/io.rb
202
219
  - spec/bard/ci/github_actions_spec.rb
220
+ - spec/bard/ci_spec.rb
221
+ - spec/bard/config_spec.rb
222
+ - spec/bard/server_spec.rb
203
223
  - spec/bard_spec.rb
204
224
  - spec/spec_helper.rb
205
225
  - spec/support/fixtures/job.json
File without changes