ixtlan-core 0.6.0 → 0.6.1

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 (47) hide show
  1. data/README.md +64 -0
  2. data/features/headers.feature +12 -0
  3. data/features/step_definitions/simple_steps.rb +1 -0
  4. data/lib/ixtlan/core/active_record.rb +22 -0
  5. data/lib/ixtlan/core/active_record.rb~ +24 -0
  6. data/lib/ixtlan/core/controllers/configuration_controller.rb~ +9 -0
  7. data/lib/ixtlan/core/data_mapper.rb +23 -0
  8. data/lib/ixtlan/core/data_mapper.rb~ +18 -0
  9. data/lib/ixtlan/core/optimistic_active_record.rb~ +21 -0
  10. data/lib/ixtlan/core/{optimistic_data_mapper.rb → optimistic_data_mapper.rb~} +1 -1
  11. data/lib/ixtlan/core/railtie.rb +6 -6
  12. data/lib/ixtlan/core/x_content_headers.rb~ +32 -0
  13. data/lib/ixtlan/core/x_content_type_headers.rb~ +30 -0
  14. data/lib/ixtlan/core/x_xss_protection_headers.rb~ +30 -0
  15. data/spec/cache_headers_spec.rb~ +52 -0
  16. data/spec/configuration_manager_spec.rb~ +40 -0
  17. data/spec/controller.rb~ +8 -0
  18. data/spec/x_headers_spec.rb~ +74 -0
  19. metadata +24 -37
  20. data/lib/generators/ixtlan/base.rb +0 -45
  21. data/lib/generators/ixtlan/configuration_model/configuration_model_generator.rb +0 -12
  22. data/lib/generators/ixtlan/configuration_scaffold/configuration_scaffold_generator.rb +0 -12
  23. data/lib/generators/ixtlan/setup/setup_generator.rb +0 -38
  24. data/lib/generators/ixtlan/setup/templates/application_layout.html.erb +0 -17
  25. data/lib/generators/ixtlan/setup/templates/database.yml.example +0 -48
  26. data/lib/generators/ixtlan/setup/templates/error.html.erb +0 -1
  27. data/lib/generators/ixtlan/setup/templates/error_with_session.html.erb +0 -1
  28. data/lib/generators/ixtlan/setup/templates/gitignore +0 -2
  29. data/lib/generators/ixtlan/setup/templates/initializer.rb +0 -64
  30. data/lib/generators/ixtlan/setup/templates/preinitializer.rb +0 -31
  31. data/lib/generators/ixtlan/setup/templates/production.yml.example +0 -8
  32. data/lib/generators/ixtlan/setup/templates/stale.html.erb +0 -2
  33. data/lib/generators/model/model_generator.rb +0 -12
  34. data/lib/generators/rails/active_record/active_record_generator.rb +0 -40
  35. data/lib/generators/rails/active_record/model/migration.rb +0 -19
  36. data/lib/generators/rails/active_record/model/model.rb +0 -16
  37. data/lib/generators/rails/erb/erb_generator.rb +0 -37
  38. data/lib/generators/rails/erb/scaffold/_form.html.erb +0 -28
  39. data/lib/generators/rails/erb/scaffold/edit.html.erb +0 -24
  40. data/lib/generators/rails/erb/scaffold/index.html.erb +0 -49
  41. data/lib/generators/rails/erb/scaffold/new.html.erb +0 -11
  42. data/lib/generators/rails/erb/scaffold/show.html.erb +0 -30
  43. data/lib/generators/rails/scaffold_controller/scaffold_controller/controller.rb +0 -129
  44. data/lib/generators/rails/scaffold_controller/scaffold_controller/singleton_controller.rb +0 -43
  45. data/lib/generators/scaffold/scaffold_generator.rb +0 -35
  46. data/lib/generators/scaffold_controller/scaffold_controller_generator.rb +0 -34
  47. data/lib/ixtlan/core/optimistic_active_record.rb +0 -18
@@ -0,0 +1,8 @@
1
+ class Controller
2
+
3
+
4
+ def warn(msg)
5
+ @warn = msg
6
+ end
7
+
8
+ end
@@ -0,0 +1,74 @@
1
+ require 'controller'
2
+
3
+ shared_examples 'a X-Headers' do
4
+
5
+ it 'should be able to switch off' do
6
+ subject.send method, :inline => "asd", :x_frame_headers => :off, :x_content_type_headers => :off, :x_xss_protection_headers => :off
7
+ subject.response.headers.should == {}
8
+ end
9
+
10
+ end
11
+
12
+ class MyController < Controller
13
+ x_frame_headers :sameorigin
14
+ x_content_type_headers :off
15
+ x_xss_protection_headers :disabled
16
+ end
17
+
18
+ [:render, :send_file, :send_data].each do |method|
19
+ describe "using controller method #{method}" do
20
+ context "with simple controller" do
21
+ before do
22
+ Rails.configuration.x_frame_headers = nil
23
+ Rails.configuration.x_content_type_headers = nil
24
+ Rails.configuration.x_xss_protection_headers = nil
25
+ end
26
+ subject { Controller.new }
27
+
28
+ it 'should use default' do
29
+ subject.send method, :inline => "asd"
30
+ subject.response.headers.should == {"X-Frame-Options"=>"DENY", "X-Content-Type-Options"=>"nosniff", "X-XSS-Protection"=>"1; mode=block"}
31
+ end
32
+
33
+ it_behaves_like "a X-Headers" do
34
+ let(:method) { method }
35
+ end
36
+ end
37
+
38
+ context "with controller with header configuration" do
39
+ before do
40
+ Rails.configuration.x_frame_headers = nil
41
+ Rails.configuration.x_content_type_headers = nil
42
+ Rails.configuration.x_xss_protection_headers = nil
43
+ end
44
+ subject { MyController.new }
45
+
46
+ it 'should use configuration' do
47
+ subject.send method, :inline => "asd"
48
+ subject.response.headers.should == {"X-Frame-Options"=>"SAMEORIGIN", "X-XSS-Protection"=>"0"}
49
+ end
50
+
51
+ it_behaves_like "a X-Headers" do
52
+ let(:method) { method }
53
+ end
54
+ end
55
+
56
+ context "with simple controller with rails configuration" do
57
+ before do
58
+ Rails.configuration.x_frame_headers = :sameorigin
59
+ Rails.configuration.x_content_type_headers = :off
60
+ Rails.configuration.x_xss_protection_headers = :disabled
61
+ end
62
+ subject { Controller.new }
63
+
64
+ it 'should use configuration' do
65
+ subject.send method, :inline => "asd"
66
+ subject.response.headers.should == {"X-Frame-Options"=>"SAMEORIGIN", "X-XSS-Protection"=>"0"}
67
+ end
68
+
69
+ it_behaves_like "a X-Headers" do
70
+ let(:method) { method }
71
+ end
72
+ end
73
+ end
74
+ end
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: ixtlan-core
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.6.0
5
+ version: 0.6.1
6
6
  platform: ruby
7
7
  authors:
8
8
  - mkristian
@@ -10,7 +10,7 @@ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
12
 
13
- date: 2011-09-05 00:00:00 +05:30
13
+ date: 2011-10-15 00:00:00 +05:30
14
14
  default_executable:
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
@@ -19,12 +19,9 @@ dependencies:
19
19
  requirement: &id001 !ruby/object:Gem::Requirement
20
20
  none: false
21
21
  requirements:
22
- - - ">="
22
+ - - ~>
23
23
  - !ruby/object:Gem::Version
24
24
  version: 0.4.2
25
- - - <
26
- - !ruby/object:Gem::Version
27
- version: 0.4.99999
28
25
  type: :runtime
29
26
  version_requirements: *id001
30
27
  - !ruby/object:Gem::Dependency
@@ -35,7 +32,7 @@ dependencies:
35
32
  requirements:
36
33
  - - "="
37
34
  - !ruby/object:Gem::Version
38
- version: 0.1.0
35
+ version: 0.1.2
39
36
  type: :development
40
37
  version_requirements: *id002
41
38
  - !ruby/object:Gem::Dependency
@@ -79,7 +76,7 @@ dependencies:
79
76
  requirements:
80
77
  - - "="
81
78
  - !ruby/object:Gem::Version
82
- version: 0.8.3.0.3.0.28.3
79
+ version: 3.0.3.0.28.5
83
80
  type: :development
84
81
  version_requirements: *id006
85
82
  description: cache header control, dynamic configuration, and optimistic find on model via updated_at timestamp
@@ -93,49 +90,37 @@ extra_rdoc_files: []
93
90
 
94
91
  files:
95
92
  - MIT-LICENSE
93
+ - README.md
96
94
  - lib/ixtlan-core.rb
97
- - lib/generators/model/model_generator.rb
98
- - lib/generators/scaffold/scaffold_generator.rb
99
- - lib/generators/scaffold_controller/scaffold_controller_generator.rb
100
- - lib/generators/rails/erb/erb_generator.rb
101
- - lib/generators/rails/erb/scaffold/new.html.erb
102
- - lib/generators/rails/erb/scaffold/_form.html.erb
103
- - lib/generators/rails/erb/scaffold/index.html.erb
104
- - lib/generators/rails/erb/scaffold/show.html.erb
105
- - lib/generators/rails/erb/scaffold/edit.html.erb
106
- - lib/generators/rails/scaffold_controller/scaffold_controller/controller.rb
107
- - lib/generators/rails/scaffold_controller/scaffold_controller/singleton_controller.rb
108
- - lib/generators/rails/active_record/active_record_generator.rb
109
- - lib/generators/rails/active_record/model/model.rb
110
- - lib/generators/rails/active_record/model/migration.rb
111
- - lib/generators/ixtlan/base.rb
112
- - lib/generators/ixtlan/configuration_scaffold/configuration_scaffold_generator.rb
113
- - lib/generators/ixtlan/setup/setup_generator.rb
114
- - lib/generators/ixtlan/setup/templates/database.yml.example
115
- - lib/generators/ixtlan/setup/templates/error_with_session.html.erb
116
- - lib/generators/ixtlan/setup/templates/error.html.erb
117
- - lib/generators/ixtlan/setup/templates/application_layout.html.erb
118
- - lib/generators/ixtlan/setup/templates/preinitializer.rb
119
- - lib/generators/ixtlan/setup/templates/initializer.rb
120
- - lib/generators/ixtlan/setup/templates/gitignore
121
- - lib/generators/ixtlan/setup/templates/stale.html.erb
122
- - lib/generators/ixtlan/setup/templates/production.yml.example
123
- - lib/generators/ixtlan/configuration_model/configuration_model_generator.rb
95
+ - lib/ixtlan/core/x_xss_protection_headers.rb~
124
96
  - lib/ixtlan/core/x_frame_headers.rb
125
- - lib/ixtlan/core/optimistic_data_mapper.rb
97
+ - lib/ixtlan/core/active_record.rb
126
98
  - lib/ixtlan/core/configuration_rack.rb
127
- - lib/ixtlan/core/optimistic_active_record.rb
99
+ - lib/ixtlan/core/x_content_headers.rb~
100
+ - lib/ixtlan/core/data_mapper.rb~
101
+ - lib/ixtlan/core/active_record.rb~
128
102
  - lib/ixtlan/core/extra_headers.rb
129
103
  - lib/ixtlan/core/x_content_type_headers.rb
104
+ - lib/ixtlan/core/x_content_type_headers.rb~
130
105
  - lib/ixtlan/core/cache_headers.rb
106
+ - lib/ixtlan/core/optimistic_data_mapper.rb~
107
+ - lib/ixtlan/core/data_mapper.rb
131
108
  - lib/ixtlan/core/x_xss_protection_headers.rb
109
+ - lib/ixtlan/core/optimistic_active_record.rb~
132
110
  - lib/ixtlan/core/railtie.rb
133
111
  - lib/ixtlan/core/configuration_manager.rb
134
112
  - lib/ixtlan/core/controllers/configuration_controller.rb
113
+ - lib/ixtlan/core/controllers/configuration_controller.rb~
114
+ - spec/cache_headers_spec.rb~
135
115
  - spec/controller.rb
116
+ - spec/controller.rb~
136
117
  - spec/cache_headers_spec.rb
118
+ - spec/x_headers_spec.rb~
137
119
  - spec/x_headers_spec.rb
120
+ - spec/configuration_manager_spec.rb~
138
121
  - spec/configuration_manager_spec.rb
122
+ - features/step_definitions/simple_steps.rb
123
+ - features/headers.feature
139
124
  has_rdoc: true
140
125
  homepage: http://github.com/mkristian/ixtlan-core
141
126
  licenses:
@@ -169,3 +154,5 @@ test_files:
169
154
  - spec/cache_headers_spec.rb
170
155
  - spec/x_headers_spec.rb
