justimmo_client 0.5.0 → 0.5.1

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: b165d1e85b2806d6a48d4549205b005bdb24ae3d
4
- data.tar.gz: 9095e7b611ba1ba1d3cc9b2fc9d9fe5bde5dd66f
3
+ metadata.gz: ca35fda69d2b9c35d6dfa8b7f79b10eb129a2ed7
4
+ data.tar.gz: b36be58f5d1c265e62ad4bf35664221797df362b
5
5
  SHA512:
6
- metadata.gz: 81adda6c7d8369c9f7b8750e9436b23311a7b9c2358ec464cdced91bd83fbbfd1beac8fde7857ad905aa9d981867361ab1abcb2f66e4c71e77b17c2807c9ec7c
7
- data.tar.gz: e09286bf5cc8089d57153396677bbe8fc561fb135a2ac6552c35f7cab68554d92ea6ac567ad78d34e177f3eb06c504252a2319b9995ccfe86fa23a6b000c20be
6
+ metadata.gz: d16797d4e4d26181d2f4eef09e72df50246a14f1325a9a5a2fdd49bb9a437e050f5ec4648617d62827ffedff06b5b772573cdbe672601d543ac48dc27673dcd0
7
+ data.tar.gz: 3f80eb73170d6e615dc6a212b5207982e3f9137cba36bf7a8ae7d3bf8ffccde929b80c1ab1bac46a0ce571899af3d841c5f128a3c609fce82e1f149193a61220
data/.rubocop.yml CHANGED
@@ -5,6 +5,7 @@ AllCops:
5
5
  - bin/**
6
6
  - cache/**/*
7
7
  - spec/**/*
8
+ - vendor/**/*
8
9
 
9
10
  # [Layout]
10
11
  Layout/CaseIndentation:
@@ -38,4 +38,7 @@ Gem::Specification.new do |spec|
38
38
  spec.add_dependency "activesupport", "~> 5.1"
39
39
  spec.add_dependency "iso_country_codes", "~> 0"
40
40
  spec.add_dependency "monetize", "~> 1"
41
+
42
+ # other
43
+ spec.add_dependency "i18n", ">= 0.7", "<= 0.9"
41
44
  end
@@ -6,6 +6,7 @@ module JustimmoClient::V1
6
6
  # @api private
7
7
  class JustimmoBase
8
8
  include JustimmoClient::Logging
9
+ include JustimmoClient::Utils
9
10
 
10
11
  # :nodoc:
11
12
  include Virtus.model do |mod|
@@ -8,5 +8,26 @@ module JustimmoClient::V1
8
8
  # @return [$2]
9
9
  attribute :buy, Boolean
10
10
  attribute :rent, Boolean
11
+
12
+ # @!group Instance Method Summary
13
+
14
+ def to_a
15
+ tmp = []
16
+ tmp << :buy if buy?
17
+ tmp << :rent if rent?
18
+ tmp
19
+ end
20
+
21
+ def map(&block)
22
+ to_a.map(&block)
23
+ end
24
+
25
+ def translated
26
+ map { |x| translate(x) }
27
+ end
28
+
29
+ def to_s
30
+ translated.join(", ")
31
+ end
11
32
  end
12
33
  end
@@ -31,12 +31,16 @@ module JustimmoClient::V1
31
31
  tmp
32
32
  end
33
33
 
34
- def to_s
35
- to_a.join(", ")
36
- end
37
-
38
34
  def map(&block)
39
35
  to_a.map(&block)
40
36
  end
37
+
38
+ def translated
39
+ map { |x| translate(x) }
40
+ end
41
+
42
+ def to_s
43
+ map_translated.join(", ")
44
+ end
41
45
  end
42
46
  end
@@ -13,7 +13,7 @@ module JustimmoClient
13
13
  SUPPORTED_API_VERSIONS = [1].freeze
14
14
  REQUIRED = %i[username password].freeze
15
15
 
16
- config_accessor(:base_url) { "api.justimmo.at/rest" }
16
+ config_accessor(:base_url) { ENV.fetch("JUSTIMMO_BASE_URL", "api.justimmo.at/rest") }
17
17
  config_accessor(:secure) { true }
18
18
  config_accessor(:api_ver) { 1 }
19
19
  config_accessor(:username) { ENV.fetch("JUSTIMMO_USERNAME", nil) }
@@ -43,6 +43,7 @@ module JustimmoClient
43
43
 
44
44
  def url
45
45
  validate_credentials
46
+ return "#{base_url}/v#{api_ver}" if self.base_url.start_with?("http")
46
47
  "#{secure ? 'https' : 'http'}://#{base_url}/v#{api_ver}"
47
48
  end
48
49
  end
@@ -38,5 +38,9 @@ module JustimmoClient
38
38
  def interface(name)
39
39
  versioned_api("#{name.to_s.classify}Interface")
40
40
  end
41
+
42
+ def translate(text)
43
+ I18n.translate("justimmo_client.#{text}")
44
+ end
41
45
  end
42
46
  end
@@ -1,10 +1,12 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require "active_support/inflector/inflections"
4
+ require "active_support/i18n"
4
5
 
5
- module JustimmoClient
6
- ActiveSupport::Inflector.inflections do |inflect|
7
- inflect.acronym "XML"
8
- inflect.acronym "JSON"
9
- end
6
+ ActiveSupport::Inflector.inflections do |inflect|
7
+ inflect.acronym "XML"
8
+ inflect.acronym "JSON"
10
9
  end
10
+
11
+ I18n.load_path += Dir[File.expand_path("../../locales/*.yml", __dir__)]
12
+ I18n.default_locale = :en
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module JustimmoClient
4
- VERSION = "0.5.0"
4
+ VERSION = "0.5.1"
5
5
  end
data/locales/de.yml ADDED
@@ -0,0 +1,7 @@
1
+ de:
2
+ justimmo_client:
3
+ buy: Kaufen
4
+ rent: Mieten
5
+ living: Wohnen
6
+ business: Gewerbe
7
+ investment: Anlage
data/locales/en.yml ADDED
@@ -0,0 +1,7 @@
1
+ en:
2
+ justimmo_client:
3
+ buy: buy
4
+ rent: rent
5
+ living: living
6
+ business: business
7
+ investment: investment
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: justimmo_client
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.0
4
+ version: 0.5.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Patrick Auernig
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-10-17 00:00:00.000000000 Z
11
+ date: 2017-10-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -164,6 +164,26 @@ dependencies:
164
164
  - - "~>"
165
165
  - !ruby/object:Gem::Version
166
166
  version: '1'
167
+ - !ruby/object:Gem::Dependency
168
+ name: i18n
169
+ requirement: !ruby/object:Gem::Requirement
170
+ requirements:
171
+ - - ">="
172
+ - !ruby/object:Gem::Version
173
+ version: '0.7'
174
+ - - "<="
175
+ - !ruby/object:Gem::Version
176
+ version: '0.9'
177
+ type: :runtime
178
+ prerelease: false
179
+ version_requirements: !ruby/object:Gem::Requirement
180
+ requirements:
181
+ - - ">="
182
+ - !ruby/object:Gem::Version
183
+ version: '0.7'
184
+ - - "<="
185
+ - !ruby/object:Gem::Version
186
+ version: '0.9'
167
187
  description:
168
188
  email: patrick.auernig@mykolab.com
169
189
  executables: []
@@ -243,6 +263,8 @@ files:
243
263
  - lib/justimmo_client/misc.rb
244
264
  - lib/justimmo_client/option_parser.rb
245
265
  - lib/justimmo_client/version.rb
266
+ - locales/de.yml
267
+ - locales/en.yml
246
268
  - notes.md
247
269
  homepage: https://gitlab.com/exacting/justimmo-client-ruby
248
270
  licenses: