cloudfactory 0.1.14 → 0.1.15

Sign up to get free protection for your applications and to get access to all the features.
data/cf.gemspec CHANGED
@@ -81,4 +81,5 @@ EOF
81
81
  s.add_development_dependency "rake"
82
82
  s.add_development_dependency "webmock"
83
83
  s.add_development_dependency "timecop"
84
+ s.add_development_dependency "awesome_print"
84
85
  end
data/lib/cf/cli/line.rb CHANGED
@@ -75,15 +75,24 @@ module Cf # :nodoc: all
75
75
  CF::Line.destroy(line_title, :forced => true)
76
76
  say("The line #{line_title} deleted forcefully!", :yellow)
77
77
  else
78
- # say("!! Warning !!\nThe following are existing production runs based on this line.\n", :cyan)
79
- # Cf::Production.new.list
80
- say("!! Warning !!\nThere are existing production runs based on this line.\n", :yellow)
81
- delete_forcefully = agree("Do you still want to delete this line? [y/n] ")
82
- if delete_forcefully
83
- CF::Line.destroy(line_title, :forced => true)
84
- say("The line #{line_title} deleted successfully!", :yellow)
78
+
79
+ # Check whether this line has existing runs or not
80
+ runs = CF::Run.all(line_title)
81
+ if runs.try(:error).blank?
82
+ say("!!! Warning !!!\nThe following are the existing production runs based on this line.", :cyan)
83
+ existing_runs = Cf::Production.new
84
+ existing_runs.options = {"line" => line_title}
85
+ existing_runs.list
86
+ delete_forcefully = agree("Do you still want to delete this line? [y/n] ")
87
+ if delete_forcefully
88
+ CF::Line.destroy(line_title, :forced => true)
89
+ say("The line #{line_title} deleted successfully!", :yellow)
90
+ else
91
+ say("Line deletion aborted!", :cyan)
92
+ end
85
93
  else
86
- say("Line deletion aborted!", :cyan)
94
+ CF::Line.destroy(line_title)
95
+ say("The line #{line_title} deleted successfully!", :yellow)
87
96
  end
88
97
  end
89
98
  else
@@ -132,6 +141,7 @@ module Cf # :nodoc: all
132
141
  line_title = line_dump['title'].parameterize
133
142
  line_description = line_dump['description']
134
143
  line_department = line_dump['department']
144
+ line_public = line_dump['public']
135
145
 
136
146
  line = CF::Line.info(line_title)
137
147
  if line.error.blank? && options.force?
@@ -146,7 +156,7 @@ module Cf # :nodoc: all
146
156
  say("Line creation aborted!!", :yellow) and exit(1)
147
157
  end
148
158
  end
149
- line = CF::Line.new(line_title, line_department, :description => line_description)
159
+ line = CF::Line.new(line_title, line_department, {:description => line_description, :public => line_public})
150
160
  say "Creating new assembly line: #{line.title}", :green
151
161
  say("Error: #{line.errors}", :red) and exit(1) if line.errors.present?
152
162
 
@@ -173,12 +183,13 @@ module Cf # :nodoc: all
173
183
  type = station_file['station']['station_type']
174
184
  index = station_file['station']['station_index']
175
185
  input_formats_for_station = station_file['station']['input_formats']
186
+ batch_size = station_file['station']['batch_size']
176
187
  if type == "tournament"
177
188
  jury_worker = station_file['station']['jury_worker']
178
189
  auto_judge = station_file['station']['auto_judge']
179
- station_params = {:line => line, :type => type, :jury_worker => jury_worker, :auto_judge => auto_judge, :input_formats => input_formats_for_station}
190
+ station_params = {:line => line, :type => type, :jury_worker => jury_worker, :auto_judge => auto_judge, :input_formats => input_formats_for_station, :batch_size => batch_size}
180
191
  else
181
- station_params = {:line => line, :type => type, :input_formats => input_formats_for_station}
192
+ station_params = {:line => line, :type => type, :input_formats => input_formats_for_station, :batch_size => batch_size}
182
193
  end
