hflr 0.11.0 → 1.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.
- data/History.txt +10 -0
- data/README.txt +0 -0
- data/hflr.gemspec +9 -19
- data/lib/hflr.rb +0 -0
- data/lib/hflr/fl_record_file.rb +24 -4
- data/lib/hflr/hflr.rb +0 -0
- data/lib/hflr/record_template.rb +2 -2
- data/test/customer_orders.dat +0 -0
- data/test/customers.dat +0 -0
- data/test/examples.rb +18 -1
- data/test/flrfile_test.rb +0 -0
- data/test/record_template_test.rb +0 -0
- data/test/sample.dat +0 -0
- data/test/sample2_out.dat +0 -0
- data/test/sample_activities.dat +0 -0
- data/test/sample_out.dat +0 -0
- data/test/test_helper.rb +0 -0
- data/test/test_hflr.rb +0 -0
- metadata +48 -66
- data/Rakefile +0 -31
- data/sample2_out.dat +0 -1
- data/tasks/ann.rake +0 -80
- data/tasks/bones.rake +0 -20
- data/tasks/gem.rake +0 -201
- data/tasks/git.rake +0 -40
- data/tasks/notes.rake +0 -27
- data/tasks/post_load.rake +0 -34
- data/tasks/rdoc.rake +0 -51
- data/tasks/rubyforge.rake +0 -55
- data/tasks/setup.rb +0 -292
- data/tasks/spec.rake +0 -54
- data/tasks/svn.rake +0 -47
- data/tasks/test.rake +0 -40
- data/tasks/zentest.rake +0 -36
    
        data/History.txt
    CHANGED
    
    | @@ -1,4 +1,14 @@ | |
| 1 | 
            +
            == 1.0.1 / 2010-01-21
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            * Fixed warnings 
         | 
| 4 | 
            +
            * Added better exception handling for badly formatted output data
         | 
| 5 | 
            +
             | 
| 6 | 
            +
             | 
| 1 7 | 
             
            == 0.11.0 / 2009-08-04
         | 
| 2 8 |  | 
| 3 9 | 
             
            *  Removed useless files 
         | 
| 4 10 | 
             
              * Corrected version number 
         | 
| 11 | 
            +
             | 
| 12 | 
            +
            == 1.0.1 / 2011-02-09
         | 
| 13 | 
            +
               * Added ability to specify file format in Ruby with Range class (see example.rb in /test.)
         | 
| 14 | 
            +
               
         | 
    
        data/README.txt
    CHANGED
    
    | 
            File without changes
         | 
    
        data/hflr.gemspec
    CHANGED
    
    | @@ -2,11 +2,11 @@ | |
| 2 2 |  | 
| 3 3 | 
             
            Gem::Specification.new do |s|
         | 
| 4 4 | 
             
              s.name = %q{hflr}
         | 
| 5 | 
            -
              s.version = "0. | 
| 5 | 
            +
              s.version = "1.0.1"
         | 
| 6 6 |  | 
| 7 7 | 
             
              s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
         | 
| 8 8 | 
             
              s.authors = ["Colin Davis"]
         | 
