mta_status 0.0.0
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 +7 -0
- data/bin/mta_status +5 -0
- data/config/environment.rb +8 -0
- data/lib/mta_status.rb +79 -0
- metadata +75 -0
    
        checksums.yaml
    ADDED
    
    | @@ -0,0 +1,7 @@ | |
| 1 | 
            +
            ---
         | 
| 2 | 
            +
            SHA1:
         | 
| 3 | 
            +
              metadata.gz: 11f214c07be912e2f83a353ea87104e492eb6134
         | 
| 4 | 
            +
              data.tar.gz: 3dfddadfebe01641beda864dffdf9144281c1adc
         | 
| 5 | 
            +
            SHA512:
         | 
| 6 | 
            +
              metadata.gz: 32829e025b2ca7c4e98ab7f56829f83e7c76dd122c3d58829f9a86a820604d948fae4a8893c6dc79eadb0cc020fa9927df91d2c5e8c0a194cc83e54111a77d10
         | 
| 7 | 
            +
              data.tar.gz: 4a2e844936c5874de836d09515d38ea4e4aff7366160757e217aa74cfd594c6c1d032985e51dd91e019e1da131d0ddb483eea5b60d9ee6dc56e3d2a41e0ea4d8
         | 
    
        data/bin/mta_status
    ADDED
    
    
    
        data/lib/mta_status.rb
    ADDED
    
    | @@ -0,0 +1,79 @@ | |
| 1 | 
            +
            require_relative '../config/environment.rb'
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            class MTAStatus
         | 
| 4 | 
            +
             | 
| 5 | 
            +
              attr_accessor :doc
         | 
| 6 | 
            +
             | 
| 7 | 
            +
              SUBWAY = ["subway", "irt", "ind", "bmt", "tube", "train", "underground"]
         | 
| 8 | 
            +
              LIRR = ["lirr", "long", "island", "rail", "road"]
         | 
| 9 | 
            +
              METRO_NORTH = ["metro-north", "metro", "north"]
         | 
| 10 | 
            +
             | 
| 11 | 
            +
              def initialize(service)
         | 
| 12 | 
            +
                if service!=nil
         | 
| 13 | 
            +
                  @service = service.downcase
         | 
| 14 | 
            +
                else
         | 
| 15 | 
            +
                  @service = "subway"
         | 
| 16 | 
            +
                end   
         | 
| 17 | 
            +
                @doc  = Nokogiri::HTML(open(MTA))
         | 
| 18 | 
            +
                run
         | 
| 19 | 
            +
              end
         | 
| 20 | 
            +
             | 
| 21 | 
            +
              def name
         | 
| 22 | 
            +
                @doc.xpath("//name").collect do |name|
         | 
| 23 | 
            +
                  name.children.text
         | 
| 24 | 
            +
                end
         | 
| 25 | 
            +
              end
         | 
| 26 | 
            +
             | 
| 27 | 
            +
              def status
         | 
| 28 | 
            +
                @doc.xpath("//status").collect do |s|
         | 
| 29 | 
            +
                  s.children.text
         | 
| 30 | 
            +
                end
         | 
| 31 | 
            +
              end
         | 
| 32 | 
            +
             | 
| 33 | 
            +
              def note
         | 
| 34 | 
            +
                @doc.xpath("//text").collect do |note|
         | 
| 35 | 
            +
                  note.children.text
         | 
| 36 | 
            +
                end
         | 
| 37 | 
            +
              end
         | 
| 38 | 
            +
             | 
| 39 | 
            +
              def output
         | 
| 40 | 
            +
                name.zip(status)
         | 
| 41 | 
            +
              end
         | 
| 42 | 
            +
             | 
| 43 | 
            +
              def subway
         | 
| 44 | 
            +
                output[0..10]
         | 
| 45 | 
            +
              end
         | 
| 46 | 
            +
             | 
| 47 | 
            +
              def lirr
         | 
| 48 | 
            +
                output[30..40]
         | 
| 49 | 
            +
              end
         | 
| 50 | 
            +
             | 
| 51 | 
            +
              def metro_north
         | 
| 52 | 
            +
                output[41..50]
         | 
| 53 | 
            +
              end
         | 
| 54 | 
            +
             | 
| 55 | 
            +
              def service_choice
         | 
| 56 | 
            +
                call = []
         | 
| 57 | 
            +
                if SUBWAY.include?(@service)
         | 
| 58 | 
            +
                  call.concat(subway)
         | 
| 59 | 
            +
                elsif LIRR.include?(@service)
         | 
| 60 | 
            +
                  call.concat(lirr)
         | 
| 61 | 
            +
                elsif METRO_NORTH.include?(@service)
         | 
| 62 | 
            +
                  call.concat(metro_north)
         | 
| 63 | 
            +
                end
         | 
| 64 | 
            +
              end
         | 
| 65 | 
            +
             | 
| 66 | 
            +
              def run
         | 
| 67 | 
            +
                puts
         | 
| 68 | 
            +
                puts "############### Status ###############"
         | 