183
194
  station = CF::Station.create(station_params) do |s|
184
195
  say "Adding Station #{index}: #{s.type}", :green
@@ -1,6 +1,6 @@
1
1
  module Cf
2
2
  class LineYamlValidator
3
-
3
+
4
4
  def self.validate(yaml_path)
5
5
  line_dump = YAML::load(File.read(yaml_path))
6
6
  errors = []
@@ -91,83 +91,85 @@ module Cf
91
91
  end
92
92
  end
93
93
 
94
- # Checking Stat_badge
95
- stat_badge = station['station']['worker']['stat_badge']
96
- if !stat_badge.nil?
97
- errors << "Stat badge setting is invalid in Block station #{i+1}!" if stat_badge.class != Hash
98
- end
94
+ if station_type != "improve"
95
+ # Checking Stat_badge
96
+ stat_badge = station['station']['worker']['stat_badge']
97
+ if !stat_badge.nil?
98
+ errors << "Stat badge setting is invalid in Block station #{i+1}!" if stat_badge.class != Hash
99
+ end
99
100
 
100
- # Checking skill_badge
101
- skill_badges = station['station']['worker']['skill_badges']
102
- if !skill_badges.nil?
103
- errors << "Skill badge settings is invalid in Block station #{i+1}!" if skill_badges.class != Array
104
- skill_badges.each_with_index do |badge, badge_index|
105
- badge_title = badge['title']
106
- badge_description = badge['description']
107
- max_badges = badge['max_badges']
108
- badge_test = badge['test']
109
- test_input = badge_test['input'] if badge_test.class == Hash
110
- expected_output = badge_test['expected_output'] if badge_test.class == Hash
111
- errors << "Skill badge title is Missing in Block #{badge_index+1}!" if badge_title.nil?
112
- errors << "Skill badge Description is Missing in Block #{badge_index+1}!" if badge_description.nil?
113
- errors << "Skill badge max_badges must be greater than 1000 in Block #{badge_index+1}!" if max_badges < 1000 && !max_badges.nil?
114
- errors << "Skill badge Test is Missing in Block #{badge_index+1}!" if badge_test.nil?
115
- errors << "Skill badge Test is Invalid (must be Hash) in Block #{badge_index+1}!" if badge_test.class != Hash && !badge_test.nil?
116
- errors << "Skill badge Test input is Missing in Block #{badge_index+1}!" if test_input.nil? && !badge_test.nil?
117
- errors << "Skill badge Test input is Invalid (must be Hash) in Block #{badge_index+1}!" if test_input.class != Hash && !test_input.nil? && !badge_test.nil?
118
- errors << "Skill badge Test expected_output is Missing in Block #{badge_index+1}!" if expected_output.nil? && !badge_test.nil?
119
- errors << "Skill badge Test expected_output is Invalid (must be an array) in Block #{badge_index+1}!" if expected_output.class != Array && !expected_output.nil? && !badge_test.nil?
101
+ # Checking skill_badge
102
+ skill_badges = station['station']['worker']['skill_badges']
103
+ if !skill_badges.nil?
104
+ errors << "Skill badge settings is invalid in Block station #{i+1}!" if skill_badges.class != Array
105
+ skill_badges.each_with_index do |badge, badge_index|
106
+ badge_title = badge['title']
107
+ badge_description = badge['description']
108
+ max_badges = badge['max_badges']
109
+ badge_test = badge['test']
110
+ test_input = badge_test['input'] if badge_test.class == Hash
111
+ expected_output = badge_test['expected_output'] if badge_test.class == Hash
112
+ errors << "Skill badge title is Missing in Block #{badge_index+1}!" if badge_title.nil?
113
+ errors << "Skill badge Description is Missing in Block #{badge_index+1}!" if badge_description.nil?
114
+ errors << "Skill badge max_badges must be greater than 1000 in Block #{badge_index+1}!" if max_badges < 1000 && !max_badges.nil?
115
+ errors << "Skill badge Test is Missing in Block #{badge_index+1}!" if badge_test.nil?
116
+ errors << "Skill badge Test is Invalid (must be Hash) in Block #{badge_index+1}!" if badge_test.class != Hash && !badge_test.nil?
117
+ errors << "Skill badge Test input is Missing in Block #{badge_index+1}!" if test_input.nil? && !badge_test.nil?
118
+ errors << "Skill badge Test input is Invalid (must be Hash) in Block #{badge_index+1}!" if test_input.class != Hash && !test_input.nil? && !badge_test.nil?
119
+ errors << "Skill badge Test expected_output is Missing in Block #{badge_index+1}!" if expected_output.nil? && !badge_test.nil?
120
+ errors << "Skill badge Test expected_output is Invalid (must be an array) in Block #{badge_index+1}!" if expected_output.class != Array && !expected_output.nil? && !badge_test.nil?
121
+ end
120
122
  end
