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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 4cd2e94fbf6300728d6faec28283a0567f40bbce
4
- data.tar.gz: 471eda4d6f81893e0993508d82a1ef8c0d1a4b1e
3
+ metadata.gz: 2c6e74fa7d05adf9592342735028198f944390d3
4
+ data.tar.gz: 3c368529abe2a59a94d9f4e8a2abd6bc189c675f
5
5
  SHA512:
6
- metadata.gz: faedca142f322138286c3f984d9ce96328229a7f3b5fe3e1e415da9df789d6d0cd8ca6212c61e7291acc31bd6052c6a41dfda54176769520342f142be0be0f72
7
- data.tar.gz: 734b5031720469dd505a13958139ff4d1c5cc28747e0ccb614f650e8b5506d89cee7f284796850d0fcf597c0cf64f9b909c081a4903429399ac804fe24b55cc9
6
+ metadata.gz: a66fdeb4b4a3efb6a0c922f2bfd869dad919f389969c71493a8daae7c7e02f78c45fdbce30262ea591902678446f16066f3249b2bc8657fc2537e87c18e2c06d
7
+ data.tar.gz: 7d9456a552b429fc3363b101b918df35cd98ff43541f2e166e80850b72f4b7602af28f8f05966d8fa1f735019089f47799cfbe95449bb1667cef9f7e5d88bb51
@@ -6,6 +6,7 @@ module C3D
6
6
 
7
7
  def initialize cli=false
8
8
  set_deps
9
+ #todo - pull these from utility module rather than use here.
9
10
  config = get_config
10
11
  set_the_env config
11
12
  set_trans_config config
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
@@ -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.3"
1
+ VERSION ||= "0.5.4"
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: c3d
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.3
4
+ version: 0.5.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Casey Kuhlman