39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
|
# File 'lib/tx-ruby/crud_requests.rb', line 39
def create(params = {}, options = {})
missing_keys = self.class::CREATE_REQUIRED_PARAMS - params.keys
raise MissingParametersError.new(missing_keys) unless (missing_keys == [:repository_url] || missing_keys == [:private]) || missing_keys.empty?
if params[:repository_url] && !params[:repository_url].empty? && params[:repository_url].match(/^(http|https|ftp):\/\/[a-zA-Z]+\.[a-zA-Z]+\.[a-zA-Z]+/).nil?
raise ParametersFormatError.new(:repository_url, "http|https|ftp://x.x.x")
end
unless options[:trad_from_file].nil?
if params[:i18n_type] == "YAML"
params[:content] = YAML::load_file(params[:content]).to_yaml
else
file = File.open(params[:content], "rb")
params[:content] = file.read
file.close
end
end
url = CrudRequests.generate_url(self)
Transifex.query_api(:post, url, params)
end
|