121
- end
122
123
 
123
- # Checking TaskForm
124
- if worker_type == "human"
125
- task_form = station['station']['task_form']
126
- if task_form.nil?
127
- custom_task_form = station['station']['custom_task_form']
128
- if custom_task_form.nil?
129
- errors << "Form is missing in Block station #{i+1}!"
130
- elsif custom_task_form.class == Hash
131
- form_title = custom_task_form['form_title']
124
+ # Checking TaskForm
125
+ if worker_type == "human"
126
+ task_form = station['station']['task_form']
127
+ if task_form.nil?
128
+ custom_task_form = station['station']['custom_task_form']
129
+ if custom_task_form.nil?
130
+ errors << "Form is missing in Block station #{i+1}!"
131
+ elsif custom_task_form.class == Hash
132
+ form_title = custom_task_form['form_title']
133
+ errors << "Form Title is missing in Block station #{i+1}!" if form_title.nil?
134
+
135
+ instruction = custom_task_form['instruction']
136
+ errors << "Form Instruction is missing in Block station #{i+1}!" if instruction.nil?
137
+ end
138
+ elsif task_form.class == Hash
139
+ form_title = task_form['form_title']
132
140
  errors << "Form Title is missing in Block station #{i+1}!" if form_title.nil?
133
141
 
134
- instruction = custom_task_form['instruction']
142
+ instruction = task_form['instruction']
135
143
  errors << "Form Instruction is missing in Block station #{i+1}!" if instruction.nil?
136
- end
137
- elsif task_form.class == Hash
138
- form_title = task_form['form_title']
139
- errors << "Form Title is missing in Block station #{i+1}!" if form_title.nil?
140
-
141
- instruction = task_form['instruction']
142
- errors << "Form Instruction is missing in Block station #{i+1}!" if instruction.nil?
143
144
 
