jiro 0.0.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,5 @@
1
+ lib/**/*.rb
2
+ bin/*
3
+ -
4
+ features/**/*.feature
5
+ LICENSE.txt
data/.rspec ADDED
@@ -0,0 +1 @@
1
+ --color
data/Gemfile ADDED
@@ -0,0 +1,10 @@
1
+ source "http://rubygems.org"
2
+
3
+ gem "redis", "~> 3.0.4"
4
+
5
+ group :development do
6
+ gem "rspec", "~> 2.8.0"
7
+ gem "rdoc", "~> 3.12"
8
+ gem "bundler", "~> 1.3.5"
9
+ gem "jeweler", "~> 1.8.4"
10
+ end
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2013 Marcin Naglik
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,19 @@
1
+ = jiro
2
+
3
+ Super simple solution for Ruby On Rails content management.
4
+
5
+ == Contributing to jiro
6
+
7
+ * Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet.
8
+ * Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it.
9
+ * Fork the project.
10
+ * Start a feature/bugfix branch.
11
+ * Commit and push until you are happy with your contribution.
12
+ * Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
13
+ * Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.
14
+
15
+ == Copyright
16
+
17
+ Copyright (c) 2013 Marcin Naglik. See LICENSE.txt for
18
+ further details.
19
+
@@ -0,0 +1,49 @@
1
+ # encoding: utf-8
2
+
3
+ require 'rubygems'
4
+ require 'bundler'
5
+ begin
6
+ Bundler.setup(:default, :development)
7
+ rescue Bundler::BundlerError => e
8
+ $stderr.puts e.message
9
+ $stderr.puts "Run `bundle install` to install missing gems"
10
+ exit e.status_code
11
+ end
12
+ require 'rake'
13
+
14
+ require 'jeweler'
15
+ Jeweler::Tasks.new do |gem|
16
+ # gem is a Gem::Specification... see http://docs.rubygems.org/read/chapter/20 for more options
17
+ gem.name = "jiro"
18
+ gem.homepage = "http://github.com/managr/jiro"
19
+ gem.license = "MIT"
20
+ gem.summary = "Simple CMS for Rails hackers"
21
+ gem.description = "CMS that intercept Rails ActionView Templates and allow changing them directly from Redis storage"
22
+ gem.email = "marcin.naglik@gmail.com"
23
+ gem.authors = ["Marcin Naglik"]
24
+ # dependencies defined in Gemfile
25
+ end
26
+ Jeweler::RubygemsDotOrgTasks.new
27
+
28
+ require 'rspec/core'
29
+ require 'rspec/core/rake_task'
30
+ RSpec::Core::RakeTask.new(:spec) do |spec|
31
+ spec.pattern = FileList['spec/**/*_spec.rb']
32
+ end
33
+
34
+ RSpec::Core::RakeTask.new(:rcov) do |spec|
35
+ spec.pattern = 'spec/**/*_spec.rb'
36
+ spec.rcov = true
37
+ end
38
+
39
+ task :default => :spec
40
+
41
+ require 'rdoc/task'
42
+ Rake::RDocTask.new do |rdoc|
43
+ version = File.exist?('VERSION') ? File.read('VERSION') : ""
44
+
45
+ rdoc.rdoc_dir = 'rdoc'
46
+ rdoc.title = "jiro #{version}"
47
+ rdoc.rdoc_files.include('README*')
48
+ rdoc.rdoc_files.include('lib/**/*.rb')
49
+ end
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.0.0
@@ -0,0 +1,67 @@
1
+ # Generated by jeweler
2
+ # DO NOT EDIT THIS FILE DIRECTLY
3
+ # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
4
+ # -*- encoding: utf-8 -*-
5
+
6
+ Gem::Specification.new do |s|
7
+ s.name = "jiro"
8
+ s.version = "0.0.0"
9
+
10
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
+ s.authors = ["Marcin Naglik"]
12
+ s.date = "2013-06-11"
13
+ s.description = "CMS that intercept Rails ActionView Templates and allow changing them directly from Redis storage"
14
+ s.email = "marcin.naglik@gmail.com"
15
+ s.extra_rdoc_files = [
16
+ "LICENSE.txt",
17
+ "README.rdoc"
18
+ ]
19
+ s.files = [
20
+ ".document",
21
+ ".rspec",
22
+ "Gemfile",
23
+ "LICENSE.txt",
24
+ "README.rdoc",
25
+ "Rakefile",
26
+ "VERSION",
27
+ "jiro.gemspec",
28
+ "lib/jiro.rb",
29
+ "lib/jiro/redis_connection.rb",
30
+ "lib/jiro/view_resolver.rb",
31
+ "spec/jiro/redis_connection_spec.rb",
32
+ "spec/jiro/view_resolver_spec.rb",
33
+ "spec/jiro_spec.rb",
34
+ "spec/spec_helper.rb",
35
+ "spec/support/file_system_resolver.rb"
36
+ ]
37
+ s.homepage = "http://github.com/managr/jiro"
38
+ s.licenses = ["MIT"]
39
+ s.require_paths = ["lib"]
40
+ s.rubygems_version = "1.8.24"
41
+ s.summary = "Simple CMS for Rails hackers"
42
+
43
+ if s.respond_to? :specification_version then
44
+ s.specification_version = 3
45
+
46
+ if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
47
+ s.add_runtime_dependency(%q<redis>, ["~> 3.0.4"])
48
+ s.add_development_dependency(%q<rspec>, ["~> 2.8.0"])
49
+ s.add_development_dependency(%q<rdoc>, ["~> 3.12"])
50
+ s.add_development_dependency(%q<bundler>, ["~> 1.3.5"])
51
+ s.add_development_dependency(%q<jeweler>, ["~> 1.8.4"])
52
+ else
53
+ s.add_dependency(%q<redis>, ["~> 3.0.4"])
54
+ s.add_dependency(%q<rspec>, ["~> 2.8.0"])
55
+ s.add_dependency(%q<rdoc>, ["~> 3.12"])
56
+ s.add_dependency(%q<bundler>, ["~> 1.3.5"])
57
+ s.add_dependency(%q<jeweler>, ["~> 1.8.4"])
58
+ end
59
+ else
60
+ s.add_dependency(%q<redis>, ["~> 3.0.4"])
61
+ s.add_dependency(%q<rspec>, ["~> 2.8.0"])
62
+ s.add_dependency(%q<rdoc>, ["~> 3.12"])
63
+ s.add_dependency(%q<bundler>, ["~> 1.3.5"])
64
+ s.add_dependency(%q<jeweler>, ["~> 1.8.4"])
65
+ end
66
+ end
67
+
@@ -0,0 +1,27 @@
1
+ require 'jiro/redis_connection'
2
+ require 'jiro/view_resolver'
3
+
4
+ module Jiro
5
+ module AppId
6
+ def app_id
7
+ defined?(@app_id) ? @app_id : Jiro.app_id
8
+ end
9
+
10
+ def app_id=(id)
11
+ @app_id = id
12
+ end
13
+
14
+ def redis_opts
15
+ defined?(@redis_opts)? @redis_opts : Jiro.redis_opts
16
+ end
17
+
18
+ def redis_opts=(opts)
19
+ @redis_opts = opts
20
+ end
21
+ end
22
+
23
+ extend AppId
24
+
25
+ self.app_id = "jiro_cms_pages"
26
+ self.redis_opts = {}
27
+ end
@@ -0,0 +1,11 @@
1
+ require "redis"
2
+
3
+ module Jiro
4
+ module RedisConnection
5
+ def get
6
+ @redis_connection ||= Redis.new(Jiro.redis_opts)
7
+ end
8
+
9
+ extend self
10
+ end
11
+ end
@@ -0,0 +1,27 @@
1
+ module Jiro
2
+ class ViewResolver < ::ActionView::FileSystemResolver
3
+
4
+ def initialize
5
+ super('app/views')
6
+ end
7
+
8
+ def find_templates(name, prefix, partial, details)
9
+ view_key = {
10
+ :name => name,
11
+ :prefix => prefix,
12
+ :partial => partial,
13
+ :locale => details[:locale],
14
+ :format => details[:formats],
15
+ :handler => details[:handler]
16
+ }
17
+
18
+ persisted = RedisConnection.get.hget(Jiro.app_id, view_key)
19
+ return YAML::load(persisted) if persisted
20
+
21
+ from_file_system = super(name, prefix, partial, details)
22
+ RedisConnection.get.hset(Jiro.app_id, view_key, YAML::dump(from_file_system)) unless from_file_system.empty?
23
+ from_file_system
24
+ end
25
+
26
+ end
27
+ end
@@ -0,0 +1,8 @@
1
+ require 'spec_helper'
2
+
3
+ describe Jiro::RedisConnection do
4
+ it "returns redis connection" do
5
+ connection = Jiro::RedisConnection.get
6
+ connection.should_not be_nil
7
+ end
8
+ end
@@ -0,0 +1,22 @@
1
+ require 'spec_helper'
2
+
3
+ describe Jiro::ViewResolver do
4
+ let(:view_resolver) {
5
+ Jiro::ViewResolver.new
6
+ }
7
+ let(:redis_connection) {
8
+ double
9
+ }
10
+ before {
11
+ Jiro::RedisConnection.stub(:get).and_return(redis_connection)
12
+ }
13
+
14
+ context "when not having page in cache" do
15
+ it "not stores new page if not exists" do
16
+ redis_connection.should_receive(:hget).and_return(nil)
17
+ result = view_resolver.find_templates("name", "prefix", "partial", {})
18
+ redis_connection.should_not_receive(:hput)
19
+ result.should be_empty
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,21 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
2
+
3
+ describe "Jiro" do
4
+ it "defines default application id" do
5
+ Jiro.app_id.should eq("jiro_cms_pages")
6
+ end
7
+
8
+ it "allows to change application id" do
9
+ Jiro.app_id = "call_me_jiro"
10
+ Jiro.app_id.should eq("call_me_jiro")
11
+ end
12
+
13
+ it "defines default redis opts" do
14
+ Jiro.redis_opts.should eq({})
15
+ end
16
+
17
+ it "allows to change redis opts" do
18
+ Jiro.redis_opts = { :port => 999 }
19
+ Jiro.redis_opts.should eq({ :port => 999})
20
+ end
21
+ end
@@ -0,0 +1,12 @@
1
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
2
+ $LOAD_PATH.unshift(File.dirname(__FILE__))
3
+ require 'rspec'
4
+
5
+ # Requires supporting files with custom matchers and macros, etc,
6
+ # in ./support/ and its subdirectories.
7
+ Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each {|f| require f}
8
+ require 'jiro'
9
+
10
+ RSpec.configure do |config|
11
+
12
+ end
@@ -0,0 +1,10 @@
1
+ module ActionView
2
+ class FileSystemResolver
3
+ def initialize(path)
4
+ end
5
+
6
+ def find_templates(name, prefix, partial, details)
7
+ []
8
+ end
9
+ end
10
+ end
metadata ADDED
@@ -0,0 +1,147 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: jiro
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.0
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Marcin Naglik
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2013-06-11 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: redis
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ~>
20
+ - !ruby/object:Gem::Version
21
+ version: 3.0.4
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ~>
28
+ - !ruby/object:Gem::Version
29
+ version: 3.0.4
30
+ - !ruby/object:Gem::Dependency
31
+ name: rspec
32
+ requirement: !ruby/object:Gem::Requirement
33
+ none: false
34
+ requirements:
35
+ - - ~>
36
+ - !ruby/object:Gem::Version
37
+ version: 2.8.0
38
+ type: :development
39
+ prerelease: false
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ~>
44
+ - !ruby/object:Gem::Version
45
+ version: 2.8.0
46
+ - !ruby/object:Gem::Dependency
47
+ name: rdoc
48
+ requirement: !ruby/object:Gem::Requirement
49
+ none: false
50
+ requirements:
51
+ - - ~>
52
+ - !ruby/object:Gem::Version
53
+ version: '3.12'
54
+ type: :development
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ~>
60
+ - !ruby/object:Gem::Version
61
+ version: '3.12'
62
+ - !ruby/object:Gem::Dependency
63
+ name: bundler
64
+ requirement: !ruby/object:Gem::Requirement
65
+ none: false
66
+ requirements:
67
+ - - ~>
68
+ - !ruby/object:Gem::Version
69
+ version: 1.3.5
70
+ type: :development
71
+ prerelease: false
72
+ version_requirements: !ruby/object:Gem::Requirement
73
+ none: false
74
+ requirements:
75
+ - - ~>
76
+ - !ruby/object:Gem::Version
77
+ version: 1.3.5
78
+ - !ruby/object:Gem::Dependency
79
+ name: jeweler
80
+ requirement: !ruby/object:Gem::Requirement
81
+ none: false
82
+ requirements:
83
+ - - ~>
84
+ - !ruby/object:Gem::Version
85
+ version: 1.8.4
86
+ type: :development
87
+ prerelease: false
88
+ version_requirements: !ruby/object:Gem::Requirement
89
+ none: false
90
+ requirements:
91
+ - - ~>
92
+ - !ruby/object:Gem::Version
93
+ version: 1.8.4
94
+ description: CMS that intercept Rails ActionView Templates and allow changing them
95
+ directly from Redis storage
96
+ email: marcin.naglik@gmail.com
97
+ executables: []
98
+ extensions: []
99
+ extra_rdoc_files:
100
+ - LICENSE.txt
101
+ - README.rdoc
102
+ files:
103
+ - .document
104
+ - .rspec
105
+ - Gemfile
106
+ - LICENSE.txt
107
+ - README.rdoc
108
+ - Rakefile
109
+ - VERSION
110
+ - jiro.gemspec
111
+ - lib/jiro.rb
112
+ - lib/jiro/redis_connection.rb
113
+ - lib/jiro/view_resolver.rb
114
+ - spec/jiro/redis_connection_spec.rb
115
+ - spec/jiro/view_resolver_spec.rb
116
+ - spec/jiro_spec.rb
117
+ - spec/spec_helper.rb
118
+ - spec/support/file_system_resolver.rb
119
+ homepage: http://github.com/managr/jiro
120
+ licenses:
121
+ - MIT
122
+ post_install_message:
123
+ rdoc_options: []
124
+ require_paths:
125
+ - lib
126
+ required_ruby_version: !ruby/object:Gem::Requirement
127
+ none: false
128
+ requirements:
129
+ - - ! '>='
130
+ - !ruby/object:Gem::Version
131
+ version: '0'
132
+ segments:
133
+ - 0
134
+ hash: -1459344032901833646
135
+ required_rubygems_version: !ruby/object:Gem::Requirement
136
+ none: false
137
+ requirements:
138
+ - - ! '>='
139
+ - !ruby/object:Gem::Version
140
+ version: '0'
141
+ requirements: []
142
+ rubyforge_project:
143
+ rubygems_version: 1.8.24
144
+ signing_key:
145
+ specification_version: 3
146
+ summary: Simple CMS for Rails hackers
147
+ test_files: []