dayvan 0.1.2 → 0.1.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/README.rdoc CHANGED
@@ -1,6 +1,6 @@
1
1
  = Dayvan
2
2
 
3
- For a full summary please see the website[http://chrislloyd.github.com/dayvan].
3
+ For a full summary please see the website[http://chrislloyd.cloudant.com/dayvan/_design/dayvan/index.html] and it's code[http://github.com/chrislloyd/dayvan/tree/example].
4
4
 
5
5
  == Copyright
6
6
 
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.2
1
+ 0.1.3
data/lib/dayvan.rb CHANGED
@@ -15,5 +15,5 @@ module Dayvan
15
15
  end
16
16
  end
17
17
 
18
- %w(attachment view security design project cli).
18
+ %w(attachment view validation design project cli).
19
19
  each {|lib| require "dayvan/#{lib}"}
@@ -5,7 +5,7 @@ require 'mime/types'
5
5
  class Dayvan::Attachment
6
6
 
7
7
  def self.all(root)
8
- Dir[root.join('**/**')].
8
+ root.exist? && Dir[root.join('**/**')].
9
9
  reject {|f| File.directory?(f)}. # Allows symlinks
10
10
  inject({}) {|all, f|
11
11
  attachment = new(f)
data/lib/dayvan/cli.rb CHANGED
@@ -17,14 +17,12 @@ class Dayvan::Cli < Thor
17
17
  empty_directory 'config'
18
18
 
19
19
  create_file "config/#{name}.yaml" do
20
- {'designs' => [name.to_s],
21
- 'database' => {
20
+ {'database' => {
22
21
  'url' => "http://localhost:5984/#{name}"
23
- }
24
- }.to_yaml.split("\n")[1..-1].join("\n") + "\n"
22
+ }}.to_yaml.split("\n")[1..-1].join("\n") + "\n"
25
23
  end
26
24
 
27
- copy_file 'security.coffee.erb', 'config/security.coffee'
25
+ copy_file 'validation.coffee.erb', 'config/validation.coffee'
28
26
 
29
27
  empty_directory 'views'
30
28
  copy_file 'all.coffee.erb', 'views/all.coffee'
@@ -42,10 +40,14 @@ class Dayvan::Cli < Thor
42
40
  def push
43
41
  Dayvan.project.create_database!
44
42
  Dayvan.project.push!
45
- rescue Errno::ECONNREFUSED, RestClient::Unauthorized
43
+ rescue SocketError, Errno::ECONNREFUSED, RestClient::Unauthorized
46
44
  abort "fatal: Couldn't connect to CouchDB at #{Dayvan.project.db.url}"
47
45
  rescue Dayvan::ConfigError
48
- abort "fatal: Not a Dayvan app"
46
+ abort "fatal: No Dayvan config found, searched for \n" +
47
+ Dayvan.project.config_search_paths.
48
+ map {|p| ' - ' + p.relative_path_from(Dayvan.project.dir).to_s}.
49
+ join("\n") +
50
+ "\n"
49
51
  end
50
52
 
51
53
  private
data/lib/dayvan/design.rb CHANGED
@@ -33,9 +33,8 @@ class Dayvan::Design
33
33
  end
34
34
 
35
35
  def attachment_path
36
- config['attachments'] ||
37
- config['attachment'] ||
38
- Dayvan.project.dir.join('public')
36
+ config_val('attachment_path', 'attachments_path', 'attachments') ||
37
+ Dayvan.project.dir.join('public')
39
38
  end
40
39
 
41
40
  def views
@@ -43,27 +42,26 @@ class Dayvan::Design
43
42
  end
44
43
 
45
44
  def view_path
46
- config['views'] ||
47
- config['view'] ||
48
- Dayvan.project.dir.join('views')
45
+ config_val('view_path', 'views_path', 'views') ||
46
+ Dayvan.project.dir.join('views')
49
47
  end
50
48
 
51
49
  def validate_doc_update
52
- Dayvan::Security.new(validate_doc_update_path)
50
+ Dayvan::Validation.all(validate_doc_update_path)
53
51
  end
54
52
 
55
53
  def validate_doc_update_path
56
- config['security'] ||
57
- Dayvan.project.dir.join('config','security.coffee')
54
+ config_val('validation_path', 'validate_path', 'validation') ||
55
+ Dayvan.project.dir.join('config','validation.coffee')
58
56
  end
59
57
 
60
58
 
61
59
  def to_hash
62
- hsh = { '_attachments' => attachments,
60
+ { '_rev' => rev,
61
+ '_attachments' => attachments,
63
62
  'views' => views,
64
63
  'validate_doc_update' => validate_doc_update
65
- }
66
- rev ? hsh.merge('_rev' => rev) : hsh
64
+ }.reject {|key, val| !val}
67
65
  end
68
66
 
69
67
  def to_json
@@ -74,4 +72,10 @@ class Dayvan::Design
74
72
  doc.put to_json
75
73
  end
76
74
 
75
+ private
76
+
77
+ def config_val(*keys)
78
+ keys.find {|key| config.has_key?(key)}
79
+ end
80
+
77
81
  end
@@ -12,7 +12,7 @@ class Dayvan::Project
12
12
  end
13
13
 
14
14
  def designs
15
- config['designs'].
15
+ (config['designs'] || [dir.basename]).
16
16
  map {|design| Dayvan::Design.new_from_config(design)}
17
17
  end
18
18
 
@@ -29,15 +29,18 @@ class Dayvan::Project
29
29
  )[dbname]
30
30
  end
31
31
 
32
- def config_path
32
+ def config_search_paths
33
33
  dirname = dir.expand_path.basename
34
- ["#{dirname}.yaml", "#{dirname}.yml", 'divan.yaml', 'divan.yml'].
34
+ ["#{dirname}.yaml", "#{dirname}.yml", 'dayvan.yaml', 'dayvan.yml'].
35
35
  inject([]) {|dirs, f|
36
36
  dirs << dir.join('config',f)
37
37
  dirs << dir.join(f)
38
38
  dirs
39
- }.
40
- find {|dir| dir.file? && dir.readable?} ||
39
+ }.uniq
40
+ end
41
+
42
+ def config_path
43
+ config_search_paths.find {|f| f.file? && f.readable?} ||
41
44
  raise(Dayvan::ConfigError)
42
45
  end
43
46
 
@@ -1,9 +1,9 @@
1
1
  require 'coffee-script'
2
2
 
3
- class Dayvan::Security
3
+ class Dayvan::Validation
4
4
 
5
- def self.all
6
- new(Dayvan.project.security_path)
5
+ def self.all(path)
6
+ path.exist? && new(path)
7
7
  end
8
8
 
9
9
  attr_accessor :path
data/lib/dayvan/view.rb CHANGED
@@ -4,7 +4,7 @@ class Dayvan::View
4
4
  attr_accessor :path
5
5
 
6
6
  def self.all(root)
7
- Dir[root.join('**/*.coffee')].
7
+ root.exist? && Dir[root.join('**/*.coffee')].
8
8
  reject {|f| File.directory?(f)}. # Allows symlinks
9
9
  inject({}) {|all, f|
10
10
  view = new(f)
@@ -24,4 +24,4 @@ a:hover { color: #06C; }
24
24
  </hgroup>
25
25
  <p>Push new versions of your app again with <code>dvn push</code>.</p>
26
26
  <p>Add attachments to <code>public</code> directory and views to the <code>views</code> directory. These settings can be changed in the <code>config/<%= @name %>.yaml</code> file.</p>
27
- <p class=footer><a href=http://chrislloyd.github.com/dayvan>Reference</a> &middot; <a href=http://github.com/chrislloyd/dayvan>Code</a> &middot; <a href=http://thelincolnshirepoacher.com>The Poacher</a></p>
27
+ <p class=footer><a href=http://chrislloyd.cloudant.com/dayvan/_design/dayvan/index.html>Reference</a> &middot; <a href=http://github.com/chrislloyd/dayvan>Code</a> &middot; <a href=http://thelincolnshirepoacher.com>The Poacher</a></p>
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dayvan
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Chris Lloyd
@@ -81,11 +81,11 @@ files:
81
81
  - lib/dayvan/cli.rb
82
82
  - lib/dayvan/design.rb
83
83
  - lib/dayvan/project.rb
84
- - lib/dayvan/security.rb
84
+ - lib/dayvan/validation.rb
85
85
  - lib/dayvan/view.rb
86
86
  - templates/all.coffee.erb
87
- - templates/security.coffee.erb
88
87
  - templates/size.coffee.erb
88
+ - templates/validation.coffee.erb
89
89
  - templates/welcome.html.erb
90
90
  has_rdoc: true
91
91
  homepage: http://chrislloyd.github.com/dayvan