144
- # Checking Form Fields
145
- form_fields = task_form['form_fields']
146
- errors << "Form Field is missing in Block station #{i+1}!" if form_fields.nil?
147
- if form_fields.class == Array
148
- form_fields.each_with_index do |form_field, index|
149
- field_label = form_field['label']
150
- errors << "Label is missing in block #{index+1} of Form Field within Station #{i+1}!" if field_label.nil?
151
- required = form_field['required']
152
- field_type = form_field['field_type']
153
- if !field_type.nil?
154
- unless %w(short_answer long_answer radio_button check_box select_box date email number).include?(field_type)
155
- errors << "Field Type of Form Field is invalid in Block #{index+1} of station Block #{i+1}!"
156
- end
157
- if field_type == "radio_button" || field_type == "select_box"
158
- option_values = form_field['option_values']
159
- if option_values.nil?
160
- errors << "Option values is required for field_type => #{field_type} in block #{index+1} of Form Field within Station #{i+1} !"
161
- elsif !option_values.nil?
162
- if option_values.class != Array
163
- errors << "Option values must be an array for field_type => #{field_type} in block #{index+1} of Form Field within Station #{i+1}!"
145
+ # Checking Form Fields
146
+ form_fields = task_form['form_fields']
147
+ errors << "Form Field is missing in Block station #{i+1}!" if form_fields.nil?
148
+ if form_fields.class == Array
149
+ form_fields.each_with_index do |form_field, index|
150
+ field_label = form_field['label']
151
+ errors << "Label is missing in block #{index+1} of Form Field within Station #{i+1}!" if field_label.nil?
152
+ required = form_field['required']
153
+ field_type = form_field['field_type']
154
+ if !field_type.nil?
155
+ unless %w(short_answer long_answer radio_button check_box select_box date email number).include?(field_type)
156
+ errors << "Field Type of Form Field is invalid in Block #{index+1} of station Block #{i+1}!"
157
+ end
158
+ if field_type == "radio_button" || field_type == "select_box"
159
+ option_values = form_field['option_values']
160
+ if option_values.nil?
161
+ errors << "Option values is required for field_type => #{field_type} in block #{index+1} of Form Field within Station #{i+1} !"
162
+ elsif !option_values.nil?
163
+ if option_values.class != Array
164
+ errors << "Option values must be an array for field_type => #{field_type} in block #{index+1} of Form Field within Station #{i+1}!"
165
+ end
164
166
  end
165
167
  end
166
168
  end
167
169
  end
170
+ else
171
+ errors << "Form fields must be an array for Station #{i+1}!"
168
172
  end
169
- else
170
- errors << "Form fields must be an array for Station #{i+1}!"
171
173
  end
172
174
  end
173
175
  end
@@ -175,9 +177,7 @@ module Cf
175
177
  end
176
178
  end
177
179
  end
178
-
179
180
  return errors
180
181
  end
181
-
182
182
  end
183
183
  end
@@ -12,85 +12,116 @@ module Cf # :nodoc: all
12
12
 
13
13
  desc "production start <run-title>", "creates a production run with input data file at input/<run-title>.csv"
14
14
  method_option :input_data, :type => :string, :aliases => "-i", :desc => "the name of the input data file"
15
- method_option :live, :type => :boolean, :default => false, :aliases => "-l", :desc => "force the host to set to live mturk environment"
16
- def start(title=nil)
17
-
15
+ method_option :live, :type => :boolean, :default => false, :desc => "specifies sandbox or live mode"
16
+ method_option :line, :type => :string, :aliases => "-l", :desc => "public line to use to do the production run. the format should be <account_name>/<line-title> e.g. millisami/brandiator"
17
+ def start(title=nil)
18
18
  line_destination = Dir.pwd
19
19
  yaml_source = "#{line_destination}/line.yml"
20
+
21
+ set_target_uri(options[:live])
22
+ set_api_key
23
+ CF.account_name = CF::Account.info.name
20
24
 
21
- unless File.exist?("#{yaml_source}")
22
- say("The current directory is not a valid line directory.", :red) and return
25
+ if File.exist?("#{yaml_source}")
26
+ line_yaml_dump = YAML::load(File.open(yaml_source))
27
+ line_title = line_yaml_dump['title'].parameterize
28
+ line = CF::Line.find(line_title)
29
+ line = Hashie::Mash.new(line)
30
+ if line.error.blank?
31
+ line_title = line_title
32
+ else
33
+ say("#{line.error.message}", :red) and return
34
+ end
35
+ elsif options[:line].present?
36
+ line = CF::Line.find(options[:line])
37
+ line = Hashie::Mash.new(line)
38
+ if line.error.blank?
39
+ line_title = options[:line]
40
+ else
41
+ say("#{line.error.message}", :red) and return
42
+ end
43
+ else
44
+ say("Looks like you're not in the Line directory or did not provide the line title to use the line", :red) and return
23
45
  end
24
46
 
25
- line_yaml_dump = YAML::load(File.open(yaml_source))
26
- line_title = line_yaml_dump['title'].parameterize
27
-
28
47
  if title.nil?
29
- run_title = "#{line_title}-#{Time.new.strftime('%y%b%e-%H%M%S')}".downcase
48
+ if line_title =~ /\w\/\w/
49
+ run_title = "#{line_title.split("/").last}-#{Time.new.strftime('%y%b%e-%H%M%S')}".downcase
50
+ else
51
+ run_title = "#{line_title}-#{Time.new.strftime('%y%b%e-%H%M%S')}".downcase
52
+ end
30
53
  else
31
54
  run_title = "#{title.parameterize}-#{Time.new.strftime('%y%b%e-%H%M%S')}".downcase
32
55
  end
33
56
 
34
- if !options[:input_data].nil?
35
- input_data = "input/#{options[:input_data]}"
57
+ input_data = options[:input_data].presence
58
+
59
+ if input_data =~ /^\// #checking absolute input data path
60
+ input_data_file = input_data
36
61
  else
37
- input_data_dir = "#{line_destination}/input"
38
- input_files = Dir["#{input_data_dir}/*.csv"]
39
- file_count = input_files.size
40
- case file_count
41
- when 0
42
- say("No input data file present inside the input folder", :red) and return
43
- when 1
44
- input_data = "input/#{extract_name(input_files.first)}"
45
- else
46
- # Let the user choose the file
47
- chosen_file = nil
48
- choose do |menu|
49
- menu.header = "Input data files"
50
- menu.prompt = "Please choose which file to be used as input data: "
62
+ if Dir.exist?("#{line_destination}/input")
63
+ input_data_dir = "#{line_destination}/input"
64
+ input_files = Dir["#{input_data_dir}/*.csv"]
65
+ file_count = input_files.size
66
+ case file_count
67
+ when 0
68
+ say("No input data file present inside the input folder", :red) and return
69
+ when 1
70
+ input_data_file = "#{Dir.pwd}/input/#{extract_name(input_files.first)}"
71
+ else
72
+ # Let the user choose the file
73
+ chosen_file = nil
74
+ choose do |menu|
75
+ menu.header = "Input data files"
76
+ menu.prompt = "Please choose which file to be used as input data: "
51
77
 
52
- input_files.each do |item|
53
- menu.choice(extract_name(item)) do
54
- chosen_file = extract_name(item)
55
- say("Using the file #{chosen_file} as input data")
78
+ input_files.each do |item|
79
+ menu.choice(extract_name(item)) do
80
+ chosen_file = extract_name(item)
81
+ say("Using the file #{chosen_file} as input data")
82
+ end
56
83
  end
57
84
  end
85
+ input_data_file = "#{Dir.pwd}/input/#{chosen_file}"
58
86
  end
59
- input_data = "input/#{chosen_file}"
87
+ else
88
+ unless File.exist?(input_data)
89
+ say("The input data file named #{input_data} doesn't exist", :red) and return
90
+ end
91
+ input_data_file = "#{Dir.pwd}/#{input_data}"
60
92
  end
61
93
  end
62
94
 
63
- unless File.exist?(input_data)
64
- say("The input data file named #{input_data} is missing.", :red) and return
95
+ unless File.exist?(input_data_file)
96
+ say("The input data file named #{input_data} is missing", :red) and return
65
97
  end
66
98
 
67
- set_target_uri(options[:live])
99
+
68
100
  # before starting the run creation process, we need to make sure whether the line exists or not
69
101
  # if not, then we got to first create the line and then do the production run
70
102
  # else we just simply do the production run
71
- set_api_key(yaml_source)
72
- CF.account_name = CF::Account.info.name
73
- line = CF::Line.info(line_title)
74
- input_data_file = "#{Dir.pwd}/#{input_data}"
103
+
75
104
  if line.error.blank?
76
105
  say "Creating a production run with title #{run_title}", :green
77
- run = CF::Run.create(line, run_title, input_data_file)
106
+ run = CF::Run.create(line_title, run_title, input_data_file)
78
107
  if run.errors.blank?
79
108
  display_success_run(run)
80
109
  else
81
110
  say("Error: #{run.errors}", :red)
82
111
  end
83
112
  else
84
- # first create line
85
- say("Creating the line: #{line_title}", :green)
86
- Cf::Line.new.create
87
- # Now create a production run with the title run_title
88
- say "Creating a production run with title #{run_title}", :green
89
- run = CF::Run.create(CF::Line.info(line_title), run_title, input_data_file)
90
- if run.errors.blank?
91
- display_success_run(run)
92
- else
93
- say("Error: #{run.errors}", :red)
113
+ if File.exist?("#{yaml_source}") and !line_title =~ /\w\/\w/
114
+ # first create line only if its in the valid line directory
115
+ say("Creating the line: #{line_title}", :green)
116
+ Cf::Line.new.create
117
+ # Now create a production run with the title run_title
118
+ say "Creating a production run with title #{run_title}", :green
119
+ run = CF::Run.create(CF::Line.info(line_title), run_title, input_data_file)
120
+ if run.errors.blank?
121
+ display_success_run(run)
122
+ else
123
+ say("Error: #{run.errors}", :red)
124
+ end
94
125
  end
95
126
  end
96
127
  end
@@ -109,7 +140,8 @@ module Cf # :nodoc: all
109
140
  set_api_key
110
141
  CF.account_name = CF::Account.info.name
111
142
  if options['line'].present?
112
- runs = CF::Run.all(options['line'].parameterize)
143
+ line_title = options['line'].parameterize
144
+ runs = CF::Run.all(line_title)
113
145
  else
114
146
  runs = CF::Run.all
115
147
  end
@@ -128,7 +160,11 @@ module Cf # :nodoc: all
128
160
  end
129
161
  end
130
162
  say("\n")
131
- say(runs_table)
163
+ if runs_table.rows.present?
164
+ say(runs_table)
165
+ else
166
+ say("No production run for line #{line_title}", :yellow)
167
+ end
132
168
  end
133
169
 
134
170
  desc "production resume", "resume a paused production run"
data/lib/cf/cli.rb CHANGED
@@ -22,6 +22,10 @@ require "#{cli_directory}/line_yaml_validator"
22
22
 
23
23
  if ENV['TEST']
24
24
  require 'ruby-debug'
25
+ require 'awesome_print'
26
+ require 'active_support/time_with_zone'
27
+ ::Debugger.start
28
+ ::Debugger.settings[:autoeval] = true if ::Debugger.respond_to?(:settings)
25
29
  end
26
30
 
27
31
  module Cf # :nodoc: all
@@ -39,7 +43,7 @@ module Cf # :nodoc: all
39
43
  set_target_uri(false)
40
44
  resp = CF::Account.login(email, passwd)
41
45
  if resp.error.blank? and resp.api_key.present?
42
- File.open(config_file, 'w') {|f| f.write({ :target_url => CF.api_url, :api_version => CF.api_version, :api_key => resp.api_key }.to_yaml) }
46
+ File.open(config_file, 'w') {|f| f.write("#Don't change this file unless you know what you're doing\n" + { :target_url => CF.api_url, :api_version => CF.api_version, :api_key => resp.api_key }.to_yaml) }
43
47
  say("\nNow you're logged in.\nTo get started, run cf help\n", :green)
44
48
  else
45
49
  say("\n#{resp.error.message}\nTry again with valid one.\n", :red)
data/lib/cf/client.rb CHANGED
@@ -56,7 +56,7 @@ module CF # :nodoc: all
56
56
  Hashie::Mash.new(new_response)
57
57
  end
58
58
  else
59
- response
59
+ JSON.load(response)
60
60
  end
61
61
  end
62
62
  end
data/lib/cf/line.rb CHANGED
@@ -56,6 +56,7 @@ module CF
56
56
  def stations stations = nil
57
57
  if stations
58
58
  type = stations.type
59
+ @batch_size = stations.batch_size
59
60
  @station_input_formats = stations.station_input_formats
