juno-report 0.0.6 → 0.0.7

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: a68a66753dafbda9b9ca912b6787055dd8705fbe
4
- data.tar.gz: 810b2177d42e6bd76fd7b498b6e479f8156b7739
3
+ metadata.gz: a932e0b73319bd1d1b13f86bbee8c72495dcdf2c
4
+ data.tar.gz: aaab4e5e593f45b7174e76a46b6701f9692c16f5
5
5
  SHA512:
6
- metadata.gz: 0998a6fdfed628d24b8fda50896fabfda3c2ec519f30d47e4b341734584686b8637f065e5d1a13e782e758460044c7f854aab631c5892f23a72930a33a48cf26
7
- data.tar.gz: 4d5880653db11a7da79216ef4989ca8fb2a3aa51b6bdef51cdbe9d103f7de5d2fcfe3ddde885999054bbce4c02adf8038d8ce4035ddc3276df03f1b25fb283a0
6
+ metadata.gz: 3dd173ca56e8258a52e82b54dac3a587344a2335d77cb48aa93147c3fc5ee9f34d64d5d66eaf3d450a77a3c1e994f16d06faf699debd9196e73137c7873a8edc
7
+ data.tar.gz: 560f334c61a12238781655db4643963bf843d94fbed282c140bf478d9ece8eb28cb1b14995be32d9a07b766c0974d8f7ea03ab6311394fcf85af53f2e926a240
data/.gitignore CHANGED
File without changes
data/Gemfile CHANGED
File without changes
data/Gemfile.lock CHANGED
@@ -1,27 +1,25 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- juno-report (0.0.5)
4
+ juno-report (0.0.6)
5
5
  prawml
6
6
 
7
7
  GEM
8
8
  remote: https://rubygems.org/
9
9
  specs:
10
10
  Ascii85 (1.0.2)
11
- activesupport (3.2.15)
12
- i18n (~> 0.6, >= 0.6.4)
11
+ activesupport (3.2.9)
12
+ i18n (~> 0.6)
13
13
  multi_json (~> 1.0)
14
- afm (0.2.0)
15
- barby (0.5.1)
16
- hashery (2.1.1)
17
- i18n (0.6.5)
18
- multi_json (1.8.2)
19
- pdf-reader (1.3.3)
14
+ barby (0.5.0)
15
+ diff-lcs (1.1.3)
16
+ hashery (2.1.0)
17
+ i18n (0.6.1)
18
+ multi_json (1.5.0)
19
+ pdf-reader (1.2.0)
20
20
  Ascii85 (~> 1.0.0)
21
- afm (~> 0.2.0)
22
21
  hashery (~> 2.0)
23
22
  ruby-rc4
24
- ttfunk
25
23
  prawml (0.1.1)
26
24
  activesupport (~> 3.0)
27
25
  barby
@@ -29,6 +27,15 @@ GEM
29
27
  prawn (0.12.0)
30
28
  pdf-reader (>= 0.9.0)
31
29
  ttfunk (~> 1.0.2)
30
+ rake (0.9.2.2)
31
+ rspec (2.12.0)
32
+ rspec-core (~> 2.12.0)
33
+ rspec-expectations (~> 2.12.0)
34
+ rspec-mocks (~> 2.12.0)
35
+ rspec-core (2.12.2)
36
+ rspec-expectations (2.12.1)
37
+ diff-lcs (~> 1.1.3)
38
+ rspec-mocks (2.12.1)
32
39
  ruby-rc4 (0.1.5)
33
40
  ttfunk (1.0.3)
34
41
 
@@ -37,3 +44,5 @@ PLATFORMS
37
44
 
38
45
  DEPENDENCIES
39
46
  juno-report!
47
+ rake
48
+ rspec
data/LICENSE.txt CHANGED
File without changes
data/README.md CHANGED
File without changes
data/Rakefile CHANGED
@@ -1 +1,7 @@
1
1
  require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new
5
+
6
+ task :default => :spec
7
+ task :test => :spec
data/juno-report.gemspec CHANGED
@@ -18,4 +18,7 @@ Gem::Specification.new do |gem|
18
18
  gem.require_paths = ["lib"]
19
19
 
20
20
  gem.add_dependency "prawml"
21
+
22
+ gem.add_development_dependency 'rake'
23
+ gem.add_development_dependency 'rspec'
21
24
  end
File without changes
@@ -1,7 +1,7 @@
1
1
  module JunoReport
2
2
  module Pdf
3
3
 
4
- #Responsible for generate a report, based on rules passed as parameter in Juno::Report::generate.
4
+ #Responsible for generate a report, based on rules passed as parameter in Juno::Report::generate.
5
5
  #Juno Reports has support groups, just by especifying them at the rules file.