| 9 | 
            -
              s.date = %q{ | 
| 9 | 
            +
              s.date = %q{2011-02-09}
         | 
| 10 10 | 
             
              s.description = %q{HFLR -- Hierarchical Fixed Length Records
         | 
| 11 11 |  | 
| 12 12 | 
             
            Allows you to read and write files of fixed width records when the file contains one or more
         | 
| @@ -17,25 +17,15 @@ Install with 'gem install hflr' | |
| 17 17 | 
             
            See the tests and examples bundled with this gem.}
         | 
| 18 18 | 
             
              s.email = %q{colin.c.davis@gmail.com}
         | 
| 19 19 | 
             
              s.extra_rdoc_files = ["History.txt", "README.txt"]
         | 
| 20 | 
            -
              s.files = ["History.txt", "README.txt", | 
| 21 | 
            -
               | 
| 22 | 
            -
               | 
| 20 | 
            +
              s.files = ["History.txt", "README.txt",  "hflr.gemspec", 
         | 
| 21 | 
            +
              "lib/hflr.rb", "lib/hflr/fl_record_file.rb", "lib/hflr/hflr.rb", "lib/hflr/record_template.rb", 
         | 
| 22 | 
            +
              "test/customer_orders.dat", "test/customers.dat", "test/examples.rb", "test/flrfile_test.rb","test/record_template_test.rb", 
         | 
| 23 | 
            +
              "test/sample.dat", "test/sample2_out.dat", "test/sample_activities.dat", "test/sample_out.dat", "test/test_helper.rb", "test/test_hflr.rb"]
         | 
| 24 | 
            +
              #s.homepage = %q{http://rubygems.org}
         | 
| 25 | 
            +
              #s.rdoc_options = ["--main", "README.txt"]
         | 
| 23 26 | 
             
              s.require_paths = ["lib"]
         | 
| 24 | 
            -
             | 
| 27 | 
            +
             | 
| 25 28 | 
             
              s.rubygems_version = %q{1.3.4}
         | 
| 26 29 | 
             
              s.summary = %q{HFLR -- Hierarchical Fixed Length Records  Allows you to read and write files of fixed width records when the file contains one or more than one type of record}
         | 
| 27 30 | 
             
              s.test_files = ["test/test_hflr.rb", "test/test_helper.rb"]
         | 
| 28 | 
            -
             | 
| 29 | 
            -
              if s.respond_to? :specification_version then
         | 
| 30 | 
            -
                current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
         | 
| 31 | 
            -
                s.specification_version = 3
         | 
| 32 | 
            -
             | 
| 33 | 
            -
                if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
         | 
| 34 | 
            -
                  s.add_development_dependency(%q<bones>, [">= 2.5.1"])
         | 
| 35 | 
            -
                else
         | 
| 36 | 
            -
                  s.add_dependency(%q<bones>, [">= 2.5.1"])
         | 
| 37 | 
            -
                end
         | 
| 38 | 
            -
              else
         | 
| 39 | 
            -
                s.add_dependency(%q<bones>, [">= 2.5.1"])
         | 
| 40 | 
            -
              end
         | 
| 41 31 | 
             
            end
         | 
    
        data/lib/hflr.rb
    CHANGED
    
    | 
            File without changes
         | 
    
        data/lib/hflr/fl_record_file.rb
    CHANGED
    
    | @@ -1,4 +1,4 @@ | |
| 1 | 
            -
            require File.expand_path(File.dirname(__FILE__) + '/record_template')
         | 
| 1 | 
            +
            #require File.expand_path(File.dirname(__FILE__) + '/record_template')
         | 
| 2 2 |  | 
| 3 3 |  | 
| 4 4 |  | 
| @@ -13,7 +13,10 @@ class FLRFile | |
| 13 13 | 
             
              def initialize(source, record_types, record_layouts, logical_first_column=0, extra_columns = nil)
         | 
| 14 14 | 
             
                # Allow record layouts like 
         | 
| 15 15 | 
             
                # {:type1=>[:var1=>1..5,:var2=>7..8],:type2=>[:var1=>1..1,:var2=>3..4]}
         | 
| 16 | 
            -
                 | 
| 16 | 
            +
                if record_layouts.values.first.is_a? Hash
         | 
| 17 | 
            +
                  record_layouts = create_layouts(record_layouts)
         | 
| 18 | 
            +
                end
         | 
| 19 | 
            +
                
         | 
| 17 20 | 
             
                @line_number = 0
         | 
| 18 21 | 
             
                @file = source    
         | 
| 19 22 | 
             
                @record_type_labels=record_types
         | 
| @@ -65,8 +68,7 @@ def get_next_known_line_type | |
| 65 68 | 
             
                line = @file.gets
         | 
| 66 69 | 
             
                record_type = line_type(line)
         | 
| 67 70 | 
             
              end
         | 
| 68 | 
            -
              record_type == :unknown ? nil : line
         | 
| 69 | 
            -
                
         | 
| 71 | 
            +
              record_type == :unknown ? nil : line   
         | 
| 70 72 | 
             
            end
         | 
| 71 73 |  | 
| 72 74 | 
             
            def each
         | 
| @@ -105,5 +107,23 @@ def self.open(path, mode, record_types, record_layouts, logical_first_column=0) | |
| 105 107 | 
             
                file.close
         | 
| 106 108 | 
             
              end
         | 
| 107 109 | 
             
            end
         | 
| 110 | 
            +
             | 
| 111 | 
            +
            private
         | 
| 112 | 
            +
             | 
| 113 | 
            +
            # If the layout is given in the convenient Ruby form
         | 
| 114 | 
            +
            def create_layouts(layout)
         | 
| 115 | 
            +
              var_class = Struct.new(:name,:start,:len)
         | 
| 116 | 
            +
            new_layout = {}
         | 
| 117 | 
            +
              layout.each_pair do |record_type,vars|
         | 
| 108 118 |  | 
| 119 | 
            +
                new_layout[record_type] = []
         | 
| 120 | 
            +
                new_vars = vars.each_pair do |var_name, range|
         | 
| 121 | 
            +
                
         | 
| 122 | 
            +
                  new_layout[record_type] << var_class.new(var_name.to_s,range.first, range.last - range.first + 1)        
         | 
| 123 | 
            +
                end
         | 
| 124 | 
            +
                new_layout[record_type].sort!{|a,b| a.start<=>b.start}
         | 
| 125 | 
            +
              end
         | 
| 126 | 
            +
              return new_layout
         | 
| 127 | 
            +
            end
         | 
| 128 | 
            +
             
         | 
| 109 129 | 
             
            end
         | 
    
        data/lib/hflr/hflr.rb
    CHANGED
    
    | 
            File without changes
         | 
    
        data/lib/hflr/record_template.rb
    CHANGED
    
    | @@ -24,12 +24,12 @@ def self.create(record_layouts, record_type_symbols, first_column_location, extr | |
| 24 24 | 
             
              templates = {}
         | 
| 25 25 | 
             
              self.check_record_layouts(record_layouts)
         | 
| 26 26 |  | 
| 27 | 
            -
              record_layouts. | 
| 27 | 
            +
              record_layouts.each_pair do |record_type, vars|    
         | 
| 28 28 | 
             
                record_label = record_type_symbols == :none ? :none : record_type_symbols[record_type]
         | 
| 29 29 | 
             
                templates[record_type] = 
         | 
| 30 30 | 
             
                self.create_template_class(record_type,
         | 
| 31 31 | 
             
                  record_label,
         | 
| 32 | 
            -
                 | 
| 32 | 
            +
                vars, 
         | 
| 33 33 | 
             
                first_column_location, 
         | 
| 34 34 | 
             
                extra_columns[record_type]) 
         | 
| 35 35 | 
             
              end
         | 
    
        data/test/customer_orders.dat
    CHANGED
    
    | 
            File without changes
         | 
    
        data/test/customers.dat
    CHANGED
    
    | 
            File without changes
         | 
    
        data/test/examples.rb
    CHANGED
    
    | @@ -46,5 +46,22 @@ customer_orders_file = FLRFile.new( | |
| 46 46 | 
             
                show record
         | 
| 47 47 | 
             
              end
         | 
| 48 48 |  | 
| 49 | 
            +
             | 
| 50 | 
            +
            puts " ----- You can also use metadata in Ruby -----"
         | 
| 51 | 
            +
            # Use Ruby metadata
         | 
| 52 | 
            +
             | 
| 53 | 
            +
            layout = {:customer=>{
         | 
| 54 | 
            +
              :name=>1..25,
         | 
| 55 | 
            +
              :zip=>26..30,
         | 
| 56 | 
            +
              :balance=>31..35
         | 
| 49 57 |  | 
| 50 | 
            -
             | 
| 58 | 
            +
            }
         | 
| 59 | 
            +
            }
         | 
| 60 | 
            +
            customer_file = FLRFile.new(File.new("customers.dat"), :customer, layout, 1, [:line_number])
         | 
| 61 | 
            +
             | 
| 62 | 
            +
             | 
| 63 | 
            +
            # You can read through the file and access the fields with methods named after the columns:
         | 
| 64 | 
            +
            customer_file.each do |record|
         | 
| 65 | 
            +
              puts "Customer #{customer_file.line_number.to_s} #{record.name} #{record.zip} "
         | 
| 66 | 
            +
            end
         | 
| 67 | 
            +
             | 
    
        data/test/flrfile_test.rb
    CHANGED
    
    | 
            File without changes
         | 
| 
            File without changes
         | 
    
        data/test/sample.dat
    CHANGED
    
    | 
            File without changes
         | 
    
        data/test/sample2_out.dat
    CHANGED
    
    | 
            File without changes
         | 
    
        data/test/sample_activities.dat
    CHANGED
    
    | 
            File without changes
         | 
    
        data/test/sample_out.dat
    CHANGED
    
    | 
            File without changes
         | 
    
        data/test/test_helper.rb
    CHANGED
    
    | 
            File without changes
         | 
    
        data/test/test_hflr.rb
    CHANGED
    
    | 
            File without changes
         | 
    
        metadata
    CHANGED
    
    | @@ -1,27 +1,23 @@ | |
| 1 1 | 
             
            --- !ruby/object:Gem::Specification 
         | 
| 2 2 | 
             
            name: hflr
         | 
| 3 3 | 
             
            version: !ruby/object:Gem::Version 
         | 
| 4 | 
            -
               | 
| 4 | 
            +
              prerelease: false
         | 
| 5 | 
            +
              segments: 
         | 
| 6 | 
            +
                - 1
         | 
| 7 | 
            +
                - 0
         | 
| 8 | 
            +
                - 1
         | 
| 9 | 
            +
              version: 1.0.1
         | 
| 5 10 | 
             
            platform: ruby
         | 
| 6 11 | 
             
            authors: 
         | 
| 7 | 
            -
            - Colin Davis
         | 
| 12 | 
            +
              - Colin Davis
         | 
| 8 13 | 
             
            autorequire: 
         | 
| 9 14 | 
             
            bindir: bin
         | 
| 10 15 | 
             
            cert_chain: []
         | 
| 11 16 |  | 
| 12 | 
            -
            date:  | 
| 17 | 
            +
            date: 2011-02-09 00:00:00 -06:00
         | 
| 13 18 | 
             
            default_executable: 
         | 
| 14 | 
            -
            dependencies: 
         | 
| 15 | 
            -
             | 
| 16 | 
            -
              name: bones
         | 
| 17 | 
            -
              type: :development
         | 
| 18 | 
            -
              version_requirement: 
         | 
| 19 | 
            -
              version_requirements: !ruby/object:Gem::Requirement 
         | 
| 20 | 
            -
                requirements: 
         | 
| 21 | 
            -
                - - ">="
         | 
| 22 | 
            -
                  - !ruby/object:Gem::Version 
         | 
| 23 | 
            -
                    version: 2.5.1
         | 
| 24 | 
            -
                version: 
         | 
| 19 | 
            +
            dependencies: []
         | 
| 20 | 
            +
             | 
| 25 21 | 
             
            description: |-
         | 
| 26 22 | 
             
              HFLR -- Hierarchical Fixed Length Records
         | 
| 27 23 |  | 
| @@ -37,71 +33,57 @@ executables: [] | |
| 37 33 | 
             
            extensions: []
         | 
| 38 34 |  | 
| 39 35 | 
             
            extra_rdoc_files: 
         | 
| 40 | 
            -
            - History.txt
         | 
| 41 | 
            -
            - README.txt
         | 
| 36 | 
            +
              - History.txt
         | 
| 37 | 
            +
              - README.txt
         | 
| 42 38 | 
             
            files: 
         | 
| 43 | 
            -
            - History.txt
         | 
| 44 | 
            -
            - README.txt
         | 
| 45 | 
            -
            -  | 
| 46 | 
            -
            - hflr. | 
| 47 | 
            -
            - lib/hflr.rb
         | 
| 48 | 
            -
            - lib/hflr/ | 
| 49 | 
            -
            - lib/hflr/ | 
| 50 | 
            -
            -  | 
| 51 | 
            -
            -  | 
| 52 | 
            -
            -  | 
| 53 | 
            -
            -  | 
| 54 | 
            -
            -  | 
| 55 | 
            -
            -  | 
| 56 | 
            -
            -  | 
| 57 | 
            -
            -  | 
| 58 | 
            -
            -  | 
| 59 | 
            -
            -  | 
| 60 | 
            -
            -  | 
| 61 | 
            -
            - tasks/spec.rake
         | 
| 62 | 
            -
            - tasks/svn.rake
         | 
| 63 | 
            -
            - tasks/test.rake
         | 
| 64 | 
            -
            - tasks/zentest.rake
         | 
| 65 | 
            -
            - test/customer_orders.dat
         | 
| 66 | 
            -
            - test/customers.dat
         | 
| 67 | 
            -
            - test/examples.rb
         | 
| 68 | 
            -
            - test/flrfile_test.rb
         | 
| 69 | 
            -
            - test/record_template_test.rb
         | 
| 70 | 
            -
            - test/sample.dat
         | 
| 71 | 
            -
            - test/sample2_out.dat
         | 
| 72 | 
            -
            - test/sample_activities.dat
         | 
| 73 | 
            -
            - test/sample_out.dat
         | 
| 74 | 
            -
            - test/test_helper.rb
         | 
| 75 | 
            -
            - test/test_hflr.rb
         | 
| 39 | 
            +
              - History.txt
         | 
| 40 | 
            +
              - README.txt
         | 
| 41 | 
            +
              - hflr.gemspec
         | 
| 42 | 
            +
              - lib/hflr.rb
         | 
| 43 | 
            +
              - lib/hflr/fl_record_file.rb
         | 
| 44 | 
            +
              - lib/hflr/hflr.rb
         | 
| 45 | 
            +
              - lib/hflr/record_template.rb
         | 
| 46 | 
            +
              - test/customer_orders.dat
         | 
| 47 | 
            +
              - test/customers.dat
         | 
| 48 | 
            +
              - test/examples.rb
         | 
| 49 | 
            +
              - test/flrfile_test.rb
         | 
| 50 | 
            +
              - test/record_template_test.rb
         | 
| 51 | 
            +
              - test/sample.dat
         | 
| 52 | 
            +
              - test/sample2_out.dat
         | 
| 53 | 
            +
              - test/sample_activities.dat
         | 
| 54 | 
            +
              - test/sample_out.dat
         | 
| 55 | 
            +
              - test/test_helper.rb
         | 
| 56 | 
            +
              - test/test_hflr.rb
         | 
| 76 57 | 
             
            has_rdoc: true
         | 
| 77 | 
            -
            homepage:  | 
| 58 | 
            +
            homepage: 
         | 
| 78 59 | 
             
            licenses: []
         | 
| 79 60 |  | 
| 80 61 | 
             
            post_install_message: 
         | 
| 81 | 
            -
            rdoc_options: 
         | 
| 82 | 
            -
             | 
| 83 | 
            -
            - README.txt
         | 
| 62 | 
            +
            rdoc_options: []
         | 
| 63 | 
            +
             | 
| 84 64 | 
             
            require_paths: 
         | 
| 85 | 
            -
            - lib
         | 
| 65 | 
            +
              - lib
         | 
| 86 66 | 
             
            required_ruby_version: !ruby/object:Gem::Requirement 
         | 
| 87 67 | 
             
              requirements: 
         | 
| 88 | 
            -
             | 
| 89 | 
            -
             | 
| 90 | 
            -
             | 
| 91 | 
            -
             | 
| 68 | 
            +
                - - ">="
         | 
| 69 | 
            +
                  - !ruby/object:Gem::Version 
         | 
| 70 | 
            +
                    segments: 
         | 
| 71 | 
            +
                      - 0
         | 
| 72 | 
            +
                    version: "0"
         | 
| 92 73 | 
             
            required_rubygems_version: !ruby/object:Gem::Requirement 
         | 
| 93 74 | 
             
              requirements: 
         | 
| 94 | 
            -
             | 
| 95 | 
            -
             | 
| 96 | 
            -
             | 
| 97 | 
            -
             | 
| 75 | 
            +
                - - ">="
         | 
| 76 | 
            +
                  - !ruby/object:Gem::Version 
         | 
| 77 | 
            +
                    segments: 
         | 
| 78 | 
            +
                      - 0
         | 
| 79 | 
            +
                    version: "0"
         | 
| 98 80 | 
             
            requirements: []
         | 
| 99 81 |  | 
| 100 | 
            -
            rubyforge_project:  | 
| 101 | 
            -
            rubygems_version: 1.3. | 
| 82 | 
            +
            rubyforge_project: 
         | 
| 83 | 
            +
            rubygems_version: 1.3.6
         | 
| 102 84 | 
             
            signing_key: 
         | 
| 103 85 | 
             
            specification_version: 3
         | 
| 104 86 | 
             
            summary: HFLR -- Hierarchical Fixed Length Records  Allows you to read and write files of fixed width records when the file contains one or more than one type of record
         | 
| 105 87 | 
             
            test_files: 
         | 
| 106 | 
            -
            - test/test_hflr.rb
         | 
| 107 | 
            -
            - test/test_helper.rb
         | 
| 88 | 
            +
              - test/test_hflr.rb
         | 
| 89 | 
            +
              - test/test_helper.rb
         | 
    
        data/Rakefile
    DELETED
    
    | @@ -1,31 +0,0 @@ | |
| 1 | 
            -
            # Look in the tasks/setup.rb file for the various options that can be
         | 
| 2 | 
            -
            # configured in this Rakefile. The .rake files in the tasks directory
         | 
| 3 | 
            -
            # are where the options are used.
         | 
| 4 | 
            -
             | 
| 5 | 
            -
            begin
         | 
| 6 | 
            -
              require 'bones'
         | 
| 7 | 
            -
              Bones.setup
         | 
| 8 | 
            -
            rescue LoadError
         | 
| 9 | 
            -
             | 
| 10 | 
            -
              begin
         | 
| 11 | 
            -
                load 'tasks/setup.rb'
         | 
| 12 | 
            -
              rescue LoadError
         | 
| 13 | 
            -
                raise RuntimeError, '### please install the "bones" gem ###'
         | 
| 14 | 
            -
              end
         | 
| 15 | 
            -
            end
         | 
| 16 | 
            -
             | 
| 17 | 
            -
            ensure_in_path 'lib'
         | 
| 18 | 
            -
            require 'hflr'
         | 
| 19 | 
            -
             | 
| 20 | 
            -
            task :default => 'spec:run'
         | 
| 21 | 
            -
             | 
| 22 | 
            -
            PROJ.name = 'hflr'
         | 
| 23 | 
            -
            PROJ.authors = 'Colin Davis'
         | 
| 24 | 
            -
            PROJ.email = 'colin.c.davis@gmail.com'
         | 
| 25 | 
            -
            PROJ.url = 'http://ruff.rubyforge.org'
         | 
| 26 | 
            -
            PROJ.version = Hflr::VERSION
         | 
| 27 | 
            -
            PROJ.rubyforge.name = 'hflr'
         | 
| 28 | 
            -
             | 
| 29 | 
            -
            PROJ.spec.opts << '--color'
         | 
| 30 | 
            -
             | 
| 31 | 
            -
            # EOF
         | 
    
        data/sample2_out.dat
    DELETED
    
    | @@ -1 +0,0 @@ | |
| 1 | 
            -
            joe                      025
         | 
    
        data/tasks/ann.rake
    DELETED
    
    | @@ -1,80 +0,0 @@ | |
| 1 | 
            -
             | 
| 2 | 
            -
            begin
         | 
| 3 | 
            -
              require 'bones/smtp_tls'
         | 
| 4 | 
            -
            rescue LoadError
         | 
| 5 | 
            -
              require 'net/smtp'
         | 
| 6 | 
            -
            end
         | 
| 7 | 
            -
            require 'time'
         | 
| 8 | 
            -
             | 
| 9 | 
            -
            namespace :ann do
         | 
| 10 | 
            -
             | 
| 11 | 
            -
              # A prerequisites task that all other tasks depend upon
         | 
| 12 | 
            -
              task :prereqs
         | 
| 13 | 
            -
             | 
| 14 | 
            -
              file PROJ.ann.file do
         | 
| 15 | 
            -
                ann = PROJ.ann
         | 
| 16 | 
            -
                puts "Generating #{ann.file}"
         | 
| 17 | 
            -
                File.open(ann.file,'w') do |fd|
         | 
| 18 | 
            -
                  fd.puts("#{PROJ.name} version #{PROJ.version}")
         | 
| 19 | 
            -
                  fd.puts("    by #{Array(PROJ.authors).first}") if PROJ.authors
         | 
| 20 | 
            -
                  fd.puts("    #{PROJ.url}") if PROJ.url.valid?
         | 
| 21 | 
            -
                  fd.puts("    (the \"#{PROJ.release_name}\" release)") if PROJ.release_name
         | 
| 22 | 
            -
                  fd.puts
         | 
| 23 | 
            -
                  fd.puts("== DESCRIPTION")
         | 
| 24 | 
            -
                  fd.puts
         | 
| 25 | 
            -
                  fd.puts(PROJ.description)
         | 
| 26 | 
            -
                  fd.puts
         | 
| 27 | 
            -
                  fd.puts(PROJ.changes.sub(%r/^.*$/, '== CHANGES'))
         | 
| 28 | 
            -
                  fd.puts
         | 
| 29 | 
            -
                  ann.paragraphs.each do |p|
         | 
| 30 | 
            -
                    fd.puts "== #{p.upcase}"
         | 
| 31 | 
            -
                    fd.puts
         | 
| 32 | 
            -
                    fd.puts paragraphs_of(PROJ.readme_file, p).join("\n\n")
         | 
| 33 | 
            -
                    fd.puts
         | 
| 34 | 
            -
                  end
         | 
| 35 | 
            -
                  fd.puts ann.text if ann.text
         | 
| 36 | 
            -
                end
         | 
| 37 | 
            -
              end
         | 
| 38 | 
            -
             | 
| 39 | 
            -
              desc "Create an announcement file"
         | 
| 40 | 
            -
              task :announcement => ['ann:prereqs', PROJ.ann.file]
         | 
| 41 | 
            -
             | 
| 42 | 
            -
              desc "Send an email announcement"
         | 
| 43 | 
            -
              task :email => ['ann:prereqs', PROJ.ann.file] do
         | 
| 44 | 
            -
                ann = PROJ.ann
         | 
| 45 | 
            -
                from = ann.email[:from] || Array(PROJ.authors).first || PROJ.email
         | 
| 46 | 
            -
                to   = Array(ann.email[:to])
         | 
| 47 | 
            -
             | 
| 48 | 
            -
                ### build a mail header for RFC 822
         | 
| 49 | 
            -
                rfc822msg =  "From: #{from}\n"
         | 
| 50 | 
            -
                rfc822msg << "To: #{to.join(',')}\n"
         | 
| 51 | 
            -
                rfc822msg << "Subject: [ANN] #{PROJ.name} #{PROJ.version}"
         | 
| 52 | 
            -
                rfc822msg << " (#{PROJ.release_name})" if PROJ.release_name
         | 
| 53 | 
            -
                rfc822msg << "\n"
         | 
| 54 | 
            -
                rfc822msg << "Date: #{Time.new.rfc822}\n"
         | 
| 55 | 
            -
                rfc822msg << "Message-Id: "
         | 
| 56 | 
            -
                rfc822msg << "<#{"%.8f" % Time.now.to_f}@#{ann.email[:domain]}>\n\n"
         | 
| 57 | 
            -
                rfc822msg << File.read(ann.file)
         | 
| 58 | 
            -
             | 
| 59 | 
            -
                params = [:server, :port, :domain, :acct, :passwd, :authtype].map do |key|
         | 
| 60 | 
            -
                  ann.email[key]
         | 
| 61 | 
            -
                end
         | 
| 62 | 
            -
             | 
| 63 | 
            -
                params[3] = PROJ.email if params[3].nil?
         | 
| 64 | 
            -
             | 
| 65 | 
            -
                if params[4].nil?
         | 
| 66 | 
            -
                  STDOUT.write "Please enter your e-mail password (#{params[3]}): "
         | 
| 67 | 
            -
                  params[4] = STDIN.gets.chomp
         | 
| 68 | 
            -
                end
         | 
| 69 | 
            -
             | 
| 70 | 
            -
                ### send email
         | 
| 71 | 
            -
                Net::SMTP.start(*params) {|smtp| smtp.sendmail(rfc822msg, from, to)}
         | 
| 72 | 
            -
              end
         | 
| 73 | 
            -
            end  # namespace :ann
         | 
| 74 | 
            -
             | 
| 75 | 
            -
            desc 'Alias to ann:announcement'
         | 
| 76 | 
            -
            task :ann => 'ann:announcement'
         | 
| 77 | 
            -
             | 
| 78 | 
            -
            CLOBBER << PROJ.ann.file
         | 
| 79 | 
            -
             | 
| 80 | 
            -
            # EOF
         | 
    
        data/tasks/bones.rake
    DELETED
    
    | @@ -1,20 +0,0 @@ | |
| 1 | 
            -
             | 
| 2 | 
            -
            if HAVE_BONES
         | 
| 3 | 
            -
             | 
| 4 | 
            -
            namespace :bones do
         | 
| 5 | 
            -
             | 
| 6 | 
            -
              desc 'Show the PROJ open struct'
         | 
| 7 | 
            -
              task :debug do |t|
         | 
| 8 | 
            -
                atr = if t.application.top_level_tasks.length == 2
         | 
| 9 | 
            -
                  t.application.top_level_tasks.pop
         | 
| 10 | 
            -
                end
         | 
| 11 | 
            -
             | 
| 12 | 
            -
                if atr then Bones::Debug.show_attr(PROJ, atr)
         | 
| 13 | 
            -
                else Bones::Debug.show PROJ end
         | 
| 14 | 
            -
              end
         | 
| 15 | 
            -
             | 
| 16 | 
            -
            end  # namespace :bones
         | 
| 17 | 
            -
             | 
| 18 | 
            -
            end  # HAVE_BONES
         | 
| 19 | 
            -
             | 
| 20 | 
            -
            # EOF
         |