60
61
  if type == "Improve" && self.stations.size < 1
61
62
  raise ImproveStationNotAllowed.new("You cannot add Improve Station as a first station of a line")
@@ -63,30 +64,53 @@ module CF
63
64
  if type == "Tournament"
64
65
  @jury_worker = stations.jury_worker
65
66
  @auto_judge = stations.auto_judge
66
- request_tournament =
67
- {
68
- :body =>
67
+ if @batch_size.nil?
68
+ request_tournament =
69
69
  {
70
- :api_key => CF.api_key,
71
- :station => {:type => type, :jury_worker => @jury_worker, :auto_judge => @auto_judge, :input_formats => @station_input_formats}
70
+ :body =>
71
+ {
72
+ :api_key => CF.api_key,
73
+ :station => {:type => type, :jury_worker => @jury_worker, :auto_judge => @auto_judge, :input_formats => @station_input_formats}
74
+ }
72
75
  }
73
- }
76
+ else
77
+ request_tournament =
78
+ {
79
+ :body =>
80
+ {
81
+ :api_key => CF.api_key,
82
+ :station => {:type => type, :jury_worker => @jury_worker, :auto_judge => @auto_judge, :input_formats => @station_input_formats, :batch_size => @batch_size}
83
+ }
84
+ }
85
+ end
74
86
  resp = HTTParty.post("#{CF.api_url}#{CF.api_version}/lines/#{CF.account_name}/#{self.title.downcase}/stations.json",request_tournament)
75
87
  else
76
- request_general =
77
- {
78
- :body =>
88
+ if @batch_size.nil?
89
+ request_general =
90
+ {
91
+ :body =>
92
+ {
93
+ :api_key => CF.api_key,
94
+ :station => {:type => type, :input_formats => @station_input_formats}
95
+ }
96
+ }
97
+ else
98
+ request_general =
79
99
  {
80
- :api_key => CF.api_key,
81
- :station => {:type => type, :input_formats => @station_input_formats}
100
+ :body =>
101
+ {
102
+ :api_key => CF.api_key,
103
+ :station => {:type => type, :input_formats => @station_input_formats, :batch_size => @batch_size}
104
+ }
82
105
  }
83
- }
106
+ end
84
107
  resp = HTTParty.post("#{CF.api_url}#{CF.api_version}/lines/#{CF.account_name}/#{self.title.downcase}/stations.json",request_general)
85
108
  end
86
109
  station = CF::Station.new()
87
110
  resp.to_hash.each_pair do |k,v|
88
111
  station.send("#{k}=",v) if station.respond_to?(k)
89
112
  end
113
+ station.batch_size = @batch_size
90
114
  station.line = self
91
115
  station.line_title = self.title
92
116
  if resp.response.code != "200"
@@ -183,9 +207,16 @@ module CF
183
207
  def self.find(line)
184
208
  if line.class == CF::Line
185
209
  resp = get("/lines/#{CF.account_name}/#{line.title.downcase}.json")
186
- else
187
- resp = get("/lines/#{CF.account_name}/#{line.downcase}.json")
210
+ elsif line.class == String
211
+ if line.split("/").count == 2
212
+ account = line.split("/").first
213
+ title = line.split("/").last
214
+ resp = get("/lines/#{account}/#{title.downcase}.json")
215
+ elsif line.split("/").count == 1
216
+ resp = get("/lines/#{CF.account_name}/#{line.downcase}.json")
217
+ end
188
218
  end
219
+ return resp.to_hash
189
220
  end
190
221
 
191
222
  # ==Returns all the lines of an account
@@ -252,7 +283,7 @@ module CF
252
283
  end
253
284
  end
254
285
 
255
- def self.details(line_title)
286
+ def self.inspect(line_title)
256
287
  resp = get("/lines/#{CF.account_name}/#{line_title.downcase}/inspect.json")
257
288
  send_resp = resp.to_hash
258
289
  @line_input_formats = []