小编Jos*_*osh的帖子

使用Rest Client Ruby Gem的身份验证标头

我已经创建了一个基本的身份验证密钥,现在我只是想利用它.我尝试了一些不同的变体,但似乎没有一个在请求标题中显示授权.

$auth = 'Basic cmFtZXNoQHVzYW1hLmNvbTpyYW1lc2h1JEBtcA=='


@response = resource.post('Authorization' => $auth)
nor
@response = resource.post(:authorization => $auth)
nor
@response = resource.post(:Authorization => $auth)
nor
@response = resource.post(:content_type => :json, :accept => :json, :headers => { 'Authorization:' => $auth })
Run Code Online (Sandbox Code Playgroud)

不幸的是,我没有在rdoc中找到很多可以帮助我解决这个问题的信息.有没有人有使用Rest Client gem添加auth标头的经验?

ruby rest rest-client

6
推荐指数
1
解决办法
2万
查看次数

如何在shell脚本中结合运行多个ruby文件?

我有一个.sh文件,如下所示:

ruby one.rb
ruby two.rb
ruby three.rb
ruby four.rb
ruby five.rb
ruby six.rb
ruby seven.rb
ruby eight.rb
Run Code Online (Sandbox Code Playgroud)

这样做是逐个运行ruby文件.我将如何开始联合发布前四个,并且在前四个完成后立即抓住下一组.不知道如何处理这个,任何建议表示赞赏.我现在想避免使用rake并继续使用shell.

ruby shell

4
推荐指数
1
解决办法
1059
查看次数

Ruby初学者试图从Ruby中的另一个类调用一个方法?

我试图让以下工作.不确定我失败的地方.我收到以下错误:

1)错误:

test_google(Google):
NoMethodError: undefined method `new' for Method:Class
    google.rb:15:in `setup'
Run Code Online (Sandbox Code Playgroud)

我是ruby的新手,所以这很漂亮101.有人可以向我解释我的错误以及为什么我能理解.谢谢!

require "test/unit"
require "selenium-webdriver"
require "json"
require "time"
require_relative "methods"

class Google < Test::Unit::TestCase

  def setup
    @driver = Selenium::WebDriver.for :firefox
    @base_url = "https://www.google.com/"
    @accept_next_alert = true
    @driver.manage.timeouts.implicit_wait = 30
    @verification_errors = []
    @search = Method.new()
  end 

  def teardown
    @driver.quit
    assert_equal [], @verification_errors
  end 

  def test_google
    @driver.get(@base_url + "/")
    @search.search
  end 

end

class Method

  def search
      @driver.find_element(:id, "gbqfq").clear
      @driver.find_element(:id, "gbqfq").send_keys "this is a test"
      @driver.find_element(:id, "gbqfb").click
      @driver.find_element(:id, "gbqfb").click
  end …
Run Code Online (Sandbox Code Playgroud)

ruby

3
推荐指数
1
解决办法
1554
查看次数

使用 git 子模块创建多个远程分支

我第一次使用 git 子模块。努力理解如何全面创建分支并将它们添加到所有远程存储库中。

目前我的文件结构类似于以下内容:

-parent_repo
  |
  |_ submodule_1
  |_ submodule_2
  |_ submodule_3
  |_ submodule_4
  |_ submodule_5
  |_ submodule_6
  |_ submodule_7
Run Code Online (Sandbox Code Playgroud)

如果我在父仓库上创建一个分支:

(master) $ git checkout -b feature/my_feature
(feature/my_feature) $ git commit -m "created my_feature"
(feature/my_feature) $ git push -u origin feature/my_feature
Run Code Online (Sandbox Code Playgroud)

我想在包括父模块在内的所有子模块中创建一个分支。之后,所有分支都被远程推送到每个子模块及其受尊重的存储库。

尝试了以下步骤:

$ git submodule foreach -b branch_name
$ git push --recurse-submodules=on-demand
$ git submodule foreach "(git checkout branch_name; git pull)&"
Run Code Online (Sandbox Code Playgroud)

..只是失败了。找不到第一个命令。

..如果我这样做:

$ git config -f .gitmodules submodule.submodule_1.branch branch_name
$ git submodule update --remote
Run Code Online (Sandbox Code Playgroud)

git 返回:

fatal: Needed …
Run Code Online (Sandbox Code Playgroud)

git version-control github git-submodules

2
推荐指数
1
解决办法
2797
查看次数

标签 统计

ruby ×3

git ×1

git-submodules ×1

github ×1

rest ×1

rest-client ×1

shell ×1

version-control ×1