6
6
  #Receives a collection as parameter, which should be a Array of records of the report.
7
7
  def generate(collection)
@@ -19,12 +19,13 @@ module JunoReport
19
19
  get_sections
20
20
  set_pos_y
21
21
 
22
- collection = [collection] unless collection.is_a?(Array)
22
+ @defaults.merge!(@section[:defaults]) unless @section[:defaults].nil?
23
+
24
+ collection = [collection] unless collection.is_a?(Array) or collection.is_a?(ActiveRecord::Relation)
23
25
  print_section :page unless @sections[:page].nil?
24
26
  set_pos_y (@sections[:body][:settings][:posY] || 0)
25
27
  @current_groups = {}
26
28
  @footers = {}
27
- @count = 0
28
29
 
29
30
  unless @sections[:groups].empty?
30
31
  reset_groups_values
@@ -37,14 +38,13 @@ module JunoReport
37
38
 
38
39
  collection.each do |record|
39
40
  @record = record.is_a?(Hash) ? ReportObject.new(record) : record #Convert the hash on a Object to futurely extend a module
40
-
41
+
41
42
  headers_to_print, headers_height = calculate_header
42
43
 
43
- unless headers_to_print.empty?
44
- @count = 0
44
+ unless headers_to_print.empty?
45
45
  draw_footer headers_to_print, @sections[:groups] if can_print_footer
46
46
  if @posY - headers_height < 2*@sections[:body][:settings][:height]
47
- new_page
47
+ new_page
48
48
  else
49
49
  headers_to_print.each { |group| print_section group, @record, true }
50
50
  draw_columns
@@ -54,7 +54,6 @@ module JunoReport
54
54
 
55
55
  update_footer_values
56
56
  print_section :body, @record
57
- @count += 1
58
57
  end
59
58
 
60
59
  draw_footer(@sections[:body][:settings][:groups].collect {|group| group.to_sym}, @sections[:groups]) if has_groups?
@@ -80,16 +79,10 @@ module JunoReport
80
79
 
81
80
  #Generic function to print a section like :body, :page or the group sections.
82
81
  def print_section(section_name, values = nil, group = false)
83
- section = !group ? @sections[section_name] : @sections[:groups][section_name]
82
+ section = !group ? @sections[section_name] : @sections[:groups][section_name]
84
83
  set_pos_y(section[:settings][:posY] || 0) unless section_name.eql?(:body) || section[:settings].nil?
85
84
  new_page if @posY < 30
86
85
 
87
- if section_name.eql? :body and @count % 2 != 0
88
- @pdf.fill_color "F7F7F7"
89
- width = @options[:page_layout] == :portrait ? 530 : 770
90
- @pdf.fill_rectangle [0, @posY+(section[:settings][:height]/2)], width, section[:settings][:height]
91
- end
92
-
93
86
  section[:fields].each do |field, settings|
94
87
  symbolize! settings[1] unless settings[1].nil?
95
88
  set_pos_y settings[1][:posY] unless settings[1].nil? || settings[1][:posY].nil?
@@ -132,7 +125,7 @@ module JunoReport
132
125
  @sections[:body][:settings][:groups].each { |group| @sections[:groups][group.to_sym] = @rules[group.to_sym] } if has_groups?
133
126
  end
134
127
 
135
- #@current_groups storages the value for all groups. When a value is changed, the header is printed.
128
+ #@current_groups storages the value for all groups. When a value is changed, the header is printed.
136
129
  #This function set nil value for every item in @current_groups if the parameter is not passed. Otherwise,
137
130
  #only the forward groups will be cleaned to avoid conflict problems with others groups.
138
131
  def reset_groups_values current_group = nil
@@ -145,7 +138,7 @@ module JunoReport
145
138
 
146
139
  #Calculates the headers which must be printed before print the current record.
147
140
  #The function also returns the current header height to create a new page if the
148
- #page remaining space is smaller than (header + a record height)
141
+ #page remaining space is smaller than (header + a record height)
149
142
  def calculate_header
150
143
  headers = []
151
144
  height = 0
@@ -164,7 +157,7 @@ module JunoReport
164
157
 
165
158
  #Create a structure to calculate the footer values for all groups. Appends the footer body to total values too.
166
159
  def initialize_footer_values
167
- @sections[:body][:settings][:groups].each do |group|
160
+ @sections[:body][:settings][:groups].each do |group|
168
161
  current_footer = {}
169
162
  @sections[:groups][group.to_sym][:footer].each { |field, settings| current_footer[field] = nil } unless @sections[:groups][group.to_sym][:footer].nil?
