patchstream 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (61) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +17 -0
  3. data/Gemfile +17 -0
  4. data/Guardfile +9 -0
  5. data/LICENSE.txt +22 -0
  6. data/README.md +59 -0
  7. data/Rakefile +1 -0
  8. data/lib/patchstream.rb +92 -0
  9. data/lib/patchstream/version.rb +3 -0
  10. data/patchstream.gemspec +23 -0
  11. data/spec/dummy/.gitignore +16 -0
  12. data/spec/dummy/Gemfile +47 -0
  13. data/spec/dummy/README.rdoc +28 -0
  14. data/spec/dummy/Rakefile +6 -0
  15. data/spec/dummy/app/assets/images/.keep +0 -0
  16. data/spec/dummy/app/assets/javascripts/application.js +16 -0
  17. data/spec/dummy/app/assets/stylesheets/application.css +13 -0
  18. data/spec/dummy/app/controllers/application_controller.rb +5 -0
  19. data/spec/dummy/app/controllers/concerns/.keep +0 -0
  20. data/spec/dummy/app/helpers/application_helper.rb +2 -0
  21. data/spec/dummy/app/mailers/.keep +0 -0
  22. data/spec/dummy/app/models/.keep +0 -0
  23. data/spec/dummy/app/models/concerns/.keep +0 -0
  24. data/spec/dummy/app/models/product.rb +4 -0
  25. data/spec/dummy/app/views/layouts/application.html.erb +14 -0
  26. data/spec/dummy/bin/bundle +3 -0
  27. data/spec/dummy/bin/rails +4 -0
  28. data/spec/dummy/bin/rake +4 -0
  29. data/spec/dummy/config.ru +4 -0
  30. data/spec/dummy/config/application.rb +23 -0
  31. data/spec/dummy/config/boot.rb +4 -0
  32. data/spec/dummy/config/database.yml +25 -0
  33. data/spec/dummy/config/environment.rb +5 -0
  34. data/spec/dummy/config/environments/development.rb +29 -0
  35. data/spec/dummy/config/environments/production.rb +80 -0
  36. data/spec/dummy/config/environments/test.rb +36 -0
  37. data/spec/dummy/config/initializers/backtrace_silencers.rb +7 -0
  38. data/spec/dummy/config/initializers/filter_parameter_logging.rb +4 -0
  39. data/spec/dummy/config/initializers/inflections.rb +16 -0
  40. data/spec/dummy/config/initializers/mime_types.rb +5 -0
  41. data/spec/dummy/config/initializers/secret_token.rb +12 -0
  42. data/spec/dummy/config/initializers/session_store.rb +3 -0
  43. data/spec/dummy/config/initializers/wrap_parameters.rb +14 -0
  44. data/spec/dummy/config/locales/en.yml +23 -0
  45. data/spec/dummy/config/routes.rb +56 -0
  46. data/spec/dummy/db/migrate/20140624014830_create_products.rb +11 -0
  47. data/spec/dummy/db/schema.rb +25 -0
  48. data/spec/dummy/db/seeds.rb +7 -0
  49. data/spec/dummy/lib/assets/.keep +0 -0
  50. data/spec/dummy/lib/tasks/.keep +0 -0
  51. data/spec/dummy/log/.keep +0 -0
  52. data/spec/dummy/public/404.html +58 -0
  53. data/spec/dummy/public/422.html +58 -0
  54. data/spec/dummy/public/500.html +57 -0
  55. data/spec/dummy/public/favicon.ico +0 -0
  56. data/spec/dummy/public/robots.txt +5 -0
  57. data/spec/dummy/vendor/assets/javascripts/.keep +0 -0
  58. data/spec/dummy/vendor/assets/stylesheets/.keep +0 -0
  59. data/spec/patchstream_spec.rb +60 -0
  60. data/spec/spec_helper.rb +26 -0
  61. metadata +182 -0
@@ -0,0 +1,58 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>The change you wanted was rejected (422)</title>
5
+ <style>
6
+ body {
7
+ background-color: #EFEFEF;
8
+ color: #2E2F30;
9
+ text-align: center;
10
+ font-family: arial, sans-serif;
11
+ }
12
+
13
+ div.dialog {
14
+ width: 25em;
15
+ margin: 4em auto 0 auto;
16
+ border: 1px solid #CCC;
17
+ border-right-color: #999;
18
+ border-left-color: #999;
19
+ border-bottom-color: #BBB;
20
+ border-top: #B00100 solid 4px;
21
+ border-top-left-radius: 9px;
22
+ border-top-right-radius: 9px;
23
+ background-color: white;
24
+ padding: 7px 4em 0 4em;
25
+ }
26
+
27
+ h1 {
28
+ font-size: 100%;
29
+ color: #730E15;
30
+ line-height: 1.5em;
31
+ }
32
+
33
+ body > p {
34
+ width: 33em;
35
+ margin: 0 auto 1em;
36
+ padding: 1em 0;
37
+ background-color: #F7F7F7;
38
+ border: 1px solid #CCC;
39
+ border-right-color: #999;
40
+ border-bottom-color: #999;
41
+ border-bottom-left-radius: 4px;
42
+ border-bottom-right-radius: 4px;
43
+ border-top-color: #DADADA;
44
+ color: #666;
45
+ box-shadow:0 3px 8px rgba(50, 50, 50, 0.17);
46
+ }
47
+ </style>
48
+ </head>
49
+
50
+ <body>
51
+ <!-- This file lives in public/422.html -->
52
+ <div class="dialog">
53
+ <h1>The change you wanted was rejected.</h1>
54
+ <p>Maybe you tried to change something you didn't have access to.</p>
55
+ </div>
56
+ <p>If you are the application owner check the logs for more information.</p>
57
+ </body>
58
+ </html>
@@ -0,0 +1,57 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>We're sorry, but something went wrong (500)</title>
5
+ <style>
6
+ body {
7
+ background-color: #EFEFEF;
8
+ color: #2E2F30;
9
+ text-align: center;
10
+ font-family: arial, sans-serif;
11
+ }
12
+
13
+ div.dialog {
14
+ width: 25em;
15
+ margin: 4em auto 0 auto;
16
+ border: 1px solid #CCC;
17
+ border-right-color: #999;
18
+ border-left-color: #999;
19
+ border-bottom-color: #BBB;
20
+ border-top: #B00100 solid 4px;
21
+ border-top-left-radius: 9px;
22
+ border-top-right-radius: 9px;
23
+ background-color: white;
24
+ padding: 7px 4em 0 4em;
25
+ }
26
+
27
+ h1 {
28
+ font-size: 100%;
29
+ color: #730E15;
30
+ line-height: 1.5em;
31
+ }
32
+
33
+ body > p {
34
+ width: 33em;
35
+ margin: 0 auto 1em;
36
+ padding: 1em 0;
37
+ background-color: #F7F7F7;
38
+ border: 1px solid #CCC;
39
+ border-right-color: #999;
40
+ border-bottom-color: #999;
41
+ border-bottom-left-radius: 4px;
42
+ border-bottom-right-radius: 4px;
43
+ border-top-color: #DADADA;
44
+ color: #666;
45
+ box-shadow:0 3px 8px rgba(50, 50, 50, 0.17);
46
+ }
47
+ </style>
48
+ </head>
49
+
50
+ <body>
51
+ <!-- This file lives in public/500.html -->
52
+ <div class="dialog">
53
+ <h1>We're sorry, but something went wrong.</h1>
54
+ </div>
55
+ <p>If you are the application owner check the logs for more information.</p>
56
+ </body>
57
+ </html>
File without changes
@@ -0,0 +1,5 @@
1
+ # See http://www.robotstxt.org/robotstxt.html for documentation on how to use the robots.txt file
2
+ #
3
+ # To ban all spiders from the entire site uncomment the next two lines:
4
+ # User-agent: *
5
+ # Disallow: /
@@ -0,0 +1,60 @@
1
+ require 'spec_helper'
2
+
3
+ describe Patchstream do
4
+ let(:now){ Time.at(1403579955) }
5
+ let(:output){ [] }
6
+
7
+ before do
8
+ Timecop.freeze(now)
9
+ Product.patch_streams.add(output)
10
+ end
11
+
12
+ context "when a record is created" do
13
+ before do
14
+ @product = Product.create name: "Bike", price: 20, id: "3b01d506-8e5b-4ae4-8860-4f2d54106ff1"
15
+ end
16
+
17
+ it "should generate a patch" do
18
+ output.first.should == {
19
+ :op => :add,
20
+ :path => "/products/3b01d506-8e5b-4ae4-8860-4f2d54106ff1",
21
+ :value => {
22
+ :id => @product.id,
23
+ :name => "Bike",
24
+ :price => 20.0,
25
+ :created_at => "2014-06-24T03:19:15.000Z",
26
+ :updated_at => "2014-06-24T03:19:15.000Z"
27
+ }.as_json
28
+ }
29
+ end
30
+ end
31
+
32
+ context "when a record is updated" do
33
+ before do
34
+ @product = Product.create name: "Bike", price: 20, id: "3b01d506-8e5b-4ae4-8860-4f2d54106ff1"
35
+ output.clear
36
+ @product.update_attributes name: "Bicycle", price: 30
37
+ end
38
+
39
+ it "should generate a patch" do
40
+ output.should == [
41
+ {:op=>:replace, :path=>"/products/3b01d506-8e5b-4ae4-8860-4f2d54106ff1/name", :value=>"Bicycle"},
42
+ {:op=>:replace, :path=>"/products/3b01d506-8e5b-4ae4-8860-4f2d54106ff1/price", :value=>30.0}
43
+ ]
44
+ end
45
+ end
46
+
47
+ context "when a record is destroyed" do
48
+ before do
49
+ @product = Product.create name: "Bike", price: 20, id: "3b01d506-8e5b-4ae4-8860-4f2d54106ff1"
50
+ output.clear
51
+ @product.destroy
52
+ end
53
+
54
+ it "should generate a patch" do
55
+ output.should == [
56
+ {:op=>:remove, :path=>"/products/3b01d506-8e5b-4ae4-8860-4f2d54106ff1"},
57
+ ]
58
+ end
59
+ end
60
+ end
@@ -0,0 +1,26 @@
1
+ ENV['RAILS_ENV'] = 'test'
2
+
3
+ require File.expand_path('../dummy/config/environment.rb', __FILE__)
4
+ require 'rails/test_help'
5
+ require 'rspec/rails'
6
+
7
+ # ActionMailer::Base.delivery_method = :test
8
+ # ActionMailer::Base.perform_deliveries = true
9
+ # ActionMailer::Base.default_url_options[:host] = 'test.com'
10
+
11
+ Rails.backtrace_cleaner.remove_silencers!
12
+
13
+ # Load support files
14
+ Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each { |f| require f }
15
+
16
+ RSpec.configure do |config|
17
+ # Remove this line if you don't want RSpec's should and should_not
18
+ # methods or matchers
19
+ require 'rspec/expectations'
20
+ config.include RSpec::Matchers
21
+
22
+ # == Mock Framework
23
+ config.mock_framework = :mocha
24
+
25
+ config.use_transactional_fixtures = true
26
+ end
metadata ADDED
@@ -0,0 +1,182 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: patchstream
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - opsb
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-06-24 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ~>
18
+ - !ruby/object:Gem::Version
19
+ version: '1.3'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ~>
25
+ - !ruby/object:Gem::Version
26
+ version: '1.3'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - '>='
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - '>='
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ description: Emits json patches when active records are updated
42
+ email:
43
+ - oliver@opsb.co.uk
44
+ executables: []
45
+ extensions: []
46
+ extra_rdoc_files: []
47
+ files:
48
+ - .gitignore
49
+ - Gemfile
50
+ - Guardfile
51
+ - LICENSE.txt
52
+ - README.md
53
+ - Rakefile
54
+ - lib/patchstream.rb
55
+ - lib/patchstream/version.rb
56
+ - patchstream.gemspec
57
+ - spec/dummy/.gitignore
58
+ - spec/dummy/Gemfile
59
+ - spec/dummy/README.rdoc
60
+ - spec/dummy/Rakefile
61
+ - spec/dummy/app/assets/images/.keep
62
+ - spec/dummy/app/assets/javascripts/application.js
63
+ - spec/dummy/app/assets/stylesheets/application.css
64
+ - spec/dummy/app/controllers/application_controller.rb
65
+ - spec/dummy/app/controllers/concerns/.keep
66
+ - spec/dummy/app/helpers/application_helper.rb
67
+ - spec/dummy/app/mailers/.keep
68
+ - spec/dummy/app/models/.keep
69
+ - spec/dummy/app/models/concerns/.keep
70
+ - spec/dummy/app/models/product.rb
71
+ - spec/dummy/app/views/layouts/application.html.erb
72
+ - spec/dummy/bin/bundle
73
+ - spec/dummy/bin/rails
74
+ - spec/dummy/bin/rake
75
+ - spec/dummy/config.ru
76
+ - spec/dummy/config/application.rb
77
+ - spec/dummy/config/boot.rb
78
+ - spec/dummy/config/database.yml
79
+ - spec/dummy/config/environment.rb
80
+ - spec/dummy/config/environments/development.rb
81
+ - spec/dummy/config/environments/production.rb
82
+ - spec/dummy/config/environments/test.rb
83
+ - spec/dummy/config/initializers/backtrace_silencers.rb
84
+ - spec/dummy/config/initializers/filter_parameter_logging.rb
85
+ - spec/dummy/config/initializers/inflections.rb
86
+ - spec/dummy/config/initializers/mime_types.rb
87
+ - spec/dummy/config/initializers/secret_token.rb
88
+ - spec/dummy/config/initializers/session_store.rb
89
+ - spec/dummy/config/initializers/wrap_parameters.rb
90
+ - spec/dummy/config/locales/en.yml
91
+ - spec/dummy/config/routes.rb
92
+ - spec/dummy/db/migrate/20140624014830_create_products.rb
93
+ - spec/dummy/db/schema.rb
94
+ - spec/dummy/db/seeds.rb
95
+ - spec/dummy/lib/assets/.keep
96
+ - spec/dummy/lib/tasks/.keep
97
+ - spec/dummy/log/.keep
98
+ - spec/dummy/public/404.html
99
+ - spec/dummy/public/422.html
100
+ - spec/dummy/public/500.html
101
+ - spec/dummy/public/favicon.ico
102
+ - spec/dummy/public/robots.txt
103
+ - spec/dummy/vendor/assets/javascripts/.keep
104
+ - spec/dummy/vendor/assets/stylesheets/.keep
105
+ - spec/patchstream_spec.rb
106
+ - spec/spec_helper.rb
107
+ homepage: ''
108
+ licenses:
109
+ - MIT
110
+ metadata: {}
111
+ post_install_message:
112
+ rdoc_options: []
113
+ require_paths:
114
+ - lib
115
+ required_ruby_version: !ruby/object:Gem::Requirement
116
+ requirements:
117
+ - - '>='
118
+ - !ruby/object:Gem::Version
119
+ version: '0'
120
+ required_rubygems_version: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - '>='
123
+ - !ruby/object:Gem::Version
124
+ version: '0'
125
+ requirements: []
126
+ rubyforge_project:
127
+ rubygems_version: 2.1.11
128
+ signing_key:
129
+ specification_version: 4
130
+ summary: Emits json patches when active records are updated
131
+ test_files:
132
+ - spec/dummy/.gitignore
133
+ - spec/dummy/Gemfile
134
+ - spec/dummy/README.rdoc
135
+ - spec/dummy/Rakefile
136
+ - spec/dummy/app/assets/images/.keep
137
+ - spec/dummy/app/assets/javascripts/application.js
138
+ - spec/dummy/app/assets/stylesheets/application.css
139
+ - spec/dummy/app/controllers/application_controller.rb
140
+ - spec/dummy/app/controllers/concerns/.keep
141
+ - spec/dummy/app/helpers/application_helper.rb
142
+ - spec/dummy/app/mailers/.keep
143
+ - spec/dummy/app/models/.keep
144
+ - spec/dummy/app/models/concerns/.keep
145
+ - spec/dummy/app/models/product.rb
146
+ - spec/dummy/app/views/layouts/application.html.erb
147
+ - spec/dummy/bin/bundle
148
+ - spec/dummy/bin/rails
149
+ - spec/dummy/bin/rake
150
+ - spec/dummy/config.ru
151
+ - spec/dummy/config/application.rb
152
+ - spec/dummy/config/boot.rb
153
+ - spec/dummy/config/database.yml
154
+ - spec/dummy/config/environment.rb
155
+ - spec/dummy/config/environments/development.rb
156
+ - spec/dummy/config/environments/production.rb
157
+ - spec/dummy/config/environments/test.rb
158
+ - spec/dummy/config/initializers/backtrace_silencers.rb
159
+ - spec/dummy/config/initializers/filter_parameter_logging.rb
160
+ - spec/dummy/config/initializers/inflections.rb
161
+ - spec/dummy/config/initializers/mime_types.rb
162
+ - spec/dummy/config/initializers/secret_token.rb
163
+ - spec/dummy/config/initializers/session_store.rb
164
+ - spec/dummy/config/initializers/wrap_parameters.rb
165
+ - spec/dummy/config/locales/en.yml
166
+ - spec/dummy/config/routes.rb
167
+ - spec/dummy/db/migrate/20140624014830_create_products.rb
168
+ - spec/dummy/db/schema.rb
169
+ - spec/dummy/db/seeds.rb
170
+ - spec/dummy/lib/assets/.keep
171
+ - spec/dummy/lib/tasks/.keep
172
+ - spec/dummy/log/.keep
173
+ - spec/dummy/public/404.html
174
+ - spec/dummy/public/422.html
175
+ - spec/dummy/public/500.html
176
+ - spec/dummy/public/favicon.ico
177
+ - spec/dummy/public/robots.txt
178
+ - spec/dummy/vendor/assets/javascripts/.keep
179
+ - spec/dummy/vendor/assets/stylesheets/.keep
180
+ - spec/patchstream_spec.rb
181
+ - spec/spec_helper.rb
182
+ has_rdoc: