activefile 0.0.1 → 0.0.2dev

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- NmI4MDNhNDAyMzNhYTllNmI2YzJlZmExNmQ4ZThlZTBjZmM0ODBmYg==
4
+ YTlhMWQ3MWI0MTUyZGUzYWM0OThlNGE2OThjMGRiYmVkNTUxNDEwYw==
5
5
  data.tar.gz: !binary |-
6
- ODY5OWY4ODljYjU0YWQxZTcwZmVkMGZjZmNjZjMxZmY5MTI5ZjBlNQ==
6
+ ZmZmODA1YjNjMTdlMmRkZWI5MmFhNzY5Y2U5MjczMTQyMmIyMGRmMA==
7
7
  !binary "U0hBNTEy":
8
8
  metadata.gz: !binary |-
9
- YzQ5ODlkODE1ODhhM2YwZmQyY2NiZjNkNTkwYTcwMjc2ZWY1ZTY3MDI1Mzdi
10
- NDNjNWEzZGU0NjAxNDFlYzc1ZGYzNTllOTE5MDM2YjViNjZkODI5Mzc4NDI2
11
- N2E1ZmU1YTQyZmE3ZWZjZTU5MWI3ZDk3MGIxZjA4MDA3MDE5MDg=
9
+ ZDViYzdiYjg3MWQxNTA5ZTA5Yzk5M2MxYTg5ZDUyYTFkODI1NDQzMjBlMWQy
10
+ M2ViZWFhOTM3ZmIzY2VmZDg0N2JhYWJmMzlmY2JkMDFjZTU4MjA2MDQ2ODMz
11
+ NTM2MWExNTQ4MWNhN2IwYWFjMzM2YjZjMzMzY2VkZDI5NGQxMDg=
12
12
  data.tar.gz: !binary |-
13
- ZjYzNjc1MjQ0MDRiNjExNTdjN2UwODgxMWViY2ZjMTdkY2YzYTZiN2QwYzAz
14
- YmIyZDcyZjlmN2QxNzhmMWIwMmFiMzY1NDJmOTE4MWFmNTQ5ZDFmYTk1NGI1
15
- MmQ3MDM5OTQ3YWUzNWYzYTUyNDBiY2QwZTgzZGY2MzFjZWUzYmY=
13
+ NDliZWViMGJlMDk4ZGQ5YzliYjM4NmE0MTFiMTc2MjMzOGQ3MWMwNzU4NjU3
14
+ ZThkODIzM2UzNzI2ZDE5ZWQ5MDM0ZGI5NGVkYjYyNjVlMzg3YjlhNGQ3Mjlh
15
+ ZGIzZWQ5MDg4MmIyNjNjYzgyNzE0ZTkxZDUwZDg4NjE5OTY0OGE=
data/README.rdoc CHANGED
@@ -1,5 +1,35 @@
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
+
1
5
  == Welcome to ActiveFile
2
6
 
3
7
  ActiveFile is a lightweight file system ORM.
4
8
 
5
9
  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,130 +1,18 @@
1
- # /Rakefile
2
1
 
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
2
+ desc "Default Task"
3
+ task default: [ :test ]
66
4
 
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
5
+ # Run the unit tests
6
+ #Rake::TestTask.new { |t|
7
+ ## t.libs << "test"
8
+ # t.pattern = 'test/**/*_test.rb'
9
+ # t.warning = true
10
+ # t.verbose = true
11
+ #}
82
12
 
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'
13
+ task :test do
14
+ ruby = File.join(*RbConfig::CONFIG.values_at('bindir', 'RUBY_INSTALL_NAME'))
15
+ Dir.glob("test/**/*_test.rb").all? do |file|
16
+ sh(ruby, '-Ilib:test', file)
17
+ end or raise "Failures"
88
18
  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,80 +1,7 @@
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
-
26
1
  module ActiveFile
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
-
2
+ # Data Source Storage Adapter
38
3
  module Adapter
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
-
4
+ require 'fileutils'
78
5
  RAISE_TRUE = true
79
6
  RAISE_FALSE = false
80
7
 
@@ -82,6 +9,11 @@ module ActiveFile
82
9
  super args
83
10
  end
84
11
 
12
+ def base_folder arg
13
+ puts "BaseFolder is #{arg}"
14
+ end
15
+
16
+
85
17
  # touch file to read!
86
18
  def load!
87
19
  self.data
@@ -131,6 +63,7 @@ module ActiveFile
131
63
  get_source_folder + get_filename
132
64
  end
133
65
  def get_extension
66
+ return ".scss" if type == SourceType::CSS
134
67
  return extension.blank? ? "" : "."+extension
135
68
 
136
69
  type_ext = SOURCE_TYPE_EXTENSIONS[type.to_i] || ""
@@ -0,0 +1,21 @@
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 ADDED
@@ -0,0 +1,29 @@
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
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: activefile
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2dev
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-09 00:00:00.000000000 Z
11
+ date: 2013-03-16 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
@@ -16,7 +16,9 @@ executables: []
16
16
  extensions: []
17
17
  extra_rdoc_files: []
18
18
  files:
19
- - lib/active_file.rb
19
+ - lib/activefile.rb
20
+ - lib/active_file/adapter.rb
21
+ - lib/active_file/base.rb
20
22
  - MIT-LICENSE
21
23
  - Rakefile
22
24
  - README.rdoc
@@ -35,13 +37,13 @@ required_ruby_version: !ruby/object:Gem::Requirement
35
37
  version: 1.9.3
36
38
  required_rubygems_version: !ruby/object:Gem::Requirement
37
39
  requirements:
38
- - - ! '>='
40
+ - - ! '>'
39
41
  - !ruby/object:Gem::Version
40
- version: '0'
42
+ version: 1.3.1
41
43
  requirements: []
42
44
  rubyforge_project:
43
45
  rubygems_version: 2.0.2
44
46
  signing_key:
45
47
  specification_version: 4
46
- summary: Object-relational mapper framework.
48
+ summary: Object-relational mapper framework. Please, be patient. Under construction.
47
49
  test_files: []