170
163
  @footers[group.to_sym] = current_footer unless current_footer.empty?
@@ -184,7 +177,7 @@ module JunoReport
184
177
  calculate_footer_values :body, @sections[:body][:footer]
185
178
  end
186
179
 
187
- #Returns the values to the group passed as parameter. If :behavior setting is used, so a
180
+ #Returns the values to the group passed as parameter. If :behavior setting is used, so a
188
181
  #function in [lib/pdf/behaviors.rb] calculates the value of current field, else the report
189
182
  #method is called
190
183
  def calculate_footer_values group, source
File without changes
@@ -1,3 +1,3 @@
1
1
  module JunoReport
2
- VERSION = "0.0.6"
2
+ VERSION = "0.0.7"
3
3
  end
data/lib/juno-report.rb CHANGED
@@ -7,7 +7,7 @@ module JunoReport
7
7
  autoload :ReportObject, 'juno-report/report_object'
8
8
 
9
9
  def self.generate(collection, options)
10
- rules = "#{options[:report]}.yml"
10
+ rules = (File.open "#{options[:report]}.yml").read
11
11
 
12
12
  defaults = {
13
13
  :page_layout => :portrait
@@ -23,7 +23,7 @@ module JunoReport
23
23
  if options[:type].eql? :file
24
24
  report.render_file (options[:filename] || "report.pdf")
25
25
  elsif options[:type].eql? :stream
26
- return report
26
+ return report.render
27
27
  else
28
28
  raise "Type options must be :file or :stream."
29
29
  end
metadata CHANGED
@@ -1,27 +1,55 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: juno-report
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.6
4
+ version: 0.0.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Edson Júnior
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-04-30 00:00:00.000000000 Z
11
+ date: 2016-03-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: prawml
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - '>='
17
+ - - ">="
18
18
  - !ruby/object:Gem::Version
19
19
  version: '0'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - '>='
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
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
+ - !ruby/object:Gem::Dependency
42
+ name: rspec
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
25
53
  - !ruby/object:Gem::Version
26
54
  version: '0'
27
55
  description: A simple, but efficient, report genarator yaml based
@@ -31,16 +59,7 @@ executables: []
31
59
  extensions: []
32
60
  extra_rdoc_files: []
33
61
  files:
34
- - .gitignore
35
- - .idea/.name
36
- - .idea/.rakeTasks
37
- - .idea/encodings.xml
38
- - .idea/juno-report.iml
39
- - .idea/misc.xml
40
- - .idea/modules.xml
41
- - .idea/scopes/scope_settings.xml
42
- - .idea/vcs.xml
43
- - .idea/workspace.xml
62
+ - ".gitignore"
44
63
  - Gemfile
45
64
  - Gemfile.lock
46
65
  - LICENSE.txt
@@ -52,9 +71,6 @@ files:
52
71
  - lib/juno-report/pdf/behaviors.rb
53
72
  - lib/juno-report/report_object.rb
54
73
  - lib/juno-report/version.rb
55
- - samples/example.rb
56
- - samples/report.pdf
57
- - samples/report.yml
58
74
  homepage: http://github.com/ebfjunior/juno-report
59
75
  licenses: []
60
76
  metadata: {}
@@ -64,17 +80,17 @@ require_paths:
64
80
  - lib
65
81
  required_ruby_version: !ruby/object:Gem::Requirement
66
82
  requirements:
67
- - - '>='
83
+ - - ">="
68
84
  - !ruby/object:Gem::Version
69
85
  version: '0'
70
86
  required_rubygems_version: !ruby/object:Gem::Requirement
71
87
  requirements:
72
- - - '>='
88
+ - - ">="
73
89
  - !ruby/object:Gem::Version
74
90
  version: '0'
75
91
  requirements: []
76
92
  rubyforge_project:
77
- rubygems_version: 2.0.6
93
+ rubygems_version: 2.4.8
78
94
  signing_key:
79
95
  specification_version: 4
80
96
  summary: Juno Reports generates reports with the minimum configuration and effort
data/.idea/.name DELETED
@@ -1 +0,0 @@
1
- juno-report
data/.idea/.rakeTasks DELETED
@@ -1,7 +0,0 @@
1
- <?xml version="1.0" encoding="UTF-8"?>
2
- <Settings><!--This file was automatically generated by Ruby plugin.
3
- You are allowed to:
4
- 1. Remove rake task
5
- 2. Add existing rake tasks
6
- To add existing rake tasks automatically delete this file and reload the project.
7
- --><RakeGroup description="" fullCmd="" taksId="rake" /></Settings>
data/.idea/encodings.xml DELETED
@@ -1,5 +0,0 @@
1
- <?xml version="1.0" encoding="UTF-8"?>
2
- <project version="4">
3
- <component name="Encoding" useUTFGuessing="true" native2AsciiForPropertiesFiles="false" />
4
- </project>
5
-
@@ -1,31 +0,0 @@
1
- <?xml version="1.0" encoding="UTF-8"?>
2
- <module type="RUBY_MODULE" version="4">
3
- <component name="FacetManager">
4
- <facet type="gem" name="Gem">
5
- <configuration>
6
- <option name="GEM_APP_ROOT_PATH" value="$MODULE_DIR$" />
7
- <option name="GEM_APP_TEST_PATH" value="" />
8
- <option name="GEM_APP_LIB_PATH" value="$MODULE_DIR$/lib" />
9
- </configuration>
10
- </facet>
11
- </component>
12
- <component name="NewModuleRootManager">
13
- <content url="file://$MODULE_DIR$" />
14
- <orderEntry type="inheritedJdk" />
15
- <orderEntry type="sourceFolder" forTests="false" />
16
- <orderEntry type="library" scope="PROVIDED" name="Ascii85 (v1.0.2, RVM: ruby-1.9.3-p286) [gem]" level="application" />
17
- <orderEntry type="library" scope="PROVIDED" name="activesupport (v3.2.15, RVM: ruby-1.9.3-p286) [gem]" level="application" />
18
- <orderEntry type="library" scope="PROVIDED" name="afm (v0.2.0, RVM: ruby-1.9.3-p286) [gem]" level="application" />
19
- <orderEntry type="library" scope="PROVIDED" name="barby (v0.5.1, RVM: ruby-1.9.3-p286) [gem]" level="application" />
20
- <orderEntry type="library" scope="PROVIDED" name="bundler (v1.3.5, RVM: ruby-1.9.3-p286) [gem]" level="application" />
21
- <orderEntry type="library" scope="PROVIDED" name="hashery (v2.1.1, RVM: ruby-1.9.3-p286) [gem]" level="application" />
22
- <orderEntry type="library" scope="PROVIDED" name="i18n (v0.6.5, RVM: ruby-1.9.3-p286) [gem]" level="application" />
23
- <orderEntry type="library" scope="PROVIDED" name="multi_json (v1.8.2, RVM: ruby-1.9.3-p286) [gem]" level="application" />
24
- <orderEntry type="library" scope="PROVIDED" name="pdf-reader (v1.3.3, RVM: ruby-1.9.3-p286) [gem]" level="application" />
25
- <orderEntry type="library" scope="PROVIDED" name="prawml (v0.1.1, RVM: ruby-1.9.3-p286) [gem]" level="application" />
26
- <orderEntry type="library" scope="PROVIDED" name="prawn (v0.12.0, RVM: ruby-1.9.3-p286) [gem]" level="application" />
27
- <orderEntry type="library" scope="PROVIDED" name="ruby-rc4 (v0.1.5, RVM: ruby-1.9.3-p286) [gem]" level="application" />
28
- <orderEntry type="library" scope="PROVIDED" name="ttfunk (v1.0.3, RVM: ruby-1.9.3-p286) [gem]" level="application" />
29
- </component>
30
- </module>
31
-
data/.idea/misc.xml DELETED
@@ -1,5 +0,0 @@
1
- <?xml version="1.0" encoding="UTF-8"?>
2
- <project version="4">
3
- <component name="ProjectRootManager" version="2" project-jdk-name="RVM: ruby-1.9.3-p286" project-jdk-type="RUBY_SDK" />
4
- </project>
5
-
data/.idea/modules.xml DELETED
@@ -1,9 +0,0 @@
1
- <?xml version="1.0" encoding="UTF-8"?>
2
- <project version="4">
3
- <component name="ProjectModuleManager">
4
- <modules>
5
- <module fileurl="file://$PROJECT_DIR$/.idea/juno-report.iml" filepath="$PROJECT_DIR$/.idea/juno-report.iml" />
6
- </modules>
7
- </component>
8
- </project>
9
-
@@ -1,5 +0,0 @@
1
- <component name="DependencyValidationManager">
2
- <state>
3
- <option name="SKIP_IMPORT_STATEMENTS" value="false" />
4
- </state>
5
- </component>
data/.idea/vcs.xml DELETED
@@ -1,7 +0,0 @@
1
- <?xml version="1.0" encoding="UTF-8"?>
2
- <project version="4">
3
- <component name="VcsDirectoryMappings">
4
- <mapping directory="" vcs="" />
5
- </component>
6
- </project>
7
-