picky 4.7.0 → 4.8.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -5,6 +5,5 @@
5
5
  #
6
6
  ENV['PICKY_ENV'] ||= ENV['RUBY_ENV'] || ENV['RACK_ENV']
7
7
  PICKY_ENVIRONMENT = ENV['PICKY_ENV'] || 'development' unless defined? PICKY_ENVIRONMENT
8
- PICKY_ROOT = Dir.pwd unless defined? PICKY_ROOT
9
8
 
10
9
  EMPTY_STRING = ''.freeze unless defined? EMPTY_STRING
data/lib/picky/index.rb CHANGED
@@ -181,8 +181,10 @@ module Picky
181
181
 
182
182
  # The directory used by this index.
183
183
  #
184
+ # Note: Used @directory ||=, but needs to be dynamic.
185
+ #
184
186
  def directory
185
- @directory ||= ::File.join(PICKY_ROOT, 'index', PICKY_ENVIRONMENT, name.to_s)
187
+ ::File.join(Picky.root, 'index', PICKY_ENVIRONMENT, name.to_s)
186
188
  end
187
189
 
188
190
  # Make this category range searchable with a fixed range. If you need other
data/lib/picky/loader.rb CHANGED
@@ -10,7 +10,7 @@ module Picky
10
10
  # First itself, then the app.
11
11
  #
12
12
  def reload app_file = 'app'
13
- Dir.chdir PICKY_ROOT
13
+ Dir.chdir Picky.root
14
14
  exclaim 'Reloading loader.'
15
15
  load_self
16
16
  exclaim 'Reloading framework.'
@@ -37,7 +37,7 @@ module Picky
37
37
  # Load a user file.
38
38
  #
39
39
  def load_user filename
40
- Kernel.load File.join(PICKY_ROOT, "#{filename}.rb")
40
+ Kernel.load File.join(Picky.root, "#{filename}.rb")
41
41
  end
42
42
 
43
43
  # Load the user's application.
@@ -45,7 +45,7 @@ module Picky
45
45
  def load_application file = 'app'
46
46
  load_user file
47
47
  rescue LoadError => e
48
- exclaim "\nBy default, Picky needs/loads the PICKY_ROOT/app.rb file as the app.\n\n"
48
+ exclaim "\nBy default, Picky needs/loads the <Picky.root>/app.rb file as the app.\n\n"
49
49
  raise e
50
50
  end
51
51
 
@@ -11,11 +11,11 @@ module Picky
11
11
  end
12
12
 
13
13
  def tokenize index_or_category, prepared_file
14
- timed_exclaim %Q{ "#{index_or_category.identifier}": Tokenized -> #{prepared_file.path.gsub("#{PICKY_ROOT}/", '')}.}
14
+ timed_exclaim %Q{ "#{index_or_category.identifier}": Tokenized -> #{prepared_file.path.gsub("#{Picky.root}/", '')}.}
15
15
  end
16
16
 
17
17
  def dump category
18
- timed_exclaim %Q{ "#{category.identifier}": Dumped -> #{category.index_directory.gsub("#{PICKY_ROOT}/", '')}/#{category.name}_*.}
18
+ timed_exclaim %Q{ "#{category.identifier}": Dumped -> #{category.index_directory.gsub("#{Picky.root}/", '')}/#{category.name}_*.}
19
19
  end
20
20
 
21
21
  def load category
data/lib/picky.rb CHANGED
@@ -1,5 +1,13 @@
1
1
  module Picky
2
2
 
3
+ # Picky class methods.
4
+ # * logger: Picky specific logger.
5
+ # * root: Root used for Picky (eg. index directories).
6
+ #
7
+ class << self
8
+ attr_accessor :logger, :root
9
+ end
10
+
3
11
  # Set default encoding.
4
12
  # (Note: Rails does this already as well)
5
13
  #
@@ -38,6 +46,11 @@ module Picky
38
46
  # Require the constants.
39
47
  #
40
48
  require_relative 'picky/constants'
49
+
50
+ # Set the root path of Picky.
51
+ # (necessary for the index directory etc.)
52
+ #
53
+ Picky.root = Dir.pwd
41
54
 
42
55
  # Loader which handles framework and app loading.
43
56
  #
@@ -50,13 +63,14 @@ module Picky
50
63
  # Check if delegators need to be installed.
51
64
  #
52
65
  require_relative 'picky/sinatra'
53
-
54
- # This is only used in the classic project style.
55
- #
56
- class << self
57
- attr_accessor :logger
58
- end
59
66
 
67
+ # Set the default logger.
68
+ #
69
+ # Options include:
70
+ # * Loggers::Silent
71
+ # * Loggers::Concise (default)
72
+ # * Loggers::Verbose
73
+ #
60
74
  self.logger = Loggers::Default
61
75
 
62
76
  end
@@ -35,12 +35,12 @@ namespace :server do
35
35
  end
36
36
 
37
37
  def chdir_to_root
38
- Dir.chdir PICKY_ROOT
38
+ Dir.chdir Picky.root
39
39
  end
40
40
 
41
41
  def current_pid
42
42
  pidfile = 'tmp/pids/unicorn.pid'
43
- pid = `cat #{File.join(PICKY_ROOT, pidfile)}`
43
+ pid = `cat #{File.join(Picky.root, pidfile)}`
44
44
  if pid.blank?
45
45
  puts
46
46
  puts "No server running (no #{pidfile} found)."
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: picky
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.7.0
4
+ version: 4.8.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-10-05 00:00:00.000000000 Z
12
+ date: 2012-10-08 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rspec
@@ -34,7 +34,7 @@ dependencies:
34
34
  requirements:
35
35
  - - ~>
36
36
  - !ruby/object:Gem::Version
37
- version: 4.7.0
37
+ version: 4.8.0
38
38
  type: :development
39
39
  prerelease: false
40
40
  version_requirements: !ruby/object:Gem::Requirement
@@ -42,7 +42,7 @@ dependencies:
42
42
  requirements:
43
43
  - - ~>
44
44
  - !ruby/object:Gem::Version
45
- version: 4.7.0
45
+ version: 4.8.0
46
46
  - !ruby/object:Gem::Dependency
47
47
  name: text
48
48
  requirement: !ruby/object:Gem::Requirement