memojs 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +24 -0
- data/Gemfile +2 -0
- data/Gemfile.lock +55 -0
- data/LICENSE +21 -0
- data/README.md +42 -0
- data/lib/assets/javascripts/memojs.coffee +30 -0
- data/lib/memojs.rb +7 -0
- data/lib/memojs/version.rb +3 -0
- data/memojs.gemspec +31 -0
- data/test/dummy/.gitignore +16 -0
- data/test/dummy/Gemfile +12 -0
- data/test/dummy/Gemfile.lock +97 -0
- data/test/dummy/README.rdoc +28 -0
- data/test/dummy/Rakefile +6 -0
- data/test/dummy/app/assets/images/.keep +0 -0
- data/test/dummy/app/assets/javascripts/application.js +14 -0
- data/test/dummy/app/assets/stylesheets/application.css +13 -0
- data/test/dummy/app/controllers/application_controller.rb +5 -0
- data/test/dummy/app/controllers/concerns/.keep +0 -0
- data/test/dummy/app/controllers/home_controller.rb +7 -0
- data/test/dummy/app/helpers/application_helper.rb +2 -0
- data/test/dummy/app/mailers/.keep +0 -0
- data/test/dummy/app/models/.keep +0 -0
- data/test/dummy/app/models/concerns/.keep +0 -0
- data/test/dummy/app/views/home/index.html +2 -0
- data/test/dummy/app/views/layouts/application.html.erb +14 -0
- data/test/dummy/bin/bundle +3 -0
- data/test/dummy/bin/rails +4 -0
- data/test/dummy/bin/rake +4 -0
- data/test/dummy/config.ru +4 -0
- data/test/dummy/config/application.rb +23 -0
- data/test/dummy/config/boot.rb +4 -0
- data/test/dummy/config/database.yml +25 -0
- data/test/dummy/config/environment.rb +5 -0
- data/test/dummy/config/environments/development.rb +29 -0
- data/test/dummy/config/environments/production.rb +80 -0
- data/test/dummy/config/environments/test.rb +36 -0
- data/test/dummy/config/initializers/backtrace_silencers.rb +7 -0
- data/test/dummy/config/initializers/filter_parameter_logging.rb +4 -0
- data/test/dummy/config/initializers/inflections.rb +16 -0
- data/test/dummy/config/initializers/mime_types.rb +5 -0
- data/test/dummy/config/initializers/secret_token.rb +12 -0
- data/test/dummy/config/initializers/session_store.rb +3 -0
- data/test/dummy/config/initializers/wrap_parameters.rb +14 -0
- data/test/dummy/config/locales/en.yml +23 -0
- data/test/dummy/config/routes.rb +3 -0
- data/test/dummy/db/seeds.rb +7 -0
- data/test/dummy/lib/assets/.keep +0 -0
- data/test/dummy/lib/tasks/.keep +0 -0
- data/test/dummy/log/.keep +0 -0
- data/test/dummy/public/404.html +58 -0
- data/test/dummy/public/422.html +58 -0
- data/test/dummy/public/500.html +57 -0
- data/test/dummy/public/favicon.ico +0 -0
- data/test/dummy/public/robots.txt +5 -0
- data/test/dummy/test/controllers/.keep +0 -0
- data/test/dummy/test/fixtures/.keep +0 -0
- data/test/dummy/test/helpers/.keep +0 -0
- data/test/dummy/test/integration/.keep +0 -0
- data/test/dummy/test/mailers/.keep +0 -0
- data/test/dummy/test/models/.keep +0 -0
- data/test/dummy/test/test_helper.rb +15 -0
- data/test/dummy/vendor/assets/javascripts/.keep +0 -0
- data/test/dummy/vendor/assets/stylesheets/.keep +0 -0
- metadata +229 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 98fd7f28e59b5fcb06f6d9535e39f93fdab1cd14
|
4
|
+
data.tar.gz: 6720573a2d4eedde4162b105f221fc35390ea977
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: e8f26f8d42419b8483eb14283708eaed5bf7e59efba8242e6040116eeece9aef65ca947e2b5403487dbb07476eb3389890208a5ae1f74df3b9304e1f542e6d57
|
7
|
+
data.tar.gz: 2c13ee9c00199a69cd9ed04f4de689e56fdb67f71a6be3bcf0db679e14d2f9285cca83d48fffcf151ca15734504bac8547a690ee337b51a875d442076306ebde
|
data/.gitignore
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
*.rbc
|
2
|
+
capybara-*.html
|
3
|
+
.rspec
|
4
|
+
/log
|
5
|
+
/tmp
|
6
|
+
/db/*.sqlite3
|
7
|
+
/public/system
|
8
|
+
/coverage/
|
9
|
+
/spec/tmp
|
10
|
+
**.orig
|
11
|
+
rerun.txt
|
12
|
+
pickle-email-*.html
|
13
|
+
config/initializers/secret_token.rb
|
14
|
+
config/secrets.yml
|
15
|
+
|
16
|
+
## Environment normalisation:
|
17
|
+
/.bundle
|
18
|
+
/vendor/bundle
|
19
|
+
|
20
|
+
# these should all be checked in to normalise the environment:
|
21
|
+
# Gemfile.lock, .ruby-version, .ruby-gemset
|
22
|
+
|
23
|
+
# unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
|
24
|
+
.rvmrc
|
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,55 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
memojs (1.0.0)
|
5
|
+
coffee-rails
|
6
|
+
railties (>= 3.1, < 5.0)
|
7
|
+
|
8
|
+
GEM
|
9
|
+
remote: https://rubygems.org/
|
10
|
+
specs:
|
11
|
+
actionpack (4.0.4)
|
12
|
+
activesupport (= 4.0.4)
|
13
|
+
builder (~> 3.1.0)
|
14
|
+
erubis (~> 2.7.0)
|
15
|
+
rack (~> 1.5.2)
|
16
|
+
rack-test (~> 0.6.2)
|
17
|
+
activesupport (4.0.4)
|
18
|
+
i18n (~> 0.6, >= 0.6.9)
|
19
|
+
minitest (~> 4.2)
|
20
|
+
multi_json (~> 1.3)
|
21
|
+
thread_safe (~> 0.1)
|
22
|
+
tzinfo (~> 0.3.37)
|
23
|
+
builder (3.1.4)
|
24
|
+
coffee-rails (4.0.1)
|
25
|
+
coffee-script (>= 2.2.0)
|
26
|
+
railties (>= 4.0.0, < 5.0)
|
27
|
+
coffee-script (2.2.0)
|
28
|
+
coffee-script-source
|
29
|
+
execjs
|
30
|
+
coffee-script-source (1.7.0)
|
31
|
+
erubis (2.7.0)
|
32
|
+
execjs (2.0.2)
|
33
|
+
i18n (0.6.9)
|
34
|
+
minitest (4.7.5)
|
35
|
+
multi_json (1.9.2)
|
36
|
+
rack (1.5.2)
|
37
|
+
rack-test (0.6.2)
|
38
|
+
rack (>= 1.0)
|
39
|
+
railties (4.0.4)
|
40
|
+
actionpack (= 4.0.4)
|
41
|
+
activesupport (= 4.0.4)
|
42
|
+
rake (>= 0.8.7)
|
43
|
+
thor (>= 0.18.1, < 2.0)
|
44
|
+
rake (10.3.1)
|
45
|
+
thor (0.19.1)
|
46
|
+
thread_safe (0.3.3)
|
47
|
+
tzinfo (0.3.39)
|
48
|
+
|
49
|
+
PLATFORMS
|
50
|
+
ruby
|
51
|
+
|
52
|
+
DEPENDENCIES
|
53
|
+
bundler (~> 1.5)
|
54
|
+
memojs!
|
55
|
+
rake
|
data/LICENSE
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2014 Lokalebasen.dk A/S
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
13
|
+
copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
21
|
+
SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,42 @@
|
|
1
|
+
memojs
|
2
|
+
======
|
3
|
+
|
4
|
+
A lightweight wrapper around the localStorage API.
|
5
|
+
|
6
|
+
### How to use
|
7
|
+
|
8
|
+
Add `memojs` to your Gemfile and require memojs in your JavaScript manifest. Add this line to your application.js file:
|
9
|
+
|
10
|
+
//= require memojs
|
11
|
+
|
12
|
+
`window` will now have a `memo` object with the following somewhat self-explanatory functions.
|
13
|
+
|
14
|
+
set(key, value)
|
15
|
+
Adds `value` to the store using `key`
|
16
|
+
|
17
|
+
get(key)
|
18
|
+
Returns the value for the given `key`. Returns null for keys without values.
|
19
|
+
|
20
|
+
keys()
|
21
|
+
Returns an array with all keys present in the store
|
22
|
+
|
23
|
+
delete(key)
|
24
|
+
Removes `key` from the store
|
25
|
+
|
26
|
+
clear()
|
27
|
+
Removes all keys from the store
|
28
|
+
|
29
|
+
all()
|
30
|
+
Returns a JavaScript object with all keys and their values.
|
31
|
+
|
32
|
+
### Is JSON supported?
|
33
|
+
|
34
|
+
Yes. Under the hood memojs uses JSON.stringify/parse allowing you set objects and read objects.
|
35
|
+
|
36
|
+
memo.set("colors", ["red", "blue", "green"])
|
37
|
+
memo.get("colors")
|
38
|
+
=> ["red", "blue", "green"]
|
39
|
+
|
40
|
+
### Supported browsers
|
41
|
+
|
42
|
+
memojs has only been tested with Chrome 34 for Mac, but should work with IE9+ and all recent versions of other browsers.
|
@@ -0,0 +1,30 @@
|
|
1
|
+
window.memo =
|
2
|
+
set: (key, value)->
|
3
|
+
unless value is undefined
|
4
|
+
serializedValue = JSON.stringify(value)
|
5
|
+
window.localStorage[key] = serializedValue
|
6
|
+
value
|
7
|
+
|
8
|
+
get: (key) ->
|
9
|
+
if value = localStorage[key]
|
10
|
+
try
|
11
|
+
JSON.parse(value)
|
12
|
+
catch error # It's not valid JSON, so probably set by something using localStorage directly.
|
13
|
+
value
|
14
|
+
else
|
15
|
+
null
|
16
|
+
|
17
|
+
keys: ->
|
18
|
+
Object.keys(localStorage)
|
19
|
+
|
20
|
+
delete: (key) ->
|
21
|
+
localStorage.removeItem(key)
|
22
|
+
|
23
|
+
clear: ->
|
24
|
+
localStorage.clear()
|
25
|
+
|
26
|
+
all: ->
|
27
|
+
object = {}
|
28
|
+
@keys().map (key) =>
|
29
|
+
object[key] = @get(key)
|
30
|
+
object
|
data/lib/memojs.rb
ADDED
data/memojs.gemspec
ADDED
@@ -0,0 +1,31 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'memojs/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "memojs"
|
8
|
+
spec.version = Memojs::VERSION
|
9
|
+
spec.authors = ["Niels Buus"]
|
10
|
+
spec.email = ["nielsbuus@gmail.com"]
|
11
|
+
spec.summary = "A lightweight wrapper for the localStorage API packaged as a Rails asset"
|
12
|
+
spec.description = <<-DESC
|
13
|
+
To use it, you must require memojs in your JavaScript manifest. Add this line to your application.js file:
|
14
|
+
|
15
|
+
//= require memojs
|
16
|
+
|
17
|
+
DESC
|
18
|
+
spec.homepage = "http://github.com/lokalebasen/memojs"
|
19
|
+
spec.license = "MIT"
|
20
|
+
|
21
|
+
spec.files = `git ls-files`.split($/)
|
22
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
23
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
24
|
+
spec.require_paths = ["lib"]
|
25
|
+
|
26
|
+
spec.add_dependency 'railties', ">= 3.1", "< 5.0"
|
27
|
+
spec.add_dependency 'coffee-rails'
|
28
|
+
|
29
|
+
spec.add_development_dependency "bundler", "~> 1.5"
|
30
|
+
spec.add_development_dependency "rake"
|
31
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
# See https://help.github.com/articles/ignoring-files for more about ignoring files.
|
2
|
+
#
|
3
|
+
# If you find yourself ignoring temporary files generated by your text editor
|
4
|
+
# or operating system, you probably want to add a global ignore instead:
|
5
|
+
# git config --global core.excludesfile '~/.gitignore_global'
|
6
|
+
|
7
|
+
# Ignore bundler config.
|
8
|
+
/.bundle
|
9
|
+
|
10
|
+
# Ignore the default SQLite database.
|
11
|
+
/db/*.sqlite3
|
12
|
+
/db/*.sqlite3-journal
|
13
|
+
|
14
|
+
# Ignore all logfiles and tempfiles.
|
15
|
+
/log/*.log
|
16
|
+
/tmp
|
data/test/dummy/Gemfile
ADDED
@@ -0,0 +1,12 @@
|
|
1
|
+
source 'https://rubygems.org'
|
2
|
+
|
3
|
+
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
|
4
|
+
gem 'rails', '4.0.4'
|
5
|
+
|
6
|
+
# Use sqlite3 as the database for Active Record
|
7
|
+
gem 'sqlite3'
|
8
|
+
|
9
|
+
# Use CoffeeScript for .js.coffee assets and views
|
10
|
+
gem 'coffee-rails', '~> 4.0.0'
|
11
|
+
|
12
|
+
gem 'memojs', path: './../..'
|
@@ -0,0 +1,97 @@
|
|
1
|
+
PATH
|
2
|
+
remote: ./../..
|
3
|
+
specs:
|
4
|
+
memojs (1.0.0)
|
5
|
+
coffee-rails
|
6
|
+
railties (>= 3.1, < 5.0)
|
7
|
+
|
8
|
+
GEM
|
9
|
+
remote: https://rubygems.org/
|
10
|
+
specs:
|
11
|
+
actionmailer (4.0.4)
|
12
|
+
actionpack (= 4.0.4)
|
13
|
+
mail (~> 2.5.4)
|
14
|
+
actionpack (4.0.4)
|
15
|
+
activesupport (= 4.0.4)
|
16
|
+
builder (~> 3.1.0)
|
17
|
+
erubis (~> 2.7.0)
|
18
|
+
rack (~> 1.5.2)
|
19
|
+
rack-test (~> 0.6.2)
|
20
|
+
activemodel (4.0.4)
|
21
|
+
activesupport (= 4.0.4)
|
22
|
+
builder (~> 3.1.0)
|
23
|
+
activerecord (4.0.4)
|
24
|
+
activemodel (= 4.0.4)
|
25
|
+
activerecord-deprecated_finders (~> 1.0.2)
|
26
|
+
activesupport (= 4.0.4)
|
27
|
+
arel (~> 4.0.0)
|
28
|
+
activerecord-deprecated_finders (1.0.3)
|
29
|
+
activesupport (4.0.4)
|
30
|
+
i18n (~> 0.6, >= 0.6.9)
|
31
|
+
minitest (~> 4.2)
|
32
|
+
multi_json (~> 1.3)
|
33
|
+
thread_safe (~> 0.1)
|
34
|
+
tzinfo (~> 0.3.37)
|
35
|
+
arel (4.0.2)
|
36
|
+
builder (3.1.4)
|
37
|
+
coffee-rails (4.0.1)
|
38
|
+
coffee-script (>= 2.2.0)
|
39
|
+
railties (>= 4.0.0, < 5.0)
|
40
|
+
coffee-script (2.2.0)
|
41
|
+
coffee-script-source
|
42
|
+
execjs
|
43
|
+
coffee-script-source (1.7.0)
|
44
|
+
erubis (2.7.0)
|
45
|
+
execjs (2.0.2)
|
46
|
+
hike (1.2.3)
|
47
|
+
i18n (0.6.9)
|
48
|
+
mail (2.5.4)
|
49
|
+
mime-types (~> 1.16)
|
50
|
+
treetop (~> 1.4.8)
|
51
|
+
mime-types (1.25.1)
|
52
|
+
minitest (4.7.5)
|
53
|
+
multi_json (1.9.2)
|
54
|
+
polyglot (0.3.4)
|
55
|
+
rack (1.5.2)
|
56
|
+
rack-test (0.6.2)
|
57
|
+
rack (>= 1.0)
|
58
|
+
rails (4.0.4)
|
59
|
+
actionmailer (= 4.0.4)
|
60
|
+
actionpack (= 4.0.4)
|
61
|
+
activerecord (= 4.0.4)
|
62
|
+
activesupport (= 4.0.4)
|
63
|
+
bundler (>= 1.3.0, < 2.0)
|
64
|
+
railties (= 4.0.4)
|
65
|
+
sprockets-rails (~> 2.0.0)
|
66
|
+
railties (4.0.4)
|
67
|
+
actionpack (= 4.0.4)
|
68
|
+
activesupport (= 4.0.4)
|
69
|
+
rake (>= 0.8.7)
|
70
|
+
thor (>= 0.18.1, < 2.0)
|
71
|
+
rake (10.3.1)
|
72
|
+
sprockets (2.11.0)
|
73
|
+
hike (~> 1.2)
|
74
|
+
multi_json (~> 1.0)
|
75
|
+
rack (~> 1.0)
|
76
|
+
tilt (~> 1.1, != 1.3.0)
|
77
|
+
sprockets-rails (2.0.1)
|
78
|
+
actionpack (>= 3.0)
|
79
|
+
activesupport (>= 3.0)
|
80
|
+
sprockets (~> 2.8)
|
81
|
+
sqlite3 (1.3.9)
|
82
|
+
thor (0.19.1)
|
83
|
+
thread_safe (0.3.3)
|
84
|
+
tilt (1.4.1)
|
85
|
+
treetop (1.4.15)
|
86
|
+
polyglot
|
87
|
+
polyglot (>= 0.3.1)
|
88
|
+
tzinfo (0.3.39)
|
89
|
+
|
90
|
+
PLATFORMS
|
91
|
+
ruby
|
92
|
+
|
93
|
+
DEPENDENCIES
|
94
|
+
coffee-rails (~> 4.0.0)
|
95
|
+
memojs!
|
96
|
+
rails (= 4.0.4)
|
97
|
+
sqlite3
|
@@ -0,0 +1,28 @@
|
|
1
|
+
== README
|
2
|
+
|
3
|
+
This README would normally document whatever steps are necessary to get the
|
4
|
+
application up and running.
|
5
|
+
|
6
|
+
Things you may want to cover:
|
7
|
+
|
8
|
+
* Ruby version
|
9
|
+
|
10
|
+
* System dependencies
|
11
|
+
|
12
|
+
* Configuration
|
13
|
+
|
14
|
+
* Database creation
|
15
|
+
|
16
|
+
* Database initialization
|
17
|
+
|
18
|
+
* How to run the test suite
|
19
|
+
|
20
|
+
* Services (job queues, cache servers, search engines, etc.)
|
21
|
+
|
22
|
+
* Deployment instructions
|
23
|
+
|
24
|
+
* ...
|
25
|
+
|
26
|
+
|
27
|
+
Please feel free to use a different markup language if you do not plan to run
|
28
|
+
<tt>rake doc:app</tt>.
|
data/test/dummy/Rakefile
ADDED
File without changes
|
@@ -0,0 +1,14 @@
|
|
1
|
+
// This is a manifest file that'll be compiled into application.js, which will include all the files
|
2
|
+
// listed below.
|
3
|
+
//
|
4
|
+
// Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
|
5
|
+
// or vendor/assets/javascripts of plugins, if any, can be referenced here using a relative path.
|
6
|
+
//
|
7
|
+
// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
|
8
|
+
// compiled file.
|
9
|
+
//
|
10
|
+
// Read Sprockets README (https://github.com/sstephenson/sprockets#sprockets-directives) for details
|
11
|
+
// about supported directives.
|
12
|
+
//
|
13
|
+
//= require memojs
|
14
|
+
//= require_tree .
|
@@ -0,0 +1,13 @@
|
|
1
|
+
/*
|
2
|
+
* This is a manifest file that'll be compiled into application.css, which will include all the files
|
3
|
+
* listed below.
|
4
|
+
*
|
5
|
+
* Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
|
6
|
+
* or vendor/assets/stylesheets of plugins, if any, can be referenced here using a relative path.
|
7
|
+
*
|
8
|
+
* You're free to add application-wide styles to this file and they'll appear at the top of the
|
9
|
+
* compiled file, but it's generally better to create a new file per style scope.
|
10
|
+
*
|
11
|
+
*= require_self
|
12
|
+
*= require_tree .
|
13
|
+
*/
|
File without changes
|