scharfie-bones 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.
Files changed (4) hide show
  1. data/README +15 -0
  2. data/bones.gemspec +2 -1
  3. data/lib/bones/release.rb +75 -0
  4. metadata +2 -1
data/README CHANGED
@@ -17,16 +17,20 @@ Requirements:
17
17
  Starting it up:
18
18
 
19
19
  - Install
20
+
20
21
  sudo gem install scharfie-bones -s http://gems.github.com
21
22
 
22
23
  - Generate:
24
+
23
25
  bones my_bones_app
24
26
  cd my_bones_app
25
27
 
26
28
  - Serve
29
+
27
30
  rake server
28
31
 
29
32
  - Browse:
33
+
30
34
  http://localhost:3000
31
35
 
32
36
  Flatten your views into .html files:
@@ -36,3 +40,14 @@ Flatten your views into .html files:
36
40
  rake cache:versioned # with versioning
37
41
 
38
42
  Then upload the entire public/ directory to your server.
43
+
44
+ Advanced features:
45
+
46
+ - Use a base URL path when caching
47
+ (for example, you need to deploy to example.com/mybonesapp)
48
+
49
+ rake cache BASE=/mybonesapp
50
+
51
+ - Use custom cache directory
52
+
53
+ rake cache DESTINATION=/some/other/path
data/bones.gemspec CHANGED
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = "bones"
3
- s.version = "0.1.2"
3
+ s.version = "0.1.3"
4
4
  s.date = "2009-02-02"
5
5
  s.authors = ["Chris Scharf", "Ryan Heath"]
6
6
  s.email = "scharfie@gmail.com"
@@ -20,6 +20,7 @@ Gem::Specification.new do |s|
20
20
  'lib/Rakefile',
21
21
  'bin/bones',
22
22
  'lib/bones.rb',
23
+ 'lib/bones/release.rb',
23
24
  'lib/boot.rb',
24
25
  'lib/cache.rb',
25
26
  'lib/extensions.rb',
@@ -0,0 +1,75 @@
1
+ class Bones
2
+ class Release
3
+ attr_accessor :original_destination
4
+ attr_accessor :release_destination
5
+
6
+ # Create new release
7
+ def initialize(original_destination, release_destination)
8
+ @original_destination = original_destination
9
+ @release_destination = release_destination
10
+ end
11
+
12
+ # Accessor for release destination
13
+ def destination
14
+ @release_destination
15
+ end
16
+
17
+ def original_destination
18
+ @original_destination || (ROOT / 'public')
19
+ end
20
+
21
+ # Copies all public directories to the new release directory
22
+ def copy_public_directories
23
+ public_directories.each do |src|
24
+ FileUtils.copy_entry ROOT / 'public' / src, destination / src
25
+ end
26
+ end
27
+ end
28
+
29
+ # Class used to encapsulate the logic needed to
30
+ # maintain mockup versions
31
+ class VersionedRelease < Release
32
+ # Pre-fix used for versioned directories
33
+ DIR_PREFIX = 'v'
34
+
35
+ def initialize(original_destination, release_destination = nil)
36
+ super
37
+ @release_destination = get_versioned_destination
38
+ end
39
+
40
+ # Returns the versioned directories within the 'public' folder
41
+ # $> Bones::Versioned.directories
42
+ # $> => ["/v1", "/v2", ... "/vN"]
43
+ def self.directories(base=nil)
44
+ base ||= ROOT / 'public'
45
+ FileUtils.mkdir_p(base) unless File.directory?(base)
46
+ Dir.chdir(base) do
47
+ Dir.glob("#{DIR_PREFIX}**").inject([]) do |dirs, dir|
48
+ dirs << '/' + File.basename(dir)
49
+ end
50
+ end
51
+ end
52
+
53
+ # Public accessor of version
54
+ def version
55
+ next_version
56
+ end
57
+
58
+ # Returns directory name of versioned path
59
+ # For example, 'v1'
60
+ def versioned_directory_name
61
+ DIR_PREFIX + next_version
62
+ end
63
+
64
+ private
65
+ # increments to the next version based on existing versions
66
+ def next_version
67
+ (self.class.directories(original_destination).size + 1).to_s
68
+ end
69
+
70
+ # constructs the next version path
71
+ def get_versioned_destination
72
+ original_destination / versioned_directory_name
73
+ end
74
+ end
75
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: scharfie-bones
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 Scharf
@@ -44,6 +44,7 @@ files:
44
44
  - lib/Rakefile
45
45
  - bin/bones
46
46
  - lib/bones.rb
47
+ - lib/bones/release.rb
47
48
  - lib/boot.rb
48
49
  - lib/cache.rb
49
50
  - lib/extensions.rb