chronicles 0.0.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.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 2a571a9a10b54a6522d54e6071ef291e81342ea1
4
+ data.tar.gz: 3d7d0f17215e36e753895dfb14f5e2782d535e80
5
+ SHA512:
6
+ metadata.gz: 166c6717d5c09e1b90340f6100c20a5095b61a455ac770958f4a80f246dcb35cab422a547601e1fe14caefac903d73913416fc0ee116170e0b5a867f861aed5a
7
+ data.tar.gz: 4557942227d44e9b9374346d06fc578b3aedd508996fecd098a5510287d16462488de92d8fa9d9e9934b0c84b328a4ed60b6a9351a19342d73f5bcebfc435154
@@ -0,0 +1,2 @@
1
+ ---
2
+ service_name: travis-ci
@@ -0,0 +1,9 @@
1
+ *.gem
2
+ *.lock
3
+ .bundle/
4
+ .yardoc/
5
+ coverage/
6
+ doc/
7
+ log/
8
+ pkg/
9
+ tmp/
@@ -0,0 +1,9 @@
1
+ # Settings for metric_fu and its packages are collected in the `config/metrics`
2
+ # and loaded by the Hexx::Suit::Metrics::MetricFu.
3
+
4
+ begin
5
+ require "hexx-suit"
6
+ Hexx::Suit::Metrics::MetricFu.load
7
+ rescue LoadError
8
+ puts "The 'hexx-suit' gem is not installed"
9
+ end
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --require spec_helper
2
+ --color
@@ -0,0 +1,2 @@
1
+ ---
2
+ inherit_from: "./config/metrics/rubocop.yml"
@@ -0,0 +1,9 @@
1
+ ---
2
+ language: ruby
3
+ bundler_args: --without metrics
4
+ script: rake test:coverage:run
5
+ rvm:
6
+ - 2.0
7
+ - ruby-head
8
+ - rbx-2 --2.0
9
+ - jruby-head-20mode
@@ -0,0 +1,3 @@
1
+ --asset LICENSE
2
+ --exclude lib/chronicles/version.rb
3
+ --output doc/api
data/Gemfile ADDED
@@ -0,0 +1,5 @@
1
+ source "https://rubygems.org"
2
+
3
+ gemspec
4
+
5
+ gem "hexx-suit", "~> 2.2", group: :metrics if RUBY_ENGINE == "ruby"
@@ -0,0 +1,15 @@
1
+ # encoding: utf-8
2
+
3
+ guard :rspec, cmd: "bundle exec rspec" do
4
+
5
+ watch(%r{^lib/(.+)\.rb$}) do |m|
6
+ "spec/tests/#{ m[1] }_spec.rb"
7
+ end
8
+
9
+ watch(%r{spec/tests/.+_spec\.rb})
10
+
11
+ watch("lib/chronicles.rb") { "spec" }
12
+ watch("spec/spec_helper.rb") { "spec" }
13
+ watch(%r{spec/support/}) { "spec" }
14
+
15
+ end # guard :rspec
data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License
2
+
3
+ Copyright (c) 2015 Andrew Kozin (nepalez), andrew.kozin@gmail.com
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
13
+ all 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
21
+ THE SOFTWARE.
@@ -0,0 +1,198 @@
1
+ Chronicles
2
+ ===================
3
+
4
+ [![Gem Version](https://img.shields.io/gem/v/chronicles.svg?style=flat)][gem]
5
+ [![Build Status](https://img.shields.io/travis/nepalez/chronicles/master.svg?style=flat)][travis]
6
+ [![Dependency Status](https://img.shields.io/gemnasium/nepalez/chronicles.svg?style=flat)][gemnasium]
7
+ [![Code Climate](https://img.shields.io/codeclimate/github/nepalez/chronicles.svg?style=flat)][codeclimate]
8
+ [![Coverage](https://img.shields.io/coveralls/nepalez/chronicles.svg?style=flat)][coveralls]
9
+ [![Inline docs](http://inch-ci.org/github/nepalez/chronicles.svg)][inch]
10
+
11
+ [codeclimate]: https://codeclimate.com/github/nepalez/chronicles
12
+ [coveralls]: https://coveralls.io/r/nepalez/chronicles
13
+ [gem]: https://rubygems.org/gems/chronicles
14
+ [gemnasium]: https://gemnasium.com/nepalez/chronicles
15
+ [travis]: https://travis-ci.org/nepalez/chronicles
16
+ [inch]: https://inch-ci.org/github/nepalez/chronicles
17
+
18
+ Allow remembering object methods' calls.
19
+
20
+ Installation
21
+ ------------
22
+
23
+ Add this line to your application's Gemfile:
24
+
25
+ ```ruby
26
+ # Gemfile
27
+ gem "chronicles"
28
+ ```
29
+
30
+ Then execute:
31
+
32
+ ```
33
+ bundle
34
+ ```
35
+
36
+ Or add it manually:
37
+
38
+ ```
39
+ gem install chronicles
40
+ ```
41
+
42
+ Usage
43
+ -----
44
+
45
+ ```ruby
46
+ class Test
47
+ include Chronicles
48
+
49
+ def initialize
50
+ start_chronicles
51
+ # ...
52
+ end
53
+
54
+ public attr_reader :foo
55
+ protected attr_reader :bar
56
+ private attr_reader :baz
57
+ end
58
+
59
+ test = Test.new
60
+ test.chronicles # => []
61
+
62
+ test.foo
63
+ test.chronicles # => [:foo]
64
+
65
+ test.send :bar
66
+ test.chronicles # => [:foo, :bar]
67
+
68
+ test.send :baz
69
+ test.chronicles # => [:foo, :bar, :baz]
70
+
71
+ test.foo
72
+ test.chronicles # => [:foo, :bar, :baz, :foo]
73
+
74
+ test.chronicles.clear
75
+ test.chronicles # => []
76
+ ```
77
+
78
+ You can restrict chronicles by public, private or protected methods only:
79
+
80
+ ```ruby
81
+ class Test
82
+ # ...
83
+ def initialize
84
+ start_chronicles private: false
85
+ end
86
+ end
87
+
88
+ test.foo # public
89
+ test.send :bar # protected
90
+ test.send :baz # private
91
+ test.chronicles # => [:foo, :bar]
92
+ ```
93
+
94
+ You can explicitly set methods to look for:
95
+
96
+ ```ruby
97
+ class Test
98
+ # ...
99
+ def initialize
100
+ start_chronicles only: [:bar]
101
+ end
102
+ end
103
+
104
+ test.foo # public
105
+ test.send :bar # protected
106
+ test.send :baz # private
107
+ test.chronicles # => [:bar]
108
+ ```
109
+
110
+ Or exclude them from being registered:
111
+
112
+ ```ruby
113
+ class Test
114
+ # ...
115
+ def initialize
116
+ start_chronicles except: [:bar]
117
+ end
118
+ end
119
+
120
+ test.foo # public
121
+ test.send :bar # protected
122
+ test.send :baz # private
123
+ test.chronicles # => [:foo, :baz]
124
+ ```
125
+
126
+ Or combine those conditions:
127
+
128
+ ```ruby
129
+ class Test
130
+ # ...
131
+ def initialize
132
+ start_chronicles protected: false, except: [:foo]
133
+ end
134
+ end
135
+
136
+ test.foo # public
137
+ test.send :bar # protected
138
+ test.send :baz # private
139
+ test.chronicles # => [:baz]
140
+ ```
141
+
142
+ Actually, you can start chronicles after initialization and do it several times to add new methods to be looked for.
143
+
144
+ The problem is all methods included to the chronicle will be kept registered. To stop registering selected methods use the `stop_chronicles`:
145
+
146
+ ```ruby
147
+ test.chronicles # => []
148
+
149
+ test.start_chronicles only: [:foo, :bar]
150
+ test.foo
151
+ test.bar
152
+ test.baz
153
+ test.chronicles # => [:foo, :bar]
154
+
155
+ test.start_chronicles only: :baz
156
+ test.foo
157
+ test.bar
158
+ test.baz
159
+ test.chronicles # => [:foo, :bar, :foo, :bar, :baz]
160
+
161
+ test.stop_chronicles except: :baz
162
+ test.foo
163
+ test.bar
164
+ test.baz
165
+ test.chronicles # => [:foo, :bar, :foo, :bar, :baz, :baz]
166
+ ```
167
+
168
+ Compatibility
169
+ -------------
170
+
171
+ Tested under rubies compatible to API 2.0+:
172
+
173
+ * MRI 2.0+
174
+ * Rubinius (mode 2.0+)
175
+ * JRuby 9.0.0.0 (mode 2.0+)
176
+
177
+ Uses [RSpec] 3.0+ for testing and [hexx-suit] for dev/test tools collection.
178
+
179
+ [RSpec]: http://rspec.info/
180
+ [hexx-suit]: http://github.com/nepalez/hexx-suit
181
+
182
+ Contributing
183
+ ------------
184
+
185
+ * Fork the project.
186
+ * Read the [STYLEGUIDE](config/metrics/STYLEGUIDE).
187
+ * Make your feature addition or bug fix.
188
+ * Add tests for it. This is important so I don't break it in a
189
+ future version unintentionally.
190
+ * Commit, do not mess with Rakefile or version
191
+ (if you want to have your own version, that is fine but bump version
192
+ in a commit by itself I can ignore when I pull)
193
+ * Send me a pull request. Bonus points for topic branches.
194
+
195
+ License
196
+ -------
197
+
198
+ See the [MIT LICENSE](LICENSE).
@@ -0,0 +1,22 @@
1
+ # encoding: utf-8
2
+ begin
3
+ require "bundler/setup"
4
+ rescue LoadError
5
+ puts "You must `gem install bundler` and `bundle install` to run rake tasks"
6
+ exit
7
+ end
8
+
9
+ # Loads bundler tasks
10
+ Bundler::GemHelper.install_tasks
11
+
12
+ # Loads the Hexx::RSpec and its tasks
13
+ begin
14
+ require "hexx-suit"
15
+ Hexx::Suit.install_tasks
16
+ rescue LoadError
17
+ require "hexx-rspec"
18
+ Hexx::RSpec.install_tasks
19
+ end
20
+
21
+ # Sets the Hexx::RSpec :test task to default
22
+ task default: "test:coverage:run"
@@ -0,0 +1,22 @@
1
+ $:.push File.expand_path("../lib", __FILE__)
2
+ require "chronicles/version"
3
+
4
+ Gem::Specification.new do |gem|
5
+
6
+ gem.name = "chronicles"
7
+ gem.version = Chronicles::VERSION.dup
8
+ gem.author = "Andrew Kozin"
9
+ gem.email = "andrew.kozin@gmail.com"
10
+ gem.homepage = "https://github.com/nepalez/chronicles"
11
+ gem.summary = "Remembering object methods' call"
12
+ gem.license = "MIT"
13
+
14
+ gem.files = `git ls-files`.split($INPUT_RECORD_SEPARATOR)
15
+ gem.test_files = Dir["spec/**/*.rb"]
16
+ gem.extra_rdoc_files = Dir["README.md", "LICENSE"]
17
+ gem.require_paths = ["lib"]
18
+
19
+ gem.required_ruby_version = "~> 2.0"
20
+ gem.add_development_dependency "hexx-rspec", "~> 0.4"
21
+
22
+ end # Gem::Specification
@@ -0,0 +1,230 @@
1
+ = Ruby Style Guide
2
+
3
+ Adapted from Dan Kubb's Ruby Style Guide
4
+ https://github.com/dkubb/styleguide/blob/master/RUBY-STYLE
5
+
6
+ == Commiting:
7
+
8
+ * Write descriptive commit messages, following the pattern:
9
+
10
+ [TYPE] name
11
+
12
+ The message, describing the changes being made
13
+
14
+ * Use the types below to mark commits:
15
+
16
+ - FEATURE - for adding new features, or backward-compatible changes;
17
+ - CHANGE - for backward-incompatible changes;
18
+ - BUG FIX - for fixing bugs;
19
+ - REFACTORING - for other changes of the code not affecting the API;
20
+ - OTHER - for changes in documentaton, metrics etc, not touching the code;
21
+ - VERSION - for version changes.
22
+
23
+ * Always separate commits of different types (such as FEATURE and CHANGE).
24
+
25
+ * Try to separate various features from each other.
26
+
27
+ * Include specification to the same commit as the code.
28
+
29
+ * Run all tests before making a commit.
30
+ Never commit the code that break unit tests.
31
+
32
+ * Use metric (run `rake check`) before making a commit.
33
+
34
+ * Do refactoring before making a commit. Best writing is rewriting.
35
+
36
+ * Follow semantic versioning.
37
+
38
+ http://semver.org/
39
+
40
+ * For versions name the commit after a version number, following the pattern:
41
+
42
+ VERSION 1.0.0-rc2
43
+
44
+
45
+ == Formatting:
46
+
47
+ * Use UTF-8. Declare encoding in the first line of every file.
48
+
49
+ # encoding: utf-8
50
+
51
+ * Use 2 space indent, no tabs.
52
+
53
+ * Use Unix-style line endings.
54
+
55
+ * Use spaces around operators, after commas, colons and semicolons,
56
+ around { and before }.
57
+
58
+ * No spaces after (, [ and before ], ).
59
+
60
+ * Align `when` and `else` with `case`.
61
+
62
+ * Use an empty line before the return value of a method (unless it
63
+ only has one line), and an empty line between defs.
64
+
65
+ * Use empty lines to break up a long method into logical paragraphs.
66
+
67
+ * Keep lines fewer than 80 characters.
68
+
69
+ * Strip trailing whitespace.
70
+
71
+
72
+ == Syntax:
73
+
74
+ * Write for 2.0.
75
+
76
+ * Use double quotes
77
+
78
+ http://viget.com/extend/just-use-double-quoted-ruby-strings
79
+
80
+ * Use def with parentheses when there are arguments.
81
+
82
+ * Never use for, unless you exactly know why.
83
+
84
+ * Never use then, except in case statements.
85
+
86
+ * Use when x then ... for one-line cases.
87
+
88
+ * Use &&/|| for boolean expressions, and/or for control flow. (Rule
89
+ of thumb: If you have to use outer parentheses, you are using the
90
+ wrong operators.)
91
+
92
+ * Avoid double negation (!!), unless Null Objects are expected.
93
+
94
+ http://devblog.avdi.org/2011/05/30/null-objects-and-falsiness
95
+
96
+ * Avoid multiline ?:, use if.
97
+
98
+ * Use {...} when defining blocks on one line. Use do...end for multiline
99
+ blocks.
100
+
101
+ * Avoid return where not required.
102
+
103
+ * Use ||= freely.
104
+
105
+ * Use OO regexps, and avoid =~ $0-9, $~, $` and $' when possible.
106
+
107
+ * Do not use Enumerable#inject when the "memo" object does not change between
108
+ iterations, use Enumerable#each_with_object instead (in ruby 1.9,
109
+ active_support and backports).
110
+
111
+ * Prefer ENV.fetch to ENV[] syntax.
112
+ Prefer block syntax for ENV.fetch to usage of the second argument.
113
+
114
+
115
+ == Naming:
116
+
117
+ * Use snake_case for methods.
118
+
119
+ * Use CamelCase for classes and modules. (Keep acronyms like HTTP,
120
+ RFC, XML uppercase.)
121
+
122
+ * Use SCREAMING_SNAKE_CASE for other constants.
123
+
124
+ * Do not use single letter variable names. Avoid uncommunicative names.
125
+
126
+ * Use consistent variable names. Try to keep the variable names close
127
+ to the object class name.
128
+
129
+ * Use names prefixed with _ for unused variables.
130
+
131
+ * When defining a predicate method that compares against another object of
132
+ a similar type, name the argument "other".
133
+
134
+ * Prefer map over collect, detect over find, select over find_all.
135
+
136
+ * Use def self.method to define singleton methods.
137
+
138
+ * Avoid alias when alias_method will do.
139
+
140
+
141
+ == Comments:
142
+
143
+ * Use YARD and its conventions for API documentation. Don't put an
144
+ empty line between the comment block and the def.
145
+
146
+ * Comments longer than a word are capitalized and use punctuation.
147
+ Use one space after periods.
148
+
149
+ * Avoid superfluous comments.
150
+
151
+
152
+ == Code structuring:
153
+
154
+ * Break code into packages, decoupled from the environment.
155
+
156
+ * Wrap packages into gems.
157
+
158
+ * Inject dependencies explicitly.
159
+ Leave all outer references on the border of any package. Inside
160
+ the package use internal references only.
161
+
162
+ * Follow SOLID principles.
163
+
164
+ http://en.wikipedia.org/wiki/SOLID_(object-oriented_design)
165
+
166
+ * Only give a method one purpose for existing. If you pass in a boolean
167
+ to a method, what you're saying is that this method has two different
168
+ behaviours. Just split it into two single purpose methods. If you have
169
+ to use the words "AND" or "OR" to describe what the method does it
170
+ probably does too much.
171
+
172
+ * Avoid long methods.
173
+ Try to keep them at no more than 6 lines long, and preferably 4 or less.
174
+
175
+ If sections of a method are logically separate by blank lines, then
176
+ that's probably a sign that those sections should be split into separate
177
+ methods.
178
+
179
+ * Avoid hashes-as-optional-parameters. Does the method do too much?
180
+
181
+ * Avoid long parameter lists.
182
+
183
+ * Add "global" methods to Kernel (if you have to) and make them private.
184
+
185
+ * Use OptionParser for parsing complex command line options and
186
+ ruby -s for trivial command line options.
187
+
188
+ * Avoid needless metaprogramming.
189
+
190
+ * Always freeze objects assigned to constants.
191
+
192
+
193
+ == General:
194
+
195
+ * Code in a functional way, avoid mutation when it makes sense.
196
+
197
+ * Try to have methods either return the state of the object and have
198
+ no side effects, or return self and have side effects. This is
199
+ otherwise known as Command-query separation (CQS):
200
+
201
+ http://en.wikipedia.org/wiki/Command-query_separation
202
+
203
+ * Do not mutate arguments unless that is the purpose of the method.
204
+
205
+ * Try following TRUE heuristics by Sandi Metz
206
+
207
+ http://designisrefactoring.com/2015/02/08/introducing-sandi-metz-true/
208
+
209
+ * Do not mess around in core classes when writing libraries.
210
+ Namespace your code inside the modules, or wrap core classes to
211
+ decorators of your own.
212
+
213
+ * Do not program defensively.
214
+
215
+ http://www.erlang.se/doc/programming_rules.shtml#HDR11
216
+
217
+ * Keep the code simple.
218
+
219
+ * Don't overdesign.
220
+
221
+ * Don't underdesign.
222
+
223
+ * Avoid bugs.
224
+
225
+ * Read other style guides and apply the parts that don't dissent with
226
+ this list.
227
+
228
+ * Be consistent.
229
+
230
+ * Use common sense.