core_ext 0.0.1 → 0.0.2

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 87d93ff39aee4506fbf6be9ce91a4c8e607e49aa
4
- data.tar.gz: f8be51872fac5c526fca972e2e022ee0c31a2cb6
3
+ metadata.gz: 9e6f668ca9887afe703850974b1180e6a41760af
4
+ data.tar.gz: 1ff512456eb749208c4ebaaa076f7c8f6e0ff215
5
5
  SHA512:
6
- metadata.gz: 5ec18c6158abd27e745625af270dadf2e0ba817255dab84ea2a799ddb6b52241061e43d89c083b4398e8c4dfe11a71152c1f3b32b8a78b4e3986769e270959a1
7
- data.tar.gz: 5091f649d5f221d95b2ce6256fe0e808fbda8c109d0eae0d8c6eab196904d146047683219796a8f795a08a3c29a5c8ccd465794ad4acd50bb464b384d85966ab
6
+ metadata.gz: 0c4cb22969e9cdaba9ef5c86ee31eb2dd45d38acb74d554c2c69ef3a9588d6fcd3be71f5021aabd998b574350e7a0a92f01de8b6997cf917a23ada51b06f4918
7
+ data.tar.gz: 7567e63821e86743b078be002d347b1d155b0e00e5cc49c5aa8208a6528038da548a043e0dbff0d2c4621731674d86c1c0e8c9ee31ab05e124517c37d5bc7fc4
data/README.md CHANGED
@@ -1,3 +1,61 @@
1
- ## core_ext
1
+ [![wercker status](https://app.wercker.com/status/5c761ef70d67c7b752d00b05972d3859/s "wercker status")](https://app.wercker.com/project/bykey/5c761ef70d67c7b752d00b05972d3859)
2
+ [![Code Climate](https://codeclimate.com/github/rpanachi/core_ext/badges/gpa.svg)](https://codeclimate.com/github/rpanachi/core_ext)
2
3
 
3
- ActiveSupport's core_ext without ActiveSupport dependency
4
+ # CoreExt
5
+
6
+ Utility classes and Ruby extensions for non Rails projects.
7
+
8
+ ## Philosophy
9
+
10
+ CoreExt is a reduced fork of ActiveSupport, shipping only the *core_ext* part and its minimal dependencies. Some stufft like *Autoload*, *Caching*, *Logging*, *Notifications* and other Rails related classes are left behind. It was built with a few goals in mind:
11
+
12
+ * Pick only what you need - use (or require) only the modules or classes that you need on your project, without load (and override) the entire stack.
13
+ * Embrace the magic - Patching Ruby core classes - excuse me the purists - is more productive that using tons of utils classes spread throughtout your project. And this, ActiveSupport does well.
14
+ * Don't Repeat Yourself - Rather than always implement the same core functionality on different projects, centralize and reuse it.
15
+
16
+ ## Installation
17
+
18
+ If using bundler, first add 'core_ext' to your Gemfile:
19
+
20
+ ```ruby
21
+ gem "core_ext"
22
+ ```
23
+
24
+ And run
25
+
26
+ ```ruby
27
+ bundle install
28
+ ```
29
+
30
+ Otherwise simply
31
+
32
+ ```ruby
33
+ gem install core_ext
34
+ ```
35
+
36
+ ## Usage
37
+
38
+ Loading all core extensions:
39
+
40
+ ```
41
+ require "core_ext/all"
42
+ ```
43
+
44
+ Cherry-picking only what you want:
45
+
46
+ ```
47
+ require "core_ext/object"
48
+ require "core_ext/time"
49
+ ```
50
+
51
+ ## Documentation
52
+
53
+ [Active Support Core Extensions](http://guides.rubyonrails.org/active_support_core_extensions.html)
54
+
55
+ ## Contributing
56
+
57
+ 1. Fork it
58
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
59
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
60
+ 4. Push to the branch (`git push origin my-new-feature`)
61
+ 5. Create new Pull Request
@@ -1,4 +1,5 @@
1
1
  require 'core_ext/array/prepend_and_append'
2
+ require 'concurrent/map'
2
3
  require 'i18n'
3
4
 
4
5
  module CoreExt
@@ -24,10 +25,7 @@ module CoreExt
24
25
  # singularization rules that is runs. This guarantees that your rules run
25
26
  # before any of the rules that may already have been loaded.
26
27
  class Inflections
27
-
28
- # TODO Add concurrent-ruby to support thread safe
29
- # @__instance__ = Concurrent::Map.new
30
- @__instance__ = {}
28
+ @__instance__ = Concurrent::Map.new
31
29
 
32
30
  class Uncountables < Array
33
31
  def initialize
@@ -1,12 +1,12 @@
1
- require 'active_support/core_ext/module/delegation'
2
- require 'active_support/core_ext/object/blank'
1
+ require 'core_ext/module/delegation'
2
+ require 'core_ext/object/blank'
3
3
  require 'logger'
4
- require 'active_support/logger'
4
+ require 'core_ext/logger'
5
5
 
6
- module ActiveSupport
6
+ module CoreExt
7
7
  # Wraps any standard Logger object to provide tagging capabilities.
8
8
  #
9
- # logger = ActiveSupport::TaggedLogging.new(Logger.new(STDOUT))
9
+ # logger = CoreExt::TaggedLogging.new(Logger.new(STDOUT))
10
10
  # logger.tagged('BCX') { logger.info 'Stuff' } # Logs "[BCX] Stuff"
11
11
  # logger.tagged('BCX', "Jason") { logger.info 'Stuff' } # Logs "[BCX] [Jason] Stuff"
12
12
  # logger.tagged('BCX') { logger.tagged('Jason') { logger.info 'Stuff' } } # Logs "[BCX] [Jason] Stuff"
@@ -44,7 +44,7 @@ module ActiveSupport
44
44
 
45
45
  def current_tags
46
46
  # We use our object ID here to avoid conflicting with other instances
47
- thread_key = @thread_key ||= "activesupport_tagged_logging_tags:#{object_id}".freeze
47
+ thread_key = @thread_key ||= "core_ext_tagged_logging_tags:#{object_id}".freeze
48
48
  Thread.current[thread_key] ||= []
49
49
  end
50
50
 
@@ -59,7 +59,7 @@ module ActiveSupport
59
59
 
60
60
  def self.new(logger)
61
61
  # Ensure we set a default formatter so we aren't extending nil!
62
- logger.formatter ||= ActiveSupport::Logger::SimpleFormatter.new
62
+ logger.formatter ||= CoreExt::Logger::SimpleFormatter.new
63
63
  logger.formatter.extend Formatter
64
64
  logger.extend(self)
65
65
  end
@@ -1,6 +1,7 @@
1
1
  require 'tzinfo'
2
2
  require 'core_ext/object/blank'
3
3
  require 'core_ext/object/try'
4
+ require 'concurrent/map'
4
5
 
5
6
  module CoreExt
6
7
  # The TimeZone class serves as a wrapper around TZInfo::Timezone instances.
@@ -182,9 +183,7 @@ module CoreExt
182
183
  UTC_OFFSET_WITH_COLON = '%s%02d:%02d'
183
184
  UTC_OFFSET_WITHOUT_COLON = UTC_OFFSET_WITH_COLON.tr(':', '')
184
185
 
185
- # TODO Add concurrent-ruby to support thread safe
186
- # @lazy_zones_map = Concurrent::Map.new
187
- @lazy_zones_map = {}
186
+ @lazy_zones_map = Concurrent::Map.new
188
187
 
189
188
  class << self
190
189
  # Assumes self represents an offset from UTC in seconds (as returned from
@@ -1,3 +1,3 @@
1
1
  module CoreExt
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: core_ext
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Rodrigo Panachi
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-11-15 00:00:00.000000000 Z
11
+ date: 2015-11-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: builder
@@ -86,6 +86,20 @@ dependencies:
86
86
  - - "~>"
87
87
  - !ruby/object:Gem::Version
88
88
  version: '5.1'
89
+ - !ruby/object:Gem::Dependency
90
+ name: concurrent-ruby
91
+ requirement: !ruby/object:Gem::Requirement
92
+ requirements:
93
+ - - "~>"
94
+ - !ruby/object:Gem::Version
95
+ version: '1.0'
96
+ type: :runtime
97
+ prerelease: false
98
+ version_requirements: !ruby/object:Gem::Requirement
99
+ requirements:
100
+ - - "~>"
101
+ - !ruby/object:Gem::Version
102
+ version: '1.0'
89
103
  - !ruby/object:Gem::Dependency
90
104
  name: method_source
91
105
  requirement: !ruby/object:Gem::Requirement
@@ -100,7 +114,7 @@ dependencies:
100
114
  - - "~>"
101
115
  - !ruby/object:Gem::Version
102
116
  version: '0.8'
103
- description: ActiveSupport's core_ext without ActiveSupport dependency
117
+ description: Utility classes and Ruby extensions for non Rails projects
104
118
  email:
105
119
  - rpanachi@gmail.com
106
120
  executables: []
@@ -305,6 +319,6 @@ rubyforge_project:
305
319
  rubygems_version: 2.2.2
306
320
  signing_key:
307
321
  specification_version: 4
308
- summary: ActiveSupport's core_ext without ActiveSupport
322
+ summary: ActiveSupport's core_ext for non Rails projects
309
323
  test_files: []
310
324
  has_rdoc: