c3d 0.5.3 → 0.5.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/c3d/util/setup.rb +1 -0
- data/lib/c3d/util/util.rb +55 -0
- data/lib/c3d/util/watch.rb +7 -0
- data/lib/c3d/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2c6e74fa7d05adf9592342735028198f944390d3
|
4
|
+
data.tar.gz: 3c368529abe2a59a94d9f4e8a2abd6bc189c675f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a66fdeb4b4a3efb6a0c922f2bfd869dad919f389969c71493a8daae7c7e02f78c45fdbce30262ea591902678446f16066f3249b2bc8657fc2537e87c18e2c06d
|
7
|
+
data.tar.gz: 7d9456a552b429fc3363b101b918df35cd98ff43541f2e166e80850b72f4b7602af28f8f05966d8fa1f735019089f47799cfbe95449bb1667cef9f7e5d88bb51
|
data/lib/c3d/util/setup.rb
CHANGED
data/lib/c3d/util/util.rb
CHANGED
@@ -12,5 +12,60 @@ module C3D
|
|
12
12
|
ENV['ETH_KEY'] = config["primary_account_key"]
|
13
13
|
File.open(config_file, 'w'){|f| f.write(JSON.pretty_generate(config))}
|
14
14
|
end
|
15
|
+
|
16
|
+
def set_config
|
17
|
+
config = get_config
|
18
|
+
set_the_env config
|
19
|
+
end
|
20
|
+
|
21
|
+
def get_config
|
22
|
+
dir_exist? File.join(ENV['HOME'], '.epm')
|
23
|
+
config_file = File.join(ENV['HOME'], '.epm', 'c3d-config.json')
|
24
|
+
config_example = File.join(File.dirname(__FILE__), '..', '..', '..', 'settings', 'c3d-config.json')
|
25
|
+
unless File.exists? config_file
|
26
|
+
tmp = File.read config_example
|
27
|
+
until ! tmp[/(\{\{USERHOME\}\})/]
|
28
|
+
tmp.gsub!("{{USERHOME}}", ENV["HOME"])
|
29
|
+
end
|
30
|
+
print "Before we begin, I need to ask you two personal questions:\n"
|
31
|
+
print "What is your primary account which I should be using to send transactions?\n\n"
|
32
|
+
account = STDIN.gets.chomp
|
33
|
+
print "Thanks. #{account} is what I will use.\n"
|
34
|
+
print "Thanks. Now what is the private key for that account which I should be using?\n\n"
|
35
|
+
secret = STDIN.gets.chomp
|
36
|
+
print "Thanks. #{secret} is what I will use.\n"
|
37
|
+
account = "0x#{account}" if account[0..1] != '0x'
|
38
|
+
secret = "0x#{secret}" if secret[0..1] != '0x'
|
39
|
+
tmp.gsub!("{{0xACCT}}", account)
|
40
|
+
tmp.gsub!("{{0xSEC}}", secret)
|
41
|
+
File.open(config_file, 'w'){|f| f.write(tmp)}
|
42
|
+
end
|
43
|
+
return JSON.load(File.read(config_file))
|
44
|
+
end
|
45
|
+
|
46
|
+
def set_the_env config
|
47
|
+
ENV['SWARM_DIR'] = config['swarm_dir']
|
48
|
+
ENV['TORRENTS_DIR'] = config['torrents_dir']
|
49
|
+
ENV['BLOBS_DIR'] = config['blobs_dir']
|
50
|
+
ENV['WATCH_FILE'] = config['watch_file']
|
51
|
+
ENV['IGNORE_FILE'] = config['ignore_file']
|
52
|
+
ENV['TORRENT_RPC'] = config['torrent_rpc']
|
53
|
+
ENV['TORRENT_USER'] = config['torrent_user']
|
54
|
+
ENV['TORRENT_PASS'] = config['torrent_pass']
|
55
|
+
ENV['UI_RESPOND'] = config['ui_respond']
|
56
|
+
ENV['UI_ANNOUNCE'] = config['ui_announce']
|
57
|
+
ENV['ETH_CONNECTOR'] = config['eth_connector']
|
58
|
+
ENV['ETH_ZMQ_ADDR'] = config['eth_zmq_addr']
|
59
|
+
ENV['ETH_HOST'] = config['eth_rpc_host']
|
60
|
+
ENV['ETH_PORT'] = config['eth_rpc_port']
|
61
|
+
ENV['ETH_KEY'] ||= config['primary_account_key']
|
62
|
+
ENV['GAS_PRICE'] = config['gas_price'] || '100000000000000'
|
63
|
+
end
|
64
|
+
|
65
|
+
def dir_exist? directry
|
66
|
+
unless File.directory? directry
|
67
|
+
FileUtils.mkdir_p directry
|
68
|
+
end
|
69
|
+
end
|
15
70
|
end
|
16
71
|
end
|
data/lib/c3d/util/watch.rb
CHANGED
@@ -5,24 +5,28 @@ module C3D
|
|
5
5
|
extend self
|
6
6
|
|
7
7
|
def subscribe contract
|
8
|
+
C3D::Utility.set_config
|
8
9
|
subscribe_file = ENV['WATCH_FILE']
|
9
10
|
subscribed = loader subscribe_file
|
10
11
|
adder subscribed, subscribe_file, contract
|
11
12
|
end
|
12
13
|
|
13
14
|
def unsubscribe contract
|
15
|
+
C3D::Utility.set_config
|
14
16
|
subscribe_file = ENV['WATCH_FILE']
|
15
17
|
subscribed = loader subscribe_file
|
16
18
|
remover subscribed, subscribe_file, contract
|
17
19
|
end
|
18
20
|
|
19
21
|
def ignore contract
|
22
|
+
C3D::Utility.set_config
|
20
23
|
ignore_file = ENV['IGNORE_FILE']
|
21
24
|
ignore = loader ignore_file
|
22
25
|
adder ignored, ignore_file, contract
|
23
26
|
end
|
24
27
|
|
25
28
|
def unignore contract
|
29
|
+
C3D::Utility.set_config
|
26
30
|
ignore_file = ENV['IGNORE_FILE']
|
27
31
|
ignore = loader ignore_file
|
28
32
|
remover ignored, ignore_file, contract
|
@@ -45,7 +49,10 @@ module C3D
|
|
45
49
|
|
46
50
|
def adder object, file, contract
|
47
51
|
unless object.include? contract
|
52
|
+
p contract
|
53
|
+
p contract.class
|
48
54
|
object << contract if contract.class == (String || Array)
|
55
|
+
p object
|
49
56
|
object.flatten if contract.class == Array
|
50
57
|
saver object, file
|
51
58
|
return true
|
data/lib/c3d/version.rb
CHANGED
@@ -1 +1 @@
|
|
1
|
-
VERSION ||= "0.5.
|
1
|
+
VERSION ||= "0.5.4"
|