qiita_org 0.1.30 → 0.1.31
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 +4 -4
- data/Gemfile.lock +1 -1
- data/lib/qiita_org.rb +4 -2
- data/lib/qiita_org/get_multiple_files.rb +1 -1
- data/lib/qiita_org/get_template.rb +19 -18
- data/lib/qiita_org/upload.rb +29 -9
- data/lib/qiita_org/version.rb +1 -1
- metadata +2 -3
- data/tests/template.org +0 -14
    
        checksums.yaml
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            ---
         | 
| 2 2 | 
             
            SHA256:
         | 
| 3 | 
            -
              metadata.gz:  | 
| 4 | 
            -
              data.tar.gz:  | 
| 3 | 
            +
              metadata.gz: 1439e34745f6fe0f0711b34b6f231124bb249dd2f1adfa6973686c0ea2e6d6f1
         | 
| 4 | 
            +
              data.tar.gz: 6ec5897e60ca99aefce238f6208eca57fa069fb89c9dc8da349e6128c78d4cb3
         | 
| 5 5 | 
             
            SHA512:
         | 
| 6 | 
            -
              metadata.gz:  | 
| 7 | 
            -
              data.tar.gz:  | 
| 6 | 
            +
              metadata.gz: 5638354fdec6cb35903bab5ae2b02b9843eb7ae78355e81c35402a597f5452998c46c28352fa4269b89775c4aa003f0d215b1005a5614a25da19a7aa4df2e388
         | 
| 7 | 
            +
              data.tar.gz: d904ef610f7a455fe48bc761b80aa129adeb69be7ea1ea3536cedc9d3bd3dbac7ef4dc9b96f19328519d338aab5926031daa7016945cc8940d89266c4030360b
         | 
    
        data/Gemfile.lock
    CHANGED
    
    
    
        data/lib/qiita_org.rb
    CHANGED
    
    | @@ -73,7 +73,7 @@ module QiitaOrg | |
| 73 73 | 
             
                    p file = argv[0] || "README.org"
         | 
| 74 74 | 
             
                    p mode = argv[1] || DecideOption.new(file).decide_option()
         | 
| 75 75 |  | 
| 76 | 
            -
                    qiita =  | 
| 76 | 
            +
                    qiita = QiitaFileUpLoad.new(file, mode, os).upload()
         | 
| 77 77 | 
             
                  end
         | 
| 78 78 | 
             
            =begin
         | 
| 79 79 | 
             
                  getpath = GetFilePath.new(file)
         | 
| @@ -117,8 +117,10 @@ module QiitaOrg | |
| 117 117 | 
             
                def template(*argv)
         | 
| 118 118 | 
             
                  checkos = CheckPcOs.new
         | 
| 119 119 | 
             
                  os = checkos.return_os()
         | 
| 120 | 
            +
                  filename = argv[0] || "template.org"
         | 
| 121 | 
            +
                  filename = (filename.include?(".org"))? filename : "#{filename}.org"
         | 
| 120 122 |  | 
| 121 | 
            -
                  template = QiitaGetTemplate.new(os).run()
         | 
| 123 | 
            +
                  template = QiitaGetTemplate.new(os, filename).run()
         | 
| 122 124 | 
             
                end
         | 
| 123 125 |  | 
| 124 126 | 
             
                desc "all [teams/public/private] [options]", "post all org files in the directory"
         | 
| @@ -5,8 +5,9 @@ require "qiita_org/search_conf_path" | |
| 5 5 | 
             
            require "qiita_org/error_message.rb"
         | 
| 6 6 |  | 
| 7 7 | 
             
            class QiitaGetTemplate
         | 
| 8 | 
            -
              def initialize(os)
         | 
| 8 | 
            +
              def initialize(os, filename)
         | 
| 9 9 | 
             
                @os = os
         | 
| 10 | 
            +
                @filename = filename
         | 
