xdg 0.4.0 → 0.5.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.
- data/CHANGES +39 -0
- data/MANIFEST +1 -1
- data/README +10 -6
- data/RELEASE +20 -12
- data/VERSION +1 -1
- data/lib/xdg.rb +61 -25
- data/test/test_xdg.rb +8 -8
- metadata +4 -3
- data/meta/releases +0 -1
    
        data/CHANGES
    ADDED
    
    | @@ -0,0 +1,39 @@ | |
| 1 | 
            +
            == 0.0.4 / 2008-10-26
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            * 9 Other Enhancements
         | 
| 4 | 
            +
             | 
| 5 | 
            +
                * removed xdg_ prefixes and replaced _file methods with _find and _glob methods (#d414dfa6fef6ec382c76689116b4483cbbcafd72)
         | 
| 6 | 
            +
                * prepare for v0.4 release (#c634ffd603b0859027dd4bfd9c1c57b87d634d9c)
         | 
| 7 | 
            +
                * remove some old commented-out code (#f62bac03f2ffe31e8a95d841be234311f7cfbff0)
         | 
| 8 | 
            +
                * fixed data_find and data_glob (#8107b5b5b8893d040c6bd60ae9a0d65d6885ae84)
         | 
| 9 | 
            +
                * Update RELEASE file. (#722f7600f403c39792c3df91ad789c5d3ae13473)
         | 
| 10 | 
            +
                * updated documentation for 0.4 release (#c535b36186a6a3d2b1ea5766a07e541ec90a75d1)
         | 
| 11 | 
            +
                * added MANIFEST to .gitignore (#723be0082d9a1e9a0f579aa094267027e1708730)
         | 
| 12 | 
            +
                * correction or RELEASE (#0f3bd5f80c241704b338037b1bb66b0fbd8e597b)
         | 
| 13 | 
            +
                * Fixed plural in RELEASE file. (#ccdf281610d5339aa1bff32be34c8369f204e463)
         | 
| 14 | 
            +
             | 
| 15 | 
            +
             | 
| 16 | 
            +
            == 0.0.3 / 2008-10-11
         | 
| 17 | 
            +
             | 
| 18 | 
            +
            * 5 Other Enhancements
         | 
| 19 | 
            +
             | 
| 20 | 
            +
                * removed xdg_ prefix from module methods (#240e88d385ee1b7e063e8cd87e22ce8fb085afd8)
         | 
| 21 | 
            +
                * moved web/index.html to doc directory (#e61b13e66eefb16566ea5f1ce3723dbfda8369dc)
         | 
| 22 | 
            +
                * updated reap serives (#5cfaf1f6ad47ecc518047053902ef4e092c69891)
         | 
| 23 | 
            +
                * prepare for next release (#7566509dd82d9cfe3bf28e32bdb68304429ebe93)
         | 
| 24 | 
            +
                * fixed issue of xdg_ prefix still being used internally (#ad95493af4413e864cfa2ef2f982c7f48f371473)
         | 
| 25 | 
            +
             | 
| 26 | 
            +
             | 
| 27 | 
            +
            == 0.0.1 / 2008-09-27
         | 
| 28 | 
            +
             | 
| 29 | 
            +
            * 1 Major Enhancements
         | 
| 30 | 
            +
             | 
| 31 | 
            +
                * Started project.  (#10ca99f20bd90399220a68939f4a04677ff22402)
         | 
| 32 | 
            +
             | 
| 33 | 
            +
            * 4 Other Enhancements
         | 
| 34 | 
            +
             | 
| 35 | 
            +
                * added gitignore (#8d1385c2bcc0acbdb5ed5e014c977213caf7d4a6)
         | 
| 36 | 
            +
                * Folio namespace is not used. (#577aca3700f5cc179a343068863a0a964133159e)
         | 
| 37 | 
            +
                * added website (#067510f4af2c7deb3c3ac27832e0980b17af1695)
         | 
| 38 | 
            +
                * VERSION file has been added. (#c76940fd4e79270d247a881a2a0e58a2f2fa9bdf)
         | 
| 39 | 
            +
             | 
    
        data/MANIFEST
    CHANGED
    
    | @@ -9,6 +9,7 @@ test/fakeroot/etc | |
| 9 9 | 
             
            test/fakeroot/etc/xdg
         | 
| 10 10 | 
             
            test/fakeroot/etc/xdg/bar.config
         | 
| 11 11 | 
             
            test/test_xdg.rb
         | 
| 12 | 
            +
            CHANGES
         | 
| 12 13 | 
             
            RELEASE
         | 
| 13 14 | 
             
            README
         | 
| 14 15 | 
             
            HISTORY
         | 
| @@ -16,7 +17,6 @@ meta | |
| 16 17 | 
             
            meta/homepage
         | 
| 17 18 | 
             
            meta/summary
         | 
| 18 19 | 
             
            meta/abstract
         | 
| 19 | 
            -
            meta/releases
         | 
| 20 20 | 
             
            meta/title
         | 
| 21 21 | 
             
            meta/authors
         | 
| 22 22 | 
             
            meta/contact
         | 
    
        data/README
    CHANGED
    
    | @@ -19,13 +19,17 @@ XDG is a module with a small set of easy to use methods: | |
| 19 19 |  | 
| 20 20 | 
             
              XDG.config_home
         | 
| 21 21 | 
             
              XDG.config_dirs
         | 
| 22 | 
            +
              XDG.config_find(pattern){ |path| ... }
         | 
| 23 | 
            +
              XDG.config_select(pattern){ |path| ... }
         | 
| 24 | 
            +
             | 
| 22 25 | 
             
              XDG.data_home
         | 
| 23 26 | 
             
              XDG.data_dirs
         | 
| 24 | 
            -
              XDG. | 
| 27 | 
            +
              XDG.data_find(pattern){ |path| ... }
         | 
| 28 | 
            +
              XDG.data_select(pattern){ |path| ... }
         | 
| 25 29 |  | 
| 26 | 
            -
              XDG. | 
| 27 | 
            -
              XDG. | 
| 28 | 
            -
              XDG. | 
| 30 | 
            +
              XDG.cache_home
         | 
| 31 | 
            +
              XDG.cache_find(pattern){ |path| ... }
         | 
| 32 | 
            +
              XDG.cache_select(pattern){ |path| ... }
         | 
| 29 33 |  | 
| 30 34 | 
             
              XDG.config_work
         | 
| 31 35 | 
             
              XDG.data_work
         | 
| @@ -43,8 +47,8 @@ Using RubyGems: | |
| 43 47 | 
             
            Installing the tarball requires Ruby Setup
         | 
| 44 48 | 
             
            (see http://setup.rubyforge.org).
         | 
| 45 49 |  | 
| 46 | 
            -
              $ tar -xvzf xdg-0. | 
| 47 | 
            -
              $ cd xdg-0. | 
| 50 | 
            +
              $ tar -xvzf xdg-0.5.0
         | 
| 51 | 
            +
              $ cd xdg-0.5.0
         | 
| 48 52 | 
             
              $ sudo setup.rb all
         | 
| 49 53 |  | 
| 50 54 | 
             
            == Development
         | 
    
        data/RELEASE
    CHANGED
    
    | @@ -1,21 +1,29 @@ | |
| 1 | 
            -
            = XDG 0. | 
| 1 | 
            +
            = XDG 0.5
         | 
| 2 2 |  | 
| 3 3 | 
             
              http://xdg.rubyforge.org
         | 
| 4 4 |  | 
| 5 | 
            -
             | 
| 6 | 
            -
             | 
| 5 | 
            +
            XDG provides a module for supporting the XDG Base Directory
         | 
| 6 | 
            +
            Standard[1].
         | 
| 7 7 |  | 
| 8 | 
            -
             | 
| 9 | 
            -
             | 
| 10 | 
            -
             | 
| 8 | 
            +
            If your program utilizes user or system-wide support files
         | 
| 9 | 
            +
            (eg. configuration files), you owe it to yourself to checkout
         | 
| 10 | 
            +
            the XDG standard.
         | 
| 11 11 |  | 
| 12 | 
            -
             | 
| 13 | 
            -
             | 
| 14 | 
            -
             | 
| 12 | 
            +
            In this release, _glob methods were renamed to _select and now
         | 
| 13 | 
            +
            can take a selection block in addition to, or as opposed to,
         | 
| 14 | 
            +
            the glob pattern argument.
         | 
| 15 15 |  | 
| 16 | 
            +
            What's next? The API should be stable now. I do not forsee
         | 
| 17 | 
            +
            and reasons for it to change. In the future, I may add some
         | 
| 18 | 
            +
            additonal ruby-esque features, but that should be purely
         | 
| 19 | 
            +
            in addition to what is already there. If all this holds true
         | 
| 20 | 
            +
            for a hwile a 1.0 release will be forth-coming.
         | 
| 16 21 |  | 
| 17 | 
            -
             | 
| 22 | 
            +
            [1]http://standards.freedesktop.org/basedir-spec/basedir-spec-0.6.html 
         | 
| 18 23 |  | 
| 19 | 
            -
             | 
| 20 | 
            -
             | 
| 24 | 
            +
            ---
         | 
| 25 | 
            +
             | 
| 26 | 
            +
            ### 0.5.0 / 2008-10-28
         | 
| 27 | 
            +
             | 
| 28 | 
            +
            * Renamed *_glob methods to *_select, and added block option.
         | 
| 21 29 |  | 
    
        data/VERSION
    CHANGED
    
    | @@ -1 +1 @@ | |
| 1 | 
            -
            xdg 0. | 
| 1 | 
            +
            xdg 0.5.0 beta (2008-10-26)
         | 
    
        data/lib/xdg.rb
    CHANGED
    
    | @@ -1,8 +1,3 @@ | |
| 1 | 
            -
            # :Title: XDG
         | 
| 2 | 
            -
            # :Author: &trans;
         | 
| 3 | 
            -
            # :Copyright: (c)2008 Tiger Ops
         | 
| 4 | 
            -
            # :License: GPLv3
         | 
| 5 | 
            -
             | 
| 6 1 | 
             
            # = XDG Base Directory Standard
         | 
| 7 2 | 
             
            #
         | 
| 8 3 | 
             
            # This provides a conveient library for conforming to the
         | 
| @@ -28,13 +23,14 @@ | |
| 28 23 | 
             
            # files. Like var/ in FHS.
         | 
| 29 24 | 
             
            #
         | 
| 30 25 | 
             
            # This module returns paths as strings.
         | 
| 31 | 
            -
             | 
| 26 | 
            +
            #
         | 
| 32 27 | 
             
            module XDG
         | 
| 33 28 |  | 
| 34 29 | 
             
              extend self    #module_function
         | 
| 35 30 |  | 
| 31 | 
            +
              # Returns user's home directory.
         | 
| 36 32 | 
             
              def home
         | 
| 37 | 
            -
                 | 
| 33 | 
            +
                File.expand_path('~') # ENV['HOME']
         | 
| 38 34 | 
             
              end
         | 
| 39 35 |  | 
| 40 36 | 
             
              # Location of user's personal config directory.
         | 
| @@ -77,12 +73,31 @@ module XDG | |
| 77 73 | 
             
              end
         | 
| 78 74 |  | 
| 79 75 | 
             
              # Find a file or directory in data dirs.
         | 
| 80 | 
            -
               | 
| 81 | 
            -
             | 
| 76 | 
            +
              #
         | 
| 77 | 
            +
              # See: +data_select+.
         | 
| 78 | 
            +
              #
         | 
| 79 | 
            +
              def data_find(*glob_and_flags, &block)
         | 
| 80 | 
            +
                data_select(*glob_and_flags, &block).first
         | 
| 82 81 | 
             
              end
         | 
| 83 82 |  | 
| 84 | 
            -
               | 
| 83 | 
            +
              # Return array of matching files or directories
         | 
| 84 | 
            +
              # in any of the data locations.
         | 
| 85 | 
            +
              #
         | 
| 86 | 
            +
              # This starts with the user's home directory
         | 
| 87 | 
            +
              # and then searches system directories.
         | 
| 88 | 
            +
              #
         | 
| 89 | 
            +
              # String parameters are joined into a pathname
         | 
| 90 | 
            +
              # while Integers and Symbols treated as flags.
         | 
| 91 | 
            +
              #
         | 
| 92 | 
            +
              # For example, the following are equivalent:
         | 
| 93 | 
            +
              #
         | 
| 94 | 
            +
              #   XDG.data_select('stick/units', File::FNM_CASEFOLD)
         | 
| 95 | 
            +
              #
         | 
| 96 | 
            +
              #   XDG.data_select('stick', 'uits', :casefold)
         | 
| 97 | 
            +
              #
         | 
| 98 | 
            +
              def data_select(*glob_and_flags, &block)
         | 
| 85 99 | 
             
                glob, flags = *glob_and_flags.partition{ |e| String===e }
         | 
| 100 | 
            +
                glob = ['**/*'] if glob.empty?
         | 
| 86 101 | 
             
                flag = flags.inject(0) do |m, f|
         | 
| 87 102 | 
             
                  if Symbol === f
         | 
| 88 103 | 
             
                    m + File::const_get("FNM_#{f.to_s.upcase}")
         | 
| @@ -93,7 +108,11 @@ module XDG | |
| 93 108 | 
             
                find = []
         | 
| 94 109 | 
             
                [data_home, *data_dirs].each do |dir|
         | 
| 95 110 | 
             
                  path = File.join(dir, *glob)
         | 
| 96 | 
            -
                   | 
| 111 | 
            +
                  if block_given?
         | 
| 112 | 
            +
                    find.concat(Dir.glob(path, flag).select(&block))
         | 
| 113 | 
            +
                  else
         | 
| 114 | 
            +
                    find.concat(Dir.glob(path, flag))
         | 
| 115 | 
            +
                  end
         | 
| 97 116 | 
             
                end
         | 
| 98 117 | 
             
                find
         | 
| 99 118 | 
             
              end
         | 
| @@ -101,9 +120,10 @@ module XDG | |
| 101 120 | 
             
              # Return the fist matching file or directory
         | 
| 102 121 | 
             
              # from the config locations.
         | 
| 103 122 | 
             
              #
         | 
| 104 | 
            -
              # See + | 
| 105 | 
            -
               | 
| 106 | 
            -
             | 
| 123 | 
            +
              # See: +config_select+.
         | 
| 124 | 
            +
              #
         | 
| 125 | 
            +
              def config_find(*glob_and_flags, &block)
         | 
| 126 | 
            +
                config_select(*glob_and_flags, &block).first
         | 
| 107 127 | 
             
              end
         | 
| 108 128 |  | 
| 109 129 | 
             
              # Return array of matching files or directories
         | 
| @@ -117,12 +137,13 @@ module XDG | |
| 117 137 | 
             
              #
         | 
| 118 138 | 
             
              # For example, the following are equivalent:
         | 
| 119 139 | 
             
              #
         | 
| 120 | 
            -
              #   XDG. | 
| 140 | 
            +
              #   XDG.config_select('sow/plugins', File::FNM_CASEFOLD)
         | 
| 121 141 | 
             
              #
         | 
| 122 | 
            -
              #   XDG. | 
| 142 | 
            +
              #   XDG.config_select('sow', 'plugins', :casefold)
         | 
| 123 143 | 
             
              #
         | 
| 124 | 
            -
              def  | 
| 144 | 
            +
              def config_select(*glob_and_flags)
         | 
| 125 145 | 
             
                glob, flags = *glob_and_flags.partition{ |e| String===e }
         | 
| 146 | 
            +
                glob = ['**/*'] if glob.empty?
         | 
| 126 147 | 
             
                flag = flags.inject(0) do |m, f|
         | 
| 127 148 | 
             
                  if Symbol === f
         | 
| 128 149 | 
             
                    m + File::const_get("FNM_#{f.to_s.upcase}")
         | 
| @@ -133,7 +154,11 @@ module XDG | |
| 133 154 | 
             
                find = []
         | 
| 134 155 | 
             
                [config_home, *config_dirs].each do |dir|
         | 
| 135 156 | 
             
                  path = File.join(dir, *glob)
         | 
| 136 | 
            -
                   | 
| 157 | 
            +
                  if block_given?
         | 
| 158 | 
            +
                    find.concat(Dir.glob(path, flag).select(&block))
         | 
| 159 | 
            +
                  else
         | 
| 160 | 
            +
                    find.concat(Dir.glob(path, flag))
         | 
| 161 | 
            +
                  end
         | 
| 137 162 | 
             
                end
         | 
| 138 163 | 
             
                find
         | 
| 139 164 | 
             
              end
         | 
| @@ -141,9 +166,10 @@ module XDG | |
| 141 166 | 
             
              # Return the fist matching file or directory
         | 
| 142 167 | 
             
              # in the cache directory.
         | 
| 143 168 | 
             
              #
         | 
| 144 | 
            -
              # See + | 
| 145 | 
            -
               | 
| 146 | 
            -
             | 
| 169 | 
            +
              # See: +cache_select+.
         | 
| 170 | 
            +
              #
         | 
| 171 | 
            +
              def cache_find(*glob_and_flags, &block)
         | 
| 172 | 
            +
                cache_select(*glob_and_flags, &block).first
         | 
| 147 173 | 
             
              end
         | 
| 148 174 |  | 
| 149 175 | 
             
              # Return array of matching files or directories
         | 
| @@ -154,12 +180,13 @@ module XDG | |
| 154 180 | 
             
              #
         | 
| 155 181 | 
             
              # For example, the following are equivalent:
         | 
| 156 182 | 
             
              #
         | 
| 157 | 
            -
              #   XDG. | 
| 183 | 
            +
              #   XDG.cache_select('sow/tmp', File::FNM_CASEFOLD)
         | 
| 158 184 | 
             
              #
         | 
| 159 | 
            -
              #   XDG. | 
| 185 | 
            +
              #   XDG.cache_select('sow', 'tmp', :casefold)
         | 
| 160 186 | 
             
              #
         | 
| 161 | 
            -
              def  | 
| 187 | 
            +
              def cache_select(*glob_and_flags)
         | 
| 162 188 | 
             
                glob, flags = *glob_and_flags.partition{ |e| String===e }
         | 
| 189 | 
            +
                glob = ['**/*'] if glob.empty?
         | 
| 163 190 | 
             
                flag = flags.inject(0) do |m, f|
         | 
| 164 191 | 
             
                  if Symbol === f
         | 
| 165 192 | 
             
                    m + File::const_get("FNM_#{f.to_s.upcase}")
         | 
| @@ -168,7 +195,11 @@ module XDG | |
| 168 195 | 
             
                  end
         | 
| 169 196 | 
             
                end
         | 
| 170 197 | 
             
                path = File.join(cache_home,*glob)
         | 
| 171 | 
            -
                 | 
| 198 | 
            +
                if block_given?
         | 
| 199 | 
            +
                  Dir.glob(path, flag).select(&block)
         | 
| 200 | 
            +
                else
         | 
| 201 | 
            +
                  Dir.glob(path, flag)
         | 
| 202 | 
            +
                end
         | 
| 172 203 | 
             
              end
         | 
| 173 204 |  | 
| 174 205 | 
             
              #--
         | 
| @@ -199,3 +230,8 @@ module XDG | |
| 199 230 |  | 
| 200 231 | 
             
            end # module XDG
         | 
| 201 232 |  | 
| 233 | 
            +
            # :Title: XDG
         | 
| 234 | 
            +
            # :Author: &trans;
         | 
| 235 | 
            +
            # :Copyright: (c)2008 Tiger Ops
         | 
| 236 | 
            +
            # :License: GPLv3
         | 
| 237 | 
            +
             | 
    
        data/test/test_xdg.rb
    CHANGED
    
    | @@ -60,23 +60,23 @@ class TestXDG < Test::Unit::TestCase | |
| 60 60 |  | 
| 61 61 | 
             
              # Test the glob methods.
         | 
| 62 62 |  | 
| 63 | 
            -
              def  | 
| 63 | 
            +
              def test_data_select
         | 
| 64 64 | 
             
                file = 'foo.dat'
         | 
| 65 | 
            -
                assert_equal(File.join(Dir.pwd,'home/.local/share', file), XDG. | 
| 65 | 
            +
                assert_equal([File.join(Dir.pwd,'home/.local/share', file)], XDG.data_select(file))
         | 
| 66 66 | 
             
                file = 'bar.dat'
         | 
| 67 | 
            -
                assert_equal([File.join(Dir.pwd,'usr/share', file)], XDG. | 
| 67 | 
            +
                assert_equal([File.join(Dir.pwd,'usr/share', file)], XDG.data_select(file))
         | 
| 68 68 | 
             
              end
         | 
| 69 69 |  | 
| 70 | 
            -
              def  | 
| 70 | 
            +
              def test_config_select
         | 
| 71 71 | 
             
                file = 'foo.config'
         | 
| 72 | 
            -
                assert_equal([File.join(Dir.pwd,'home/.config', file)], XDG. | 
| 72 | 
            +
                assert_equal([File.join(Dir.pwd,'home/.config', file)], XDG.config_select(file))
         | 
| 73 73 | 
             
                file = 'bar.config'
         | 
| 74 | 
            -
                assert_equal([File.join(Dir.pwd,'etc/xdg', file)], XDG. | 
| 74 | 
            +
                assert_equal([File.join(Dir.pwd,'etc/xdg', file)], XDG.config_select(file))
         | 
| 75 75 | 
             
              end
         | 
| 76 76 |  | 
| 77 | 
            -
              def  | 
| 77 | 
            +
              def test_cache_select
         | 
| 78 78 | 
             
                file = 'foo.cache'
         | 
| 79 | 
            -
                assert_equal([File.join(Dir.pwd,'home/.cache', file)], XDG. | 
| 79 | 
            +
                assert_equal([File.join(Dir.pwd,'home/.cache', file)], XDG.cache_select(file))
         | 
| 80 80 | 
             
              end
         | 
| 81 81 |  | 
| 82 82 | 
             
              # Test the working directory variations.
         | 
    
        metadata
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            --- !ruby/object:Gem::Specification 
         | 
| 2 2 | 
             
            name: xdg
         | 
| 3 3 | 
             
            version: !ruby/object:Gem::Version 
         | 
| 4 | 
            -
              version: 0. | 
| 4 | 
            +
              version: 0.5.0
         | 
| 5 5 | 
             
            platform: ruby
         | 
| 6 6 | 
             
            authors: 
         | 
| 7 7 | 
             
            - tigerops-community@rubyforge.org
         | 
| @@ -10,7 +10,7 @@ autorequire: | |
| 10 10 | 
             
            bindir: bin
         | 
| 11 11 | 
             
            cert_chain: []
         | 
| 12 12 |  | 
| 13 | 
            -
            date: 2008-10- | 
| 13 | 
            +
            date: 2008-10-28 00:00:00 -04:00
         | 
| 14 14 | 
             
            default_executable: 
         | 
| 15 15 | 
             
            dependencies: []
         | 
| 16 16 |  | 
| @@ -23,6 +23,7 @@ extensions: [] | |
| 23 23 | 
             
            extra_rdoc_files: 
         | 
| 24 24 | 
             
            - README
         | 
| 25 25 | 
             
            - MANIFEST
         | 
| 26 | 
            +
            - CHANGES
         | 
| 26 27 | 
             
            - RELEASE
         | 
| 27 28 | 
             
            - HISTORY
         | 
| 28 29 | 
             
            - VERSION
         | 
| @@ -32,6 +33,7 @@ files: | |
| 32 33 | 
             
            - meta
         | 
| 33 34 | 
             
            - test
         | 
| 34 35 | 
             
            - MANIFEST
         | 
| 36 | 
            +
            - CHANGES
         | 
| 35 37 | 
             
            - RELEASE
         | 
| 36 38 | 
             
            - README
         | 
| 37 39 | 
             
            - HISTORY
         | 
| @@ -41,7 +43,6 @@ files: | |
| 41 43 | 
             
            - meta/homepage
         | 
| 42 44 | 
             
            - meta/summary
         | 
| 43 45 | 
             
            - meta/abstract
         | 
| 44 | 
            -
            - meta/releases
         | 
| 45 46 | 
             
            - meta/title
         | 
| 46 47 | 
             
            - meta/authors
         | 
| 47 48 | 
             
            - meta/contact
         | 
    
        data/meta/releases
    DELETED
    
    | @@ -1 +0,0 @@ | |
| 1 | 
            -
             |