activefile 0.0.0beta → 0.0.0.beta1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +8 -8
- data/README.rdoc +0 -30
- data/Rakefile +126 -14
- data/lib/{active_file/adapter.rb → active_file.rb} +75 -8
- metadata +9 -8
- data/lib/active_file/base.rb +0 -21
- data/lib/activefile.rb +0 -29
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
NzU2ZTQ2ZGM1MGYyNTQyYTc4ZDkyNGU3NjUzNGM0M2ZiY2ZkZTg1Mw==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
NWQ1Y2FlZDU1MmM1YzY1ZmQxYjU1ZjFmNDRlY2M4ZjQzMWZlNDNkYg==
|
7
7
|
!binary "U0hBNTEy":
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
NTQxZTIwNGE3YjJhZDkwZGE5NjNmMjM2MjMzZGVlYTBjMzFiOGY5OWFkMWNk
|
10
|
+
MjZhNDZhZWY1M2Y3NjgyYTBmMWFlMGIyNTg4OGI0ZGMzNzJhMzc1MWNmNzBh
|
11
|
+
Y2E2YmJmNWIwMWEzN2U5NzgxNzUzMDc3OGNhYmFkNjY5MWJkM2Y=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
NjQyZmE2MTc1OTllOTlkNGUyMmM2YTM2YTNjNzNjNTQ4MjZjZmMwZjM3Nzhj
|
14
|
+
MzQzMzc0NTAxZDYwZTI1ZmI0ZGQzOTRjYTgxNGY0MjU3MTgzYjY1NmM1ODc4
|
15
|
+
ZGVkZjFjYjE5MDUwOTRjN2VmYTEzYTgwOWE5OGNmMTI1MWQ5NWY=
|
data/README.rdoc
CHANGED
@@ -1,35 +1,5 @@
|
|
1
|
-
== Gem under construction. Base functionality already done, but I still need reorganize it. I work with Unit tests now.
|
2
|
-
|
3
|
-
Please, be patient! All work will be done untill May.
|
4
|
-
|
5
1
|
== Welcome to ActiveFile
|
6
2
|
|
7
3
|
ActiveFile is a lightweight file system ORM.
|
8
4
|
|
9
5
|
Build a persistent domain model by mapping file system objects to Ruby classes. It inherits ActiveRecord-similar interface.
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
class Shop < ActiveFile::Base
|
14
|
-
parent_to :product
|
15
|
-
end
|
16
|
-
|
17
|
-
class Product < ActiveFile::Base
|
18
|
-
child_of :shop
|
19
|
-
end
|
20
|
-
|
21
|
-
shop = Shop.new(:name => "Apple Store")
|
22
|
-
shop.save!
|
23
|
-
|
24
|
-
Shop.all.size #> 1
|
25
|
-
|
26
|
-
iPad = Product.new(:name => "iPad", :parent => shop, :data => "The iPad is a line of tablet computers designed and marketed by Apple Inc., which runs Apple's iOS operating system.")
|
27
|
-
iPad.save!
|
28
|
-
|
29
|
-
product = Product.where(:name => "iPad")[0]
|
30
|
-
product.data #> "The iPad "...
|
31
|
-
product.shop #> <Shop instance>
|
32
|
-
product.shop.name #> "Apple Store"
|
33
|
-
|
34
|
-
|
35
|
-
# In result, two persistent files were created, accessible via ORM mechanism.
|
data/Rakefile
CHANGED
@@ -1,18 +1,130 @@
|
|
1
|
+
# /Rakefile
|
1
2
|
|
2
|
-
|
3
|
-
|
3
|
+
#!/usr/bin/env rake
|
4
|
+
begin
|
5
|
+
require 'bundler/setup'
|
6
|
+
rescue LoadError
|
7
|
+
puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
|
8
|
+
end
|
9
|
+
begin
|
10
|
+
require 'rdoc/task'
|
11
|
+
rescue LoadError
|
12
|
+
require 'rdoc/rdoc'
|
13
|
+
require 'rake/rdoctask'
|
14
|
+
RDoc::Task = Rake::RDocTask
|
15
|
+
end
|
16
|
+
|
17
|
+
RDoc::Task.new(:rdoc) do |rdoc|
|
18
|
+
rdoc.rdoc_dir = 'rdoc'
|
19
|
+
rdoc.title = 'ActiveFile'
|
20
|
+
rdoc.options << '--line-numbers' << '--inline-source'
|
21
|
+
rdoc.rdoc_files.include('README.rdoc')
|
22
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
23
|
+
end
|
24
|
+
|
25
|
+
# notice the path change in the following line
|
26
|
+
APP_RAKEFILE = File.expand_path("../spec/dummy/Rakefile", __FILE__)
|
27
|
+
load 'rails/tasks/engine.rake'
|
28
|
+
|
29
|
+
require 'rake/testtask'
|
30
|
+
|
31
|
+
Rake::TestTask.new(:test) do |t|
|
32
|
+
t.libs << 'lib'
|
33
|
+
t.libs << 'test'
|
34
|
+
t.pattern = 'test/**/*_test.rb'
|
35
|
+
t.verbose = false
|
36
|
+
end
|
37
|
+
|
38
|
+
task :default => :test
|
39
|
+
|
40
|
+
Bundler::GemHelper.install_tasks
|
41
|
+
|
42
|
+
=begin
|
43
|
+
|
44
|
+
require 'rspec/core/rake_task'
|
45
|
+
RSpec::Core::RakeTask.new(:spec)
|
46
|
+
|
47
|
+
load 'lib/tasks/devcms_tasks.rake'
|
48
|
+
|
49
|
+
# RSpec as default
|
50
|
+
task :default => :spec
|
51
|
+
=end
|
52
|
+
|
53
|
+
=begin
|
54
|
+
#!/usr/bin/env rake
|
55
|
+
begin
|
56
|
+
require 'bundler/setup'
|
57
|
+
rescue LoadError
|
58
|
+
puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
|
59
|
+
end
|
60
|
+
|
61
|
+
APP_RAKEFILE = File.expand_path("../spec/dummy/Rakefile", __FILE__)
|
62
|
+
|
63
|
+
if File.exists?(APP_RAKEFILE)
|
64
|
+
load 'rails/tasks/engine.rake'
|
65
|
+
end
|
4
66
|
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
#
|
10
|
-
|
11
|
-
|
67
|
+
Dir[File.expand_path('../tasks/**/*', __FILE__)].each do |task|
|
68
|
+
load task
|
69
|
+
end
|
70
|
+
|
71
|
+
#require "refinerycms-testing"
|
72
|
+
Devcms::Testing::Railtie.load_tasks
|
73
|
+
Devcms::Testing::Railtie.load_dummy_tasks(File.dirname(__FILE__))
|
74
|
+
|
75
|
+
desc "Build gem files for all projects"
|
76
|
+
task :build => "all:build"
|
77
|
+
|
78
|
+
task :default => :spec
|
79
|
+
=end
|
80
|
+
|
81
|
+
=begin
|
12
82
|
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
83
|
+
#?!/usr/bin/env rake
|
84
|
+
begin
|
85
|
+
require 'bundler/setup'
|
86
|
+
rescue LoadError
|
87
|
+
puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
|
18
88
|
end
|
89
|
+
begin
|
90
|
+
require 'rdoc/task'
|
91
|
+
rescue LoadError
|
92
|
+
require 'rdoc/rdoc'
|
93
|
+
require 'rake/rdoctask'
|
94
|
+
RDoc::Task = Rake::RDocTask
|
95
|
+
end
|
96
|
+
|
97
|
+
RDoc::Task.new(:rdoc) do |rdoc|
|
98
|
+
rdoc.rdoc_dir = 'rdoc'
|
99
|
+
rdoc.title = 'Devcms'
|
100
|
+
rdoc.options << '--line-numbers'
|
101
|
+
rdoc.rdoc_files.include('README.rdoc')
|
102
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
103
|
+
end
|
104
|
+
|
105
|
+
APP_RAKEFILE = File.expand_path("../spec/dummy/Rakefile", __FILE__)
|
106
|
+
load 'rails/tasks/engine.rake'
|
107
|
+
|
108
|
+
Bundler::GemHelper.install_tasks
|
109
|
+
|
110
|
+
require 'rake/testtask'
|
111
|
+
|
112
|
+
Rake::TestTask.new(:test) do |t|
|
113
|
+
t.libs << 'lib'
|
114
|
+
t.libs << 'test'
|
115
|
+
t.pattern = 'test/**/*_test.rb'
|
116
|
+
t.verbose = false
|
117
|
+
end
|
118
|
+
|
119
|
+
require 'aloha-rails'
|
120
|
+
Rake::TestTask.new(:test) do |t|
|
121
|
+
t.libs << 'test'
|
122
|
+
t.test_files = FileList['test/**/*_test.rb']
|
123
|
+
t.verbose = true
|
124
|
+
end
|
125
|
+
|
126
|
+
|
127
|
+
|
128
|
+
task :default => :test
|
129
|
+
|
130
|
+
=end
|
@@ -1,7 +1,80 @@
|
|
1
|
+
#--
|
2
|
+
# Copyright (c) 2004-2013 David Heinemeier Hansson
|
3
|
+
#
|
4
|
+
# Permission is hereby granted, free of charge, to any person obtaining
|
5
|
+
# a copy of this software and associated documentation files (the
|
6
|
+
# "Software"), to deal in the Software without restriction, including
|
7
|
+
# without limitation the rights to use, copy, modify, merge, publish,
|
8
|
+
# distribute, sublicense, and/or sell copies of the Software, and to
|
9
|
+
# permit persons to whom the Software is furnished to do so, subject to
|
10
|
+
# the following conditions:
|
11
|
+
#
|
12
|
+
# The above copyright notice and this permission notice shall be
|
13
|
+
# included in all copies or substantial portions of the Software.
|
14
|
+
#
|
15
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
16
|
+
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
17
|
+
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
18
|
+
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
19
|
+
# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
20
|
+
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
21
|
+
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
22
|
+
#++
|
23
|
+
|
24
|
+
require 'fileutils'
|
25
|
+
|
1
26
|
module ActiveFile
|
2
|
-
|
27
|
+
|
28
|
+
module SourceType
|
29
|
+
UNDEFINED = 0
|
30
|
+
LAYOUT = 1
|
31
|
+
CONTENT = 2
|
32
|
+
CSS = 3
|
33
|
+
SEO = 4
|
34
|
+
IMAGE = 6
|
35
|
+
COMPILED = 7
|
36
|
+
end
|
37
|
+
|
3
38
|
module Adapter
|
4
|
-
|
39
|
+
|
40
|
+
SOURCE_FOLDER = "data_source"
|
41
|
+
SOURCE_FOLDERS = {
|
42
|
+
SourceType::CSS => "app/assets/stylesheets/custom/",
|
43
|
+
SourceType::IMAGE => "public/img/storage/",
|
44
|
+
SourceType::LAYOUT => "#{SOURCE_FOLDER}/layouts/",
|
45
|
+
SourceType::CONTENT => "#{SOURCE_FOLDER}/contents/",
|
46
|
+
SourceType::SEO => "#{SOURCE_FOLDER}/seotags/",
|
47
|
+
SourceType::UNDEFINED => "#{SOURCE_FOLDER}/others/",
|
48
|
+
SourceType::COMPILED => "#{SOURCE_FOLDER}/compiled/",
|
49
|
+
}
|
50
|
+
TEST_SOURCE_FOLDER = "data_source_test"
|
51
|
+
TEST_SOURCE_FOLDERS = {
|
52
|
+
SourceType::CSS => "app/assets/stylesheets/custom_test/",
|
53
|
+
SourceType::IMAGE => "public/img/storage_test/",
|
54
|
+
SourceType::LAYOUT => "#{TEST_SOURCE_FOLDER}/layouts/",
|
55
|
+
SourceType::CONTENT => "#{TEST_SOURCE_FOLDER}/contents/",
|
56
|
+
SourceType::SEO => "#{TEST_SOURCE_FOLDER}/seotags/",
|
57
|
+
SourceType::UNDEFINED => "#{TEST_SOURCE_FOLDER}/others/",
|
58
|
+
SourceType::COMPILED => "#{TEST_SOURCE_FOLDER}/compiled/"
|
59
|
+
}
|
60
|
+
SOURCE_TYPE_EXTENSIONS = {
|
61
|
+
SourceType::CSS => "scss",
|
62
|
+
SourceType::IMAGE => "*", # * - file extension gets from the source file extension
|
63
|
+
SourceType::LAYOUT => "",
|
64
|
+
SourceType::CONTENT => "",
|
65
|
+
SourceType::SEO => "",
|
66
|
+
SourceType::UNDEFINED => "",
|
67
|
+
SourceType::COMPILED => ""
|
68
|
+
}
|
69
|
+
# use it for file name decorations:
|
70
|
+
# ID_PREFIX + type_integer + ID_DIVIDER + source_name < for simple source
|
71
|
+
# target_type_integer + TARGET_DIVIDER + target_name + extension < for attached sources
|
72
|
+
ID_PREFIX = 'pre'
|
73
|
+
ID_DIVIDER = '-id-'
|
74
|
+
TARGET_DIVIDER = '-tar-'
|
75
|
+
CUSTOM_SCSS_FOLDER = "custom/"
|
76
|
+
|
77
|
+
|
5
78
|
RAISE_TRUE = true
|
6
79
|
RAISE_FALSE = false
|
7
80
|
|
@@ -9,11 +82,6 @@ module ActiveFile
|
|
9
82
|
super args
|
10
83
|
end
|
11
84
|
|
12
|
-
def base_folder arg
|
13
|
-
puts "BaseFolder is #{arg}"
|
14
|
-
end
|
15
|
-
|
16
|
-
|
17
85
|
# touch file to read!
|
18
86
|
def load!
|
19
87
|
self.data
|
@@ -63,7 +131,6 @@ module ActiveFile
|
|
63
131
|
get_source_folder + get_filename
|
64
132
|
end
|
65
133
|
def get_extension
|
66
|
-
return ".scss" if type == SourceType::CSS
|
67
134
|
return extension.blank? ? "" : "."+extension
|
68
135
|
|
69
136
|
type_ext = SOURCE_TYPE_EXTENSIONS[type.to_i] || ""
|
metadata
CHANGED
@@ -1,24 +1,23 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: activefile
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.0.beta1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Vitaly Pestov
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-03-
|
11
|
+
date: 2013-03-09 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: Build a hierarchical model of filesystem objects.
|
14
14
|
email: vitalyp@softwareplanet.uk.com
|
15
15
|
executables: []
|
16
16
|
extensions: []
|
17
|
-
extra_rdoc_files:
|
17
|
+
extra_rdoc_files:
|
18
|
+
- README.rdoc
|
18
19
|
files:
|
19
|
-
- lib/
|
20
|
-
- lib/active_file/adapter.rb
|
21
|
-
- lib/active_file/base.rb
|
20
|
+
- lib/active_file.rb
|
22
21
|
- MIT-LICENSE
|
23
22
|
- Rakefile
|
24
23
|
- README.rdoc
|
@@ -27,7 +26,9 @@ licenses:
|
|
27
26
|
- MIT
|
28
27
|
metadata: {}
|
29
28
|
post_install_message:
|
30
|
-
rdoc_options:
|
29
|
+
rdoc_options:
|
30
|
+
- --main
|
31
|
+
- README.rdoc
|
31
32
|
require_paths:
|
32
33
|
- lib
|
33
34
|
required_ruby_version: !ruby/object:Gem::Requirement
|
@@ -45,5 +46,5 @@ rubyforge_project:
|
|
45
46
|
rubygems_version: 2.0.2
|
46
47
|
signing_key:
|
47
48
|
specification_version: 4
|
48
|
-
summary: Object-relational mapper framework.
|
49
|
+
summary: Object-relational mapper framework.
|
49
50
|
test_files: []
|
data/lib/active_file/base.rb
DELETED
@@ -1,21 +0,0 @@
|
|
1
|
-
module ActiveFile
|
2
|
-
require 'ostruct'
|
3
|
-
class Base < OpenStruct
|
4
|
-
|
5
|
-
|
6
|
-
include Adapter
|
7
|
-
extend Adapter::ClassMethods
|
8
|
-
def ahola
|
9
|
-
puts 'ahols here!'
|
10
|
-
end
|
11
|
-
#'a'.camelize.safe_constantize
|
12
|
-
#def child_of(parent_name)
|
13
|
-
# puts "ok, I am a child of #{parent_name}"
|
14
|
-
#end
|
15
|
-
#
|
16
|
-
#def parent_to(child_name)
|
17
|
-
# puts "OH, I am a parent to #{child_name}"
|
18
|
-
#end
|
19
|
-
|
20
|
-
end
|
21
|
-
end
|
data/lib/activefile.rb
DELETED
@@ -1,29 +0,0 @@
|
|
1
|
-
#--
|
2
|
-
# Copyright (c) 2013 ariekdev
|
3
|
-
#
|
4
|
-
# Permission is hereby granted, free of charge, to any person obtaining
|
5
|
-
# a copy of this software and associated documentation files (the
|
6
|
-
# "Software"), to deal in the Software without restriction, including
|
7
|
-
# without limitation the rights to use, copy, modify, merge, publish,
|
8
|
-
# distribute, sublicense, and/or sell copies of the Software, and to
|
9
|
-
# permit persons to whom the Software is furnished to do so, subject to
|
10
|
-
# the following conditions:
|
11
|
-
#
|
12
|
-
# The above copyright notice and this permission notice shall be
|
13
|
-
# included in all copies or substantial portions of the Software.
|
14
|
-
#
|
15
|
-
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
16
|
-
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
17
|
-
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
18
|
-
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
19
|
-
# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
20
|
-
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
21
|
-
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
22
|
-
#++
|
23
|
-
|
24
|
-
require "active_support/dependencies/autoload"
|
25
|
-
module ActiveFile
|
26
|
-
extend ActiveSupport::Autoload
|
27
|
-
autoload :Base
|
28
|
-
autoload :Adapter
|
29
|
-
end
|