@@ -29,7 +29,6 @@ def finalize
2929
3030 def publish
3131 status = poll_status ( 'staging' )
32- puts "staging status: #{ status } "
3332 if status == 'Staged'
3433 post ( base_url +'list' , '' )
3534 else
@@ -38,14 +37,6 @@ def publish
3837 end
3938
4039 def stage
41- if ( is_staging )
42- raise "an offer is staging"
43- end
44-
45- if ( is_staged )
46- raise "an offer is staged"
47- end
48-
4940 response = get ( base_url )
5041 unless response . kind_of? Net ::HTTPSuccess
5142 raise "could not obtain offer data. expected 200 but got '#{ response . code } '"
@@ -70,7 +61,13 @@ def base_url
7061 def poll_status ( mode )
7162 status = ''
7263 while true
73- status = get_status ( mode )
64+ response = get ( base_url +'progress' )
65+ unless response . kind_of? Net ::HTTPSuccess
66+ raise "could not obtain progress data. expected 200 but got '#{ response . code } '"
67+ end
68+ response_body = JSON . parse ( response . body )
69+ status = response_body [ mode ] [ 'State' ]
70+ puts "#{ mode } status: #{ status } "
7471 break if status != 'InProgress'
7572 puts "#{ Time . now } Starting to sleep for an hour"
7673 sleep 60 * 60
@@ -79,25 +76,6 @@ def poll_status(mode)
7976 return status
8077 end
8178
82- def get_status ( mode )
83- response = get ( base_url +'progress' )
84- unless response . kind_of? Net ::HTTPSuccess
85- raise "could not obtain progress data. expected 200 but got '#{ response . code } '"
86- end
87- response_body = JSON . parse ( response . body )
88- response_body [ mode ] [ 'State' ]
89- end
90-
91- def is_staged ( )
92- status = get_status ( 'staging' )
93- status == 'Staged'
94- end
95-
96- def is_staging ( )
97- status = get_status ( 'staging' )
98- status == 'InProgress'
99- end
100-
10179 def json ( response_string )
10280 response_json = JSON . parse ( response_string )
10381 json = response_json [ 'Offer' ]
0 commit comments