| 10 11 | 
             
                search = SearchConfPath.new(Dir.pwd, Dir.home)
         | 
| 11 12 | 
             
                @conf_dir = search.search_conf_path()
         | 
| 12 13 | 
             
                # check_write_header()
         | 
| @@ -18,9 +19,9 @@ class QiitaGetTemplate | |
| 18 19 | 
             
                m = []
         | 
| 19 20 | 
             
                m = version.match(/ProductName:\t(.+)\nProductVersion:\t(.+)\nBuildVersion:\t(.+)\n/)
         | 
| 20 21 | 
             
                system 'rm hoge.txt'
         | 
| 21 | 
            -
                conts = File.read( | 
| 22 | 
            +
                conts = File.read(@filename)
         | 
| 22 23 | 
             
                conts << "![#{m[1]}-#{m[2]}](https://img.shields.io/badge/#{m[1].gsub(" ", "")}-#{m[2]}-brightgreen) "
         | 
| 23 | 
            -
                File.write( | 
| 24 | 
            +
                File.write(@filename, conts) # + "# {m[1]}: # {m[2]}\n")
         | 
| 24 25 | 
             
              end
         | 
| 25 26 |  | 
| 26 27 | 
             
              def get_windowsos_version()
         | 
| @@ -33,9 +34,9 @@ class QiitaGetTemplate | |
| 33 34 | 
             
                m2 = version2.match(/OSArchitecture\n(.+)-bit/)
         | 
| 34 35 | 
             
                system 'rm hoge1.txt'
         | 
| 35 36 | 
             
                system 'rm hoge2.txt'
         | 
| 36 | 
            -
                conts = File.read( | 
| 37 | 
            +
                conts = File.read(@filename)
         | 
| 37 38 | 
             
                conts << "![#{m1[1]}-#{m1[2]}](https://img.shields.io/badge/#{m1[1].gsub(" ", "")}#{m1[2]}-#{m2[1]}bit-brightgreen) "
         | 
| 38 | 
            -
                File.write( | 
| 39 | 
            +
                File.write(@filename, conts) # + "# {m[1]}: # {m[2]}\n")
         | 
| 39 40 | 
             
              end
         | 
| 40 41 |  | 
| 41 42 | 
             
              def get_ubuntu_version()
         | 
| @@ -44,9 +45,9 @@ class QiitaGetTemplate | |
| 44 45 | 
             
                m = []
         | 
| 45 46 | 
             
                m = version.match(/(.+) (.+) LTS /)
         | 
| 46 47 | 
             
                system 'rm hoge.txt'
         | 
| 47 | 
            -
                conts = File.read( | 
| 48 | 
            +
                conts = File.read(@filename)
         | 
| 48 49 | 
             
                conts << "![#{m[1]}-#{m[2]}](https://img.shields.io/badge/#{m[1]}-#{m[2]}-brightgreen) "
         | 
| 49 | 
            -
                File.write( | 
| 50 | 
            +
                File.write(@filename, conts)
         | 
| 50 51 | 
             
              end
         | 
| 51 52 |  | 
| 52 53 | 
             
              def get_ruby_version()
         | 
| @@ -55,9 +56,9 @@ class QiitaGetTemplate | |
| 55 56 | 
             
                m = []
         | 
| 56 57 | 
             
                m = version.match(/ruby (.+) \((.+)/)
         | 
| 57 58 | 
             
                system 'rm hoge.txt'
         | 
| 58 | 
            -
                conts = File.read( | 
| 59 | 
            +
                conts = File.read(@filename)
         | 
| 59 60 | 
             
                conts << "![ruby-#{m[1]}](https://img.shields.io/badge/ruby-#{m[1].gsub(" ", "")}-brightgreen) "
         | 
| 60 | 
            -
                File.write( | 
| 61 | 
            +
                File.write(@filename, conts) # + "ruby: # {m[1]}\n")
         | 
| 61 62 | 
             
              end
         | 
| 62 63 |  | 
| 63 64 | 
             
              # cp template.org
         | 
| @@ -65,11 +66,11 @@ class QiitaGetTemplate | |
| 65 66 | 
             
                lib = File.expand_path("../../../lib", __FILE__)
         | 
| 66 67 | 
             
                cp_file = File.join(lib, "qiita_org", "template.org")
         | 
| 67 68 |  | 
| 68 | 
            -
                if File.exists?(" | 
| 69 | 
            -
                  puts " | 
| 69 | 
            +
                if File.exists?("./#{@filename}")
         | 
| 70 | 
            +
                  puts "#{@filename} exists.".red
         | 
| 70 71 | 
             
                  exit
         | 
| 71 72 | 
             
                else
         | 
| 72 | 
            -
                  FileUtils.cp(cp_file,  | 
| 73 | 
            +
                  FileUtils.cp(cp_file, @filename, verbose: true)
         | 
| 73 74 | 
             
                end
         | 
| 74 75 | 
             
              end
         | 
| 75 76 |  | 
| @@ -116,19 +117,19 @@ class QiitaGetTemplate | |
| 116 117 | 
             
              end
         | 
| 117 118 |  | 
| 118 119 | 
             
              def get_name()
         | 
| 119 | 
            -
                conts = File.readlines( | 
| 120 | 
            +
                conts = File.readlines(@filename)
         | 
| 120 121 | 
             
                p "Type your name"
         | 
| 121 122 | 
             
                name = STDIN.gets
         | 
| 122 123 | 
             
                conts[3] = "#+AUTHOR: #{name}"
         | 
| 123 | 
            -
                File.write( | 
| 124 | 
            +
                File.write(@filename, conts.join)
         | 
| 124 125 | 
             
              end
         | 
| 125 126 |  | 
| 126 127 | 
             
              def get_email()
         | 
| 127 | 
            -
                conts = File.readlines( | 
| 128 | 
            +
                conts = File.readlines(@filename)
         | 
| 128 129 | 
             
                p "Type your email"
         | 
| 129 130 | 
             
                email = STDIN.gets
         | 
| 130 131 | 
             
                conts[4] = "#+EMAIL:     (concat \"#{email.chomp}\")\n"
         | 
| 131 | 
            -
                File.write( | 
| 132 | 
            +
                File.write(@filename, conts.join)
         | 
| 132 133 | 
             
              end
         | 
| 133 134 |  | 
| 134 135 | 
             
              def set_name_and_email()
         | 
| @@ -136,10 +137,10 @@ class QiitaGetTemplate | |
| 136 137 | 
             
                conf = JSON.load(File.read(conf_path))
         | 
| 137 138 | 
             
                name = conf["name"]
         | 
| 138 139 | 
             
                email = conf["email"]
         | 
| 139 | 
            -
                conts = File.readlines( | 
| 140 | 
            +
                conts = File.readlines(@filename)
         | 
| 140 141 | 
             
                conts[3] = "#+AUTHOR: #{name}\n"
         | 
| 141 142 | 
             
                conts[4] = "#+EMAIL:     (concat \"#{email}\")\n"
         | 
| 142 | 
            -
                File.write( | 
| 143 | 
            +
                File.write(@filename, conts.join)
         | 
| 143 144 | 
             
              end
         | 
| 144 145 |  | 
| 145 146 | 
             
              def run()
         | 
    
        data/lib/qiita_org/upload.rb
    CHANGED
    
    | @@ -6,27 +6,34 @@ require "qiita_org/file_open.rb" | |
| 6 6 | 
             
            require "qiita_org/set_config.rb"
         | 
| 7 7 | 
             
            require "qiita_org/access_qiita.rb"
         | 
| 8 8 |  | 
| 9 | 
            -
            class  | 
| 9 | 
            +
            class QiitaFileUpLoad
         | 
| 10 10 | 
             
              def initialize(src, option, os)
         | 
| 11 11 | 
             
                @src = src
         | 
| 12 12 | 
             
                @option = (option == "qiita" || option == "open")? "public" : option
         | 
| 13 13 | 
             
                @os = os
         | 
| 14 14 | 
             
                @fileopen = FileOpen.new(@os)
         | 
| 15 | 
            +
                @access_token, @teams_url, @display, @ox_qmd_load_path = SetConfig.new().set_config()
         | 
| 16 | 
            +
                if @option == "teams"
         | 
| 17 | 
            +
                  ErrorMessage.new().teams_url_error(@teams_url)
         | 
| 18 | 
            +
                end
         | 
| 15 19 | 
             
              end
         | 
| 16 20 |  | 
| 17 21 | 
             
              def upload()
         | 
| 18 | 
            -
                paths = GetFilePath.new(@src).get_file_path()
         | 
| 19 | 
            -
                 | 
| 22 | 
            +
                #paths = GetFilePath.new(@src).get_file_path()
         | 
| 23 | 
            +
                paths = get_file_path(@src)
         | 
| 20 24 | 
             
                unless paths.empty?
         | 
| 21 | 
            -
                  showfile = ShowFile.new(paths, @src, @option, @os)
         | 
| 22 | 
            -
                  showfile.open_file_dir() | 
| 23 | 
            -
                   | 
| 25 | 
            +
                  #showfile = ShowFile.new(paths, @src, @option, @os)
         | 
| 26 | 
            +
                  #showfile.open_file_dir()
         | 
| 27 | 
            +
                  open_file_dir(paths)
         | 
| 28 | 
            +
                  #showfile.open_qiita()
         | 
| 29 | 
            +
                  open_qiita()
         | 
| 24 30 |  | 
| 25 31 | 
             
                  puts "Overwrite file URL's on #{@src}? (y/n)".green
         | 
| 26 32 | 
             
                  ans = STDIN.getch
         | 
| 27 33 |  | 
| 28 34 | 
             
                  if ans == "y"
         | 
| 29 | 
            -
                    showfile.input_url_to_org()
         | 
| 35 | 
            +
                    #showfile.input_url_to_org()
         | 
| 36 | 
            +
                    input_url_to_org(paths)
         | 
| 30 37 | 
             
                  end
         | 
| 31 38 | 
             
                else
         | 
| 32 39 | 
             
                  puts "file path is empty.".red
         | 
| @@ -65,17 +72,20 @@ class QiitaUpLoad | |
| 65 72 |  | 
| 66 73 | 
             
              def open_qiita()
         | 
| 67 74 | 
             
                conts = File.read(@src)
         | 
| 68 | 
            -
                id = conts.match(/\#\+qiita_#{option}: (.+)/)[1]
         | 
| 75 | 
            +
                id = conts.match(/\#\+qiita_#{@option}: (.+)/)[1]
         | 
| 69 76 |  | 
| 77 | 
            +
            =begin
         | 
| 70 78 | 
             
                @access_token, @teams_url, @display, @ox_qmd_load_path = SetConfig.new().set_config()
         | 
| 71 79 | 
             
                if @option == "teams"
         | 
| 72 80 | 
             
                  ErrorMassage.new().teams_url_error(@teams_url)
         | 
| 73 81 | 
             
                end
         | 
| 82 | 
            +
            =end
         | 
| 74 83 |  | 
| 75 84 | 
             
                qiita = (@option == "teams") ? @teams_url : "https://qiita.com/"
         | 
| 76 85 | 
             
                path = "api/v2/items/#{id}"
         | 
| 77 86 |  | 
| 78 | 
            -
                 | 
| 87 | 
            +
                @access = AccessQiita.new(@access_token, qiita, path)
         | 
| 88 | 
            +
                items = @access.access_qiita()
         | 
| 79 89 |  | 
| 80 90 | 
             
                @fileopen.file_open(items["url"])
         | 
| 81 91 | 
             
              end
         | 
| @@ -97,4 +107,14 @@ class QiitaUpLoad | |
| 97 107 |  | 
| 98 108 | 
             
                File.write(@src, lines.join)
         | 
| 99 109 | 
             
              end
         | 
| 110 | 
            +
             | 
| 111 | 
            +
              def get_file_url(id, file_name)
         | 
| 112 | 
            +
                qiita = (@option == "teams")? @teams_url : "https://qiita.com/"
         | 
| 113 | 
            +
                path = "api/v2/items/#{@id}"
         | 
| 114 | 
            +
             | 
| 115 | 
            +
                items = @access.access_qiita()
         | 
| 116 | 
            +
             | 
| 117 | 
            +
                file_url = items["body"].match(/\!\[#{file_name}\]\(((.+))\)/)[2]
         | 
| 118 | 
            +
                return file_url
         | 
| 119 | 
            +
              end
         | 
| 100 120 | 
             
            end
         | 
    
        data/lib/qiita_org/version.rb
    CHANGED
    
    
    
        metadata
    CHANGED
    
    | @@ -1,14 +1,14 @@ | |
| 1 1 | 
             
            --- !ruby/object:Gem::Specification
         | 
| 2 2 | 
             
            name: qiita_org
         | 
| 3 3 | 
             
            version: !ruby/object:Gem::Version
         | 
| 4 | 
            -
              version: 0.1. | 
| 4 | 
            +
              version: 0.1.31
         | 
| 5 5 | 
             
            platform: ruby
         | 
| 6 6 | 
             
            authors:
         | 
| 7 7 | 
             
            - Kenta Yamamoto
         | 
| 8 8 | 
             
            autorequire:
         | 
| 9 9 | 
             
            bindir: exe
         | 
| 10 10 | 
             
            cert_chain: []
         | 
| 11 | 
            -
            date: 2020- | 
| 11 | 
            +
            date: 2020-12-01 00:00:00.000000000 Z
         | 
| 12 12 | 
             
            dependencies:
         | 
| 13 13 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 14 14 | 
             
              name: bundler
         | 
| @@ -2583,7 +2583,6 @@ files: | |
| 2583 2583 | 
             
            - lib/qiita_org/version.rb
         | 
| 2584 2584 | 
             
            - qiita_org.gemspec
         | 
| 2585 2585 | 
             
            - tests/hoge.rb
         | 
| 2586 | 
            -
            - tests/template.org
         | 
| 2587 2586 | 
             
            - tests/test.html
         | 
| 2588 2587 | 
             
            - tests/test.org
         | 
| 2589 2588 | 
             
            - tests/test2.org
         | 
    
        data/tests/template.org
    DELETED
    
    | @@ -1,14 +0,0 @@ | |
| 1 | 
            -
            #+qiita_private: baededc5aa906407da33
         | 
| 2 | 
            -
            #+OPTIONS: ^:{}
         | 
| 3 | 
            -
            #+STARTUP: indent nolineimages
         | 
| 4 | 
            -
            #+TITLE: title
         | 
| 5 | 
            -
            #+AUTHOR: Kenta Yamamoto
         | 
| 6 | 
            -
            #+EMAIL:     (concat "doi35077@kwansei.ac.jp")
         | 
| 7 | 
            -
            #+LANGUAGE:  jp
         | 
| 8 | 
            -
            # +OPTIONS:   H:4 toc:t num:2
         | 
| 9 | 
            -
            #+OPTIONS:   toc:nil
         | 
| 10 | 
            -
            #+TAG: tag1, tag2
         | 
| 11 | 
            -
            #+TWITTER: off
         | 
| 12 | 
            -
            # +SETUPFILE: ~/.emacs.d/org-mode/theme-readtheorg.setup
         | 
| 13 | 
            -
             | 
| 14 | 
            -
              
         |