171
156
  - spec/configuration_manager_spec.rb
157
+ - features/headers.feature
158
+ - features/step_definitions/simple_steps.rb
@@ -1,45 +0,0 @@
1
- require 'rails/generators/named_base'
2
- module Ixtlan
3
- module Generators
4
- class Base < Rails::Generators::Base
5
-
6
- argument :name, :type => :string, :required => false
7
-
8
- protected
9
- def generator_name
10
- raise "please overwrite generator_name"
11
- end
12
-
13
- public
14
- def create
15
- args = []
16
- if name
17
- args << ARGV.shift
18
- else
19
- args << "configuration"
20
- end
21
-
22
- if defined? ::Ixtlan::Errors
23
- args << "errors_keep_dump:integer"
24
- args << "errors_dir:string"
25
- args << "errors_from:string"
26
- args << "errors_to:string"
27
- end
28
-
29
- if defined? ::Ixtlan::Sessions
30
- args << "idle_session_timeout:integer"
31
- end
32
-
33
- if defined? ::Ixtlan::Audit
34
- args << "audit_keep_log:integer"
35
- end
36
-
37
- args += ARGV[0, 10000] || []
38
-
39
- args << "--singleton"
40
-
41
- generate generator_name, *args
42
- end
43
- end
44
- end
45
- end
@@ -1,12 +0,0 @@
1
- require 'generators/ixtlan/base'
2
- module Ixtlan
3
- module Generators
4
- class ConfigurationModelGenerator < Base
5
-
6
- protected
7
- def generator_name
8
- "model"
9
- end
10
- end
11
- end
12
- end
@@ -1,12 +0,0 @@
1
- require 'generators/ixtlan/base'
2
- module Ixtlan
3
- module Generators
4
- class ConfigurationScaffoldGenerator < Base
5
-
6
- protected
7
- def generator_name
8
- "scaffold"
9
- end
10
- end
11
- end
12
- end
@@ -1,38 +0,0 @@
1
- require 'rails/generators/base'
2
- module Ixtlan
3
- module Generators
4
- class SetupGenerator < Rails::Generators::Base
5
-
6
- source_root File.expand_path('../templates', __FILE__)
7
-
8
- def create_preinitializer_files
9
- template 'preinitializer.rb', File.join('config', "preinitializer.rb")
10
- template 'gitignore', File.join('config', ".gitignore")
11
- template 'production.yml.example', File.join('config', "production.yml.example")
12
- template 'database.yml.example', File.join('config', "database.yml.example")
13
- end
14
-
15
- def create_initializer_file
16
- template 'initializer.rb', File.join('config', "initializers", "ixtlan.rb")
17
- end
18
-
19
- # TODO make only if template-engine is ERB
20
- def error_templates
21
- if defined? Ixtlan::Errors
22
- views_dir = File.join('app', 'views', 'errors')
23
- ['error', 'error_with_session', 'stale'].each do |f|
24
- file = "#{f}.html.erb"
25
- template file, File.join(views_dir, file)
26
- end
27
- end
28
- end
29
-
30
- def create_application_layout_file
31
- if defined? Ixtlan::Sessions
32
- layout = File.join('app', 'views', 'layouts', 'application.html.erb')
33
- template 'application_layout.html.erb', layout
34
- end
35
- end
36
- end
37
- end
38
- end
@@ -1,17 +0,0 @@
1
- <!DOCTYPE html>
2
- <html>
3
- <head>
4
- <title><%= app_const_base %></title>
5
- <%%= stylesheet_link_tag :all %>
6
- <%%= javascript_include_tag :defaults %>
7
- <%%= csrf_meta_tag %>
8
- <%% if controller.respond_to?(:current_user) && controller.send(:current_user) != nil %>
9
- <meta http-equiv="refresh" content="<%%= controller.send(:idle_session_timeout) * 60 + 5 %>" />
10
- <%% end %>
11
- </head>
12
- <body>
13
-
14
- <%%= yield %>
15
-
16
- </body>
17
- </html>
@@ -1,48 +0,0 @@
1
- # MySQL. Versions 4.1 and 5.0 are recommended.
2
- #
3
- # Install the MySQL driver:
4
- # gem install mysql
5
- # On Mac OS X:
6
- # sudo gem install mysql -- --with-mysql-dir=/usr/local/mysql
7
- # On Mac OS X Leopard:
8
- # sudo env ARCHFLAGS="-arch i386" gem install mysql -- --with-mysql-config=/usr/local/mysql/bin/mysql_config
9
- # This sets the ARCHFLAGS environment variable to your native architecture
10
- # On Windows:
11
- # gem install mysql
12
- # Choose the win32 build.
13
- # Install MySQL and put its /bin directory on your path.
14
- #
15
- # And be sure to use new-style password hashing:
16
- # http://dev.mysql.com/doc/refman/5.0/en/old-client.html
17
- development:
18
- adapter: mysql
19
- encoding: utf8
20
- reconnect: false
21
- database: test_development
22
- pool: 5
23
- username: root
24
- password:
25
- socket: /var/run/mysqld/mysqld.sock
26
-
27
- # Warning: The database defined as "test" will be erased and
28
- # re-generated from your development database when you run "rake".
29
- # Do not set this db to the same as development or production.
30
- test:
31
- adapter: mysql
32
- encoding: utf8
33
- reconnect: false
34
- database: test_test
35
- pool: 5
36
- username: root
37
- password:
38
- socket: /var/run/mysqld/mysqld.sock
39
-
40
- production:
41
- adapter: mysql
42
- encoding: utf8
43
- reconnect: false
44
- database: CONFIG[:db][:database]
45
- pool: 5
46
- username: CONFIG[:db][:username]
47
- password: CONFIG[:db][:password]
48
- socket: /var/run/mysqld/mysqld.sock
@@ -1 +0,0 @@
1
- <h1><%%= @notice %></h1>
@@ -1 +0,0 @@
1
- <h1><%%= @notice %></h1>
@@ -1,2 +0,0 @@
1
- production.yml
2
- *.example
@@ -1,64 +0,0 @@
1
- # dynamic configuration through a Configuration singleton model
2
-
3
- # configuration model
4
- # -------------------
5
- # CONFIGURATION = Configuration
6
- # config.configuration_model = CONFIGURATION
7
- begin
8
- config_instance = CONFIGURATION.instance
9
- rescue
10
- # allow rake tasks to work without configuration migrated
11
- return
12
- end
13
-
14
- # notification email on errors and dump directory for the system dump
15
- # the error dumps will be cleanup after the days to keeps dump expired
16
- # --------------------------------------------------------------------
17
- # config_instance.register("error_dumper") do |config|
18
- # Rails.configuration.error_dumper.dump_dir = config.errors_dir
19
- # Rails.configuration.error_dumper.email_from = config.errors_from
20
- # Rails.configuration.error_dumper.email_to = config.errors_to
21
- # Rails.configuration.error_dumper.keep_dumps = config.errors_keep_dump # days
22
- # end
23
-
24
- # idle session timeout configuration (in minutes)
25
- # -----------------------------------------------
26
- # config_instance.register("session_idle_timeout") do |config|
27
- # Rails.configuration.session_idle_timeout = config.session_idle_timeout
28
- # end
29
-
30
- # audit log manager
31
- # -----------------
32
-
33
- # config.audit_manager.model = MyAudit # default: Audit
34
- # config.audit_manager.username_method = :username # default: :login
35
-
36
- # config_instance.register("audit_manager") do |config|
37
- # Rails.configuration.audit_manager.keep_log = config.keep_log # days
38
- # end
39
-
40
- # --------------------
41
- # static configuration
42
- # --------------------
43
-
44
- # error dumper
45
- # ------------
46
- # notification email on errors and dump directory for the system dump. per
47
- # default there is no email notification and if email_from or email_to is
48
- # missing then there is no email too
49
-
50
- # config.error_dumper.dump_dir = Rails.root + "/log/errors" # default: log/errors
51
- # config.error_dumper.email_from = "no-reply@example.com"
52
- # config.error_dumper.email_to = "developer1@example.com,developer2@example.com"
53
- # config.error_dumper.keep_dumps = 30 # days
54
- # config.skip_rescue_module = true # do not include the predefined Rescue
55
-
56
- # idle session timeout configuration
57
- # ----------------------------------
58
- # config.session_idle_timeout = 30 #minutes
59
-
60
- # audit log manager
61
- # -----------------
62
- # config.audit_manager.model = MyAudit # default: Audit
63
- # config.audit_manager.username_method = :username # default: :login
64
- # config.audit_manager.keep_log = 30 # days