contracto 0.0.6 → 0.0.7

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.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- MzNkYThkNzlhMWZjNjI1ZWQ1MjYwNTIxMmUwMWVlY2NhNWEyMjMxYg==
4
+ MDljYTgwNGI5NjBjOGE4YjFkOTJmZjEyZjViNmNhODNhMTM2OTA1NQ==
5
5
  data.tar.gz: !binary |-
6
- NDZmNzFiNGFjYWMyZjJkZDBlMjQ2N2IyNzQ3ZDRjZmFkNmYyODRmZg==
6
+ MDdjMzZkNmNjNTk4NmVmYjRiY2Y1MzhhZjJhZjYzMDFlYzExN2M3ZQ==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- NDkwZjRlMzEyYWE2ZDJlOTIzNWIyNTJjNTMxZDU4NzYyYjZiMjczOWMxZjU4
10
- N2MwNjYxMDQ4ZjE5YTg4MTA1NGQzNGE4YTU3MjY4MzdkM2ViOWIzY2YwYzE2
11
- NjEwZTFhMWQ0NzdjMDFjNGIwYjkxMTQ4NzU0N2VhOTU1ZTE3ODk=
9
+ MTczMzMzMTU0ZGZlZWFmNjU1ZTcyMmNjMjIyNmI3NWQ3NWU1OWUwOGU1ZmQy
10
+ M2IxYWFjYzk4NGU2YTIwOWQwNTZlNzhjNTkxY2E1Y2FmMjFiNTAzMmQxNDM4
11
+ Yjc2NTU2YjUyZjExYzk1ZGQxM2YwNzgwMTA4YWYzY2YyZmVjZmM=
12
12
  data.tar.gz: !binary |-
13
- ZWFlMTZmYjQ2ODhkZGVjNGE5ZjVmM2M2YmZmMWI0ZGM0NmI3ZjllODNhMGQy
14
- OTRkNzFiZTYzYTUxZWI3MjEzNWM0OWZiM2YxOTMxMDZhMTQwNjQ5NzdkYWRi
15
- ODc5NmY3ZDc2MGY5NTQzZDBkZTU2YTNlZWUzYmMzMjU5MTcyODQ=
13
+ NjA1ZDVmOTY3YTczYTczMzI5Zjc5M2M3ODBkZTliOThhN2RkMTE3OGU1ZGM0
14
+ N2FlOTQzN2RiMmU2ZmQxNWZiZmVlMzIzYzVlYTc3N2MyMDVhNjhiM2VmZjQ1
15
+ MmEwOWIzMmNiZjQ3Y2M4NWZkNGY1YmRjYzk3OGUwYmU4N2I4N2U=
data/lib/contracto.rb CHANGED
@@ -6,7 +6,9 @@ module Contracto
6
6
  CONTRACTO_TMP_DIR = '.tmp.contracto'
7
7
  RUBY_SERVER_DIR = "#{GEM_DIR}/lib/contracto/server/ruby"
8
8
  CONTRACT_FILENAME = 'contract.cdc.rb'
9
+ CONTRACT_PID_FILEPATH = "#{CONTRACTO_DIR}/server.pid"
9
10
 
10
11
  require 'contracto/installer'
11
12
  require 'contracto/runner'
13
+ require 'contracto/terminator'
12
14
  end
@@ -3,10 +3,12 @@ class Contracto::Command
3
3
 
4
4
  def run(command, args)
5
5
  case command
6
- when 'install'
6
+ when 'init'
7
7
  Contracto::Installer.new(args).execute
8
- when 'run'
8
+ when 'start'
9
9
  Contracto::Runner.new(args).execute
10
+ when 'stop'
11
+ Contracto::Terminator.new(args).execute
10
12
  end
11
13
  end
12
14
  end
@@ -6,6 +6,8 @@ class Contracto::Installer::Local
6
6
  remove_old_dir
7
7
  cp_server_files
8
8
  create_contract unless contract_already_exists?
9
+ puts 'contracto initialized'
10
+ puts "start writing contracts in #{Contracto::CONTRACT_FILENAME}"
9
11
  rescue
10
12
  revert
11
13
  end
@@ -5,7 +5,8 @@ class Contracto::Runner
5
5
  end
6
6
 
7
7
  def execute
8
- system "rackup contracto/config.ru -p #{PORT} &"
8
+ system "rackup #{Contracto::CONTRACTO_DIR}/config.ru -p #{PORT} -D -P #{Contracto::CONTRACT_PID_FILEPATH}"
9
9
  system "while ! echo exit | nc localhost #{PORT} > /dev/null && echo \"Waiting for server...\"; do sleep 1; done"
10
+ system "curl 0.0.0.0:#{PORT}"
10
11
  end
11
12
  end
@@ -0,0 +1,10 @@
1
+ class Contracto::Terminator
2
+ def initialize(args)
3
+ end
4
+
5
+ def execute
6
+ puts 'killing server...'
7
+ Process.kill(15, File.read(Contracto::CONTRACT_PID_FILEPATH).to_i)
8
+ puts 'server terminated'
9
+ end
10
+ end
@@ -1,3 +1,3 @@
1
1
  module Contracto
2
- VERSION = '0.0.6'
2
+ VERSION = '0.0.7'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: contracto
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.6
4
+ version: 0.0.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kacper Walanus
@@ -75,6 +75,7 @@ files:
75
75
  - lib/contracto/server/ruby/config.ru
76
76
  - lib/contracto/server/ruby/contract.cdc.rb
77
77
  - lib/contracto/server/ruby/server.rb
78
+ - lib/contracto/terminator.rb
78
79
  - lib/contracto/version.rb
79
80
  homepage: ''
80
81
  licenses: