snails 0.2.2 → 0.2.3

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: 4434461cb2530dcf84cac86e3a4fc469effde080
4
- data.tar.gz: bbb479d99909d465dbe56aa4704320a896d82b95
3
+ metadata.gz: '0139ffb8929e8bbf7455b932634891b49b6ce21e'
4
+ data.tar.gz: 1ee0b9696376d5ce411b8997d767aa49c98aa64c
5
5
  SHA512:
6
- metadata.gz: aad07e606f8d7e194b0b4f3242cc65083a5c7a53dff4178a5a6f4d5af1c32657eee13e7466aa8d7542f1231540b67b453e68f43688d282a75e3917c27e947108
7
- data.tar.gz: 1b6337f12fcbc565425d8080aa819e3a921b81a1da0d6bd7e782ae67f474fea329cc32c0658158e70495f2036dd2f0f226a80adb2bfbdfaf82bcac8e67a64663
6
+ metadata.gz: 32e8d129242be198cf7000ca15e21ee9401fe8297edaaf864f542443fda71c91d556f0983d51e96e31f1b0b8ac2bc0c150b26e175af2ffe6fa8b6d69e98c6f8b
7
+ data.tar.gz: cab0a4118662cce34ebd2b4ca4ea0ca72f10cdd7eff0aa375128b18936004ce16087928fc454fc7136c417815a39d19a457548b211c778bb4f70315d3da35757
@@ -1,19 +1,27 @@
1
1
  require 'logger'
2
2
  require 'pathname'
3
- require 'active_support/string_inquirer'
4
3
 
5
4
  module Snails
6
- class EnvInquirer < ActiveSupport::StringInquirer
7
- def dev?; development?; end
8
- def prod?; production?; end
9
- end
5
+ class Environment
6
+ def initialize(str); @str = str.to_sym; end
7
+ def to_s; @str.to_s; end
8
+ def inspect; to_s.inspect; end
10
9
 
11
- def self.root
12
- @root ||= Pathname.new(Dir.pwd)
10
+ %i(production staging development test).each do |key|
11
+ define_method("#{key}?") { @str == key }
12
+ end
13
+
14
+ alias_method :dev?, :development?
15
+ alias_method :prod?, :production?
16
+ alias_method :testing?, :test?
13
17
  end
14
18
 
15
19
  def self.env
16
- @env ||= EnvInquirer.new(ENV['RACK_ENV'] || ENV['RAILS_ENV'] || 'development')
20
+ @env ||= Environment.new(ENV['RACK_ENV'] || ENV['RAILS_ENV'] || 'development')
21
+ end
22
+
23
+ def self.root
24
+ @root ||= Pathname.new(Dir.pwd)
17
25
  end
18
26
 
19
27
  def self.apps
@@ -17,7 +17,7 @@ module Snails
17
17
  app.register Snails::Locales
18
18
  app.register Snails::Assets
19
19
  end
20
-
20
+
21
21
  end
22
22
 
23
23
  module Database
@@ -36,23 +36,28 @@ module Snails
36
36
 
37
37
  module Locales
38
38
 
39
+ def self.load!(path, lang = nil)
40
+ I18n::Backend::Simple.send(:include, I18n::Backend::Fallbacks)
41
+ I18n.load_path = Dir[File.join(path, '*.yml')]
42
+ I18n.enforce_available_locales = false
43
+ I18n.backend.load_translations
44
+ I18n.locale = lang if lang
45
+ end
46
+
39
47
  def self.registered(app)
40
48
  require 'i18n'
41
49
  require 'i18n/backend/fallbacks'
42
50
 
43
51
  cwd = Pathname.new(Dir.pwd)
44
52
  app.set :locale, :es
45
- app.set :locales_path, cwd.join('config', 'locales')
53
+ app.set :locales_path, app.respond_to?(:locales_path) ? app.locales_path : cwd.join('config', 'locales')
46
54
 
47
55
  app.helpers do
48
56
  def t(key); I18n.t(key); end
49
57
  end
50
58
 
51
59
  app.configure do
52
- I18n::Backend::Simple.send(:include, I18n::Backend::Fallbacks)
53
- I18n.load_path = Dir[File.join(app.settings.locales_path, '*.yml')]
54
- I18n.enforce_available_locales = false
55
- I18n.backend.load_translations
60
+ Locales.load!(app.settings.locales_path)
56
61
  end
57
62
 
58
63
  app.before do
@@ -18,6 +18,13 @@ RSpec.configure do |config|
18
18
  end
19
19
  end
20
20
 
21
+ # config.include Capybara
22
+ # config.include FactoryGirl::Syntax::Methods
23
+ # config.include RequestHelpers, type: :request
24
+ # config.include ControllerTestHelpers, type: :controller
25
+ # config.expect_with(:rspec) { |c| c.syntax = :expect }
26
+
27
+ # config.order = 'random'
21
28
  config.formatter = 'Fuubar' if defined?(Fuubar)
22
29
  config.color = true
23
30
  config.before(:suite) { load_db! }
@@ -3,7 +3,7 @@
3
3
 
4
4
  Gem::Specification.new do |s|
5
5
  s.name = "snails"
6
- s.version = '0.2.2'
6
+ s.version = '0.2.3'
7
7
  s.platform = Gem::Platform::RUBY
8
8
  s.authors = ['Tomás Pollak']
9
9
  s.email = ['tomas@forkhq.com']
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: snails
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.2
4
+ version: 0.2.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tomás Pollak
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-01-23 00:00:00.000000000 Z
11
+ date: 2019-01-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler