Module: Localeapp::Routes

Included in:
ApiCaller, Sender
Defined in:
lib/localeapp/routes.rb

Constant Summary collapse

VERSION =
'v1'

Instance Method Summary collapse

Instance Method Details

#create_translation_endpoint(options = {}) ⇒ Object



27
28
29
# File 'lib/localeapp/routes.rb', line 27

def create_translation_endpoint(options = {})
  [:post, translations_url(options)]
end

#export_endpoint(options = {}) ⇒ Object



31
32
33
# File 'lib/localeapp/routes.rb', line 31

def export_endpoint(options = {})
  [:get, export_url(options)]
end

#export_url(options = {}) ⇒ Object



53
54
55
56
57
58
# File 'lib/localeapp/routes.rb', line 53

def export_url(options = {})
  options[:format] ||= 'yml'
  url = http_scheme.build(base_options.merge(:path => export_path(options[:format])))
  url.query = options[:query].map { |k,v| "#{k}=#{v}" }.join('&') if options[:query]
  url.to_s
end

#import_endpoint(options = {}) ⇒ Object



71
72
73
# File 'lib/localeapp/routes.rb', line 71

def import_endpoint(options = {})
  [:post, import_url(options)]
end

#import_url(options = {}) ⇒ Object



75
76
77
# File 'lib/localeapp/routes.rb', line 75

def import_url(options={})
  http_scheme.build(base_options.merge(:path => import_path)).to_s
end

#missing_translations_endpoint(options = {}) ⇒ Object



60
61
62
# File 'lib/localeapp/routes.rb', line 60

def missing_translations_endpoint(options = {})
  [:post, missing_translations_url(options)]
end

#missing_translations_url(options = {}) ⇒ Object



64
65
66
67
68
69
# File 'lib/localeapp/routes.rb', line 64

def missing_translations_url(options={})
  options[:format] ||= 'json'
  url = http_scheme.build(base_options.merge(:path => missing_translations_path(options[:format])))
  url.query = options[:query].map { |k,v| "#{k}=#{v}" }.join('&') if options[:query]
  url.to_s
end

#project_endpoint(options = {}) ⇒ Object



7
8
9
# File 'lib/localeapp/routes.rb', line 7

def project_endpoint(options = {})
  [:get, project_url(options)]
end

#project_url(options = {}) ⇒ Object



11
12
13
14
# File 'lib/localeapp/routes.rb', line 11

def project_url(options = {})
  options[:format] ||= 'json'
  http_scheme.build(base_options.merge(:path => project_path(options[:format]))).to_s
end

#remove_endpoint(options = {}) ⇒ Object



35
36
37
# File 'lib/localeapp/routes.rb', line 35

def remove_endpoint(options = {})
  [:delete, remove_url(options)]
end

#remove_url(options = {}) ⇒ Object



39
40
41
42
# File 'lib/localeapp/routes.rb', line 39

def remove_url(options = {})
  url = http_scheme.build(base_options.merge(:path => remove_path(options[:key], options[:format])))
  url.to_s
end

#rename_endpoint(options = {}) ⇒ Object



44
45
46
# File 'lib/localeapp/routes.rb', line 44

def rename_endpoint(options = {})
  [:post, rename_url(options)]
end

#rename_url(options = {}) ⇒ Object



48
49
50
51
# File 'lib/localeapp/routes.rb', line 48

def rename_url(options = {})
  url = http_scheme.build(base_options.merge(:path => rename_path(options[:current_name], options[:format])))
  url.to_s
end

#translations_endpoint(options = {}) ⇒ Object



23
24
25
# File 'lib/localeapp/routes.rb', line 23

def translations_endpoint(options = {})
  [:get, translations_url(options)]
end

#translations_url(options = {}) ⇒ Object



16
17
18
19
20
21
# File 'lib/localeapp/routes.rb', line 16

def translations_url(options={})
  options[:format] ||= 'yml'
  url = http_scheme.build(base_options.merge(:path => translations_path(options[:format])))
  url.query = options[:query].map { |k,v| "#{k}=#{v}" }.join('&') if options[:query]
  url.to_s
end