| 69 | 
            +
                service_choice.each do |line_pair|
         | 
| 70 | 
            +
                  if line_pair[1]!="GOOD SERVICE"
         | 
| 71 | 
            +
                    puts "#{line_pair[0].bold}: #{line_pair[1].red}"
         | 
| 72 | 
            +
                  else
         | 
| 73 | 
            +
                    puts "#{line_pair[0]}: #{line_pair[1].green}"
         | 
| 74 | 
            +
                  end
         | 
| 75 | 
            +
                end
         | 
| 76 | 
            +
                puts "######################################"
         | 
| 77 | 
            +
              end
         | 
| 78 | 
            +
             | 
| 79 | 
            +
            end
         | 
    
        metadata
    ADDED
    
    | @@ -0,0 +1,75 @@ | |
| 1 | 
            +
            --- !ruby/object:Gem::Specification
         | 
| 2 | 
            +
            name: mta_status
         | 
| 3 | 
            +
            version: !ruby/object:Gem::Version
         | 
| 4 | 
            +
              version: 0.0.0
         | 
| 5 | 
            +
            platform: ruby
         | 
| 6 | 
            +
            authors:
         | 
| 7 | 
            +
            - John Richardson
         | 
| 8 | 
            +
            autorequire: 
         | 
| 9 | 
            +
            bindir: bin
         | 
| 10 | 
            +
            cert_chain: []
         | 
| 11 | 
            +
            date: 2010-10-21 00:00:00.000000000 Z
         | 
| 12 | 
            +
            dependencies:
         | 
| 13 | 
            +
            - !ruby/object:Gem::Dependency
         | 
| 14 | 
            +
              name: nokogiri
         | 
| 15 | 
            +
              requirement: !ruby/object:Gem::Requirement
         | 
| 16 | 
            +
                requirements:
         | 
| 17 | 
            +
                - - '>='
         | 
| 18 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 19 | 
            +
                    version: '0'
         | 
| 20 | 
            +
              type: :runtime
         | 
| 21 | 
            +
              prerelease: false
         | 
| 22 | 
            +
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 23 | 
            +
                requirements:
         | 
| 24 | 
            +
                - - '>='
         | 
| 25 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 26 | 
            +
                    version: '0'
         | 
| 27 | 
            +
            - !ruby/object:Gem::Dependency
         | 
| 28 | 
            +
              name: colorize
         | 
| 29 | 
            +
              requirement: !ruby/object:Gem::Requirement
         | 
| 30 | 
            +
                requirements:
         | 
| 31 | 
            +
                - - '>='
         | 
| 32 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 33 | 
            +
                    version: '0'
         | 
| 34 | 
            +
              type: :runtime
         | 
| 35 | 
            +
              prerelease: false
         | 
| 36 | 
            +
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 37 | 
            +
                requirements:
         | 
| 38 | 
            +
                - - '>='
         | 
| 39 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 40 | 
            +
                    version: '0'
         | 
| 41 | 
            +
            description: MTA train line status from your terminal
         | 
| 42 | 
            +
            email: richardsonjm@gmail.com
         | 
| 43 | 
            +
            executables:
         | 
| 44 | 
            +
            - mta_status
         | 
| 45 | 
            +
            extensions: []
         | 
| 46 | 
            +
            extra_rdoc_files: []
         | 
| 47 | 
            +
            files:
         | 
| 48 | 
            +
            - config/environment.rb
         | 
| 49 | 
            +
            - lib/mta_status.rb
         | 
| 50 | 
            +
            - bin/mta_status
         | 
| 51 | 
            +
            homepage: http://www.github.com/richardsonjm/mta_status
         | 
| 52 | 
            +
            licenses:
         | 
| 53 | 
            +
            - MIT
         | 
| 54 | 
            +
            metadata: {}
         | 
| 55 | 
            +
            post_install_message: 
         | 
| 56 | 
            +
            rdoc_options: []
         | 
| 57 | 
            +
            require_paths:
         | 
| 58 | 
            +
            - lib
         | 
| 59 | 
            +
            required_ruby_version: !ruby/object:Gem::Requirement
         | 
| 60 | 
            +
              requirements:
         | 
| 61 | 
            +
              - - '>='
         | 
| 62 | 
            +
                - !ruby/object:Gem::Version
         | 
| 63 | 
            +
                  version: '0'
         | 
| 64 | 
            +
            required_rubygems_version: !ruby/object:Gem::Requirement
         | 
| 65 | 
            +
              requirements:
         | 
| 66 | 
            +
              - - '>='
         | 
| 67 | 
            +
                - !ruby/object:Gem::Version
         | 
| 68 | 
            +
                  version: '0'
         | 
| 69 | 
            +
            requirements: []
         | 
| 70 | 
            +
            rubyforge_project: 
         | 
| 71 | 
            +
            rubygems_version: 2.0.6
         | 
| 72 | 
            +
            signing_key: 
         | 
| 73 | 
            +
            specification_version: 4
         | 
| 74 | 
            +
            summary: MTA status
         | 
| 75 | 
            +
            test_files: []
         |