intuition 0.0.0 → 0.0.1.alpha1

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: e7dd37f47bac0bc0a6673ab0b9dc7ad9ca377e67
4
- data.tar.gz: f21cfde9008b7e77e1f71cded22c5a5a18e75c88
3
+ metadata.gz: e7898dab89b946f512837b787aa9e3747d3035cf
4
+ data.tar.gz: cbe430fe85d81ed0fd936437c8bb822395b3473e
5
5
  SHA512:
6
- metadata.gz: d51de5185b88ab8dde5222b6db0e422bceb99d34784aedefece8715912dda6f15693b15886ded67ea4e1f3e6436d0cbc0c3179f9dd036352067ab7bc60eea471
7
- data.tar.gz: c505734749f568ff3895e096b4332ad7b7a464eb10e6ac4588f320c419d4ac1b3386a7d7668c4236d4dcb5f666b777d49e43d04891bcd4e238a0df17e9071f29
6
+ metadata.gz: ed3c6ff3af0c9c1c184c91530f92e241354d93f0830c0971abaf8e6e0e6107baf2b8f13ecdc59b445742c3de399246a32d7dda5a24f2d8ecdac5b7f287511264
7
+ data.tar.gz: a14d52517177b0dbc3eb08a27c023653b0f21894a98f4b5185446c062b6673947143ab49b52dc9bd63810f05c73c16a6626d5b4804d6abead213879bfd893eb9
data/.gitignore ADDED
@@ -0,0 +1,4 @@
1
+ pkg/*
2
+ coverage
3
+ *.gem
4
+ .bundle
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --color
2
+ --require spec_helper
data/Gemfile ADDED
@@ -0,0 +1,3 @@
1
+ source :rubygems
2
+
3
+ gemspec
data/Gemfile.lock ADDED
@@ -0,0 +1,80 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ intuition (0.0.1.alpha1)
5
+
6
+ GEM
7
+ remote: http://rubygems.org/
8
+ specs:
9
+ coderay (1.1.0)
10
+ diff-lcs (1.2.5)
11
+ docile (1.1.5)
12
+ ffaker (2.1.0)
13
+ ffi (1.9.10)
14
+ formatador (0.2.5)
15
+ guard (2.13.0)
16
+ formatador (>= 0.2.4)
17
+ listen (>= 2.7, <= 4.0)
18
+ lumberjack (~> 1.0)
19
+ nenv (~> 0.1)
20
+ notiffany (~> 0.0)
21
+ pry (>= 0.9.12)
22
+ shellany (~> 0.0)
23
+ thor (>= 0.18.1)
24
+ guard-compat (1.2.1)
25
+ guard-rspec (4.6.4)
26
+ guard (~> 2.1)
27
+ guard-compat (~> 1.1)
28
+ rspec (>= 2.99.0, < 4.0)
29
+ json (1.8.3)
30
+ listen (3.0.4)
31
+ rb-fsevent (>= 0.9.3)
32
+ rb-inotify (>= 0.9)
33
+ lumberjack (1.0.9)
34
+ method_source (0.8.2)
35
+ nenv (0.2.0)
36
+ notiffany (0.0.8)
37
+ nenv (~> 0.1)
38
+ shellany (~> 0.0)
39
+ pry (0.10.3)
40
+ coderay (~> 1.1.0)
41
+ method_source (~> 0.8.1)
42
+ slop (~> 3.4)
43
+ rb-fsevent (0.9.6)
44
+ rb-inotify (0.9.5)
45
+ ffi (>= 0.5.0)
46
+ rspec (3.4.0)
47
+ rspec-core (~> 3.4.0)
48
+ rspec-expectations (~> 3.4.0)
49
+ rspec-mocks (~> 3.4.0)
50
+ rspec-core (3.4.0)
51
+ rspec-support (~> 3.4.0)
52
+ rspec-expectations (3.4.0)
53
+ diff-lcs (>= 1.2.0, < 2.0)
54
+ rspec-support (~> 3.4.0)
55
+ rspec-mocks (3.4.0)
56
+ diff-lcs (>= 1.2.0, < 2.0)
57
+ rspec-support (~> 3.4.0)
58
+ rspec-support (3.4.0)
59
+ shellany (0.0.1)
60
+ simplecov (0.10.0)
61
+ docile (~> 1.1.0)
62
+ json (~> 1.8)
63
+ simplecov-html (~> 0.10.0)
64
+ simplecov-html (0.10.0)
65
+ slop (3.6.0)
66
+ thor (0.19.1)
67
+
68
+ PLATFORMS
69
+ ruby
70
+
71
+ DEPENDENCIES
72
+ bundler (>= 1.0.0)
73
+ ffaker (~> 2.1.0)
74
+ guard-rspec (~> 4.6.4)
75
+ intuition!
76
+ rspec (~> 3.4.0)
77
+ simplecov (~> 0.10.0)
78
+
79
+ BUNDLED WITH
80
+ 1.10.6
data/Guardfile ADDED
@@ -0,0 +1,70 @@
1
+ # A sample Guardfile
2
+ # More info at https://github.com/guard/guard#readme
3
+
4
+ ## Uncomment and set this to only include directories you want to watch
5
+ # directories %w(app lib config test spec features) \
6
+ # .select{|d| Dir.exists?(d) ? d : UI.warning("Directory #{d} does not exist")}
7
+
8
+ ## Note: if you are using the `directories` clause above and you are not
9
+ ## watching the project directory ('.'), then you will want to move
10
+ ## the Guardfile to a watched dir and symlink it back, e.g.
11
+ #
12
+ # $ mkdir config
13
+ # $ mv Guardfile config/
14
+ # $ ln -s config/Guardfile .
15
+ #
16
+ # and, you'll have to watch "config/Guardfile" instead of "Guardfile"
17
+
18
+ # Note: The cmd option is now required due to the increasing number of ways
19
+ # rspec may be run, below are examples of the most common uses.
20
+ # * bundler: 'bundle exec rspec'
21
+ # * bundler binstubs: 'bin/rspec'
22
+ # * spring: 'bin/rspec' (This will use spring if running and you have
23
+ # installed the spring binstubs per the docs)
24
+ # * zeus: 'zeus rspec' (requires the server to be started separately)
25
+ # * 'just' rspec: 'rspec'
26
+
27
+ guard :rspec, cmd: "bundle exec rspec" do
28
+ require "guard/rspec/dsl"
29
+ dsl = Guard::RSpec::Dsl.new(self)
30
+
31
+ # Feel free to open issues for suggestions and improvements
32
+
33
+ # RSpec files
34
+ rspec = dsl.rspec
35
+ watch(rspec.spec_helper) { rspec.spec_dir }
36
+ watch(rspec.spec_support) { rspec.spec_dir }
37
+ watch(rspec.spec_files)
38
+
39
+ # Ruby files
40
+ ruby = dsl.ruby
41
+ dsl.watch_spec_files_for(ruby.lib_files)
42
+
43
+ # Rails files
44
+ rails = dsl.rails(view_extensions: %w(erb haml slim))
45
+ dsl.watch_spec_files_for(rails.app_files)
46
+ dsl.watch_spec_files_for(rails.views)
47
+
48
+ watch(rails.controllers) do |m|
49
+ [
50
+ rspec.spec.("routing/#{m[1]}_routing"),
51
+ rspec.spec.("controllers/#{m[1]}_controller"),
52
+ rspec.spec.("acceptance/#{m[1]}")
53
+ ]
54
+ end
55
+
56
+ # Rails config changes
57
+ watch(rails.spec_helper) { rspec.spec_dir }
58
+ watch(rails.routes) { "#{rspec.spec_dir}/routing" }
59
+ watch(rails.app_controller) { "#{rspec.spec_dir}/controllers" }
60
+
61
+ # Capybara features specs
62
+ watch(rails.view_dirs) { |m| rspec.spec.("features/#{m[1]}") }
63
+ watch(rails.layouts) { |m| rspec.spec.("features/#{m[1]}") }
64
+
65
+ # Turnip features and steps
66
+ watch(%r{^spec/acceptance/(.+)\.feature$})
67
+ watch(%r{^spec/acceptance/steps/(.+)_steps\.rb$}) do |m|
68
+ Dir[File.join("**/#{m[1]}.feature")][0] || "spec/acceptance"
69
+ end
70
+ end
data/README.md ADDED
@@ -0,0 +1 @@
1
+ # intuition
data/Rakefile ADDED
@@ -0,0 +1,3 @@
1
+ require 'bundler'
2
+
3
+ Bundler::GemHelper.install_tasks
Binary file
data/intuition.gemspec ADDED
@@ -0,0 +1,26 @@
1
+ $:.push File.expand_path('../lib', __FILE__)
2
+
3
+ require 'intuition/version'
4
+
5
+ Gem::Specification.new do |s|
6
+ s.name = 'intuition'
7
+ s.version = Intuition::VERSION
8
+ s.platform = Gem::Platform::RUBY
9
+
10
+ s.summary = 'Reporting'
11
+ s.description = 'Reporting'
12
+ s.authors = ['Anton Zhavoronkov']
13
+ s.email = 'anton.zhavoronkov@gmail.com'
14
+ s.homepage = 'https://github.com/AntonZh/intuition'
15
+
16
+ s.add_development_dependency 'bundler', '>= 1.0.0'
17
+ s.add_development_dependency 'rspec', '~> 3.4.0'
18
+ s.add_development_dependency 'simplecov', '~> 0.10.0'
19
+ s.add_development_dependency 'guard-rspec', '~> 4.6.4'
20
+ s.add_development_dependency 'ffaker', '~> 2.1.0'
21
+
22
+ s.files = `git ls-files`.split("\n")
23
+ s.require_path = 'lib'
24
+
25
+ s.license = 'MIT'
26
+ end
@@ -0,0 +1,54 @@
1
+ require_relative 'sheet'
2
+ require_relative 'result'
3
+
4
+ module Intuition
5
+ class Report
6
+ attr_reader :filter
7
+ attr_reader :context
8
+
9
+ def initialize(filter, args = {})
10
+ @filter = filter
11
+ @context = args[:context]
12
+ @sheets = []
13
+ end
14
+
15
+ def result
16
+ calculate_if_needed
17
+ @result
18
+ end
19
+
20
+ def f
21
+ filter
22
+ end
23
+
24
+ private
25
+
26
+ def calculate
27
+ raise NotImplementedError
28
+ end
29
+
30
+ def calculate_if_needed
31
+ calculate unless @calculated
32
+ @calculated = true
33
+ @result = Result.new(@sheets)
34
+ end
35
+
36
+ def sheet(name, &block)
37
+ new_sheet = Sheet.new(name)
38
+ yield new_sheet
39
+ add_sheet(new_sheet)
40
+ end
41
+
42
+ def add_sheet(sheet)
43
+ @sheets << sheet
44
+ end
45
+
46
+ def method_missing(m, *args, &block)
47
+ if context && context.respond_to?(m)
48
+ context.send(m, *args, &block)
49
+ else
50
+ super
51
+ end
52
+ end
53
+ end
54
+ end
@@ -0,0 +1,9 @@
1
+ module Intuition
2
+ class Result
3
+ attr_reader :sheets
4
+
5
+ def initialize(sheets)
6
+ @sheets = sheets
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,41 @@
1
+ require_relative 'table'
2
+
3
+ module Intuition
4
+ class Sheet
5
+ attr_reader :title
6
+
7
+ def initialize(title)
8
+ @title = title
9
+ end
10
+
11
+ def header(*value)
12
+ if value.any?
13
+ @header = [value].flatten
14
+ else
15
+ @header
16
+ end
17
+ end
18
+
19
+ def table(args = {}, &block)
20
+ if block_given?
21
+ @table = Table.new(args)
22
+ yield @table
23
+ @table.finalize
24
+ else
25
+ if args.is_a? Array
26
+ @table = Table.new
27
+ args.each {|r| @table.row(r) }
28
+ @table.finalize
29
+ end
30
+ end
31
+ @table
32
+ end
33
+
34
+ def full_table
35
+ [header] + table.rows
36
+ end
37
+
38
+ def run_conversions(*args)
39
+ end
40
+ end
41
+ end
@@ -0,0 +1,19 @@
1
+ module Intuition
2
+ class Table
3
+ attr_reader :rows
4
+ attr_reader :sorted
5
+
6
+ def initialize(args = {})
7
+ @rows = []
8
+ @sorted = args.fetch(:sorted, false)
9
+ end
10
+
11
+ def row(*row)
12
+ @rows << [row].flatten
13
+ end
14
+
15
+ def finalize
16
+ rows.sort! if sorted
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,3 @@
1
+ module Intuition
2
+ VERSION = '0.0.1.alpha1'
3
+ end
data/lib/intuition.rb CHANGED
@@ -0,0 +1,4 @@
1
+ require 'intuition/report'
2
+
3
+ module Intuition
4
+ end
@@ -0,0 +1,32 @@
1
+ require 'intuition/report'
2
+
3
+ class SampleReport < Intuition::Report
4
+ def calculate
5
+ sheet 'First' do
6
+ header ['Name', 'Date', 'Count']
7
+
8
+ table do
9
+ row 'Jack', Time.new(2015, 10, 12), 5
10
+ row 'James', Time.new(2014, 4, 21), 83
11
+ row 'John', Time.new(2013, 2, 5), 161
12
+ end
13
+ end
14
+ end
15
+ end
16
+
17
+ describe Intuition::Report do
18
+ describe '.new' do
19
+ it 'creates new report object' do
20
+ expect(described_class.new).to be_a_instance_of(described_class)
21
+ end
22
+ end
23
+
24
+ it 'simple report' do
25
+ report = SampleReport.new
26
+ result = report.result
27
+
28
+ result.sheets.each do |sheet|
29
+ p sheet
30
+ end
31
+ end
32
+ end
@@ -0,0 +1,28 @@
1
+ require 'intuition/sheet'
2
+
3
+ describe Intuition::Sheet do
4
+ describe '.new' do
5
+ let(:title) { FFaker::Lorem.phrase }
6
+ it 'takes sheet title' do
7
+ expect(described_class.new(title).title).to eq(title)
8
+ end
9
+ end
10
+
11
+ describe '#header' do
12
+ subject { described_class.new(FFaker::Lorem.phrase) }
13
+ let(:header) { FFaker::Lorem.phrase }
14
+
15
+ context 'with parameter' do
16
+ it 'sets header' do
17
+ subject.header header
18
+ expect(subject.instance_variable_get(:@header)).to eq([header])
19
+ end
20
+ end
21
+ context 'without parameter' do
22
+ it 'gets header' do
23
+ subject.instance_variable_set(:@header, [header])
24
+ expect(subject.header).to eq([header])
25
+ end
26
+ end
27
+ end
28
+ end
@@ -0,0 +1,101 @@
1
+ require 'simplecov'
2
+ SimpleCov.start
3
+
4
+ require 'ffaker'
5
+
6
+ # This file was generated by the `rspec --init` command. Conventionally, all
7
+ # specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
8
+ # The generated `.rspec` file contains `--require spec_helper` which will cause
9
+ # this file to always be loaded, without a need to explicitly require it in any
10
+ # files.
11
+ #
12
+ # Given that it is always loaded, you are encouraged to keep this file as
13
+ # light-weight as possible. Requiring heavyweight dependencies from this file
14
+ # will add to the boot time of your test suite on EVERY test run, even for an
15
+ # individual file that may not need all of that loaded. Instead, consider making
16
+ # a separate helper file that requires the additional dependencies and performs
17
+ # the additional setup, and require it from the spec files that actually need
18
+ # it.
19
+ #
20
+ # The `.rspec` file also contains a few flags that are not defaults but that
21
+ # users commonly want.
22
+ #
23
+ # See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
24
+ RSpec.configure do |config|
25
+ # rspec-expectations config goes here. You can use an alternate
26
+ # assertion/expectation library such as wrong or the stdlib/minitest
27
+ # assertions if you prefer.
28
+ config.expect_with :rspec do |expectations|
29
+ # This option will default to `true` in RSpec 4. It makes the `description`
30
+ # and `failure_message` of custom matchers include text for helper methods
31
+ # defined using `chain`, e.g.:
32
+ # be_bigger_than(2).and_smaller_than(4).description
33
+ # # => "be bigger than 2 and smaller than 4"
34
+ # ...rather than:
35
+ # # => "be bigger than 2"
36
+ expectations.include_chain_clauses_in_custom_matcher_descriptions = true
37
+ end
38
+
39
+ # rspec-mocks config goes here. You can use an alternate test double
40
+ # library (such as bogus or mocha) by changing the `mock_with` option here.
41
+ config.mock_with :rspec do |mocks|
42
+ # Prevents you from mocking or stubbing a method that does not exist on
43
+ # a real object. This is generally recommended, and will default to
44
+ # `true` in RSpec 4.
45
+ mocks.verify_partial_doubles = true
46
+ end
47
+
48
+ # The settings below are suggested to provide a good initial experience
49
+ # with RSpec, but feel free to customize to your heart's content.
50
+ =begin
51
+ # These two settings work together to allow you to limit a spec run
52
+ # to individual examples or groups you care about by tagging them with
53
+ # `:focus` metadata. When nothing is tagged with `:focus`, all examples
54
+ # get run.
55
+ config.filter_run :focus
56
+ config.run_all_when_everything_filtered = true
57
+
58
+ # Allows RSpec to persist some state between runs in order to support
59
+ # the `--only-failures` and `--next-failure` CLI options. We recommend
60
+ # you configure your source control system to ignore this file.
61
+ config.example_status_persistence_file_path = "spec/examples.txt"
62
+
63
+ # Limits the available syntax to the non-monkey patched syntax that is
64
+ # recommended. For more details, see:
65
+ # - http://rspec.info/blog/2012/06/rspecs-new-expectation-syntax/
66
+ # - http://www.teaisaweso.me/blog/2013/05/27/rspecs-new-message-expectation-syntax/
67
+ # - http://rspec.info/blog/2014/05/notable-changes-in-rspec-3/#zero-monkey-patching-mode
68
+ config.disable_monkey_patching!
69
+
70
+ # This setting enables warnings. It's recommended, but in some cases may
71
+ # be too noisy due to issues in dependencies.
72
+ config.warnings = true
73
+
74
+ # Many RSpec users commonly either run the entire suite or an individual
75
+ # file, and it's useful to allow more verbose output when running an
76
+ # individual spec file.
77
+ if config.files_to_run.one?
78
+ # Use the documentation formatter for detailed output,
79
+ # unless a formatter has already been configured
80
+ # (e.g. via a command-line flag).
81
+ config.default_formatter = 'doc'
82
+ end
83
+
84
+ # Print the 10 slowest examples and example groups at the
85
+ # end of the spec run, to help surface which specs are running
86
+ # particularly slow.
87
+ config.profile_examples = 10
88
+
89
+ # Run specs in random order to surface order dependencies. If you find an
90
+ # order dependency and want to debug it, you can fix the order by providing
91
+ # the seed, which is printed after each run.
92
+ # --seed 1234
93
+ config.order = :random
94
+
95
+ # Seed global randomization in this process using the `--seed` CLI option.
96
+ # Setting this allows you to use `--seed` to deterministically reproduce
97
+ # test failures related to randomization by passing the same `--seed` value
98
+ # as the one that triggered the failure.
99
+ Kernel.srand config.seed
100
+ =end
101
+ end
metadata CHANGED
@@ -1,22 +1,109 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: intuition
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.0
4
+ version: 0.0.1.alpha1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Anton Zhavoronkov
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-12-01 00:00:00.000000000 Z
12
- dependencies: []
11
+ date: 2015-12-03 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.0.0
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: 1.0.0
27
+ - !ruby/object:Gem::Dependency
28
+ name: rspec
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: 3.4.0
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: 3.4.0
41
+ - !ruby/object:Gem::Dependency
42
+ name: simplecov
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: 0.10.0
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: 0.10.0
55
+ - !ruby/object:Gem::Dependency
56
+ name: guard-rspec
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: 4.6.4
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: 4.6.4
69
+ - !ruby/object:Gem::Dependency
70
+ name: ffaker
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: 2.1.0
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: 2.1.0
13
83
  description: Reporting
14
84
  email: anton.zhavoronkov@gmail.com
15
85
  executables: []
16
86
  extensions: []
17
87
  extra_rdoc_files: []
18
88
  files:
89
+ - ".gitignore"
90
+ - ".rspec"
91
+ - Gemfile
92
+ - Gemfile.lock
93
+ - Guardfile
94
+ - README.md
95
+ - Rakefile
96
+ - intuition-0.0.0.gem
97
+ - intuition.gemspec
19
98
  - lib/intuition.rb
99
+ - lib/intuition/report.rb
100
+ - lib/intuition/result.rb
101
+ - lib/intuition/sheet.rb
102
+ - lib/intuition/table.rb
103
+ - lib/intuition/version.rb
104
+ - spec/intuition/report_spec.rb
105
+ - spec/intuition/sheet_spec.rb
106
+ - spec/spec_helper.rb
20
107
  homepage: https://github.com/AntonZh/intuition
21
108
  licenses:
22
109
  - MIT
@@ -32,9 +119,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
32
119
  version: '0'
33
120
  required_rubygems_version: !ruby/object:Gem::Requirement
34
121
  requirements:
35
- - - ">="
122
+ - - ">"
36
123
  - !ruby/object:Gem::Version
37
- version: '0'
124
+ version: 1.3.1
38
125
  requirements: []
39
126
  rubyforge_project:
40
127
  rubygems_version: 2.4.5.1
@@ -42,4 +129,3 @@ signing_key:
42
129
  specification_version: 4
43
130
  summary: Reporting
44
131
  test_files: []
45
- has_rdoc: