-
-
Notifications
You must be signed in to change notification settings - Fork 12.1k
/
jrnl.rb
143 lines (116 loc) 路 6.46 KB
/
jrnl.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
class Jrnl < Formula
include Language::Python::Virtualenv
desc "Command-line note taker"
homepage "https://jrnl.sh/en/stable/"
url "https://files.pythonhosted.org/packages/b6/65/3b0649ac261e3cf7c110acbdd74b13eeb3e9e6a91eb41832cb4d7d1f9049/jrnl-4.1.tar.gz"
sha256 "980848f9c7ae8d4c844a4cae770c9686b5dda98f479dafac2c3cd72268a53f8b"
license "GPL-3.0-only"
bottle do
rebuild 1
sha256 cellar: :any_skip_relocation, arm64_sonoma: "85898cf630345e671ee5f961b9546bf65f6865671fec86262f2b895d6e02c596"
sha256 cellar: :any_skip_relocation, arm64_ventura: "13f50cda801c259d520ba8b672f524e1597b9a310b402d2414453ae0f77a0f86"
sha256 cellar: :any_skip_relocation, arm64_monterey: "25361f40c55aebb843e5179d2685601f5c7dc0472c7951ad46e6cfc2d25a5a70"
sha256 cellar: :any_skip_relocation, sonoma: "01412bd6fc7eafdc070698511a392043a1cea98bc7d4f117b96397577cbea431"
sha256 cellar: :any_skip_relocation, ventura: "d381fcac93c185be1a926a1141a90f5a6f4520bf7e2df6fcfe2c0920e6785e91"
sha256 cellar: :any_skip_relocation, monterey: "c582677de9d0dd65992a9150de7ee366c34305a46d812e3cfa2ee923e4394b88"
sha256 cellar: :any_skip_relocation, x86_64_linux: "bc36a6efe3bb34278cdcaea83dafb134a9180249776d76f695a98a5907888f3e"
end
depends_on "cryptography"
depends_on "libyaml"
depends_on "python@3.12"
uses_from_macos "expect" => :test
resource "colorama" do
url "https://files.pythonhosted.org/packages/d8/53/6f443c9a4a8358a93a6792e2acffb9d9d5cb0a5cfd8802644b7b1c9a02e4/colorama-0.4.6.tar.gz"
sha256 "08695f5cb7ed6e0531a20572697297273c47b8cae5a63ffc6d6ed5c201be6e44"
end
resource "jaraco-classes" do
url "https://files.pythonhosted.org/packages/a5/8a/ed955184b2ef9c1eef3aa800557051c7354e5f40a9efc9a46e38c3e6d237/jaraco.classes-3.3.1.tar.gz"
sha256 "cb28a5ebda8bc47d8c8015307d93163464f9f2b91ab4006e09ff0ce07e8bfb30"
end
resource "keyring" do
url "https://files.pythonhosted.org/packages/69/cd/889c6569a7e5e9524bc1e423fd2badd967c4a5dcd670c04c2eff92a9d397/keyring-24.3.0.tar.gz"
sha256 "e730ecffd309658a08ee82535a3b5ec4b4c8669a9be11efb66249d8e0aeb9a25"
end
resource "markdown-it-py" do
url "https://files.pythonhosted.org/packages/38/71/3b932df36c1a044d397a1f92d1cf91ee0a503d91e470cbd670aa66b07ed0/markdown-it-py-3.0.0.tar.gz"
sha256 "e3f60a94fa066dc52ec76661e37c851cb232d92f9886b15cb560aaada2df8feb"
end
resource "mdurl" do
url "https://files.pythonhosted.org/packages/d6/54/cfe61301667036ec958cb99bd3efefba235e65cdeb9c84d24a8293ba1d90/mdurl-0.1.2.tar.gz"
sha256 "bb413d29f5eea38f31dd4754dd7377d4465116fb207585f97bf925588687c1ba"
end
resource "more-itertools" do
url "https://files.pythonhosted.org/packages/df/ad/7905a7fd46ffb61d976133a4f47799388209e73cbc8c1253593335da88b4/more-itertools-10.2.0.tar.gz"
sha256 "8fccb480c43d3e99a00087634c06dd02b0d50fbf088b380de5a41a015ec239e1"
end
resource "parsedatetime" do
url "https://files.pythonhosted.org/packages/a8/20/cb587f6672dbe585d101f590c3871d16e7aec5a576a1694997a3777312ac/parsedatetime-2.6.tar.gz"
sha256 "4cb368fbb18a0b7231f4d76119165451c8d2e35951455dfee97c62a87b04d455"
end
resource "pygments" do
url "https://files.pythonhosted.org/packages/55/59/8bccf4157baf25e4aa5a0bb7fa3ba8600907de105ebc22b0c78cfbf6f565/pygments-2.17.2.tar.gz"
sha256 "da46cec9fd2de5be3a8a784f434e4c4ab670b4ff54d605c4c2717e9d49c4c367"
end
resource "python-dateutil" do
url "https://files.pythonhosted.org/packages/4c/c4/13b4776ea2d76c115c1d1b84579f3764ee6d57204f6be27119f13a61d0a9/python-dateutil-2.8.2.tar.gz"
sha256 "0123cacc1627ae19ddf3c27a5de5bd67ee4586fbdd6440d9748f8abb483d3e86"
end
resource "pyxdg" do
url "https://files.pythonhosted.org/packages/b0/25/7998cd2dec731acbd438fbf91bc619603fc5188de0a9a17699a781840452/pyxdg-0.28.tar.gz"
sha256 "3267bb3074e934df202af2ee0868575484108581e6f3cb006af1da35395e88b4"
end
resource "rich" do
url "https://files.pythonhosted.org/packages/a7/ec/4a7d80728bd429f7c0d4d51245287158a1516315cadbb146012439403a9d/rich-13.7.0.tar.gz"
sha256 "5cb5123b5cf9ee70584244246816e9114227e0b98ad9176eede6ad54bf5403fa"
end
resource "ruamel-yaml" do
url "https://files.pythonhosted.org/packages/29/81/4dfc17eb6ebb1aac314a3eb863c1325b907863a1b8b1382cdffcb6ac0ed9/ruamel.yaml-0.18.6.tar.gz"
sha256 "8b27e6a217e786c6fbe5634d8f3f11bc63e0f80f6a5890f28863d9c45aac311b"
end
resource "ruamel-yaml-clib" do
url "https://files.pythonhosted.org/packages/46/ab/bab9eb1566cd16f060b54055dd39cf6a34bfa0240c53a7218c43e974295b/ruamel.yaml.clib-0.2.8.tar.gz"
sha256 "beb2e0404003de9a4cab9753a8805a8fe9320ee6673136ed7f04255fe60bb512"
end
resource "six" do
url "https://files.pythonhosted.org/packages/71/39/171f1c67cd00715f190ba0b100d606d440a28c93c7714febeca8b79af85e/six-1.16.0.tar.gz"
sha256 "1e61c37477a1626458e36f7b1d82aa5c9b094fa4802892072e49de9c60c4c926"
end
resource "tzlocal" do
url "https://files.pythonhosted.org/packages/04/d3/c19d65ae67636fe63953b20c2e4a8ced4497ea232c43ff8d01db16de8dc0/tzlocal-5.2.tar.gz"
sha256 "8d399205578f1a9342816409cc1e46a93ebd5755e39ea2d85334bea911bf0e6e"
end
def install
# Work around ruamel.yaml.clib not building on Xcode 15.3, remove after a new release
# has resolved: https://sourceforge.net/p/ruamel-yaml-clib/tickets/32/
ENV.append_to_cflags "-Wno-incompatible-function-pointer-types" if DevelopmentTools.clang_build_version >= 1500
virtualenv_install_with_resources
end
test do
(testpath/"tests.sh").write <<~EOS
#!/usr/bin/env expect
set timeout 3
match_max 100000
spawn "#{bin}/jrnl" --encrypt
expect -exact "Enter password for journal 'default': "
sleep 0.5
send -- "homebrew\\r"
expect -exact "Enter password again: "
sleep 0.5
send -- "homebrew\\r"
expect -exact "Do you want to store the password in your keychain? \\[Y/n\\] "
send -- "n\\r"
expect -re "Journal encrypted to .*"
expect eof
EOS
# Write the journal
input = "#{testpath}/journal.txt\nn\nn"
assert_match "Journal 'default' created", pipe_output("#{bin}/jrnl My journal entry 2>&1", input, 0)
assert_predicate testpath/"journal.txt", :exist?
# Read the journal
assert_match "#{testpath}/journal.txt", shell_output("#{bin}/jrnl --list 2>&1")
# Encrypt the journal. Needs a TTY to read password.
system "expect", "./tests.sh"
assert_predicate testpath/".config/jrnl/jrnl.yaml", :exist?
assert_match "encrypt: true", (testpath/".config/jrnl/jrnl.yaml").read
end
end