-
Notifications
You must be signed in to change notification settings - Fork 4
/
Makefile
78 lines (57 loc) · 1.78 KB
/
Makefile
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
## gem tasks ##
NAME != \
ruby -e "s = eval(File.read(Dir['*.gemspec'][0])); puts s.name"
VERSION != \
ruby -e "s = eval(File.read(Dir['*.gemspec'][0])); puts s.version"
PORT = 7007
PID_FILE = tmp/$(NAME).pid
count_lines:
find lib -name "*.rb" | xargs cat | ruby -e "p STDIN.readlines.count { |l| l = l.strip; l[0, 1] != '#' && l != '' }"
cl: count_lines
gemspec_validate:
@echo "---"
ruby -e "s = eval(File.read(Dir['*.gemspec'].first)); s.validate"
@echo "---"
name: gemspec_validate
@echo "$(NAME) $(VERSION)"
build: gemspec_validate
gem build $(NAME).gemspec
mkdir -p pkg
mv $(NAME)-$(VERSION).gem pkg/
push: build
gem push --otp "$(OTP)" pkg/$(NAME)-$(VERSION).gem
## flor tasks
RUBY=bundle exec ruby
FLOR_ENV?=dev
TO?=nil
FROM?=nil
migrate:
$(RUBY) -Ilib -e "require 'flor/unit'; Flor::Unit.new('envs/$(FLOR_ENV)/etc/conf.json').storage.migrate($(TO), $(FROM))"
## flack tasks
serve:
bundle exec rackup -p $(PORT)
s: serve
curl:
curl -s http://127.0.0.1:$(PORT)/ | \
$(RUBY) -e "require 'json'; puts JSON.pretty_generate(JSON.load(STDIN.read))"
c: curl
start:
@if [ ! -f $(PID_FILE) ]; then \
bundle exec rackup -p $(PORT) -P $(PID_FILE) -D; \
sleep 1; \
echo "listening on $(PORT), pid `cat $(PID_FILE)`"; \
else \
echo "already running at `cat $(PID_FILE)`"; \
fi
stop:
@if [ -f $(PID_FILE) ]; then \
echo "stopping flack pid `cat $(PID_FILE)`"; \
kill `cat $(PID_FILE)`; \
fi
restart:
@if [ -f $(PID_FILE) ]; then make -s stop; fi; make -s start
# Calls / and lists the links available
#
links:
bundle exec ruby -Ilib -r 'flack' \
-e "app = Flack::App.new('envs/test/', start: false); pp JSON.parse(app.call('REQUEST_METHOD' => 'GET', 'PATH_INFO' => '/', 'REQUEST_PATH' => '/', 'SCRIPT_NAME' => '')[2].first)"