workbox 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: f52785f3b11c3709527d9232ebe880fbf87a8d67
4
+ data.tar.gz: c29901fb16ae2951308b49cfa6a77f2282eabfcb
5
+ SHA512:
6
+ metadata.gz: 30ebb734d97700e0c906d7eb656993f102d7f81c7aa493e0f6e8e05f45e5d78479b2573b17780cca2baf3d2923157bb71342d027494cd8502c6b0790098e5fd7
7
+ data.tar.gz: 2f9f3d3f9558e1b48a2c8d2cf089b555429a7767173c22d71114512a0beab0c8713d16be77c883747005c9ee5c46773ba162c25a05d1da702d0a1c180b75400c
@@ -0,0 +1,22 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
18
+ *.bundle
19
+ *.so
20
+ *.o
21
+ *.a
22
+ mkmf.log
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --color
2
+ --format documentation
3
+ --require spec_helper
data/Gemfile ADDED
@@ -0,0 +1,8 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gemspec
4
+
5
+ gem 'rspec', '~> 3.1.0'
6
+
7
+ gem 'guard-rspec'
8
+ gem 'ruby_gntp'
@@ -0,0 +1,32 @@
1
+ notification :gntp
2
+
3
+ # Note: The cmd option is now required due to the increasing number of ways
4
+ # rspec may be run, below are examples of the most common uses.
5
+ # * bundler: 'bundle exec rspec'
6
+ # * bundler binstubs: 'bin/rspec'
7
+ # * spring: 'bin/rsspec' (This will use spring if running and you have
8
+ # installed the spring binstubs per the docs)
9
+ # * zeus: 'zeus rspec' (requires the server to be started separetly)
10
+ # * 'just' rspec: 'rspec'
11
+ guard :rspec, cmd: 'bundle exec rspec' do
12
+ watch(%r{^spec/.+_spec\.rb$})
13
+ watch(%r{^lib/(.+)\.rb$}) { |m| "spec/lib/#{m[1]}_spec.rb" }
14
+ watch('spec/spec_helper.rb') { "spec" }
15
+
16
+ # Rails example
17
+ watch(%r{^app/(.+)\.rb$}) { |m| "spec/#{m[1]}_spec.rb" }
18
+ watch(%r{^app/(.*)(\.erb|\.haml|\.slim)$}) { |m| "spec/#{m[1]}#{m[2]}_spec.rb" }
19
+ watch(%r{^app/controllers/(.+)_(controller)\.rb$}) { |m| ["spec/routing/#{m[1]}_routing_spec.rb", "spec/#{m[2]}s/#{m[1]}_#{m[2]}_spec.rb", "spec/acceptance/#{m[1]}_spec.rb"] }
20
+ watch(%r{^spec/support/(.+)\.rb$}) { "spec" }
21
+ watch('config/routes.rb') { "spec/routing" }
22
+ watch('app/controllers/application_controller.rb') { "spec/controllers" }
23
+ watch('spec/rails_helper.rb') { "spec" }
24
+
25
+ # Capybara features specs
26
+ watch(%r{^app/views/(.+)/.*\.(erb|haml|slim)$}) { |m| "spec/features/#{m[1]}_spec.rb" }
27
+
28
+ # Turnip features and steps
29
+ watch(%r{^spec/acceptance/(.+)\.feature$})
30
+ watch(%r{^spec/acceptance/steps/(.+)_steps\.rb$}) { |m| Dir[File.join("**/#{m[1]}.feature")][0] || 'spec/acceptance' }
31
+ end
32
+
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2014 Slava Pavlutin
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,3 @@
1
+ # Workbox
2
+
3
+ Useful extensions for everyday coding with Ruby.
@@ -0,0 +1,2 @@
1
+ require "bundler/gem_tasks"
2
+
@@ -0,0 +1,7 @@
1
+ require "workbox/version"
2
+
3
+ module Workbox
4
+ autoload 'Time', 'workbox/time'
5
+ autoload 'Text', 'workbox/text'
6
+ autoload 'JSON', 'workbox/json'
7
+ end
@@ -0,0 +1,29 @@
1
+ module Workbox
2
+ module Text
3
+ PAIR_MAP = {
4
+ '{' => '}',
5
+ '[' => ']',
6
+ '(' => ')',
7
+ ')' => '(',
8
+ ']' => '[',
9
+ '}' => '{',
10
+ '>' => '<',
11
+ '<' => '>',
12
+ }
13
+
14
+ def wrap(opening, closing=nil)
15
+ closing = opening.reflect unless closing
16
+ to_s.clone.insert(0, opening) << closing
17
+ end
18
+
19
+ def reflect
20
+ to_s.each_char.map do |char|
21
+ PAIR_MAP.fetch(char) { char }
22
+ end.reverse.join
23
+ end
24
+
25
+ def slug
26
+ to_s.gsub(/[\s-]/, '_').gsub(/[,.?!+-=]/, '')
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,21 @@
1
+ module Workbox
2
+ # Time provides basic time functionality.
3
+ # It requires the including class or module to implement
4
+ # 'to_i' and return a number.
5
+ module Time
6
+ def minutes
7
+ to_i * 60
8
+ end
9
+ alias minute minutes
10
+
11
+ def hours
12
+ minutes*60
13
+ end
14
+ alias hour hours
15
+
16
+ def days
17
+ hours*24
18
+ end
19
+ alias day days
20
+ end
21
+ end
@@ -0,0 +1,3 @@
1
+ module Workbox
2
+ VERSION = "0.0.1"
3
+ end
@@ -0,0 +1,90 @@
1
+ require 'workbox'
2
+ # This file was generated by the `rspec --init` command. Conventionally, all
3
+ # specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
4
+ # The generated `.rspec` file contains `--require spec_helper` which will cause this
5
+ # file to always be loaded, without a need to explicitly require it in any files.
6
+ #
7
+ # Given that it is always loaded, you are encouraged to keep this file as
8
+ # light-weight as possible. Requiring heavyweight dependencies from this file
9
+ # will add to the boot time of your test suite on EVERY test run, even for an
10
+ # individual file that may not need all of that loaded. Instead, consider making
11
+ # a separate helper file that requires the additional dependencies and performs
12
+ # the additional setup, and require it from the spec files that actually need it.
13
+ #
14
+ # The `.rspec` file also contains a few flags that are not defaults but that
15
+ # users commonly want.
16
+ #
17
+ # See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
18
+ RSpec.configure do |config|
19
+ # rspec-expectations config goes here. You can use an alternate
20
+ # assertion/expectation library such as wrong or the stdlib/minitest
21
+ # assertions if you prefer.
22
+ config.expect_with :rspec do |expectations|
23
+ # This option will default to `true` in RSpec 4. It makes the `description`
24
+ # and `failure_message` of custom matchers include text for helper methods
25
+ # defined using `chain`, e.g.:
26
+ # be_bigger_than(2).and_smaller_than(4).description
27
+ # # => "be bigger than 2 and smaller than 4"
28
+ # ...rather than:
29
+ # # => "be bigger than 2"
30
+ expectations.include_chain_clauses_in_custom_matcher_descriptions = true
31
+ end
32
+
33
+ # rspec-mocks config goes here. You can use an alternate test double
34
+ # library (such as bogus or mocha) by changing the `mock_with` option here.
35
+ config.mock_with :rspec do |mocks|
36
+ # Prevents you from mocking or stubbing a method that does not exist on
37
+ # a real object. This is generally recommended, and will default to
38
+ # `true` in RSpec 4.
39
+ mocks.verify_partial_doubles = true
40
+ end
41
+
42
+ # The settings below are suggested to provide a good initial experience
43
+ # with RSpec, but feel free to customize to your heart's content.
44
+ =begin
45
+ # These two settings work together to allow you to limit a spec run
46
+ # to individual examples or groups you care about by tagging them with
47
+ # `:focus` metadata. When nothing is tagged with `:focus`, all examples
48
+ # get run.
49
+ config.filter_run :focus
50
+ config.run_all_when_everything_filtered = true
51
+
52
+ # Limits the available syntax to the non-monkey patched syntax that is recommended.
53
+ # For more details, see:
54
+ # - http://myronmars.to/n/dev-blog/2012/06/rspecs-new-expectation-syntax
55
+ # - http://teaisaweso.me/blog/2013/05/27/rspecs-new-message-expectation-syntax/
56
+ # - http://myronmars.to/n/dev-blog/2014/05/notable-changes-in-rspec-3#new__config_option_to_disable_rspeccore_monkey_patching
57
+ config.disable_monkey_patching!
58
+
59
+ # This setting enables warnings. It's recommended, but in some cases may
60
+ # be too noisy due to issues in dependencies.
61
+ config.warnings = true
62
+
63
+ # Many RSpec users commonly either run the entire suite or an individual
64
+ # file, and it's useful to allow more verbose output when running an
65
+ # individual spec file.
66
+ if config.files_to_run.one?
67
+ # Use the documentation formatter for detailed output,
68
+ # unless a formatter has already been configured
69
+ # (e.g. via a command-line flag).
70
+ config.default_formatter = 'doc'
71
+ end
72
+
73
+ # Print the 10 slowest examples and example groups at the
74
+ # end of the spec run, to help surface which specs are running
75
+ # particularly slow.
76
+ config.profile_examples = 10
77
+
78
+ # Run specs in random order to surface order dependencies. If you find an
79
+ # order dependency and want to debug it, you can fix the order by providing
80
+ # the seed, which is printed after each run.
81
+ # --seed 1234
82
+ config.order = :random
83
+
84
+ # Seed global randomization in this process using the `--seed` CLI option.
85
+ # Setting this allows you to use `--seed` to deterministically reproduce
86
+ # test failures related to randomization by passing the same `--seed` value
87
+ # as the one that triggered the failure.
88
+ Kernel.srand config.seed
89
+ =end
90
+ end
@@ -0,0 +1,52 @@
1
+ require 'spec_helper'
2
+
3
+ class String
4
+ include Workbox::Text
5
+ end
6
+
7
+ class Testie
8
+ include Workbox::Text
9
+
10
+ def to_s
11
+ 'testie'
12
+ end
13
+ end
14
+
15
+ RSpec.describe Workbox::Text do
16
+ specify "slugging a string" do
17
+ expect('some string'.slug).to eq 'some_string'
18
+ expect('some-string, with marks...'.slug).to eq 'some_string_with_marks'
19
+ end
20
+
21
+ specify "reflecting a string" do
22
+ expect('<>'.reflect).to eq('<>')
23
+ expect('<h1>'.reflect).to eq('<1h>')
24
+ expect('{%'.reflect).to eq('%}')
25
+ expect('(ss'.reflect).to eq('ss)')
26
+ expect(']_'.reflect).to eq('_[')
27
+ end
28
+
29
+ specify "wrapping with characters" do
30
+ string = 'string'
31
+ # one matching parameter
32
+ expect(string.wrap('{')).to eq '{string}'
33
+ expect(string.wrap('[')).to eq '[string]'
34
+ expect(string.wrap('(')).to eq '(string)'
35
+ expect(string.wrap('<')).to eq '<string>'
36
+
37
+ # one not matching parameter
38
+ expect(string.wrap('-')).to eq '-string-'
39
+ expect(string.wrap('**')).to eq '**string**'
40
+ expect(string.wrap('"')).to eq %{"string"}
41
+ expect(string.wrap("'")).to eq %{'string'}
42
+
43
+ # two parameters
44
+ expect(string.wrap('<h1>', '</h1>')).to eq '<h1>string</h1>'
45
+ expect(string.wrap('{% ', ' %}')).to eq '{% string %}'
46
+ end
47
+
48
+ specify "wrapping custom objects with some characters" do
49
+ testie = Testie.new
50
+ expect(testie.wrap('{%')).to eq('{%testie%}')
51
+ end
52
+ end
@@ -0,0 +1,28 @@
1
+ require 'spec_helper'
2
+
3
+ class Fixnum
4
+ include Workbox::Time
5
+ end
6
+
7
+ class String
8
+ include Workbox::Time
9
+ end
10
+
11
+ RSpec.describe Workbox::Time do
12
+ it "converts a number into minutes" do
13
+ expect(10.minutes).to eq(600)
14
+ end
15
+
16
+ it "converts a string into minutes" do
17
+ expect('10'.hours).to eq(600.minutes)
18
+ end
19
+
20
+ it "converts a number into hours" do
21
+ expect(1.hour).to eq(60.minutes)
22
+ expect(1.hour).to eq(1.minute*60)
23
+ end
24
+
25
+ it "converts a number into days" do
26
+ expect(1.day).to eq(24.hours)
27
+ end
28
+ end
@@ -0,0 +1,23 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'workbox/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "workbox"
8
+ spec.version = Workbox::VERSION
9
+ spec.authors = ["Slava Pavlutin"]
10
+ spec.email = ["sl.pavlutin@gmail.com"]
11
+ spec.summary = %q{Your Ruby workbox}
12
+ spec.description = %q{Useful mixins for everyday coding.}
13
+ spec.homepage = ""
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files -z`.split("\x0")
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.add_development_dependency "bundler", "~> 1.6"
22
+ spec.add_development_dependency "rake"
23
+ end
metadata ADDED
@@ -0,0 +1,90 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: workbox
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Slava Pavlutin
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-09-29 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.6'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.6'
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: Useful mixins for everyday coding.
42
+ email:
43
+ - sl.pavlutin@gmail.com
44
+ executables: []
45
+ extensions: []
46
+ extra_rdoc_files: []
47
+ files:
48
+ - ".gitignore"
49
+ - ".rspec"
50
+ - Gemfile
51
+ - Guardfile
52
+ - LICENSE.txt
53
+ - README.md
54
+ - Rakefile
55
+ - lib/workbox.rb
56
+ - lib/workbox/text.rb
57
+ - lib/workbox/time.rb
58
+ - lib/workbox/version.rb
59
+ - spec/spec_helper.rb
60
+ - spec/text_spec.rb
61
+ - spec/time_spec.rb
62
+ - workbox.gemspec
63
+ homepage: ''
64
+ licenses:
65
+ - MIT
66
+ metadata: {}
67
+ post_install_message:
68
+ rdoc_options: []
69
+ require_paths:
70
+ - lib
71
+ required_ruby_version: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ required_rubygems_version: !ruby/object:Gem::Requirement
77
+ requirements:
78
+ - - ">="
79
+ - !ruby/object:Gem::Version
80
+ version: '0'
81
+ requirements: []
82
+ rubyforge_project:
83
+ rubygems_version: 2.2.2
84
+ signing_key:
85
+ specification_version: 4
86
+ summary: Your Ruby workbox
87
+ test_files:
88
+ - spec/spec_helper.rb
89
+ - spec/text_spec.rb
90
+ - spec/time_spec.rb